summaryrefslogtreecommitdiff
path: root/test/MC/COFF
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-06-06 19:26:12 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-06-06 19:26:12 +0000
commit013321a0f9e9f784ebb9a78ebf19e5f5099d5b16 (patch)
tree753bc6d742f12a5bb5f04d59afe902c14caba635 /test/MC/COFF
parent5448320a2061faeadedc800dff9a9adf14005a72 (diff)
downloadllvm-013321a0f9e9f784ebb9a78ebf19e5f5099d5b16.tar.gz
llvm-013321a0f9e9f784ebb9a78ebf19e5f5099d5b16.tar.bz2
llvm-013321a0f9e9f784ebb9a78ebf19e5f5099d5b16.tar.xz
Fix a few issues with comdat handling on COFF.
* Section association cannot use just the section name as many sections can have the same name. With this patch, the comdat symbol in an assoc section is interpreted to mean a symbol in the associated section and the mapping is discovered from it. * Comdat symbols were not being set correctly. Instead we were getting whatever was output first for that section. A consequence is that associative sections now must use .section to set the association. Using .linkonce would not work since it is not possible to change a sections comdat symbol (it is used to decide if we should create a new section or reuse an existing one). This includes r210298, which was reverted because it was asserting on an associated section having the same comdat as the associated section. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210367 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/MC/COFF')
-rw-r--r--test/MC/COFF/global_ctors_dtors.ll4
-rw-r--r--test/MC/COFF/linkonce-invalid.s14
-rw-r--r--test/MC/COFF/linkonce.s29
-rw-r--r--test/MC/COFF/section-comdat-conflict.s13
-rw-r--r--test/MC/COFF/section-comdat-conflict2.s6
-rw-r--r--test/MC/COFF/section-comdat.s53
6 files changed, 50 insertions, 69 deletions
diff --git a/test/MC/COFF/global_ctors_dtors.ll b/test/MC/COFF/global_ctors_dtors.ll
index 735c493683..ca17f24a68 100644
--- a/test/MC/COFF/global_ctors_dtors.ll
+++ b/test/MC/COFF/global_ctors_dtors.ll
@@ -51,14 +51,14 @@ define i32 @main() nounwind {
; WIN32: .section .CRT$XCU,"rd"
; WIN32: a_global_ctor
-; WIN32: .section .CRT$XCU,"rd",associative .bss,{{_?}}b
+; WIN32: .section .CRT$XCU,"rd",associative,{{_?}}b
; WIN32: b_global_ctor
; WIN32-NOT: c_global_ctor
; WIN32: .section .CRT$XTX,"rd"
; WIN32: a_global_dtor
; MINGW32: .section .ctors,"wd"
; MINGW32: a_global_ctor
-; MINGW32: .section .ctors,"wd",associative .bss,{{_?}}b
+; MINGW32: .section .ctors,"wd",associative,{{_?}}b
; MINGW32: b_global_ctor
; MINGW32-NOT: c_global_ctor
; MINGW32: .section .dtors,"wd"
diff --git a/test/MC/COFF/linkonce-invalid.s b/test/MC/COFF/linkonce-invalid.s
index 90ce4a7ad3..cc3a27c903 100644
--- a/test/MC/COFF/linkonce-invalid.s
+++ b/test/MC/COFF/linkonce-invalid.s
@@ -19,21 +19,9 @@
// CHECK: error: unexpected token in directive
.linkonce discard foo
-// CHECK: error: expected associated section name
+// CHECK: error: cannot make section associative with .linkonce
.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
diff --git a/test/MC/COFF/linkonce.s b/test/MC/COFF/linkonce.s
index e7b7f475a3..b6e81ad4b6 100644
--- a/test/MC/COFF/linkonce.s
+++ b/test/MC/COFF/linkonce.s
@@ -24,7 +24,6 @@
.long 1
.section s6
-.linkonce associative s1
.long 1
.section s7
@@ -39,11 +38,6 @@
.linkonce discard
.long 1
-// Check that valid '.section' names can be associated.
-.section multi
-.linkonce associative .foo$bar
-.long 1
-
// CHECK: Sections [
// CHECK: Section {
@@ -79,7 +73,6 @@
// CHECK: Section {
// CHECK: Name: s6
// CHECK: Characteristics [
-// CHECK: IMAGE_SCN_LNK_COMDAT
// CHECK: ]
// CHECK: }
// CHECK: Section {
@@ -94,12 +87,6 @@
// 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 {
@@ -144,12 +131,6 @@
// 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
@@ -167,13 +148,3 @@
// 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: }
diff --git a/test/MC/COFF/section-comdat-conflict.s b/test/MC/COFF/section-comdat-conflict.s
new file mode 100644
index 0000000000..7ed452a5cd
--- /dev/null
+++ b/test/MC/COFF/section-comdat-conflict.s
@@ -0,0 +1,13 @@
+// RUN: not llvm-mc -triple i386-pc-win32 -filetype=obj < %s 2>&1 | FileCheck %s
+
+// CHECK: conflicting sections for symbol
+
+ .section .xyz
+ .global bar
+bar:
+ .long 42
+
+ .section .abcd,"xr",discard,bar
+ .global foo
+foo:
+ .long 42
diff --git a/test/MC/COFF/section-comdat-conflict2.s b/test/MC/COFF/section-comdat-conflict2.s
new file mode 100644
index 0000000000..e2dfc2d68b
--- /dev/null
+++ b/test/MC/COFF/section-comdat-conflict2.s
@@ -0,0 +1,6 @@
+// RUN: not llvm-mc -triple i386-pc-win32 -filetype=obj < %s 2>&1 | FileCheck %s
+
+// CHECK: two sections have the same comdat
+
+ .section .xyz,"xr",discard,bar
+ .section .abcd,"xr",discard,bar
diff --git a/test/MC/COFF/section-comdat.s b/test/MC/COFF/section-comdat.s
index dd5be871b0..a0ea7d0928 100644
--- a/test/MC/COFF/section-comdat.s
+++ b/test/MC/COFF/section-comdat.s
@@ -1,8 +1,7 @@
// 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 assocSec
-.linkonce
+.section assocSec, "dr", discard, "assocSym"
.long 1
.section secName, "dr", discard, "Symbol1"
@@ -25,7 +24,7 @@ Symbol3:
Symbol4:
.long 1
-.section SecName, "dr", associative assocSec, "Symbol5"
+.section SecName, "dr", associative, "assocSym"
.globl Symbol5
Symbol5:
.long 1
@@ -107,6 +106,10 @@ Symbol7:
// CHECK: }
// CHECK: }
// CHECK: Symbol {
+// CHECK: Name: assocSym
+// CHECK: Section: assocSec
+// CHECK: }
+// CHECK: Symbol {
// CHECK: Name: secName
// CHECK: Section: secName (2)
// CHECK: AuxSectionDef {
@@ -114,6 +117,10 @@ Symbol7:
// CHECK: }
// CHECK: }
// CHECK: Symbol {
+// CHECK: Name: Symbol1
+// CHECK: Section: secName (2)
+// CHECK: }
+// CHECK: Symbol {
// CHECK: Name: secName
// CHECK: Section: secName (3)
// CHECK: AuxSectionDef {
@@ -121,6 +128,10 @@ Symbol7:
// CHECK: }
// CHECK: }
// CHECK: Symbol {
+// CHECK: Name: Symbol2
+// CHECK: Section: secName (3)
+// CHECK: }
+// CHECK: Symbol {
// CHECK: Name: SecName
// CHECK: Section: SecName (4)
// CHECK: AuxSectionDef {
@@ -128,6 +139,10 @@ Symbol7:
// CHECK: }
// CHECK: }
// CHECK: Symbol {
+// CHECK: Name: Symbol3
+// CHECK: Section: SecName (4)
+// CHECK: }
+// CHECK: Symbol {
// CHECK: Name: SecName
// CHECK: Section: SecName (5)
// CHECK: AuxSymbolCount: 1
@@ -136,6 +151,10 @@ Symbol7:
// CHECK: }
// CHECK: }
// CHECK: Symbol {
+// CHECK: Name: Symbol4
+// CHECK: Section: SecName (5)
+// CHECK: }
+// CHECK: Symbol {
// CHECK: Name: SecName
// CHECK: Section: SecName (6)
// CHECK: AuxSectionDef {
@@ -151,6 +170,10 @@ Symbol7:
// CHECK: }
// CHECK: }
// CHECK: Symbol {
+// CHECK: Name: Symbol6
+// CHECK: Section: SecName (7)
+// CHECK: }
+// CHECK: Symbol {
// CHECK: Name: SecName
// CHECK: Section: SecName (8)
// CHECK: AuxSectionDef {
@@ -158,31 +181,11 @@ Symbol7:
// CHECK: }
// CHECK: }
// CHECK: Symbol {
-// CHECK: Name: Symbol1
-// CHECK: Section: secName (2)
-// CHECK: }
-// CHECK: Symbol {
-// CHECK: Name: Symbol2
-// CHECK: Section: secName (3)
-// CHECK: }
-// CHECK: Symbol {
-// CHECK: Name: Symbol3
-// CHECK: Section: SecName (4)
-// CHECK: }
-// CHECK: Symbol {
-// CHECK: Name: Symbol4
-// CHECK: Section: SecName (5)
+// CHECK: Name: Symbol7
+// CHECK: Section: SecName (8)
// CHECK: }
// CHECK: Symbol {
// CHECK: Name: Symbol5
// CHECK: Section: SecName (6)
// CHECK: }
-// CHECK: Symbol {
-// CHECK: Name: Symbol6
-// CHECK: Section: SecName (7)
-// CHECK: }
-// CHECK: Symbol {
-// CHECK: Name: Symbol7
-// CHECK: Section: SecName (8)
-// CHECK: }
// CHECK: ]