[llvm] r200488 - Only ELF has a dynamic symbol table. Remove it from ObjectFile.
Rafael Espindola
rafael.espindola at gmail.com
Thu Jan 30 12:45:33 PST 2014
Author: rafael
Date: Thu Jan 30 14:45:33 2014
New Revision: 200488
URL: http://llvm.org/viewvc/llvm-project?rev=200488&view=rev
Log:
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.
Modified:
llvm/trunk/include/llvm/Object/COFF.h
llvm/trunk/include/llvm/Object/ELFObjectFile.h
llvm/trunk/include/llvm/Object/MachO.h
llvm/trunk/include/llvm/Object/ObjectFile.h
llvm/trunk/lib/Object/COFFObjectFile.cpp
llvm/trunk/lib/Object/MachOObjectFile.cpp
llvm/trunk/test/Object/nm-shared-object.test
llvm/trunk/tools/llvm-nm/llvm-nm.cpp
Modified: llvm/trunk/include/llvm/Object/COFF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/COFF.h?rev=200488&r1=200487&r2=200488&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/COFF.h (original)
+++ llvm/trunk/include/llvm/Object/COFF.h Thu Jan 30 14:45:33 2014
@@ -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;
Modified: llvm/trunk/include/llvm/Object/ELFObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELFObjectFile.h?rev=200488&r1=200487&r2=200488&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ELFObjectFile.h (original)
+++ llvm/trunk/include/llvm/Object/ELFObjectFile.h Thu Jan 30 14:45:33 2014
@@ -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;
Modified: llvm/trunk/include/llvm/Object/MachO.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/MachO.h?rev=200488&r1=200487&r2=200488&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/MachO.h (original)
+++ llvm/trunk/include/llvm/Object/MachO.h Thu Jan 30 14:45:33 2014
@@ -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;
Modified: llvm/trunk/include/llvm/Object/ObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ObjectFile.h?rev=200488&r1=200487&r2=200488&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ObjectFile.h (original)
+++ llvm/trunk/include/llvm/Object/ObjectFile.h Thu Jan 30 14:45:33 2014
@@ -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;
Modified: llvm/trunk/lib/Object/COFFObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/COFFObjectFile.cpp?rev=200488&r1=200487&r2=200488&view=diff
==============================================================================
--- llvm/trunk/lib/Object/COFFObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/COFFObjectFile.cpp Thu Jan 30 14:45:33 2014
@@ -550,16 +550,6 @@ symbol_iterator COFFObjectFile::end_symb
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");
Modified: llvm/trunk/lib/Object/MachOObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/MachOObjectFile.cpp?rev=200488&r1=200487&r2=200488&view=diff
==============================================================================
--- llvm/trunk/lib/Object/MachOObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/MachOObjectFile.cpp Thu Jan 30 14:45:33 2014
@@ -1192,16 +1192,6 @@ symbol_iterator MachOObjectFile::end_sym
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));
Modified: llvm/trunk/test/Object/nm-shared-object.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/nm-shared-object.test?rev=200488&r1=200487&r2=200488&view=diff
==============================================================================
--- llvm/trunk/test/Object/nm-shared-object.test (original)
+++ llvm/trunk/test/Object/nm-shared-object.test Thu Jan 30 14:45:33 2014
@@ -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.
Modified: llvm/trunk/tools/llvm-nm/llvm-nm.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-nm/llvm-nm.cpp?rev=200488&r1=200487&r2=200488&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-nm/llvm-nm.cpp (original)
+++ llvm/trunk/tools/llvm-nm/llvm-nm.cpp Thu Jan 30 14:45:33 2014
@@ -527,12 +527,38 @@ static char getNMTypeChar(ObjectFile *Ob
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;
More information about the llvm-commits
mailing list