From b54e11862878cf88a427fa225407d1128abd21f2 Mon Sep 17 00:00:00 2001 From: "Deyuan Guo ext:(%2C%20Nilay%20Vaish%20%3Cnilay%40cs.wisc.edu%3E)" Date: Wed, 17 Apr 2013 16:07:19 -0500 Subject: [PATCH] base: load weak symbols from object file Without loading weak symbols into gem5, some function names and the given PC cannot correspond correctly, because the binding attributes of unction names in an ELF file are not only STB_GLOBAL or STB_LOCAL, but also STB_WEAK. This patch adds a function for loading weak symbols. Committed by: Nilay Vaish --- src/base/loader/elf_object.cc | 6 ++++++ src/base/loader/elf_object.hh | 2 ++ src/base/loader/object_file.hh | 3 +++ src/sim/process.cc | 3 ++- 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/base/loader/elf_object.cc b/src/base/loader/elf_object.cc index f6a18db8a..b6253adbe 100644 --- a/src/base/loader/elf_object.cc +++ b/src/base/loader/elf_object.cc @@ -414,6 +414,12 @@ ElfObject::loadLocalSymbols(SymbolTable *symtab, Addr addrMask) return loadSomeSymbols(symtab, STB_LOCAL, addrMask); } +bool +ElfObject::loadWeakSymbols(SymbolTable *symtab, Addr addrMask) +{ + return loadSomeSymbols(symtab, STB_WEAK, addrMask); +} + bool ElfObject::loadSections(PortProxy& memProxy, Addr addrMask) { diff --git a/src/base/loader/elf_object.hh b/src/base/loader/elf_object.hh index 350a80db1..d3d3e5197 100644 --- a/src/base/loader/elf_object.hh +++ b/src/base/loader/elf_object.hh @@ -71,6 +71,8 @@ class ElfObject : public ObjectFile std::numeric_limits::max()); virtual bool loadLocalSymbols(SymbolTable *symtab, Addr addrMask = std::numeric_limits::max()); + virtual bool loadWeakSymbols(SymbolTable *symtab, Addr addrMask = + std::numeric_limits::max()); virtual bool isDynamic() { return sectionExists(".interp"); } virtual bool hasTLS() { return sectionExists(".tbss"); } diff --git a/src/base/loader/object_file.hh b/src/base/loader/object_file.hh index 4a789d321..bdc9a31a1 100644 --- a/src/base/loader/object_file.hh +++ b/src/base/loader/object_file.hh @@ -89,6 +89,9 @@ class ObjectFile std::numeric_limits::max()) = 0; virtual bool loadLocalSymbols(SymbolTable *symtab, Addr addrMask = std::numeric_limits::max()) = 0; + virtual bool loadWeakSymbols(SymbolTable *symtab, Addr addrMask = + std::numeric_limits::max()) + { return false; } virtual bool isDynamic() { return false; } virtual bool hasTLS() { return false; } diff --git a/src/sim/process.cc b/src/sim/process.cc index 22a886303..1654ea5c5 100644 --- a/src/sim/process.cc +++ b/src/sim/process.cc @@ -574,7 +574,8 @@ LiveProcess::LiveProcess(LiveProcessParams * params, ObjectFile *_objFile) if (!debugSymbolTable) { debugSymbolTable = new SymbolTable(); if (!objFile->loadGlobalSymbols(debugSymbolTable) || - !objFile->loadLocalSymbols(debugSymbolTable)) { + !objFile->loadLocalSymbols(debugSymbolTable) || + !objFile->loadWeakSymbols(debugSymbolTable)) { // didn't load any symbols delete debugSymbolTable; debugSymbolTable = NULL; -- 2.30.2