summaryrefslogtreecommitdiff
path: root/src/base/loader/elf_object.cc
diff options
context:
space:
mode:
authorAli Saidi <saidi@eecs.umich.edu>2007-01-22 16:17:11 -0500
committerAli Saidi <saidi@eecs.umich.edu>2007-01-22 16:17:11 -0500
commitddab4d756a5f2978fed1481bfaabbfabbc8eb1db (patch)
tree534267c6e0f22b991a3d76700c1c4ee4fa61372a /src/base/loader/elf_object.cc
parent01c959aeaf7f4c6e15bae9d8de227b6d2cbb7ae1 (diff)
parent5c1d631f36bc0d1a99875fb54b92a5df510fa9e3 (diff)
downloadgem5-ddab4d756a5f2978fed1481bfaabbfabbc8eb1db.tar.xz
Merge zizzer:/bk/newmem
into zeep.pool:/z/saidi/work/m5.newmem --HG-- extra : convert_revision : 21e1bfa49a933f3b39bd2e7bcd873428f9d01a1b
Diffstat (limited to 'src/base/loader/elf_object.cc')
-rw-r--r--src/base/loader/elf_object.cc38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/base/loader/elf_object.cc b/src/base/loader/elf_object.cc
index 7339507f6..89a5d4512 100644
--- a/src/base/loader/elf_object.cc
+++ b/src/base/loader/elf_object.cc
@@ -340,3 +340,41 @@ ElfObject::loadLocalSymbols(SymbolTable *symtab, Addr addrMask)
{
return loadSomeSymbols(symtab, STB_LOCAL);
}
+
+bool
+ElfObject::isDynamic()
+{
+ Elf *elf;
+ int sec_idx = 1; // there is a 0 but it is nothing, go figure
+ Elf_Scn *section;
+ GElf_Shdr shdr;
+
+ GElf_Ehdr ehdr;
+
+ // check that header matches library version
+ if (elf_version(EV_CURRENT) == EV_NONE)
+ panic("wrong elf version number!");
+
+ // get a pointer to elf structure
+ elf = elf_memory((char*)fileData,len);
+ assert(elf != NULL);
+
+ // Check that we actually have a elf file
+ if (gelf_getehdr(elf, &ehdr) ==0) {
+ panic("Not ELF, shouldn't be here");
+ }
+
+ // Get the first section
+ section = elf_getscn(elf, sec_idx);
+
+ // While there are no more sections
+ while (section != NULL) {
+ gelf_getshdr(section, &shdr);
+ if (!strcmp(".dynamic", elf_strptr(elf, ehdr.e_shstrndx, shdr.sh_name)))
+ return true;
+ section = elf_getscn(elf, ++sec_idx);
+ } // while sections
+ return false;
+}
+
+