diff options
author | Gabe Black <gabeblack@google.com> | 2019-10-01 01:25:53 -0700 |
---|---|---|
committer | Gabe Black <gabeblack@google.com> | 2019-10-10 01:25:17 +0000 |
commit | a3d2a9ec92ad4406ccf51ff45a4a1d2aa16eaa69 (patch) | |
tree | 6ced63b62e070382a4c517bf63c0b4625a6aa433 /src/sim | |
parent | 70f66f77942872ace0af50170dcbb68ef2311095 (diff) | |
download | gem5-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/sim')
-rw-r--r-- | src/sim/syscall_emul.hh | 9 | ||||
-rw-r--r-- | src/sim/system.cc | 17 |
2 files changed, 12 insertions, 14 deletions
diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh index fb6e9a168..6c3b172c2 100644 --- a/src/sim/syscall_emul.hh +++ b/src/sim/syscall_emul.hh @@ -1888,19 +1888,14 @@ mmapImpl(SyscallDesc *desc, int num, ThreadContext *tc, bool is_mmap2) // this will not work since there is a single global symbol table. ObjectFile *interpreter = p->getInterpreter(); if (interpreter) { - Addr text_start = interpreter->textBase(); - Addr text_end = text_start + interpreter->textSize(); - - Addr pc = tc->pcState().pc(); - - if (pc >= text_start && pc < text_end) { + if (interpreter->contains(tc->pcState().instAddr())) { std::shared_ptr<FDEntry> fdep = (*p->fds)[tgt_fd]; auto ffdp = std::dynamic_pointer_cast<FileFDEntry>(fdep); ObjectFile *lib = createObjectFile(ffdp->getFileName()); if (lib) { lib->loadAllSymbols(debugSymbolTable, - lib->textBase(), start); + lib->minSegmentAddr(), start); } } } diff --git a/src/sim/system.cc b/src/sim/system.cc index 73f93a257..bf8b45239 100644 --- a/src/sim/system.cc +++ b/src/sim/system.cc @@ -152,14 +152,16 @@ System::System(Params *p) } else { // Get the kernel code kernel = createObjectFile(params()->kernel); + kernel->setLoadOffset(loadAddrOffset); + kernel->setLoadMask(loadAddrMask); inform("kernel located at: %s", params()->kernel); if (kernel == NULL) fatal("Could not load kernel file %s", params()->kernel); // setup entry points - kernelStart = kernel->textBase(); - kernelEnd = kernel->bssBase() + kernel->bssSize(); + kernelStart = kernel->minSegmentAddr(); + kernelEnd = kernel->maxSegmentAddr(); kernelEntry = kernel->entryPoint(); // If load_addr_mask is set to 0x0, then auto-calculate @@ -168,6 +170,7 @@ System::System(Params *p) if (loadAddrMask == 0) { Addr shift_amt = findMsbSet(kernelEnd - kernelStart) + 1; loadAddrMask = ((Addr)1 << shift_amt) - 1; + kernel->setLoadMask(loadAddrMask); } // load symbols @@ -192,6 +195,8 @@ System::System(Params *p) ObjectFile *obj = createObjectFile(obj_name); fatal_if(!obj, "Failed to additional kernel object '%s'.\n", obj_name); + obj->setLoadOffset(loadAddrOffset); + obj->setLoadMask(loadAddrMask); kernelExtras.push_back(obj); } } @@ -327,11 +332,9 @@ System::initState() } } // Load program sections into memory - kernel->loadSegments(physProxy, loadAddrMask, loadAddrOffset); - for (const auto &extra_kernel : kernelExtras) { - extra_kernel->loadSegments(physProxy, loadAddrMask, - loadAddrOffset); - } + kernel->loadSegments(physProxy); + for (const auto &extra_kernel : kernelExtras) + extra_kernel->loadSegments(physProxy); DPRINTF(Loader, "Kernel start = %#x\n", kernelStart); DPRINTF(Loader, "Kernel end = %#x\n", kernelEnd); |