summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorNico Rieck <nico.rieck@gmail.com>2013-07-06 12:13:10 +0000
committerNico Rieck <nico.rieck@gmail.com>2013-07-06 12:13:10 +0000
commit80646283796b20c6a1b7d8eb69ce6f0478d54383 (patch)
tree83b9be6b71faffa6cd481cea7736a172d36609ea /test
parent2be430d251a781e76634e945d56224a7a0ef5a39 (diff)
downloadllvm-80646283796b20c6a1b7d8eb69ce6f0478d54383.tar.gz
llvm-80646283796b20c6a1b7d8eb69ce6f0478d54383.tar.bz2
llvm-80646283796b20c6a1b7d8eb69ce6f0478d54383.tar.xz
MC: Implement COFF .linkonce directive
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185753 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/MC/COFF/linkonce-invalid.s40
-rw-r--r--test/MC/COFF/linkonce.s179
2 files changed, 219 insertions, 0 deletions
diff --git a/test/MC/COFF/linkonce-invalid.s b/test/MC/COFF/linkonce-invalid.s
new file mode 100644
index 0000000000..90ce4a7ad3
--- /dev/null
+++ b/test/MC/COFF/linkonce-invalid.s
@@ -0,0 +1,40 @@
+// Test invalid use of the .linkonce directive.
+//
+// RUN: not llvm-mc -triple i386-pc-win32 -filetype=obj %s 2>&1 | FileCheck %s
+
+.section non_comdat
+
+.section comdat
+.linkonce discard
+
+.section assoc
+.linkonce associative comdat
+
+
+.section invalid
+
+// CHECK: error: unrecognized COMDAT type 'unknown'
+.linkonce unknown
+
+// CHECK: error: unexpected token in directive
+.linkonce discard foo
+
+// CHECK: error: expected associated section name
+.linkonce associative
+
+// CHECK: error: cannot associate unknown section 'unknown'
+.linkonce associative unknown
+
+// CHECK: error: cannot associate a section with itself
+.linkonce associative invalid
+
+// CHECK: error: associated section must be a COMDAT section
+.linkonce associative non_comdat
+
+// CHECK: error: associated section cannot be itself associative
+.linkonce associative assoc
+
+// CHECK: error: section 'multi' is already linkonce
+.section multi
+.linkonce discard
+.linkonce same_size
diff --git a/test/MC/COFF/linkonce.s b/test/MC/COFF/linkonce.s
new file mode 100644
index 0000000000..e7b7f475a3
--- /dev/null
+++ b/test/MC/COFF/linkonce.s
@@ -0,0 +1,179 @@
+// Test section manipulation via .linkonce directive.
+//
+// RUN: llvm-mc -triple i386-pc-win32 -filetype=obj %s | llvm-readobj -s -t | FileCheck %s
+// RUN: llvm-mc -triple x86_64-pc-win32 -filetype=obj %s | llvm-readobj -s -t | FileCheck %s
+
+.section s1
+.linkonce
+.long 1
+
+.section s2
+.linkonce one_only
+.long 1
+
+.section s3
+.linkonce discard
+.long 1
+
+.section s4
+.linkonce same_size
+.long 1
+
+.section s5
+.linkonce same_contents
+.long 1
+
+.section s6
+.linkonce associative s1
+.long 1
+
+.section s7
+.linkonce largest
+.long 1
+
+.section s8
+.linkonce newest
+.long 1
+
+.section .foo$bar
+.linkonce discard
+.long 1
+
+// Check that valid '.section' names can be associated.
+.section multi
+.linkonce associative .foo$bar
+.long 1
+
+
+// CHECK: Sections [
+// CHECK: Section {
+// CHECK: Name: s1
+// CHECK: Characteristics [
+// CHECK: IMAGE_SCN_LNK_COMDAT
+// CHECK: ]
+// CHECK: }
+// CHECK: Section {
+// CHECK: Name: s2
+// CHECK: Characteristics [
+// CHECK: IMAGE_SCN_LNK_COMDAT
+// CHECK: ]
+// CHECK: }
+// CHECK: Section {
+// CHECK: Name: s3
+// CHECK: Characteristics [
+// CHECK: IMAGE_SCN_LNK_COMDAT
+// CHECK: ]
+// CHECK: }
+// CHECK: Section {
+// CHECK: Name: s4
+// CHECK: Characteristics [
+// CHECK: IMAGE_SCN_LNK_COMDAT
+// CHECK: ]
+// CHECK: }
+// CHECK: Section {
+// CHECK: Name: s5
+// CHECK: Characteristics [
+// CHECK: IMAGE_SCN_LNK_COMDAT
+// CHECK: ]
+// CHECK: }
+// CHECK: Section {
+// CHECK: Name: s6
+// CHECK: Characteristics [
+// CHECK: IMAGE_SCN_LNK_COMDAT
+// CHECK: ]
+// CHECK: }
+// CHECK: Section {
+// CHECK: Name: s7
+// CHECK: Characteristics [
+// CHECK: IMAGE_SCN_LNK_COMDAT
+// CHECK: ]
+// CHECK: }
+// CHECK: Section {
+// CHECK: Name: s8
+// CHECK: Characteristics [
+// CHECK: IMAGE_SCN_LNK_COMDAT
+// CHECK: ]
+// CHECK: }
+// CHECK: Section {
+// CHECK: Name: multi
+// CHECK: Characteristics [
+// CHECK: IMAGE_SCN_LNK_COMDAT
+// CHECK: ]
+// CHECK: }
+// CHECK: ]
+// CHECK: Symbols [
+// CHECK: Symbol {
+// CHECK: Name: s1
+// CHECK: Section: s1 (1)
+// CHECK: AuxSectionDef {
+// CHECK: Number: 1
+// CHECK: Selection: Any (0x2)
+// CHECK: }
+// CHECK: }
+// CHECK: Symbol {
+// CHECK: Name: s2
+// CHECK: Section: s2 (2)
+// CHECK: AuxSectionDef {
+// CHECK: Number: 2
+// CHECK: Selection: NoDuplicates (0x1)
+// CHECK: }
+// CHECK: }
+// CHECK: Symbol {
+// CHECK: Name: s3
+// CHECK: Section: s3 (3)
+// CHECK: AuxSectionDef {
+// CHECK: Number: 3
+// CHECK: Selection: Any (0x2)
+// CHECK: }
+// CHECK: }
+// CHECK: Symbol {
+// CHECK: Name: s4
+// CHECK: Section: s4 (4)
+// CHECK: AuxSectionDef {
+// CHECK: Number: 4
+// CHECK: Selection: SameSize (0x3)
+// CHECK: }
+// CHECK: }
+// CHECK: Symbol {
+// CHECK: Name: s5
+// CHECK: Section: s5 (5)
+// CHECK: AuxSectionDef {
+// CHECK: Number: 5
+// CHECK: Selection: ExactMatch (0x4)
+// CHECK: }
+// CHECK: }
+// CHECK: Symbol {
+// CHECK: Name: s6
+// CHECK: Section: s6 (6)
+// CHECK: AuxSectionDef {
+// CHECK: Number: 1
+// CHECK: Selection: Associative (0x5)
+// CHECK: AssocSection: s1
+// CHECK: }
+// CHECK: }
+// CHECK: Symbol {
+// CHECK: Name: s7
+// CHECK: Section: s7 (7)
+// CHECK: AuxSectionDef {
+// CHECK: Number: 7
+// CHECK: Selection: Largest (0x6)
+// CHECK: }
+// CHECK: }
+// CHECK: Symbol {
+// CHECK: Name: s8
+// CHECK: Section: s8 (8)
+// CHECK: AuxSectionDef {
+// CHECK: Number: 8
+// CHECK: Selection: Newest (0x7)
+// CHECK: }
+// CHECK: }
+// CHECK: Symbol {
+// CHECK: Name: multi
+// CHECK: Value: 0
+// CHECK: Section: multi (10)
+// CHECK: AuxSectionDef {
+// CHECK: Number: 9
+// CHECK: Selection: Associative (0x5)
+// CHECK: AssocSection: .foo$bar
+// CHECK: }
+// CHECK: }