diff options
author | Ali Saidi <saidi@eecs.umich.edu> | 2004-01-14 04:18:20 -0500 |
---|---|---|
committer | Ali Saidi <saidi@eecs.umich.edu> | 2004-01-14 04:18:20 -0500 |
commit | c9d88aa08941d41d3d89d91b2c1c5e6eaa6f2894 (patch) | |
tree | 8fc04085be1729c45b28e2c6fbb294e5ec15b8eb /base | |
parent | a44248aab04a3b48864308a478ad676def175158 (diff) | |
download | gem5-c9d88aa08941d41d3d89d91b2c1c5e6eaa6f2894.tar.xz |
Minor fixes to loader and an additional header file in alpha_access.h
when we are compiling the console.
base/loader/elf_object.cc:
added code to verify that the .bss section is 0;
added code to only load function and label types
dev/alpha_access.h:
include inittypes if we are compiling the console code
--HG--
extra : convert_revision : b88fb36500b1c1003d44ed95cefdd2a30b7466b8
Diffstat (limited to 'base')
-rw-r--r-- | base/loader/elf_object.cc | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/base/loader/elf_object.cc b/base/loader/elf_object.cc index d43e2fe7c..2cdce4259 100644 --- a/base/loader/elf_object.cc +++ b/base/loader/elf_object.cc @@ -115,10 +115,14 @@ ElfObject::loadSections(FunctionalMemory *mem, bool loadPhys) Elf_Scn *section; GElf_Shdr shdr; GElf_Ehdr ehdr; + uint8_t *zeromem; + uint8_t *sectionData; Addr address; char *secname; + + /* check that header matches library version */ assert(elf_version(EV_CURRENT) != EV_NONE); @@ -152,6 +156,9 @@ ElfObject::loadSections(FunctionalMemory *mem, bool loadPhys) elf_strptr(elf, ehdr.e_shstrndx, shdr.sh_name), shdr.sh_addr, shdr.sh_size, shdr.sh_offset, shdr.sh_flags, shdr.sh_flags & SHF_ALLOC ? "ALLOC" : ""); secname = elf_strptr(elf, ehdr.e_shstrndx, shdr.sh_name); + + sectionData = fileData + shdr.sh_offset; + if(secname) { if (strcmp(secname, ".text")==0) @@ -168,6 +175,13 @@ ElfObject::loadSections(FunctionalMemory *mem, bool loadPhys) { bss.baseAddr = shdr.sh_addr; bss.size = shdr.sh_size; + + /* If this is the .bss section it must be 0, so just + to be extra causious, lets allocate some memory + bzero it, and write that */ + zeromem = (uint8_t*)malloc(shdr.sh_size); + memset(zeromem, 0, shdr.sh_size); + sectionData = zeromem; } } if(shdr.sh_size != 0) @@ -175,11 +189,11 @@ ElfObject::loadSections(FunctionalMemory *mem, bool loadPhys) if (loadPhys) { address = shdr.sh_addr &= (ULL(1) << 40) - 1; - mem->prot_write(address, fileData + shdr.sh_offset, shdr.sh_size); + mem->prot_write(address, sectionData, shdr.sh_size); } else { - mem->prot_write(shdr.sh_addr, fileData + shdr.sh_offset, shdr.sh_size); + mem->prot_write(shdr.sh_addr, sectionData, shdr.sh_size); } } @@ -188,6 +202,7 @@ ElfObject::loadSections(FunctionalMemory *mem, bool loadPhys) ++secidx; section = elf_getscn(elf, secidx); } + free(zeromem); elf_end(elf); @@ -239,7 +254,8 @@ ElfObject::loadGlobalSymbols(SymbolTable *symtab) for (ii = 0; ii < count; ++ii) { gelf_getsym(data, ii, &sym); - if (GELF_ST_BIND(sym.st_info) & STB_GLOBAL) + if ((GELF_ST_BIND(sym.st_info) & STB_GLOBAL) && + ((GELF_ST_TYPE(sym.st_info) == STT_FUNC) || (GELF_ST_TYPE(sym.st_info) == STT_NOTYPE))) { symtab->insert(sym.st_value, elf_strptr(elf, shdr.sh_link, sym.st_name)); } |