objFile->bssSize();
brk_point = roundUp(brk_point, PageBytes);
- // Set up stack. On Alpha, stack goes below text section. This
- // code should get moved to some architecture-specific spot.
- Addr stack_base = objFile->textBase() - (409600+4096);
+ // Set up stack. On Alpha, stack goes below the image.
+ Addr stack_base = objFile->textBase() - (409600 + 4096);
// Set up region for mmaps.
Addr mmap_end = 0x10000;
// Patch the ld_bias for dynamic executables.
updateBias();
- objFile->loadSections(initVirtMem);
+ objFile->loadSegments(initVirtMem);
std::vector<AuxVector<uint64_t>> auxv;
System::initState();
// Load program sections into memory
- pal->loadSections(physProxy, loadAddrMask);
- console->loadSections(physProxy, loadAddrMask);
+ pal->loadSegments(physProxy, loadAddrMask);
+ console->loadSegments(physProxy, loadAddrMask);
/**
* Copy the osflags (kernel arguments) into the consoles
bootReleaseAddr = ra & ~ULL(0x7F);
dtb_file->setTextBase(params()->atags_addr + loadAddrOffset);
- dtb_file->loadSections(physProxy);
+ dtb_file->loadSegments(physProxy);
delete dtb_file;
// Kernel boot requirements to set up r0, r1 and r2 in ARMv7
}
dtb_file->setTextBase(params()->atags_addr + loadAddrOffset);
- dtb_file->loadSections(physProxy);
+ dtb_file->loadSegments(physProxy);
delete dtb_file;
} else {
// Using ATAGS
updateBias();
// load object file into target memory
- objFile->loadSections(initVirtMem);
+ objFile->loadSegments(initVirtMem);
//Setup the auxilliary vectors. These will already have endian conversion.
//Auxilliary vectors are loaded only for elf formatted executables.
if (bootldr) {
bool isGICv3System = dynamic_cast<Gicv3 *>(getGIC()) != nullptr;
- bootldr->loadSections(physProxy);
+ bootldr->loadSegments(physProxy);
inform("Using bootloader at address %#x\n", bootldr->entryPoint());
updateBias();
// load object file into target memory
- objFile->loadSections(initVirtMem);
+ objFile->loadSegments(initVirtMem);
std::vector<AuxVector<IntType>> auxv;
updateBias();
// load object file into target memory
- objFile->loadSections(initVirtMem);
+ objFile->loadSegments(initVirtMem);
//Setup the auxilliary vectors. These will already have endian conversion.
//Auxilliary vectors are loaded only for elf formatted executables.
RiscvSystem::initState();
// load program sections into memory
- if (!bootloader->loadSections(physProxy)) {
+ if (!bootloader->loadSegments(physProxy)) {
warn("could not load sections to memory");
}
}
const int addrSize = sizeof(IntType);
updateBias();
- objFile->loadSections(initVirtMem);
+ objFile->loadSegments(initVirtMem);
ElfObject* elfObject = dynamic_cast<ElfObject*>(objFile);
memState->setStackMin(memState->getStackBase());
updateBias();
// load object file into target memory
- objFile->loadSections(initVirtMem);
+ objFile->loadSegments(initVirtMem);
enum hardwareCaps
{
// Load reset binary into memory
reset->setTextBase(params()->reset_addr);
- reset->loadSections(physProxy);
+ reset->loadSegments(physProxy);
// Load the openboot binary
openboot->setTextBase(params()->openboot_addr);
- openboot->loadSections(physProxy);
+ openboot->loadSegments(physProxy);
// Load the hypervisor binary
hypervisor->setTextBase(params()->hypervisor_addr);
- hypervisor->loadSections(physProxy);
+ hypervisor->loadSegments(physProxy);
// Load the nvram image
nvram->setTextBase(params()->nvram_addr);
- nvram->loadSections(physProxy);
+ nvram->loadSegments(physProxy);
// Load the hypervisor description image
hypervisor_desc->setTextBase(params()->hypervisor_desc_addr);
- hypervisor_desc->loadSections(physProxy);
+ hypervisor_desc->loadSegments(physProxy);
// Load the partition description image
partition_desc->setTextBase(params()->partition_desc_addr);
- partition_desc->loadSections(physProxy);
+ partition_desc->loadSegments(physProxy);
// @todo any fixup code over writing data in binaries on setting break
updateBias();
// load object file into target memory
- objFile->loadSections(initVirtMem);
+ objFile->loadSegments(initVirtMem);
enum X86CpuFeature {
X86_OnboardFPU = 1 << 0,
// right now this is only used for Alpha PAL code
return new AoutObject(fname, len, data,
ObjectFile::Alpha, ObjectFile::UnknownOpSys);
- }
- else {
- return NULL;
+ } else {
+ return nullptr;
}
}
entry = execHdr->entry;
- text.baseAddr = N_TXTADDR(*execHdr);
+ text.base = N_TXTADDR(*execHdr);
text.size = execHdr->tsize;
- text.fileImage = fileData + N_TXTOFF(*execHdr);
+ text.data = fileData + N_TXTOFF(*execHdr);
- data.baseAddr = N_DATADDR(*execHdr);
+ data.base = N_DATADDR(*execHdr);
data.size = execHdr->dsize;
- data.fileImage = fileData + N_DATOFF(*execHdr);
+ data.data = fileData + N_DATOFF(*execHdr);
- bss.baseAddr = N_BSSADDR(*execHdr);
+ bss.base = N_BSSADDR(*execHdr);
bss.size = execHdr->bsize;
- bss.fileImage = NULL;
+ bss.data = NULL;
DPRINTFR(Loader, "text: 0x%x %d\ndata: 0x%x %d\nbss: 0x%x %d\n",
- text.baseAddr, text.size, data.baseAddr, data.size,
- bss.baseAddr, bss.size);
+ text.base, text.size, data.base, data.size,
+ bss.base, bss.size);
}
Arch _arch, OpSys _opSys)
: ObjectFile(_filename, _len, _data, _arch, _opSys)
{
- text.baseAddr = 0;
+ text.base = 0;
text.size = len;
- text.fileImage = fileData;
+ text.data = fileData;
- data.baseAddr = 0;
+ data.base = 0;
data.size = 0;
- data.fileImage = NULL;
+ data.data = nullptr;
- bss.baseAddr = 0;
+ bss.base = 0;
bss.size = 0;
- bss.fileImage = NULL;
+ bss.data = nullptr;
fileDataMmapped = true;
}
}
text.size = newLen;
- text.fileImage = fdt_buf_w_space;
+ text.data = fdt_buf_w_space;
// clean up old buffer and set to new fdt blob
munmap(fileData, this->len);
entry = aoutHdr->entry;
- text.baseAddr = aoutHdr->text_start;
+ text.base = aoutHdr->text_start;
text.size = aoutHdr->tsize;
- text.fileImage = fileData + ECOFF_TXTOFF(execHdr);
+ text.data = fileData + ECOFF_TXTOFF(execHdr);
- data.baseAddr = aoutHdr->data_start;
+ data.base = aoutHdr->data_start;
data.size = aoutHdr->dsize;
- data.fileImage = fileData + ECOFF_DATOFF(execHdr);
+ data.data = fileData + ECOFF_DATOFF(execHdr);
- bss.baseAddr = aoutHdr->bss_start;
+ bss.base = aoutHdr->bss_start;
bss.size = aoutHdr->bsize;
- bss.fileImage = NULL;
+ bss.data = nullptr;
- DPRINTFR(Loader, "text: 0x%x %d\ndata: 0x%x %d\nbss: 0x%x %d\n",
- text.baseAddr, text.size, data.baseAddr, data.size,
- bss.baseAddr, bss.size);
+ DPRINTFR(Loader, "text: %#x %d\ndata: %#x %d\nbss: %#x %d\n",
+ text.base, text.size, data.base, data.size,
+ bss.base, bss.size);
}
bool
// initialize segment sizes to 0 in case they're not present
text.size = data.size = bss.size = 0;
- text.baseAddr = data.baseAddr = bss.baseAddr = 0;
+ text.base = data.base = bss.base = 0;
int sec_idx = 1;
if (phdr.p_paddr <= bss_sec_start &&
phdr.p_paddr + phdr.p_memsz > bss_sec_start &&
phdr.p_memsz - phdr.p_filesz > 0) {
- bss.baseAddr = phdr.p_paddr + phdr.p_filesz;
+ bss.base = phdr.p_paddr + phdr.p_filesz;
bss.size = phdr.p_memsz - phdr.p_filesz;
- bss.fileImage = NULL;
+ bss.data = nullptr;
}
// Check to see if this is the text or data segment
if (phdr.p_vaddr != 0)
relocate = false;
- text.baseAddr = phdr.p_paddr;
+ text.base = phdr.p_paddr;
text.size = phdr.p_filesz;
- text.fileImage = fileData + phdr.p_offset;
+ text.data = fileData + phdr.p_offset;
} else if (phdr.p_vaddr <= data_sec_start &&
phdr.p_vaddr + phdr.p_filesz > data_sec_start) {
- data.baseAddr = phdr.p_paddr;
+ data.base = phdr.p_paddr;
data.size = phdr.p_filesz;
- data.fileImage = fileData + phdr.p_offset;
+ data.data = fileData + phdr.p_offset;
} else {
// If it's none of the above but is loadable,
// load the filesize worth of data
Segment extra;
- extra.baseAddr = phdr.p_paddr;
+ extra.base = phdr.p_paddr;
extra.size = phdr.p_filesz;
- extra.fileImage = fileData + phdr.p_offset;
+ extra.data = fileData + phdr.p_offset;
extraSegments.push_back(extra);
}
}
"Empty .text segment in '%s'. ELF file corrupted?\n",
filename);
- DPRINTFR(Loader, "text: 0x%x %d\ndata: 0x%x %d\nbss: 0x%x %d\n",
- text.baseAddr, text.size, data.baseAddr, data.size,
- bss.baseAddr, bss.size);
+ DPRINTFR(Loader, "text: %#x %d\ndata: %#x %d\nbss: %#x %d\n",
+ text.base, text.size, data.base, data.size,
+ bss.base, bss.size);
elf_end(elf);
}
bool
-ElfObject::loadSections(const PortProxy& mem_proxy, Addr addr_mask,
+ElfObject::loadSegments(const PortProxy& mem_proxy, Addr addr_mask,
Addr offset)
{
- if (!ObjectFile::loadSections(mem_proxy, addr_mask, offset))
+ if (!ObjectFile::loadSegments(mem_proxy, addr_mask, offset))
return false;
for (auto seg : extraSegments) {
- if (!loadSection(&seg, mem_proxy, addr_mask, offset)) {
+ if (!loadSegment(&seg, mem_proxy, addr_mask, offset)) {
return false;
}
}
if (interpreter)
- interpreter->loadSections(mem_proxy, addr_mask, offset);
+ interpreter->loadSegments(mem_proxy, addr_mask, offset);
return true;
}
entry += bias_addr;
// Patch segments with the bias_addr.
- text.baseAddr += bias_addr;
- data.baseAddr += bias_addr;
- bss.baseAddr += bias_addr;
+ text.base += bias_addr;
+ data.base += bias_addr;
+ bss.base += bias_addr;
for (auto &segment : extraSegments)
- segment.baseAddr += bias_addr;
+ segment.base += bias_addr;
}
class ElfObject : public ObjectFile
{
protected:
- // The global definition of a gem5 "Section" is closest to ELF's segments.
- typedef ObjectFile::Section Segment;
-
// These values are provided to a linux process by the kernel, so we
// need to keep them around.
Addr _programHeaderTable;
public:
virtual ~ElfObject() {}
- bool loadSections(const PortProxy& mem_proxy, Addr addr_mask = maxAddr,
+ bool loadSegments(const PortProxy& mem_proxy, Addr addr_mask = maxAddr,
Addr offset = 0) override;
virtual bool loadAllSymbols(SymbolTable *symtab, Addr base = 0,
}
bool
-HexFile::loadSections(PortProxy& memProxy)
+HexFile::loadSegments(PortProxy& memProxy)
{
char Line[64];
Addr MemAddr;
virtual ~HexFile();
void close();
- bool loadSections(PortProxy& memProxy);
+ bool loadSegments(PortProxy& memProxy);
};
#endif // __BASE_LOADER_HEX_FILE_HH__
bool
-ObjectFile::loadSection(Section *sec, const PortProxy& mem_proxy,
+ObjectFile::loadSegment(Segment *seg, const PortProxy& mem_proxy,
Addr addr_mask, Addr offset)
{
- if (sec->size != 0) {
- Addr addr = (sec->baseAddr & addr_mask) + offset;
- if (sec->fileImage) {
- mem_proxy.writeBlob(addr, sec->fileImage, sec->size);
- }
- else {
+ if (seg->size != 0) {
+ Addr addr = (seg->base & addr_mask) + offset;
+ if (seg->data) {
+ mem_proxy.writeBlob(addr, seg->data, seg->size);
+ } else {
// no image: must be bss
- mem_proxy.memsetBlob(addr, 0, sec->size);
+ mem_proxy.memsetBlob(addr, 0, seg->size);
}
}
return true;
bool
-ObjectFile::loadSections(const PortProxy& mem_proxy, Addr addr_mask,
+ObjectFile::loadSegments(const PortProxy& mem_proxy, Addr addr_mask,
Addr offset)
{
- return (loadSection(&text, mem_proxy, addr_mask, offset)
- && loadSection(&data, mem_proxy, addr_mask, offset)
- && loadSection(&bss, mem_proxy, addr_mask, offset));
+ return (loadSegment(&text, mem_proxy, addr_mask, offset)
+ && loadSegment(&data, mem_proxy, addr_mask, offset)
+ && loadSegment(&bss, mem_proxy, addr_mask, offset));
}
namespace
static const Addr maxAddr = std::numeric_limits<Addr>::max();
- virtual bool loadSections(const PortProxy& mem_proxy,
- Addr mask = maxAddr, Addr offset = 0);
+ virtual bool loadSegments(const PortProxy &mem_proxy,
+ Addr mask=maxAddr, Addr offset=0);
virtual bool loadAllSymbols(SymbolTable *symtab, Addr base = 0,
- Addr offset = 0, Addr mask = maxAddr) = 0;
+ Addr offset=0, Addr mask=maxAddr) = 0;
virtual bool loadGlobalSymbols(SymbolTable *symtab, Addr base = 0,
- Addr offset = 0, Addr mask = maxAddr) = 0;
- virtual bool loadLocalSymbols(SymbolTable *symtab, Addr base = 0,
- Addr offset = 0, Addr mask = maxAddr) = 0;
- virtual bool loadWeakSymbols(SymbolTable *symtab, Addr base = 0,
- Addr offset = 0, Addr mask = maxAddr)
+ Addr offset=0, Addr mask=maxAddr) = 0;
+ virtual bool loadLocalSymbols(SymbolTable *symtab, Addr base=0,
+ Addr offset=0, Addr mask=maxAddr) = 0;
+ virtual bool loadWeakSymbols(SymbolTable *symtab, Addr base=0,
+ Addr offset=0, Addr mask=maxAddr)
{ return false; }
virtual ObjectFile *getInterpreter() const { return nullptr; }
protected:
- struct Section {
- Addr baseAddr;
- uint8_t *fileImage;
+ struct Segment
+ {
+ Addr base;
+ uint8_t *data;
size_t size;
};
Addr entry;
- Section text;
- Section data;
- Section bss;
+ Segment text;
+ Segment data;
+ Segment bss;
- bool loadSection(Section *sec, const PortProxy& mem_proxy, Addr mask,
- Addr offset = 0);
+ bool loadSegment(Segment *seg, const PortProxy &mem_proxy, Addr mask,
+ Addr offset=0);
public:
Addr entryPoint() const { return entry; }
- Addr textBase() const { return text.baseAddr; }
- Addr dataBase() const { return data.baseAddr; }
- Addr bssBase() const { return bss.baseAddr; }
+ Addr textBase() const { return text.base; }
+ Addr dataBase() const { return data.base; }
+ Addr bssBase() const { return bss.base; }
size_t textSize() const { return text.size; }
size_t dataSize() const { return data.size; }
* blob that doesn't include an object header.
* @param a address to load the binary/text section at
*/
- void setTextBase(Addr a) { text.baseAddr = a; }
+ void setTextBase(Addr a) { text.base = a; }
/**
* Each instance of a Loader subclass will have a chance to try to load
uint8_t *_data, Arch _arch, OpSys _opSys)
: ObjectFile(_filename, _len, _data, _arch, _opSys)
{
- text.baseAddr = 0;
+ text.base = 0;
text.size = len;
- text.fileImage = fileData;
+ text.data = fileData;
- data.baseAddr = 0;
+ data.base = 0;
data.size = 0;
- data.fileImage = NULL;
+ data.data = nullptr;
- bss.baseAddr = 0;
+ bss.base = 0;
bss.size = 0;
- bss.fileImage = NULL;
+ bss.data = nullptr;
- DPRINTFR(Loader, "text: 0x%x %d\ndata: 0x%x %d\nbss: 0x%x %d\n",
- text.baseAddr, text.size, data.baseAddr, data.size,
- bss.baseAddr, bss.size);
+ DPRINTFR(Loader, "text: %#x %d\ndata: %#x %d\nbss: %#x %d\n",
+ text.base, text.size, data.base, data.size,
+ bss.base, bss.size);
}
bool
RawObject::loadGlobalSymbols(SymbolTable *symtab, Addr base, Addr offset,
Addr addr_mask)
{
-/* int fnameStart = filename.rfind('/',filename.size()) + 1;
- int extStart = filename.rfind('.',filename.size());
- symtab->insert(text.baseAddr & addr_mask, filename.substr(fnameStart,
- extStart-fnameStart) + "_start");*/
return true;
}
RawObject::loadLocalSymbols(SymbolTable *symtab, Addr base, Addr offset,
Addr addr_mask)
{
-/* int fnameStart = filename.rfind('/',filename.size()) + 1;
- int extStart = filename.rfind('.',filename.size());
- symtab->insert(text.baseAddr & addr_mask, filename.substr(fnameStart,
- extStart-fnameStart) + "_start");*/
return true;
}
}
}
// Load program sections into memory
- kernel->loadSections(physProxy, loadAddrMask, loadAddrOffset);
+ kernel->loadSegments(physProxy, loadAddrMask, loadAddrOffset);
for (const auto &extra_kernel : kernelExtras) {
- extra_kernel->loadSections(physProxy, loadAddrMask,
+ extra_kernel->loadSegments(physProxy, loadAddrMask,
loadAddrOffset);
}