Only ELF has a dynamic symbol table. Remove it from ObjectFile.

COFF has only one symbol table.
MachO has a LC_DYSYMTAB, but that is not a symbol table, just extra info about
the one symbol table (LC_SYMTAB).
IR (coming soon) also has only one table.

llvm-svn: 200488
This commit is contained in:
Rafael Espindola 2014-01-30 20:45:33 +00:00
parent 41186dd288
commit 196666cf5f
8 changed files with 41 additions and 34 deletions

View File

@ -335,8 +335,6 @@ public:
COFFObjectFile(MemoryBuffer *Object, error_code &EC, bool BufferOwned = true);
symbol_iterator begin_symbols() const LLVM_OVERRIDE;
symbol_iterator end_symbols() const LLVM_OVERRIDE;
symbol_iterator begin_dynamic_symbols() const LLVM_OVERRIDE;
symbol_iterator end_dynamic_symbols() const LLVM_OVERRIDE;
library_iterator begin_libraries_needed() const LLVM_OVERRIDE;
library_iterator end_libraries_needed() const LLVM_OVERRIDE;
section_iterator begin_sections() const LLVM_OVERRIDE;

View File

@ -183,8 +183,8 @@ public:
symbol_iterator begin_symbols() const LLVM_OVERRIDE;
symbol_iterator end_symbols() const LLVM_OVERRIDE;
symbol_iterator begin_dynamic_symbols() const LLVM_OVERRIDE;
symbol_iterator end_dynamic_symbols() const LLVM_OVERRIDE;
symbol_iterator begin_dynamic_symbols() const;
symbol_iterator end_dynamic_symbols() const;
section_iterator begin_sections() const LLVM_OVERRIDE;
section_iterator end_sections() const LLVM_OVERRIDE;

View File

@ -130,9 +130,6 @@ public:
symbol_iterator begin_symbols() const LLVM_OVERRIDE;
symbol_iterator end_symbols() const LLVM_OVERRIDE;
symbol_iterator begin_dynamic_symbols() const LLVM_OVERRIDE;
symbol_iterator end_dynamic_symbols() const LLVM_OVERRIDE;
section_iterator begin_sections() const LLVM_OVERRIDE;
section_iterator end_sections() const LLVM_OVERRIDE;

View File

@ -347,9 +347,6 @@ public:
virtual symbol_iterator begin_symbols() const = 0;
virtual symbol_iterator end_symbols() const = 0;
virtual symbol_iterator begin_dynamic_symbols() const = 0;
virtual symbol_iterator end_dynamic_symbols() const = 0;
virtual section_iterator begin_sections() const = 0;
virtual section_iterator end_sections() const = 0;

View File

@ -550,16 +550,6 @@ symbol_iterator COFFObjectFile::end_symbols() const {
return symbol_iterator(SymbolRef(Ret, this));
}
symbol_iterator COFFObjectFile::begin_dynamic_symbols() const {
// TODO: implement
report_fatal_error("Dynamic symbols unimplemented in COFFObjectFile");
}
symbol_iterator COFFObjectFile::end_dynamic_symbols() const {
// TODO: implement
report_fatal_error("Dynamic symbols unimplemented in COFFObjectFile");
}
library_iterator COFFObjectFile::begin_libraries_needed() const {
// TODO: implement
report_fatal_error("Libraries needed unimplemented in COFFObjectFile");

View File

@ -1192,16 +1192,6 @@ symbol_iterator MachOObjectFile::end_symbols() const {
return symbol_iterator(SymbolRef(DRI, this));
}
symbol_iterator MachOObjectFile::begin_dynamic_symbols() const {
// TODO: implement
report_fatal_error("Dynamic symbols unimplemented in MachOObjectFile");
}
symbol_iterator MachOObjectFile::end_dynamic_symbols() const {
// TODO: implement
report_fatal_error("Dynamic symbols unimplemented in MachOObjectFile");
}
section_iterator MachOObjectFile::begin_sections() const {
DataRefImpl DRI;
return section_iterator(SectionRef(DRI, this));

View File

@ -1,7 +1,5 @@
RUN: llvm-nm -D %p/Inputs/shared-object-test.elf-i386 \
RUN: | FileCheck %s -check-prefix ELF-32
RUN: llvm-nm -D %p/Inputs/shared-object-test.elf-x86-64 \
RUN: | FileCheck %s -check-prefix ELF-64
ELF-32: 0012c8 A __bss_start
ELF-32: 0012c8 A _edata
@ -11,6 +9,9 @@ ELF-32: 0012c4 D defined_sym
ELF-32: 0001f0 T global_func
ELF-32: 000000 D tls_sym
RUN: llvm-nm -D %p/Inputs/shared-object-test.elf-x86-64 \
RUN: | FileCheck %s -check-prefix ELF-64
ELF-64: 200454 A __bss_start
ELF-64: 200454 A _edata
ELF-64: 200458 A _end
@ -18,3 +19,11 @@ ELF-64: 200454 B common_sym
ELF-64: 200450 D defined_sym
ELF-64: 0002f0 T global_func
ELF-64: 000000 D tls_sym
RUN: not llvm-nm -D %p/Inputs/weak-global-symbol.macho-i386 2>&1 \
RUN: | FileCheck %s -check-prefix ERROR
RUN: not llvm-nm -D %p/Inputs/trivial-object-test.coff-i386 2>&1 \
RUN: | FileCheck %s -check-prefix ERROR
ERROR: File format has no dynamic symbol table.

View File

@ -527,12 +527,38 @@ static char getNMTypeChar(ObjectFile *Obj, symbol_iterator I) {
return Res;
}
static void getDynamicSymbolIterators(ObjectFile *Obj, symbol_iterator &Begin,
symbol_iterator &End) {
if (ELF32LEObjectFile *ELF = dyn_cast<ELF32LEObjectFile>(Obj)) {
Begin = ELF->begin_dynamic_symbols();
End = ELF->end_dynamic_symbols();
return;
}
if (ELF64LEObjectFile *ELF = dyn_cast<ELF64LEObjectFile>(Obj)) {
Begin = ELF->begin_dynamic_symbols();
End = ELF->end_dynamic_symbols();
return;
}
if (ELF32BEObjectFile *ELF = dyn_cast<ELF32BEObjectFile>(Obj)) {
Begin = ELF->begin_dynamic_symbols();
End = ELF->end_dynamic_symbols();
return;
}
ELF64BEObjectFile *ELF = cast<ELF64BEObjectFile>(Obj);
Begin = ELF->begin_dynamic_symbols();
End = ELF->end_dynamic_symbols();
return;
}
static void dumpSymbolNamesFromObject(ObjectFile *Obj) {
symbol_iterator IBegin = Obj->begin_symbols();
symbol_iterator IEnd = Obj->end_symbols();
if (DynamicSyms) {
IBegin = Obj->begin_dynamic_symbols();
IEnd = Obj->end_dynamic_symbols();
if (!Obj->isELF()) {
error("File format has no dynamic symbol table", Obj->getFileName());
return;
}
getDynamicSymbolIterators(Obj, IBegin, IEnd);
}
for (symbol_iterator I = IBegin; I != IEnd; ++I) {
uint32_t SymFlags;