diff options
author | Nico Rieck <nico.rieck@gmail.com> | 2013-07-29 13:58:39 +0000 |
---|---|---|
committer | Nico Rieck <nico.rieck@gmail.com> | 2013-07-29 13:58:39 +0000 |
commit | fdbea5107b5a8249421fd5e603a31f40f05ea25f (patch) | |
tree | 8fad36d3436d0bb285eb5182e011f6f626e78391 /test/MC | |
parent | 944061c4e152e9f66ffaaca5905253ba8012a4fa (diff) | |
download | llvm-fdbea5107b5a8249421fd5e603a31f40f05ea25f.tar.gz llvm-fdbea5107b5a8249421fd5e603a31f40f05ea25f.tar.bz2 llvm-fdbea5107b5a8249421fd5e603a31f40f05ea25f.tar.xz |
Use proper section suffix for COFF weak symbols
32-bit symbols have "_" as global prefix, but when forming the name of
COMDAT sections this prefix is ignored. The current behavior assumes that
this prefix is always present which is not the case for 64-bit and names
are truncated.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187356 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/MC')
-rw-r--r-- | test/MC/COFF/weak-symbol-section-specification.ll | 25 | ||||
-rw-r--r-- | test/MC/COFF/weak-symbol.ll | 44 |
2 files changed, 44 insertions, 25 deletions
diff --git a/test/MC/COFF/weak-symbol-section-specification.ll b/test/MC/COFF/weak-symbol-section-specification.ll deleted file mode 100644 index 4772c929f2..0000000000 --- a/test/MC/COFF/weak-symbol-section-specification.ll +++ /dev/null @@ -1,25 +0,0 @@ -; The purpose of this test is to verify that weak linkage type is not ignored by backend, -; if section was specialized. - -; RUN: llc -filetype=obj -mtriple i686-pc-win32 %s -o - | llvm-readobj -s -sd | FileCheck %s - -@a = weak unnamed_addr constant { i32, i32, i32 } { i32 0, i32 0, i32 0}, section ".data" - -; CHECK: Name: .data$a -; CHECK-NEXT: VirtualSize: 0 -; CHECK-NEXT: VirtualAddress: 0 -; CHECK-NEXT: RawDataSize: {{[0-9]+}} -; CHECK-NEXT: PointerToRawData: 0x{{[0-9A-F]+}} -; CHECK-NEXT: PointerToRelocations: 0x0 -; CHECK-NEXT: PointerToLineNumbers: 0x0 -; CHECK-NEXT: RelocationCount: 0 -; CHECK-NEXT: LineNumberCount: 0 -; CHECK-NEXT: Characteristics [ (0x40401040) -; CHECK-NEXT: IMAGE_SCN_ALIGN_8BYTES -; CHECK-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA -; CHECK-NEXT: IMAGE_SCN_LNK_COMDAT -; CHECK-NEXT: IMAGE_SCN_MEM_READ -; CHECK-NEXT: ] -; CHECK-NEXT: SectionData ( -; CHECK-NEXT: 0000: 00000000 00000000 00000000 -; CHECK-NEXT: ) diff --git a/test/MC/COFF/weak-symbol.ll b/test/MC/COFF/weak-symbol.ll new file mode 100644 index 0000000000..7f2e87cb75 --- /dev/null +++ b/test/MC/COFF/weak-symbol.ll @@ -0,0 +1,44 @@ +; Test that weak functions and globals are placed into selectany COMDAT
+; sections with the mangled name as suffix. Ensure that the weak linkage
+; type is not ignored by the backend if the section was specialized.
+;
+; RUN: llc -mtriple=i686-pc-win32 %s -o - | FileCheck %s --check-prefix=X86
+; RUN: llc -mtriple=i686-pc-mingw32 %s -o - | FileCheck %s --check-prefix=X86
+; RUN: llc -mtriple=x86_64-pc-win32 %s -o - | FileCheck %s --check-prefix=X64
+; RUN: llc -mtriple=x86_64-pc-mingw32 %s -o - | FileCheck %s --check-prefix=X64
+
+; Mangled function
+; X86: .section .text$_Z3foo
+; X86: .linkonce discard
+; X86: .globl __Z3foo
+;
+; X64: .section .text$_Z3foo
+; X64: .linkonce discard
+; X64: .globl _Z3foo
+define weak void @_Z3foo() {
+ ret void
+}
+
+; Unmangled function
+; X86: .section .sect$f
+; X86: .linkonce discard
+; X86: .globl _f
+;
+; X64: .section .sect$f
+; X64: .linkonce discard
+; X64: .globl f
+define weak void @f() section ".sect" {
+ ret void
+}
+
+; Weak global
+; X86: .section .data$a
+; X86: .linkonce discard
+; X86: .globl _a
+; X86: .zero 12
+;
+; X64: .section .data$a
+; X64: .linkonce discard
+; X64: .globl a
+; X64: .zero 12
+@a = weak unnamed_addr constant { i32, i32, i32 } { i32 0, i32 0, i32 0}, section ".data"
|