more changes for subtick labels.
[gem5.git] / base / loader / elf_object.cc
index 9889b9d4cc98b41a7663ffb095df380f7d1ce8f3..b74d537af8e7f9e42920fa5b6fd58a7e17de975b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003 The Regents of The University of Michigan
+ * Copyright (c) 2003-2005 The Regents of The University of Michigan
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
 // 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>
 
 #include "base/loader/elf_object.hh"
 
-#include "mem/functional_mem/functional_memory.hh"
+#include "mem/functional/functional.hh"
 #include "base/loader/symtab.hh"
 
 #include "base/trace.hh"       // for DPRINTF
@@ -57,7 +58,8 @@ ElfObject::tryFile(const string &fname, int fd, size_t len, uint8_t *data)
     GElf_Ehdr ehdr;
 
     // check that header matches library version
-    assert(elf_version(EV_CURRENT) != EV_NONE);
+    if (elf_version(EV_CURRENT) == EV_NONE)
+        panic("wrong elf version number!");
 
     // get a pointer to elf structure
     elf = elf_memory((char*)data,len);
@@ -73,8 +75,10 @@ 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");
+        /* @todo this emachine value isn't offical yet.
+         *       so we probably shouldn't check it. */
+//        if (ehdr.e_machine != EM_ALPHA)
+//            panic("Non Alpha Binary, Not Supported");
 
         elf_end(elf);
 
@@ -94,7 +98,8 @@ ElfObject::ElfObject(const string &_filename, int _fd,
     GElf_Ehdr ehdr;
 
     // check that header matches library version
-    assert(elf_version(EV_CURRENT) != EV_NONE);
+    if (elf_version(EV_CURRENT) == EV_NONE)
+        panic("wrong elf version number!");
 
     // get a pointer to elf structure
     elf = elf_memory((char*)fileData,len);
@@ -202,7 +207,8 @@ ElfObject::loadSomeSymbols(SymbolTable *symtab, int binding)
         return false;
 
     // check that header matches library version
-    assert(elf_version(EV_CURRENT) != EV_NONE);
+    if (elf_version(EV_CURRENT) == EV_NONE)
+        panic("wrong elf version number!");
 
     // get a pointer to elf structure
     elf = elf_memory((char*)fileData,len);
@@ -225,7 +231,7 @@ 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));
                 }