Merge saidi@zizzer.eecs.umich.edu:/bk/linux
[gem5.git] / base / loader / elf_object.cc
index f2a67f22e32cf8d9629573db4b78860221f2af7d..b8f46449a0ae9033693309d723c86752b9312ed2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003 The Regents of The University of Michigan
+ * Copyright (c) 2003-2004 The Regents of The University of Michigan
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -36,6 +36,7 @@
 // set this now (it causes things to break on 64-bit platforms).
 #define __LIBELF64_LINUX        0
 #define __LIBELF_NEED_LINK_H    0
+#define __LIBELF_SYMBOL_VERSIONS 0
 
 #include <libelf/libelf.h>
 #include <libelf/gelf.h>
@@ -73,8 +74,9 @@ ElfObject::tryFile(const string &fname, int fd, size_t len, uint8_t *data)
     else {
         if (ehdr.e_ident[EI_CLASS] == ELFCLASS32)
             panic("32 bit ELF Binary, Not Supported");
-        if (ehdr.e_machine != EM_ALPHA)
-            panic("Non Alpha Binary, Not Supported");
+        printf("emachine = %x\n", ehdr.e_machine);
+//        if (ehdr.e_machine != EM_ALPHA)
+//            panic("Non Alpha Binary, Not Supported");
 
         elf_end(elf);
 
@@ -190,7 +192,7 @@ bool
 ElfObject::loadSomeSymbols(SymbolTable *symtab, int binding)
 {
     Elf *elf;
-    int secidx = 1; // there is a 0 but it is nothing, go figure
+    int sec_idx = 1; // there is a 0 but it is nothing, go figure
     Elf_Scn *section;
     GElf_Shdr shdr;
     Elf_Data *data;
@@ -210,7 +212,7 @@ ElfObject::loadSomeSymbols(SymbolTable *symtab, int binding)
     assert(elf != NULL);
 
     // Get the first section
-    section = elf_getscn(elf, secidx);
+    section = elf_getscn(elf, sec_idx);
 
     // While there are no more sections
     while (section != NULL) {
@@ -225,14 +227,14 @@ ElfObject::loadSomeSymbols(SymbolTable *symtab, int binding)
             // loop through all the symbols, only loading global ones
             for (ii = 0; ii < count; ++ii) {
                 gelf_getsym(data, ii, &sym);
-                if (GELF_ST_BIND(sym.st_info) & binding) {
+                if (GELF_ST_BIND(sym.st_info) == binding) {
                    symtab->insert(sym.st_value,
                                   elf_strptr(elf, shdr.sh_link, sym.st_name));
                 }
             }
         }
-        ++secidx;
-        section = elf_getscn(elf, secidx);
+        ++sec_idx;
+        section = elf_getscn(elf, sec_idx);
     }
 
     elf_end(elf);