[llvm] r218172 - llvm-readobj: pretty-print special COFF section names
David Majnemer
david.majnemer at gmail.com
Fri Sep 19 17:25:06 PDT 2014
Author: majnemer
Date: Fri Sep 19 19:25:06 2014
New Revision: 218172
URL: http://llvm.org/viewvc/llvm-project?rev=218172&view=rev
Log:
llvm-readobj: pretty-print special COFF section names
Print IMAGE_SYM_DEBUG and the like instead of (-2).
Modified:
llvm/trunk/test/MC/ARM/coff-file.s
llvm/trunk/test/MC/COFF/alias.s
llvm/trunk/test/MC/COFF/basic-coff-64.s
llvm/trunk/test/MC/COFF/basic-coff.s
llvm/trunk/test/MC/COFF/comm.s
llvm/trunk/test/MC/COFF/feat00.s
llvm/trunk/test/MC/COFF/file.s
llvm/trunk/test/MC/COFF/symbol-fragment-offset-64.s
llvm/trunk/test/MC/COFF/symbol-fragment-offset.s
llvm/trunk/test/MC/COFF/weak.s
llvm/trunk/test/tools/llvm-readobj/bigobj.test
llvm/trunk/test/tools/llvm-readobj/coff-file-sections-reading.test
llvm/trunk/test/tools/llvm-readobj/cxx-cli-aux.test
llvm/trunk/test/tools/llvm-readobj/symbols.test
llvm/trunk/tools/llvm-readobj/COFFDumper.cpp
Modified: llvm/trunk/test/MC/ARM/coff-file.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/coff-file.s?rev=218172&r1=218171&r2=218172&view=diff
==============================================================================
--- llvm/trunk/test/MC/ARM/coff-file.s (original)
+++ llvm/trunk/test/MC/ARM/coff-file.s Fri Sep 19 19:25:06 2014
@@ -21,7 +21,7 @@
// CHECK-SCN: Symbols [
// CHECK-SCN: Symbol {
// CHECK-SCN: Name: .file
-// CHECK-SCN: Section: (-2)
+// CHECK-SCN: Section: IMAGE_SYM_DEBUG (-2)
// CHECK-SCN: StorageClass: File
// CHECK-SCN: AuxFileRecord {
// CHECK-SCN: FileName: null-padded.asm
@@ -29,7 +29,7 @@
// CHECK-SCN: }
// CHECK-SCN: Symbol {
// CHECK-SCN: Name: .file
-// CHECK-SCN: Section: (-2)
+// CHECK-SCN: Section: IMAGE_SYM_DEBUG (-2)
// CHECK-SCN: StorageClass: File
// CHECK-SCN: AuxFileRecord {
// CHECK-SCN: FileName: eighteen-chars.asm
@@ -37,7 +37,7 @@
// CHECK-SCN: }
// CHECK-SCN: Symbol {
// CHECK-SCN: Name: .file
-// CHECK-SCN: Section: (-2)
+// CHECK-SCN: Section: IMAGE_SYM_DEBUG (-2)
// CHECK-SCN: StorageClass: File
// CHECK-SCN: AuxFileRecord {
// CHECK-SCN: FileName: multiple-auxiliary-entries.asm
Modified: llvm/trunk/test/MC/COFF/alias.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/COFF/alias.s?rev=218172&r1=218171&r2=218172&view=diff
==============================================================================
--- llvm/trunk/test/MC/COFF/alias.s (original)
+++ llvm/trunk/test/MC/COFF/alias.s Fri Sep 19 19:25:06 2014
@@ -48,7 +48,7 @@ weak_aliased_to_external = external2
// CHECK-NEXT: Symbol {
// CHECK: Name: global_aliased_to_external
// CHECK-NEXT: Value: 0
-// CHECK-NEXT: Section: (0)
+// CHECK-NEXT: Section: IMAGE_SYM_UNDEFINED (0)
// CHECK-NEXT: BaseType: Null (0x0)
// CHECK-NEXT: ComplexType: Null (0x0)
// CHECK-NEXT: StorageClass: External (0x2)
@@ -57,7 +57,7 @@ weak_aliased_to_external = external2
// CHECK-NEXT: Symbol {
// CHECK-NEXT: Name: external1
// CHECK-NEXT: Value: 0
-// CHECK-NEXT: Section: (0)
+// CHECK-NEXT: Section: IMAGE_SYM_UNDEFINED (0)
// CHECK-NEXT: BaseType: Null (0x0)
// CHECK-NEXT: ComplexType: Null (0x0)
// CHECK-NEXT: StorageClass: External (0x2)
@@ -84,7 +84,7 @@ weak_aliased_to_external = external2
// CHECK-NEXT: Symbol {
// CHECK-NEXT: Name: weak_aliased_to_external
// CHECK-NEXT: Value: 0
-// CHECK-NEXT: Section: (0)
+// CHECK-NEXT: Section: IMAGE_SYM_UNDEFINED (0)
// CHECK-NEXT: BaseType: Null (0x0)
// CHECK-NEXT: ComplexType: Null (0x0)
// CHECK-NEXT: StorageClass: WeakExternal (0x69)
@@ -97,7 +97,7 @@ weak_aliased_to_external = external2
// CHECK-NEXT: Symbol {
// CHECK-NEXT: Name: external2
// CHECK-NEXT: Value: 0
-// CHECK-NEXT: Section: (0)
+// CHECK-NEXT: Section: IMAGE_SYM_UNDEFINED (0)
// CHECK-NEXT: BaseType: Null (0x0)
// CHECK-NEXT: ComplexType: Null (0x0)
// CHECK-NEXT: StorageClass: External (0x2)
Modified: llvm/trunk/test/MC/COFF/basic-coff-64.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/COFF/basic-coff-64.s?rev=218172&r1=218171&r2=218172&view=diff
==============================================================================
--- llvm/trunk/test/MC/COFF/basic-coff-64.s (original)
+++ llvm/trunk/test/MC/COFF/basic-coff-64.s Fri Sep 19 19:25:06 2014
@@ -127,7 +127,7 @@ _main:
// CHECK: Symbol {
// CHECK: Name: _printf
// CHECK: Value: 0
-// CHECK: Section: (0)
+// CHECK: Section: IMAGE_SYM_UNDEFINED (0)
// CHECK: BaseType: Null
// CHECK: ComplexType: Null
// CHECK: StorageClass: External
Modified: llvm/trunk/test/MC/COFF/basic-coff.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/COFF/basic-coff.s?rev=218172&r1=218171&r2=218172&view=diff
==============================================================================
--- llvm/trunk/test/MC/COFF/basic-coff.s (original)
+++ llvm/trunk/test/MC/COFF/basic-coff.s Fri Sep 19 19:25:06 2014
@@ -127,7 +127,7 @@ L_.str:
// CHECK: Symbol {
// CHECK: Name: _printf
// CHECK: Value: 0
-// CHECK: Section: (0)
+// CHECK: Section: IMAGE_SYM_UNDEFINED (0)
// CHECK: BaseType: Null
// CHECK: ComplexType: Null
// CHECK: StorageClass: External
Modified: llvm/trunk/test/MC/COFF/comm.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/COFF/comm.s?rev=218172&r1=218171&r2=218172&view=diff
==============================================================================
--- llvm/trunk/test/MC/COFF/comm.s (original)
+++ llvm/trunk/test/MC/COFF/comm.s Fri Sep 19 19:25:06 2014
@@ -17,7 +17,7 @@
// CHECK: Symbol {
// CHECK: Name: _b
// CHECK-NEXT: Value: 4
-// CHECK-NEXT: Section: (0)
+// CHECK-NEXT: Section: IMAGE_SYM_UNDEFINED (0)
// CHECK-NEXT: BaseType: Null
// CHECK-NEXT: ComplexType: Null
// CHECK-NEXT: StorageClass: External
Modified: llvm/trunk/test/MC/COFF/feat00.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/COFF/feat00.s?rev=218172&r1=218171&r2=218172&view=diff
==============================================================================
--- llvm/trunk/test/MC/COFF/feat00.s (original)
+++ llvm/trunk/test/MC/COFF/feat00.s Fri Sep 19 19:25:06 2014
@@ -6,7 +6,7 @@
// CHECK: Symbol {
// CHECK: Name: @feat.00
// CHECK: Value: 123
-// CHECK: Section: (-1)
+// CHECK: Section: IMAGE_SYM_ABSOLUTE (-1)
// CHECK: BaseType: Null (0x0)
// CHECK: ComplexType: Null (0x0)
// CHECK: StorageClass: External (0x2)
Modified: llvm/trunk/test/MC/COFF/file.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/COFF/file.s?rev=218172&r1=218171&r2=218172&view=diff
==============================================================================
--- llvm/trunk/test/MC/COFF/file.s (original)
+++ llvm/trunk/test/MC/COFF/file.s Fri Sep 19 19:25:06 2014
@@ -21,7 +21,7 @@
// CHECK-SCN: Symbols [
// CHECK-SCN: Symbol {
// CHECK-SCN: Name: .file
-// CHECK-SCN: Section: (-2)
+// CHECK-SCN: Section: IMAGE_SYM_DEBUG (-2)
// CHECK-SCN: StorageClass: File
// CHECK-SCN: AuxFileRecord {
// CHECK-SCN: FileName: null-padded.asm
@@ -29,7 +29,7 @@
// CHECK-SCN: }
// CHECK-SCN: Symbol {
// CHECK-SCN: Name: .file
-// CHECK-SCN: Section: (-2)
+// CHECK-SCN: Section: IMAGE_SYM_DEBUG (-2)
// CHECK-SCN: StorageClass: File
// CHECK-SCN: AuxFileRecord {
// CHECK-SCN: FileName: eighteen-chars.asm
@@ -37,7 +37,7 @@
// CHECK-SCN: }
// CHECK-SCN: Symbol {
// CHECK-SCN: Name: .file
-// CHECK-SCN: Section: (-2)
+// CHECK-SCN: Section: IMAGE_SYM_DEBUG (-2)
// CHECK-SCN: StorageClass: File
// CHECK-SCN: AuxFileRecord {
// CHECK-SCN: FileName: multiple-auxiliary-entries.asm
Modified: llvm/trunk/test/MC/COFF/symbol-fragment-offset-64.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/COFF/symbol-fragment-offset-64.s?rev=218172&r1=218171&r2=218172&view=diff
==============================================================================
--- llvm/trunk/test/MC/COFF/symbol-fragment-offset-64.s (original)
+++ llvm/trunk/test/MC/COFF/symbol-fragment-offset-64.s Fri Sep 19 19:25:06 2014
@@ -148,7 +148,7 @@ _main:
// CHECK: Symbol {
// CHECK: Name: _printf
// CHECK: Value: 0
-// CHECK: Section: (0)
+// CHECK: Section: IMAGE_SYM_UNDEFINED (0)
// CHECK: BaseType: Null
// CHECK: ComplexType: Null
// CHECK: StorageClass: External
@@ -157,7 +157,7 @@ _main:
// CHECK: Symbol {
// CHECK: Name: _puts
// CHECK: Value: 0
-// CHECK: Section: (0)
+// CHECK: Section: IMAGE_SYM_UNDEFINED (0)
// CHECK: BaseType: Null
// CHECK: ComplexType: Null
// CHECK: StorageClass: External
Modified: llvm/trunk/test/MC/COFF/symbol-fragment-offset.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/COFF/symbol-fragment-offset.s?rev=218172&r1=218171&r2=218172&view=diff
==============================================================================
--- llvm/trunk/test/MC/COFF/symbol-fragment-offset.s (original)
+++ llvm/trunk/test/MC/COFF/symbol-fragment-offset.s Fri Sep 19 19:25:06 2014
@@ -148,7 +148,7 @@ L_.str2:
// CHECK: Symbol {
// CHECK: Name: _printf
// CHECK: Value: 0
-// CHECK: Section: (0)
+// CHECK: Section: IMAGE_SYM_UNDEFINED (0)
// CHECK: BaseType: Null
// CHECK: ComplexType: Null
// CHECK: StorageClass: External
@@ -157,7 +157,7 @@ L_.str2:
// CHECK: Symbol {
// CHECK: Name: _puts
// CHECK: Value: 0
-// CHECK: Section: (0)
+// CHECK: Section: IMAGE_SYM_UNDEFINED (0)
// CHECK: BaseType: Null
// CHECK: ComplexType: Null
// CHECK: StorageClass: External
Modified: llvm/trunk/test/MC/COFF/weak.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/COFF/weak.s?rev=218172&r1=218171&r2=218172&view=diff
==============================================================================
--- llvm/trunk/test/MC/COFF/weak.s (original)
+++ llvm/trunk/test/MC/COFF/weak.s Fri Sep 19 19:25:06 2014
@@ -37,7 +37,7 @@ LBB0_2:
// CHECK: Symbol {
// CHECK: Name: _test_weak
// CHECK-NEXT: Value: 0
-// CHECK-NEXT: Section: (0)
+// CHECK-NEXT: Section: IMAGE_SYM_UNDEFINED (0)
// CHECK-NEXT: BaseType: Null
// CHECK-NEXT: ComplexType: Null
// CHECK-NEXT: StorageClass: WeakExternal
@@ -51,7 +51,7 @@ LBB0_2:
// CHECK: Symbol {
// CHECK: Name: .weak._test_weak.default
// CHECK-NEXT: Value: 0
-// CHECK-NEXT: Section: (-1)
+// CHECK-NEXT: Section: IMAGE_SYM_ABSOLUTE (-1)
// CHECK-NEXT: BaseType: Null
// CHECK-NEXT: ComplexType: Null
// CHECK-NEXT: StorageClass: External
@@ -61,7 +61,7 @@ LBB0_2:
// CHECK: Symbol {
// CHECK: Name: _test_weak_alias
// CHECK-NEXT: Value: 0
-// CHECK-NEXT: Section: (0)
+// CHECK-NEXT: Section: IMAGE_SYM_UNDEFINED (0)
// CHECK-NEXT: BaseType: Null
// CHECK-NEXT: ComplexType: Null
// CHECK-NEXT: StorageClass: WeakExternal
Modified: llvm/trunk/test/tools/llvm-readobj/bigobj.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-readobj/bigobj.test?rev=218172&r1=218171&r2=218172&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-readobj/bigobj.test (original)
+++ llvm/trunk/test/tools/llvm-readobj/bigobj.test Fri Sep 19 19:25:06 2014
@@ -76,7 +76,7 @@ CHECK-NEXT: Symbols [
CHECK-NEXT: Symbol {
CHECK-NEXT: Name: .file
CHECK-NEXT: Value: 0
-CHECK-NEXT: Section: (-2)
+CHECK-NEXT: Section: IMAGE_SYM_DEBUG (-2)
CHECK-NEXT: BaseType: Null (0x0)
CHECK-NEXT: ComplexType: Null (0x0)
CHECK-NEXT: StorageClass: File (0x67)
Modified: llvm/trunk/test/tools/llvm-readobj/coff-file-sections-reading.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-readobj/coff-file-sections-reading.test?rev=218172&r1=218171&r2=218172&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-readobj/coff-file-sections-reading.test (original)
+++ llvm/trunk/test/tools/llvm-readobj/coff-file-sections-reading.test Fri Sep 19 19:25:06 2014
@@ -4,7 +4,7 @@ CHECK: Symbols [
CHECK: Symbol {
CHECK: Name: .file
CHECK: Value: 0
-CHECK: Section: (-2)
+CHECK: Section: IMAGE_SYM_DEBUG (-2)
CHECK: BaseType: Null (0x0)
CHECK: ComplexType: Null (0x0)
CHECK: StorageClass: File (0x67)
Modified: llvm/trunk/test/tools/llvm-readobj/cxx-cli-aux.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-readobj/cxx-cli-aux.test?rev=218172&r1=218171&r2=218172&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-readobj/cxx-cli-aux.test (original)
+++ llvm/trunk/test/tools/llvm-readobj/cxx-cli-aux.test Fri Sep 19 19:25:06 2014
@@ -9,7 +9,7 @@ CHECK: Symbols [
CHECK: Symbol {
CHECK: Name: ?PerAppDomain@@$$Q3HA
CHECK-NEXT: Value: 4
-CHECK-NEXT: Section: (-1)
+CHECK-NEXT: Section: IMAGE_SYM_ABSOLUTE (-1)
CHECK-NEXT: BaseType: Null (0x0)
CHECK-NEXT: ComplexType: Null (0x0)
CHECK-NEXT: StorageClass: External (0x2)
@@ -27,7 +27,7 @@ CHECK-NEXT: }
CHECK: Symbol {
CHECK: Name: 04000001
CHECK-NEXT: Value: 4
-CHECK-NEXT: Section: (-1)
+CHECK-NEXT: Section: IMAGE_SYM_ABSOLUTE (-1)
CHECK-NEXT: BaseType: Null (0x0)
CHECK-NEXT: ComplexType: Null (0x0)
CHECK-NEXT: StorageClass: CLRToken (0x6B)
Modified: llvm/trunk/test/tools/llvm-readobj/symbols.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-readobj/symbols.test?rev=218172&r1=218171&r2=218172&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-readobj/symbols.test (original)
+++ llvm/trunk/test/tools/llvm-readobj/symbols.test Fri Sep 19 19:25:06 2014
@@ -7,7 +7,7 @@ COFF: Symbols [
COFF-NEXT: Symbol {
COFF-NEXT: Name: @comp.id
COFF-NEXT: Value: 14766605
-COFF-NEXT: Section: (-1)
+COFF-NEXT: Section: IMAGE_SYM_ABSOLUTE (-1)
COFF-NEXT: BaseType: Null (0x0)
COFF-NEXT: ComplexType: Null (0x0)
COFF-NEXT: StorageClass: Static (0x3)
@@ -16,7 +16,7 @@ COFF-NEXT: }
COFF-NEXT: Symbol {
COFF-NEXT: Name: @feat.00
COFF-NEXT: Value: 2147484049
-COFF-NEXT: Section: (-1)
+COFF-NEXT: Section: IMAGE_SYM_ABSOLUTE (-1)
COFF-NEXT: BaseType: Null (0x0)
COFF-NEXT: ComplexType: Null (0x0)
COFF-NEXT: StorageClass: Static (0x3)
Modified: llvm/trunk/tools/llvm-readobj/COFFDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/COFFDumper.cpp?rev=218172&r1=218171&r2=218172&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/COFFDumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/COFFDumper.cpp Fri Sep 19 19:25:06 2014
@@ -715,6 +715,24 @@ void COFFDumper::printSymbols() {
void COFFDumper::printDynamicSymbols() { ListScope Group(W, "DynamicSymbols"); }
+static StringRef getSectionName(const llvm::object::COFFObjectFile *Obj,
+ COFFSymbolRef Symbol,
+ const coff_section *Section) {
+ if (Section) {
+ StringRef SectionName;
+ Obj->getSectionName(Section, SectionName);
+ return SectionName;
+ }
+ int32_t SectionNumber = Symbol.getSectionNumber();
+ if (SectionNumber == llvm::COFF::IMAGE_SYM_DEBUG)
+ return "IMAGE_SYM_DEBUG";
+ if (SectionNumber == llvm::COFF::IMAGE_SYM_ABSOLUTE)
+ return "IMAGE_SYM_ABSOLUTE";
+ if (SectionNumber == llvm::COFF::IMAGE_SYM_UNDEFINED)
+ return "IMAGE_SYM_UNDEFINED";
+ return "";
+}
+
void COFFDumper::printSymbol(const SymbolRef &Sym) {
DictScope D(W, "Symbol");
@@ -730,9 +748,7 @@ void COFFDumper::printSymbol(const Symbo
if (Obj->getSymbolName(Symbol, SymbolName))
SymbolName = "";
- StringRef SectionName = "";
- if (Section)
- Obj->getSectionName(Section, SectionName);
+ StringRef SectionName = getSectionName(Obj, Symbol, Section);
W.printString("Name", SymbolName);
W.printNumber("Value", Symbol.getValue());
More information about the llvm-commits
mailing list