diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2015-07-23 09:11:05 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2015-07-23 09:11:05 +0000 |
| commit | b82657d3f14aa00df26549dc80319b33db14409f (patch) | |
| tree | b6f41daba68f74ed027f643d5c6a2d9e7cdc9fbd /llvm | |
| parent | 05569f679a132d146252f31810409d176438a9ac (diff) | |
| download | bcm5719-llvm-b82657d3f14aa00df26549dc80319b33db14409f.tar.gz bcm5719-llvm-b82657d3f14aa00df26549dc80319b33db14409f.zip | |
Support printing relocations in files with no section table.
llvm-svn: 242998
Diffstat (limited to 'llvm')
| -rwxr-xr-x | llvm/test/Object/Inputs/rel-no-sec-table.elf-x86-64 | bin | 0 -> 2152 bytes | |||
| -rw-r--r-- | llvm/test/Object/relocation-executable.test | 12 | ||||
| -rw-r--r-- | llvm/tools/llvm-readobj/ELFDumper.cpp | 13 |
3 files changed, 21 insertions, 4 deletions
diff --git a/llvm/test/Object/Inputs/rel-no-sec-table.elf-x86-64 b/llvm/test/Object/Inputs/rel-no-sec-table.elf-x86-64 Binary files differnew file mode 100755 index 00000000000..d527305d659 --- /dev/null +++ b/llvm/test/Object/Inputs/rel-no-sec-table.elf-x86-64 diff --git a/llvm/test/Object/relocation-executable.test b/llvm/test/Object/relocation-executable.test index 38ad5968af8..93d4dee3089 100644 --- a/llvm/test/Object/relocation-executable.test +++ b/llvm/test/Object/relocation-executable.test @@ -35,3 +35,15 @@ RUN: %p/Inputs/hello-world.elf-x86-64 | FileCheck %s --check-prefix=DYN // DYN-NEXT: Addend: 0x0 // DYN-NEXT: } // DYN-NEXT: } + +RUN: llvm-readobj -dyn-relocations -expand-relocs \ +RUN: %p/Inputs/rel-no-sec-table.elf-x86-64 | FileCheck %s --check-prefix=DYN2 + +// DYN2: Dynamic Relocations { +// DYN2-NEXT: Relocation { +// DYN2-NEXT: Offset: 0x12F0 +// DYN2-NEXT: Type: R_X86_64_GLOB_DAT (6) +// DYN2-NEXT: Symbol: g +// DYN2-NEXT: Addend: 0x0 +// DYN2-NEXT: } +// DYN2-NEXT: } diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp index 6e4eaec475c..b4118f06665 100644 --- a/llvm/tools/llvm-readobj/ELFDumper.cpp +++ b/llvm/tools/llvm-readobj/ELFDumper.cpp @@ -110,6 +110,7 @@ private: DynRegionInfo DynRelaRegion; DynRegionInfo DynamicRegion; StringRef DynamicStringTable; + const Elf_Sym *DynSymStart = nullptr; StringRef SOName; const Elf_Hash *HashTable = nullptr; }; @@ -660,6 +661,10 @@ ELFDumper<ELFT>::ELFDumper(const ELFFile<ELFT> *Obj, StreamWriter &Writer) case ELF::DT_STRSZ: StringTableSize = Dyn.getVal(); break; + case ELF::DT_SYMTAB: + DynSymStart = + reinterpret_cast<const Elf_Sym *>(toMappedAddr(Dyn.getPtr())); + break; } } if (StringTableBegin) @@ -837,7 +842,7 @@ void ELFDumper<ELFT>::printDynamicRelocations() { Obj->getRelocationTypeName(Rel.getType(Obj->isMips64EL()), RelocName); StringRef SymbolName; uint32_t SymIndex = Rel.getSymbol(Obj->isMips64EL()); - const Elf_Sym *Sym = Obj->dynamic_symbol_begin() + SymIndex; + const Elf_Sym *Sym = DynSymStart + SymIndex; SymbolName = errorOrDefault(Sym->getName(DynamicStringTable)); if (opts::ExpandRelocs) { DictScope Group(W, "Relocation"); @@ -931,7 +936,7 @@ void ELFDumper<ELFT>::printDynamicSymbols() { ErrorOr<StringRef> StrTableOrErr = Obj->getStringTableForSymtab(*Symtab); error(StrTableOrErr.getError()); StringRef StrTable = *StrTableOrErr; - for (const Elf_Sym &Sym : Obj->dynamic_symbols()) + for (const Elf_Sym &Sym : Obj->symbols(Symtab)) printSymbol(&Sym, StrTable, true); } @@ -1431,8 +1436,8 @@ template <class ELFT> void MipsGOTParser<ELFT>::parseGOT() { const Elf_Shdr *DynSymSec = Obj->getDotDynSymSec(); ErrorOr<StringRef> StrTable = Obj->getStringTableForSymtab(*DynSymSec); error(StrTable.getError()); - const Elf_Sym *DynSymBegin = Obj->dynamic_symbol_begin(); - const Elf_Sym *DynSymEnd = Obj->dynamic_symbol_end(); + const Elf_Sym *DynSymBegin = Obj->symbol_begin(DynSymSec); + const Elf_Sym *DynSymEnd = Obj->symbol_end(DynSymSec); std::size_t DynSymTotal = std::size_t(std::distance(DynSymBegin, DynSymEnd)); if (*DtGotSym > DynSymTotal) { |

