diff options
Diffstat (limited to 'test/ELF')
-rw-r--r-- | test/ELF/comdat-linkonce.s | 9 | ||||
-rw-r--r-- | test/ELF/linkerscript/symbol-assignexpr.s | 17 | ||||
-rw-r--r-- | test/ELF/mips-gp-ext.s | 6 | ||||
-rw-r--r-- | test/ELF/reproduce-linkerscript.s | 3 | ||||
-rw-r--r-- | test/ELF/undefined-versioned-symbol.s | 74 |
5 files changed, 105 insertions, 4 deletions
diff --git a/test/ELF/comdat-linkonce.s b/test/ELF/comdat-linkonce.s new file mode 100644 index 000000000000..78611b4a9f26 --- /dev/null +++ b/test/ELF/comdat-linkonce.s @@ -0,0 +1,9 @@ +// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o +// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/comdat.s -o %t2.o +// RUN: ld.lld -shared %t.o %t2.o -o %t +// RUN: ld.lld -shared %t2.o %t.o -o %t + +.section .gnu.linkonce.t.zed +.globl abc +abc: +nop diff --git a/test/ELF/linkerscript/symbol-assignexpr.s b/test/ELF/linkerscript/symbol-assignexpr.s index b988abcdfe98..5132ab11d821 100644 --- a/test/ELF/linkerscript/symbol-assignexpr.s +++ b/test/ELF/linkerscript/symbol-assignexpr.s @@ -13,14 +13,20 @@ # RUN: symbol9 = - 4; \ # RUN: symbol10 = 0xfedcba9876543210; \ # RUN: symbol11 = ((0x28000 + 0x1fff) & ~(0x1000 + -1)); \ +# RUN: symbol12 = 0x1234; \ +# RUN: symbol12 += 1; \ +# RUN: bar = 0x5678; \ +# RUN: baz = 0x9abc; \ # RUN: }" > %t.script # RUN: ld.lld -o %t1 --script %t.script %t # RUN: llvm-objdump -t %t1 | FileCheck %s # CHECK: SYMBOL TABLE: # CHECK-NEXT: 0000000000000000 *UND* 00000000 -# CHECK-NEXT: .text 00000000 _start -# CHECK-NEXT: .text 00000000 foo +# CHECK-NEXT: 0000000000000000 .text 00000000 _start +# CHECK-NEXT: 0000000000005678 *ABS* 00000000 bar +# CHECK-NEXT: 0000000000009abc *ABS* 00000000 baz +# CHECK-NEXT: 0000000000000001 .text 00000000 foo # CHECK-NEXT: 0000000000001000 *ABS* 00000000 symbol # CHECK-NEXT: 0000000000002234 *ABS* 00000000 symbol2 # CHECK-NEXT: 0000000000002234 *ABS* 00000000 symbol3 @@ -32,6 +38,7 @@ # CHECK-NEXT: fffffffffffffffc *ABS* 00000000 symbol9 # CHECK-NEXT: fedcba9876543210 *ABS* 00000000 symbol10 # CHECK-NEXT: 0000000000029000 *ABS* 00000000 symbol11 +# CHECK-NEXT: 0000000000001235 *ABS* 00000000 symbol12 # RUN: echo "SECTIONS { \ # RUN: symbol2 = symbol; \ @@ -46,3 +53,9 @@ _start: .global foo foo: + nop + +.global bar +bar = 0x1234 + +.comm baz,8,8 diff --git a/test/ELF/mips-gp-ext.s b/test/ELF/mips-gp-ext.s index b6c49e0fd422..212fd0fd21e4 100644 --- a/test/ELF/mips-gp-ext.s +++ b/test/ELF/mips-gp-ext.s @@ -1,8 +1,10 @@ # Check that the linker use a value of _gp symbol defined # in a linker script to calculate GOT relocations. -# FIXME: This test is xfailed because it depends on D27276 patch -# that enables absolute symbols redefinition by a linker's script. +# FIXME: This test is xfailed because there is currently a bug +# that causes symbols defined by linker scripts to be put in the +# wrong sections. In particular, `_gp = . + 0x100` ends up in +# `.text` when it should be in `*ABS*`. # XFAIL: * # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t.o diff --git a/test/ELF/reproduce-linkerscript.s b/test/ELF/reproduce-linkerscript.s index 1938e2b6cf94..2b0081501a62 100644 --- a/test/ELF/reproduce-linkerscript.s +++ b/test/ELF/reproduce-linkerscript.s @@ -4,10 +4,13 @@ # RUN: mkdir -p %t.dir/build # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.dir/build/foo.o # RUN: echo "INPUT(\"%t.dir/build/foo.o\")" > %t.dir/build/foo.script +# RUN: echo "INCLUDE \"%t.dir/build/bar.script\"" >> %t.dir/build/foo.script +# RUN: echo "/* empty */" > %t.dir/build/bar.script # RUN: cd %t.dir # RUN: ld.lld build/foo.script -o bar --reproduce repro.tar # RUN: tar xf repro.tar # RUN: diff build/foo.script repro/%:t.dir/build/foo.script +# RUN: diff build/bar.script repro/%:t.dir/build/bar.script # RUN: diff build/foo.o repro/%:t.dir/build/foo.o .globl _start diff --git a/test/ELF/undefined-versioned-symbol.s b/test/ELF/undefined-versioned-symbol.s new file mode 100644 index 000000000000..4e0957f25500 --- /dev/null +++ b/test/ELF/undefined-versioned-symbol.s @@ -0,0 +1,74 @@ +// REQUIRES: x86 +// RUN: echo ".data; \ +// RUN: .quad \"basename\"; \ +// RUN: .quad \"basename@FBSD_1.0\"; \ +// RUN: .quad \"basename@FBSD_1.1\" " > %t.s +// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %t.s -o %t.o +// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t2.o +// RUN: echo "FBSD_1.0 { local: *; }; FBSD_1.1 { };" > %t2.ver +// RUN: ld.lld --shared --version-script %t2.ver %t2.o -o %t2.so +// RUN: echo "LIBPKG_1.3 { };" > %t.ver +// RUN: ld.lld --shared %t.o --version-script %t.ver %t2.so -o %t.so +// RUN: llvm-readobj --dyn-symbols -r --expand-relocs %t.so | FileCheck %s + +// Test that each relocation points to the correct version. + +// CHECK: Section ({{.*}}) .rela.dyn { +// CHECK-NEXT: Relocation { +// CHECK-NEXT: Offset: 0x2000 +// CHECK-NEXT: Type: R_X86_64_64 (1) +// CHECK-NEXT: Symbol: basename (1) +// CHECK-NEXT: Addend: 0x0 +// CHECK-NEXT: } +// CHECK-NEXT: Relocation { +// CHECK-NEXT: Offset: 0x2008 +// CHECK-NEXT: Type: R_X86_64_64 (1) +// CHECK-NEXT: Symbol: basename (2) +// CHECK-NEXT: Addend: 0x0 +// CHECK-NEXT: } +// CHECK-NEXT: Relocation { +// CHECK-NEXT: Offset: 0x2010 +// CHECK-NEXT: Type: R_X86_64_64 (1) +// CHECK-NEXT: Symbol: basename (3) +// CHECK-NEXT: Addend: 0x0 +// CHECK-NEXT: } +// CHECK-NEXT: } + + +// CHECK: DynamicSymbols [ +// CHECK-NEXT: Symbol { +// CHECK-NEXT: Name: +// CHECK-NEXT: Value: +// CHECK-NEXT: Size: +// CHECK-NEXT: Binding: +// CHECK-NEXT: Type: +// CHECK-NEXT: Other: +// CHECK-NEXT: Section: +// CHECK-NEXT: } +// CHECK-NEXT: Symbol { +// CHECK-NEXT: Name: basename@FBSD_1.1 +// CHECK-NEXT: Value: +// CHECK-NEXT: Size: +// CHECK-NEXT: Binding: +// CHECK-NEXT: Type: +// CHECK-NEXT: Other: +// CHECK-NEXT: Section: +// CHECK-NEXT: } +// CHECK-NEXT: Symbol { +// CHECK-NEXT: Name: basename@FBSD_1.0 +// CHECK-NEXT: Value: +// CHECK-NEXT: Size: +// CHECK-NEXT: Binding: +// CHECK-NEXT: Type: +// CHECK-NEXT: Other: +// CHECK-NEXT: Section: +// CHECK-NEXT: } +// CHECK-NEXT: Symbol { +// CHECK-NEXT: Name: basename@FBSD_1.1 + + +.global "basename@FBSD_1.0" +"basename@FBSD_1.0": + +.global "basename@@FBSD_1.1" +"basename@@FBSD_1.1": |