summaryrefslogtreecommitdiff
path: root/src/arch
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2019-10-01 01:25:53 -0700
committerGabe Black <gabeblack@google.com>2019-10-10 01:25:17 +0000
commita3d2a9ec92ad4406ccf51ff45a4a1d2aa16eaa69 (patch)
tree6ced63b62e070382a4c517bf63c0b4625a6aa433 /src/arch
parent70f66f77942872ace0af50170dcbb68ef2311095 (diff)
downloadgem5-a3d2a9ec92ad4406ccf51ff45a4a1d2aa16eaa69.tar.xz
arch, base: Stop assuming object files have three segments.
The ObjectFile class has hardcoded assumptions that there are three segments, text, bss and data. There are some files which have one "segment" like raw files, where the entire file's contents are considered a single segment. There are also ELF files which can have an arbitrary number of segments, and those segments can hold any number of sections, including the text, data and/or bss sections. Removing this assumption frees up some object file formats from having to twist themselves to fit in that structure, possibly introducing ambiguities when some segments may fulfill multiple roles. Change-Id: I976e06a3a90ef852b17a6485e2595b006b2090d5 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/21463 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src/arch')
-rw-r--r--src/arch/alpha/process.cc6
-rw-r--r--src/arch/alpha/system.cc6
-rw-r--r--src/arch/arm/freebsd/system.cc2
-rw-r--r--src/arch/arm/linux/system.cc2
-rw-r--r--src/arch/arm/process.cc6
-rw-r--r--src/arch/mips/process.cc3
-rw-r--r--src/arch/power/process.cc3
-rw-r--r--src/arch/riscv/process.cc6
-rw-r--r--src/arch/sparc/process.hh6
-rw-r--r--src/arch/sparc/system.cc12
-rw-r--r--src/arch/x86/process.cc6
11 files changed, 24 insertions, 34 deletions
diff --git a/src/arch/alpha/process.cc b/src/arch/alpha/process.cc
index d0bfa79c8..59cbebc1c 100644
--- a/src/arch/alpha/process.cc
+++ b/src/arch/alpha/process.cc
@@ -54,12 +54,10 @@ AlphaProcess::AlphaProcess(ProcessParams *params, ObjectFile *objFile)
objFile)
{
fatal_if(params->useArchPT, "Arch page tables not implemented.");
- Addr brk_point = objFile->dataBase() + objFile->dataSize() +
- objFile->bssSize();
- brk_point = roundUp(brk_point, PageBytes);
+ Addr brk_point = roundUp(objFile->maxSegmentAddr(), PageBytes);
// Set up stack. On Alpha, stack goes below the image.
- Addr stack_base = objFile->textBase() - (409600 + 4096);
+ Addr stack_base = objFile->minSegmentAddr() - (409600 + 4096);
// Set up region for mmaps.
Addr mmap_end = 0x10000;
diff --git a/src/arch/alpha/system.cc b/src/arch/alpha/system.cc
index 7bff6da01..31e7aa062 100644
--- a/src/arch/alpha/system.cc
+++ b/src/arch/alpha/system.cc
@@ -57,11 +57,13 @@ AlphaSystem::AlphaSystem(Params *p)
*/
// Load Console Code
console = createObjectFile(params()->console);
+ console->setLoadMask(loadAddrMask);
if (console == NULL)
fatal("Could not load console file %s", params()->console);
// Load pal file
pal = createObjectFile(params()->pal);
+ pal->setLoadMask(loadAddrMask);
if (pal == NULL)
fatal("Could not load PALcode file %s", params()->pal);
@@ -109,8 +111,8 @@ AlphaSystem::initState()
System::initState();
// Load program sections into memory
- pal->loadSegments(physProxy, loadAddrMask);
- console->loadSegments(physProxy, loadAddrMask);
+ pal->loadSegments(physProxy);
+ console->loadSegments(physProxy);
/**
* Copy the osflags (kernel arguments) into the consoles
diff --git a/src/arch/arm/freebsd/system.cc b/src/arch/arm/freebsd/system.cc
index 6e544a70e..764f036b4 100644
--- a/src/arch/arm/freebsd/system.cc
+++ b/src/arch/arm/freebsd/system.cc
@@ -132,7 +132,7 @@ FreebsdArmSystem::initState()
if (ra)
bootReleaseAddr = ra & ~ULL(0x7F);
- dtb_file->setTextBase(params()->atags_addr + loadAddrOffset);
+ dtb_file->setLoadOffset(params()->atags_addr + loadAddrOffset);
dtb_file->loadSegments(physProxy);
delete dtb_file;
diff --git a/src/arch/arm/linux/system.cc b/src/arch/arm/linux/system.cc
index f03a5c6cb..a0869b46a 100644
--- a/src/arch/arm/linux/system.cc
+++ b/src/arch/arm/linux/system.cc
@@ -151,7 +151,7 @@ LinuxArmSystem::initState()
"to DTB file: %s\n", params()->dtb_filename);
}
- dtb_file->setTextBase(params()->atags_addr + loadAddrOffset);
+ dtb_file->setLoadOffset(params()->atags_addr + loadAddrOffset);
dtb_file->loadSegments(physProxy);
delete dtb_file;
} else {
diff --git a/src/arch/arm/process.cc b/src/arch/arm/process.cc
index 1a1d4a2a0..f98572690 100644
--- a/src/arch/arm/process.cc
+++ b/src/arch/arm/process.cc
@@ -75,8 +75,7 @@ ArmProcess32::ArmProcess32(ProcessParams *params, ObjectFile *objFile,
ObjectFile::Arch _arch)
: ArmProcess(params, objFile, _arch)
{
- Addr brk_point = roundUp(objFile->dataBase() + objFile->dataSize() +
- objFile->bssSize(), PageBytes);
+ Addr brk_point = roundUp(objFile->maxSegmentAddr(), PageBytes);
Addr stack_base = 0xbf000000L;
Addr max_stack_size = 8 * 1024 * 1024;
Addr next_thread_stack_base = stack_base - max_stack_size;
@@ -90,8 +89,7 @@ ArmProcess64::ArmProcess64(ProcessParams *params, ObjectFile *objFile,
ObjectFile::Arch _arch)
: ArmProcess(params, objFile, _arch)
{
- Addr brk_point = roundUp(objFile->dataBase() + objFile->dataSize() +
- objFile->bssSize(), PageBytes);
+ Addr brk_point = roundUp(objFile->maxSegmentAddr(), PageBytes);
Addr stack_base = 0x7fffff0000L;
Addr max_stack_size = 8 * 1024 * 1024;
Addr next_thread_stack_base = stack_base - max_stack_size;
diff --git a/src/arch/mips/process.cc b/src/arch/mips/process.cc
index e3405fdaa..1808372d9 100644
--- a/src/arch/mips/process.cc
+++ b/src/arch/mips/process.cc
@@ -65,8 +65,7 @@ MipsProcess::MipsProcess(ProcessParams *params, ObjectFile *objFile)
Addr next_thread_stack_base = stack_base - max_stack_size;
// Set up break point (Top of Heap)
- Addr brk_point = objFile->dataBase() + objFile->dataSize() +
- objFile->bssSize();
+ Addr brk_point = objFile->maxSegmentAddr();
brk_point = roundUp(brk_point, PageBytes);
// Set up region for mmaps. Start it 1GB above the top of the heap.
diff --git a/src/arch/power/process.cc b/src/arch/power/process.cc
index 467c820f2..b391773ee 100644
--- a/src/arch/power/process.cc
+++ b/src/arch/power/process.cc
@@ -56,8 +56,7 @@ PowerProcess::PowerProcess(ProcessParams *params, ObjectFile *objFile)
{
fatal_if(params->useArchPT, "Arch page tables not implemented.");
// Set up break point (Top of Heap)
- Addr brk_point = objFile->dataBase() + objFile->dataSize() +
- objFile->bssSize();
+ Addr brk_point = objFile->maxSegmentAddr();
brk_point = roundUp(brk_point, PageBytes);
Addr stack_base = 0xbf000000L;
diff --git a/src/arch/riscv/process.cc b/src/arch/riscv/process.cc
index ca3f0e2b8..e15197d78 100644
--- a/src/arch/riscv/process.cc
+++ b/src/arch/riscv/process.cc
@@ -75,8 +75,7 @@ RiscvProcess64::RiscvProcess64(ProcessParams *params, ObjectFile *objFile) :
const Addr stack_base = 0x7FFFFFFFFFFFFFFFL;
const Addr max_stack_size = 8 * 1024 * 1024;
const Addr next_thread_stack_base = stack_base - max_stack_size;
- const Addr brk_point = roundUp(objFile->bssBase() + objFile->bssSize(),
- PageBytes);
+ const Addr brk_point = roundUp(objFile->maxSegmentAddr(), PageBytes);
const Addr mmap_end = 0x4000000000000000L;
memState = make_shared<MemState>(brk_point, stack_base, max_stack_size,
next_thread_stack_base, mmap_end);
@@ -88,8 +87,7 @@ RiscvProcess32::RiscvProcess32(ProcessParams *params, ObjectFile *objFile) :
const Addr stack_base = 0x7FFFFFFF;
const Addr max_stack_size = 8 * 1024 * 1024;
const Addr next_thread_stack_base = stack_base - max_stack_size;
- const Addr brk_point = roundUp(objFile->bssBase() + objFile->bssSize(),
- PageBytes);
+ const Addr brk_point = roundUp(objFile->maxSegmentAddr(), PageBytes);
const Addr mmap_end = 0x40000000L;
memState = make_shared<MemState>(brk_point, stack_base, max_stack_size,
next_thread_stack_base, mmap_end);
diff --git a/src/arch/sparc/process.hh b/src/arch/sparc/process.hh
index eeb267116..f8f19f290 100644
--- a/src/arch/sparc/process.hh
+++ b/src/arch/sparc/process.hh
@@ -78,8 +78,7 @@ class Sparc32Process : public SparcProcess
Sparc32Process(ProcessParams * params, ObjectFile *objFile)
: SparcProcess(params, objFile, 0)
{
- Addr brk_point = objFile->dataBase() + objFile->dataSize() +
- objFile->bssSize();
+ Addr brk_point = objFile->maxSegmentAddr();
brk_point = roundUp(brk_point, SparcISA::PageBytes);
// Reserve 8M for main stack.
@@ -123,8 +122,7 @@ class Sparc64Process : public SparcProcess
Sparc64Process(ProcessParams * params, ObjectFile *objFile)
: SparcProcess(params, objFile, 2047)
{
- Addr brk_point = objFile->dataBase() + objFile->dataSize() +
- objFile->bssSize();
+ Addr brk_point = objFile->maxSegmentAddr();
brk_point = roundUp(brk_point, SparcISA::PageBytes);
Addr max_stack_size = 8 * 1024 * 1024;
diff --git a/src/arch/sparc/system.cc b/src/arch/sparc/system.cc
index 5896061a6..e9615b00c 100644
--- a/src/arch/sparc/system.cc
+++ b/src/arch/sparc/system.cc
@@ -137,22 +137,22 @@ SparcSystem::initState()
System::initState();
// Load reset binary into memory
- reset->setTextBase(params()->reset_addr);
+ reset->setLoadOffset(params()->reset_addr);
reset->loadSegments(physProxy);
// Load the openboot binary
- openboot->setTextBase(params()->openboot_addr);
+ openboot->setLoadOffset(params()->openboot_addr);
openboot->loadSegments(physProxy);
// Load the hypervisor binary
- hypervisor->setTextBase(params()->hypervisor_addr);
+ hypervisor->setLoadOffset(params()->hypervisor_addr);
hypervisor->loadSegments(physProxy);
// Load the nvram image
- nvram->setTextBase(params()->nvram_addr);
+ nvram->setLoadOffset(params()->nvram_addr);
nvram->loadSegments(physProxy);
// Load the hypervisor description image
- hypervisor_desc->setTextBase(params()->hypervisor_desc_addr);
+ hypervisor_desc->setLoadOffset(params()->hypervisor_desc_addr);
hypervisor_desc->loadSegments(physProxy);
// Load the partition description image
- partition_desc->setTextBase(params()->partition_desc_addr);
+ partition_desc->setLoadOffset(params()->partition_desc_addr);
partition_desc->loadSegments(physProxy);
diff --git a/src/arch/x86/process.cc b/src/arch/x86/process.cc
index 60f4f474b..c743685d0 100644
--- a/src/arch/x86/process.cc
+++ b/src/arch/x86/process.cc
@@ -136,8 +136,7 @@ X86_64Process::X86_64Process(ProcessParams *params, ObjectFile *objFile,
vsyscallPage.vtimeOffset = 0x400;
vsyscallPage.vgettimeofdayOffset = 0x0;
- Addr brk_point = roundUp(objFile->dataBase() + objFile->dataSize() +
- objFile->bssSize(), PageBytes);
+ Addr brk_point = roundUp(objFile->maxSegmentAddr(), PageBytes);
Addr stack_base = 0x7FFFFFFFF000ULL;
Addr max_stack_size = 8 * 1024 * 1024;
Addr next_thread_stack_base = stack_base - max_stack_size;
@@ -176,8 +175,7 @@ I386Process::I386Process(ProcessParams *params, ObjectFile *objFile,
vsyscallPage.vsyscallOffset = 0x400;
vsyscallPage.vsysexitOffset = 0x410;
- Addr brk_point = roundUp(objFile->dataBase() + objFile->dataSize() +
- objFile->bssSize(), PageBytes);
+ Addr brk_point = roundUp(objFile->maxSegmentAddr(), PageBytes);
Addr stack_base = _gdtStart;
Addr max_stack_size = 8 * 1024 * 1024;
Addr next_thread_stack_base = stack_base - max_stack_size;