summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNico Rieck <nico.rieck@gmail.com>2014-03-17 01:46:28 +0000
committerNico Rieck <nico.rieck@gmail.com>2014-03-17 01:46:28 +0000
commit23653b1265439147c27893a6832a70c93d0623dc (patch)
tree4151cb188bc9d55d937877198d4365c7a465fce0
parent960c80d8a9babe4def0af24119191bdd4316c859 (diff)
llvm-readobj: Add test for COFF auxiliary symbols as used by C++/CLI
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204023 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--test/tools/llvm-readobj/Inputs/cxx-cli-aux.cpp2
-rw-r--r--test/tools/llvm-readobj/Inputs/cxx-cli-aux.obj.coff-i386bin0 -> 2682 bytes
-rw-r--r--test/tools/llvm-readobj/cxx-cli-aux.test42
-rw-r--r--tools/llvm-readobj/COFFDumper.cpp4
4 files changed, 47 insertions, 1 deletions
diff --git a/test/tools/llvm-readobj/Inputs/cxx-cli-aux.cpp b/test/tools/llvm-readobj/Inputs/cxx-cli-aux.cpp
new file mode 100644
index 00000000000..6386cb2e015
--- /dev/null
+++ b/test/tools/llvm-readobj/Inputs/cxx-cli-aux.cpp
@@ -0,0 +1,2 @@
+// cl.exe -clr -c t.cpp -Fo"cxx-cli-aux.obj.coff-i386"
+__declspec(appdomain) int PerAppDomain = 0;
diff --git a/test/tools/llvm-readobj/Inputs/cxx-cli-aux.obj.coff-i386 b/test/tools/llvm-readobj/Inputs/cxx-cli-aux.obj.coff-i386
new file mode 100644
index 00000000000..a88c670643a
--- /dev/null
+++ b/test/tools/llvm-readobj/Inputs/cxx-cli-aux.obj.coff-i386
Binary files differ
diff --git a/test/tools/llvm-readobj/cxx-cli-aux.test b/test/tools/llvm-readobj/cxx-cli-aux.test
new file mode 100644
index 00000000000..eac3041b1cc
--- /dev/null
+++ b/test/tools/llvm-readobj/cxx-cli-aux.test
@@ -0,0 +1,42 @@
+Ensure that we can read the COFF auxiliary symbols 'section definition' and
+'CLR token definition' as used in C++/CLI object files. Auxiliary section
+definitions usually only follow a symbol with static storage class, but
+non-const appdomain globals (external ABS) also get one.
+
+RUN: llvm-readobj -t %p/Inputs/cxx-cli-aux.obj.coff-i386 | FileCheck %s
+
+CHECK: Symbols [
+CHECK: Symbol {
+CHECK: Name: ?PerAppDomain@@$$Q3HA
+CHECK-NEXT: Value: 4
+CHECK-NEXT: Section: (65535)
+CHECK-NEXT: BaseType: Null (0x0)
+CHECK-NEXT: ComplexType: Null (0x0)
+CHECK-NEXT: StorageClass: External (0x2)
+CHECK-NEXT: AuxSymbolCount: 1
+CHECK-NEXT: AuxSectionDef {
+CHECK-NEXT: Length: 0
+CHECK-NEXT: RelocationCount: 0
+CHECK-NEXT: LineNumberCount: 0
+CHECK-NEXT: Checksum: 0x0
+CHECK-NEXT: Number: 0
+CHECK-NEXT: Selection: NoDuplicates (0x1)
+CHECK-NEXT: Unused: (00 00 00)
+CHECK-NEXT: }
+CHECK-NEXT: }
+
+CHECK: Symbol {
+CHECK: Name: 04000001
+CHECK-NEXT: Value: 4
+CHECK-NEXT: Section: (65535)
+CHECK-NEXT: BaseType: Null (0x0)
+CHECK-NEXT: ComplexType: Null (0x0)
+CHECK-NEXT: StorageClass: CLRToken (0x6B)
+CHECK-NEXT: AuxSymbolCount: 1
+CHECK-NEXT: AuxCLRToken {
+CHECK-NEXT: AuxType: 1
+CHECK-NEXT: Reserved: 0
+CHECK-NEXT: SymbolTableIndex: 19
+CHECK-NEXT: Unused: (00 00 00 00 00 00 00 00 00 00 00 00)
+CHECK-NEXT: }
+CHECK-NEXT: }
diff --git a/tools/llvm-readobj/COFFDumper.cpp b/tools/llvm-readobj/COFFDumper.cpp
index dfe89d69ec5..28ac3cb4164 100644
--- a/tools/llvm-readobj/COFFDumper.cpp
+++ b/tools/llvm-readobj/COFFDumper.cpp
@@ -1022,9 +1022,11 @@ void COFFDumper::printSymbol(symbol_iterator SymI) {
DictScope AS(W, "AuxFileRecord");
W.printString("FileName", StringRef(Aux->FileName));
+ // C++/CLI creates external ABS symbols for non-const appdomain globals.
+ // These are also followed by an auxiliary section definition.
} else if (Symbol->StorageClass == COFF::IMAGE_SYM_CLASS_STATIC ||
(Symbol->StorageClass == COFF::IMAGE_SYM_CLASS_EXTERNAL &&
- Symbol->SectionNumber != COFF::IMAGE_SYM_UNDEFINED)) {
+ Symbol->SectionNumber == COFF::IMAGE_SYM_ABSOLUTE)) {
const coff_aux_section_definition *Aux;
if (error(getSymbolAuxData(Obj, Symbol + I, Aux)))
break;