From 6ee86bf497ea87a585fe8e4651760e71244fa2fb Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Tue, 1 Oct 2019 21:15:06 -0700 Subject: arch,base: Separate the idea of a memory image and object file. A memory image can be described by an object file, but an object file is more than a memory image. Also, it makes sense to manipulate a memory image to, for instance, change how it's loaded into memory. That takes on larger implications (relocations, the entry point, symbols, etc.) when talking about the whole object file, and also modifies aspects which may not need to change. For instance if an image needs to be loaded into memory at addresses different from what's in the object file, but other things like symbols need to stay unmodified. Change-Id: Ia360405ffb2c1c48e0cc201ac0a0764357996a54 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/21466 Tested-by: kokoro Reviewed-by: Brandon Potter Maintainer: Gabe Black --- src/arch/arm/freebsd/system.cc | 4 ++-- src/arch/arm/linux/system.cc | 4 ++-- src/arch/arm/process.cc | 12 ++---------- src/arch/arm/system.cc | 2 +- 4 files changed, 7 insertions(+), 15 deletions(-) (limited to 'src/arch/arm') diff --git a/src/arch/arm/freebsd/system.cc b/src/arch/arm/freebsd/system.cc index 764f036b4..106c8e432 100644 --- a/src/arch/arm/freebsd/system.cc +++ b/src/arch/arm/freebsd/system.cc @@ -132,8 +132,8 @@ FreebsdArmSystem::initState() if (ra) bootReleaseAddr = ra & ~ULL(0x7F); - dtb_file->setLoadOffset(params()->atags_addr + loadAddrOffset); - dtb_file->loadSegments(physProxy); + dtb_file->buildImage(). + offset(params()->atags_addr + loadAddrOffset).write(physProxy); delete dtb_file; // Kernel boot requirements to set up r0, r1 and r2 in ARMv7 diff --git a/src/arch/arm/linux/system.cc b/src/arch/arm/linux/system.cc index a0869b46a..740d2e0e6 100644 --- a/src/arch/arm/linux/system.cc +++ b/src/arch/arm/linux/system.cc @@ -151,8 +151,8 @@ LinuxArmSystem::initState() "to DTB file: %s\n", params()->dtb_filename); } - dtb_file->setLoadOffset(params()->atags_addr + loadAddrOffset); - dtb_file->loadSegments(physProxy); + dtb_file->buildImage(). + offset(params()->atags_addr + loadAddrOffset).write(physProxy); delete dtb_file; } else { // Using ATAGS diff --git a/src/arch/arm/process.cc b/src/arch/arm/process.cc index ff3b92f48..d9b714c44 100644 --- a/src/arch/arm/process.cc +++ b/src/arch/arm/process.cc @@ -75,7 +75,7 @@ ArmProcess32::ArmProcess32(ProcessParams *params, ObjectFile *objFile, ObjectFile::Arch _arch) : ArmProcess(params, objFile, _arch) { - Addr brk_point = roundUp(objFile->maxSegmentAddr(), PageBytes); + Addr brk_point = roundUp(image.maxAddr(), PageBytes); Addr stack_base = 0xbf000000L; Addr max_stack_size = 8 * 1024 * 1024; Addr next_thread_stack_base = stack_base - max_stack_size; @@ -89,7 +89,7 @@ ArmProcess64::ArmProcess64(ProcessParams *params, ObjectFile *objFile, ObjectFile::Arch _arch) : ArmProcess(params, objFile, _arch) { - Addr brk_point = roundUp(objFile->maxSegmentAddr(), PageBytes); + Addr brk_point = roundUp(image.maxAddr(), PageBytes); Addr stack_base = 0x7fffff0000L; Addr max_stack_size = 8 * 1024 * 1024; Addr next_thread_stack_base = stack_base - max_stack_size; @@ -266,14 +266,6 @@ ArmProcess::argsInit(int pageSize, IntRegIndex spIndex) //We want 16 byte alignment uint64_t align = 16; - // Patch the ld_bias for dynamic executables. - updateBias(); - - // load object file into target memory - objFile->loadSegments(initVirtMem); - if (objFile->getInterpreter()) - objFile->getInterpreter()->loadSegments(initVirtMem); - //Setup the auxilliary vectors. These will already have endian conversion. //Auxilliary vectors are loaded only for elf formatted executables. ElfObject * elfObject = dynamic_cast(objFile); diff --git a/src/arch/arm/system.cc b/src/arch/arm/system.cc index efc347d9d..bf2881026 100644 --- a/src/arch/arm/system.cc +++ b/src/arch/arm/system.cc @@ -143,7 +143,7 @@ ArmSystem::initState() if (bootldr) { bool isGICv3System = dynamic_cast(getGIC()) != nullptr; - bootldr->loadSegments(physProxy); + bootldr->buildImage().write(physProxy); inform("Using bootloader at address %#x\n", bootldr->entryPoint()); -- cgit v1.2.3