mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-12 13:38:21 +00:00
Fix SymbolRef::getAddress implementation for ELF. The 'value' field in symbol table entry should be treated differently for relocatable and relocated files. This patch fixes symbol addresses printed by llvm-nm for executables and shared objects.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164365 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -951,7 +951,18 @@ error_code ELFObjectFile<target_endianness, is64Bits>
|
||||
case ELF::STT_FUNC:
|
||||
case ELF::STT_OBJECT:
|
||||
case ELF::STT_NOTYPE:
|
||||
Result = symb->st_value + (Section ? Section->sh_addr : 0);
|
||||
bool IsRelocatable;
|
||||
switch(Header->e_type) {
|
||||
case ELF::ET_EXEC:
|
||||
case ELF::ET_DYN:
|
||||
IsRelocatable = false;
|
||||
break;
|
||||
default:
|
||||
IsRelocatable = true;
|
||||
}
|
||||
Result = symb->st_value;
|
||||
if (IsRelocatable && Section != 0)
|
||||
Result += Section->sh_addr;
|
||||
return object_error::success;
|
||||
default:
|
||||
Result = UnknownAddressOrSize;
|
||||
|
@ -212,6 +212,8 @@ public:
|
||||
error_code getNext(SymbolRef &Result) const;
|
||||
|
||||
error_code getName(StringRef &Result) const;
|
||||
/// Returns the symbol virtual address (i.e. address at which it will be
|
||||
/// mapped).
|
||||
error_code getAddress(uint64_t &Result) const;
|
||||
error_code getFileOffset(uint64_t &Result) const;
|
||||
error_code getSize(uint64_t &Result) const;
|
||||
|
Reference in New Issue
Block a user