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/riscv/bare_metal/system.cc | 2 +- src/arch/riscv/process.cc | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) (limited to 'src/arch/riscv') diff --git a/src/arch/riscv/bare_metal/system.cc b/src/arch/riscv/bare_metal/system.cc index 3fb07a489..44e14e5ce 100644 --- a/src/arch/riscv/bare_metal/system.cc +++ b/src/arch/riscv/bare_metal/system.cc @@ -55,7 +55,7 @@ BareMetalRiscvSystem::initState() RiscvSystem::initState(); // load program sections into memory - if (!bootloader->loadSegments(physProxy)) { + if (!bootloader->buildImage().write(physProxy)) { warn("could not load sections to memory"); } } diff --git a/src/arch/riscv/process.cc b/src/arch/riscv/process.cc index 35dde7600..617efa0ee 100644 --- a/src/arch/riscv/process.cc +++ b/src/arch/riscv/process.cc @@ -75,7 +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->maxSegmentAddr(), PageBytes); + const Addr brk_point = roundUp(image.maxAddr(), PageBytes); const Addr mmap_end = 0x4000000000000000L; memState = make_shared(brk_point, stack_base, max_stack_size, next_thread_stack_base, mmap_end); @@ -87,7 +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->maxSegmentAddr(), PageBytes); + const Addr brk_point = roundUp(image.maxAddr(), PageBytes); const Addr mmap_end = 0x40000000L; memState = make_shared(brk_point, stack_base, max_stack_size, next_thread_stack_base, mmap_end); @@ -123,10 +123,6 @@ RiscvProcess::argsInit(int pageSize) const int RandomBytes = 16; const int addrSize = sizeof(IntType); - updateBias(); - objFile->loadSegments(initVirtMem); - if (objFile->getInterpreter()) - objFile->getInterpreter()->loadSegments(initVirtMem); ElfObject* elfObject = dynamic_cast(objFile); memState->setStackMin(memState->getStackBase()); -- cgit v1.2.3