From: Fangrui Song Date: Tue, 10 Sep 2019 12:28:07 +0000 (+0000) Subject: [ELF][test] Make tests more tolerant to exact symbol addresses X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1eda21e214f2fd5a7d54bec854e4cd83b2800d41;p=platform%2Fupstream%2Fllvm.git [ELF][test] Make tests more tolerant to exact symbol addresses Delete relocation-local.s and relocation-shared.s - covered by various tests llvm-svn: 371514 --- diff --git a/lld/test/ELF/Inputs/copy-in-shared.s b/lld/test/ELF/Inputs/copy-in-shared.s index 52e99c6..a8ea262 100644 --- a/lld/test/ELF/Inputs/copy-in-shared.s +++ b/lld/test/ELF/Inputs/copy-in-shared.s @@ -2,3 +2,4 @@ .global foo foo: .size foo, 4 +.space 4 diff --git a/lld/test/ELF/Inputs/relocation-copy-align-common.s b/lld/test/ELF/Inputs/relocation-copy-align-common.s index b2fc8fd..6d5bb13 100644 --- a/lld/test/ELF/Inputs/relocation-copy-align-common.s +++ b/lld/test/ELF/Inputs/relocation-copy-align-common.s @@ -1,7 +1,7 @@ .data .global foo .type foo, @object -.align 8 -.size foo, 8 +.align 32 +.size foo, 32 foo: .quad 0 diff --git a/lld/test/ELF/compressed-debug-input.s b/lld/test/ELF/compressed-debug-input.s index 32991a8..c9bfd3e 100644 --- a/lld/test/ELF/compressed-debug-input.s +++ b/lld/test/ELF/compressed-debug-input.s @@ -54,7 +54,7 @@ # DATA-NEXT: SHF_STRINGS (0x20) # DATA-NEXT: ] # DATA-NEXT: Address: 0x0 -# DATA-NEXT: Offset: 0x1060 +# DATA-NEXT: Offset: # DATA-NEXT: Size: 69 # DATA-NEXT: Link: 0 # DATA-NEXT: Info: 0 diff --git a/lld/test/ELF/discard-merge-unnamed.s b/lld/test/ELF/discard-merge-unnamed.s index f2cbe18..2bd3873 100644 --- a/lld/test/ELF/discard-merge-unnamed.s +++ b/lld/test/ELF/discard-merge-unnamed.s @@ -15,7 +15,7 @@ // CHECK-NEXT: } // CHECK-NEXT: Symbol { // CHECK-NEXT: Name: _DYNAMIC -// CHECK-NEXT: Value: 0x2000 +// CHECK-NEXT: Value: // CHECK-NEXT: Size: 0 // CHECK-NEXT: Binding: Local // CHECK-NEXT: Type: None diff --git a/lld/test/ELF/dynamic-list-weak-archive.s b/lld/test/ELF/dynamic-list-weak-archive.s index 627b76d..494e6e7 100644 --- a/lld/test/ELF/dynamic-list-weak-archive.s +++ b/lld/test/ELF/dynamic-list-weak-archive.s @@ -1,7 +1,11 @@ # REQUIRES: x86 +## A weak reference does not fetch the lazy definition. Test foo is preemptable +## even in the presence of a dynamic list, so a dynamic relocation will be +## produced. + # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t1.o -# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/dynamic-list-weak-archive.s -o %t2.o +# RUN: echo '.globl foo; foo:' | llvm-mc -filetype=obj -triple=x86_64 - -o %t2.o # RUN: rm -f %t.a # RUN: llvm-ar rcs %t.a %t2.o # RUN: echo "{ zed; };" > %t.list @@ -10,7 +14,7 @@ # CHECK: Relocations [ # CHECK-NEXT: Section ({{.*}}) .rela.plt { -# CHECK-NEXT: 0x3018 R_X86_64_JUMP_SLOT foo +# CHECK-NEXT: R_X86_64_JUMP_SLOT foo # CHECK-NEXT: } # CHECK-NEXT: ] diff --git a/lld/test/ELF/gc-sections-string.s b/lld/test/ELF/gc-sections-string.s index 4bc7e80..90104e2 100644 --- a/lld/test/ELF/gc-sections-string.s +++ b/lld/test/ELF/gc-sections-string.s @@ -35,7 +35,7 @@ // CHECK-NEXT: } // CHECK-NEXT: Symbol { // CHECK-NEXT: Name: _start -// CHECK-NEXT: Value: 0x201000 +// CHECK-NEXT: Value: // CHECK-NEXT: Size: 0 // CHECK-NEXT: Binding: Global (0x1) // CHECK-NEXT: Type: Function (0x2) diff --git a/lld/test/ELF/gnu-ifunc-noplt.s b/lld/test/ELF/gnu-ifunc-noplt.s index 95ae741d..f3e50b1 100644 --- a/lld/test/ELF/gnu-ifunc-noplt.s +++ b/lld/test/ELF/gnu-ifunc-noplt.s @@ -1,6 +1,9 @@ // REQUIRES: x86 + +/// Test -z ifunc-noplt. + // RUN: llvm-mc -filetype=obj -triple=x86_64-pc-freebsd %S/Inputs/shared2-x86-64.s -o %t1.o -// RUN: ld.lld %t1.o --shared -o %t.so +// RUN: ld.lld %t1.o --shared -soname=so -o %t.so // RUN: llvm-mc -filetype=obj -triple=x86_64-pc-freebsd %s -o %t.o // RUN: ld.lld -z ifunc-noplt -z notext --hash-style=sysv %t.so %t.o -o %tout // RUN: llvm-objdump -d --no-show-raw-insn %tout | FileCheck %s --check-prefix=DISASM diff --git a/lld/test/ELF/gnu-ifunc-plt.s b/lld/test/ELF/gnu-ifunc-plt.s index e535888..25cefb8 100644 --- a/lld/test/ELF/gnu-ifunc-plt.s +++ b/lld/test/ELF/gnu-ifunc-plt.s @@ -1,9 +1,12 @@ // REQUIRES: x86 + +/// For non-preemptable ifunc, place ifunc PLT entries after regular PLT entries. + // RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/shared2-x86-64.s -o %t1.o -// RUN: ld.lld %t1.o --shared -o %t.so +// RUN: ld.lld %t1.o --shared -soname=so -o %t.so // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o // RUN: ld.lld --hash-style=sysv %t.so %t.o -o %tout -// RUN: llvm-objdump -d %tout | FileCheck %s --check-prefix=DISASM +// RUN: llvm-objdump -d --no-show-raw-insn %tout | FileCheck %s --check-prefix=DISASM // RUN: llvm-objdump -s %tout | FileCheck %s --check-prefix=GOTPLT // RUN: llvm-readobj -r --dynamic-table %tout | FileCheck %s @@ -34,37 +37,37 @@ // DISASM: Disassembly of section .text: // DISASM-EMPTY: // DISASM-NEXT: foo: -// DISASM-NEXT: 201000: c3 retq +// DISASM-NEXT: 201000: retq // DISASM: bar: -// DISASM-NEXT: 201001: c3 retq +// DISASM-NEXT: 201001: retq // DISASM: _start: -// DISASM-NEXT: 201002: e8 49 00 00 00 callq 73 -// DISASM-NEXT: 201007: e8 54 00 00 00 callq 84 -// DISASM-NEXT: 20100c: e8 1f 00 00 00 callq 31 -// DISASM-NEXT: 201011: e8 2a 00 00 00 callq 42 +// DISASM-NEXT: 201002: callq 73 +// DISASM-NEXT: 201007: callq 84 +// DISASM-NEXT: callq {{.*}} +// DISASM-NEXT: callq {{.*}} // DISASM-EMPTY: // DISASM-NEXT: Disassembly of section .plt: // DISASM-EMPTY: // DISASM-NEXT: .plt: -// DISASM-NEXT: 201020: ff 35 e2 1f 00 00 pushq 8162(%rip) -// DISASM-NEXT: 201026: ff 25 e4 1f 00 00 jmpq *8164(%rip) -// DISASM-NEXT: 20102c: 0f 1f 40 00 nopl (%rax) +// DISASM-NEXT: 201020: pushq 8162(%rip) +// DISASM-NEXT: 201026: jmpq *8164(%rip) +// DISASM-NEXT: 20102c: nopl (%rax) // DISASM-EMPTY: // DISASM-NEXT: bar2@plt: -// DISASM-NEXT: 201030: ff 25 e2 1f 00 00 jmpq *8162(%rip) -// DISASM-NEXT: 201036: 68 00 00 00 00 pushq $0 -// DISASM-NEXT: 20103b: e9 e0 ff ff ff jmp -32 <.plt> +// DISASM-NEXT: 201030: jmpq *8162(%rip) +// DISASM-NEXT: 201036: pushq $0 +// DISASM-NEXT: 20103b: jmp -32 <.plt> // DISASM-EMPTY: // DISASM-NEXT: zed2@plt: -// DISASM-NEXT: 201040: ff 25 da 1f 00 00 jmpq *8154(%rip) -// DISASM-NEXT: 201046: 68 01 00 00 00 pushq $1 -// DISASM-NEXT: 20104b: e9 d0 ff ff ff jmp -48 <.plt> -// DISASM-NEXT: 201050: ff 25 d2 1f 00 00 jmpq *8146(%rip) -// DISASM-NEXT: 201056: 68 00 00 00 00 pushq $0 -// DISASM-NEXT: 20105b: e9 e0 ff ff ff jmp -32 -// DISASM-NEXT: 201060: ff 25 ca 1f 00 00 jmpq *8138(%rip) -// DISASM-NEXT: 201066: 68 01 00 00 00 pushq $1 -// DISASM-NEXT: 20106b: e9 d0 ff ff ff jmp -48 +// DISASM-NEXT: 201040: jmpq *8154(%rip) +// DISASM-NEXT: 201046: pushq $1 +// DISASM-NEXT: 20104b: jmp -48 <.plt> +// DISASM-NEXT: 201050: jmpq *8146(%rip) +// DISASM-NEXT: 201056: pushq $0 +// DISASM-NEXT: 20105b: jmp -32 +// DISASM-NEXT: 201060: jmpq *8138(%rip) +// DISASM-NEXT: 201066: pushq $1 +// DISASM-NEXT: 20106b: jmp -48 .text .type foo STT_GNU_IFUNC diff --git a/lld/test/ELF/gnu-ifunc-shared.s b/lld/test/ELF/gnu-ifunc-shared.s index 237875b..06789df 100644 --- a/lld/test/ELF/gnu-ifunc-shared.s +++ b/lld/test/ELF/gnu-ifunc-shared.s @@ -1,7 +1,10 @@ // REQUIRES: x86 + +/// For non-preemptable ifunc, place ifunc PLT entries after regular PLT entries. + // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o -// RUN: ld.lld --hash-style=sysv --shared -o %t.so %t.o -// RUN: llvm-objdump -d %t.so | FileCheck %s --check-prefix=DISASM +// RUN: ld.lld --shared -o %t.so %t.o +// RUN: llvm-objdump -d --no-show-raw-insn %t.so | FileCheck %s --check-prefix=DISASM // RUN: llvm-readobj -r %t.so | FileCheck %s // Check that an IRELATIVE relocation is used for a non-preemptible ifunc @@ -9,42 +12,42 @@ // DISASM: Disassembly of section .text: // DISASM-EMPTY: // DISASM-NEXT: fct: -// DISASM-NEXT: 1000: c3 retq +// DISASM-NEXT: 1000: retq // DISASM: fct2: -// DISASM-NEXT: 1001: c3 retq +// DISASM-NEXT: 1001: retq // DISASM: f1: -// DISASM-NEXT: 1002: e8 49 00 00 00 callq 73 -// DISASM-NEXT: 1007: e8 24 00 00 00 callq 36 -// DISASM-NEXT: 100c: e8 2f 00 00 00 callq 47 -// DISASM-NEXT: 1011: c3 retq +// DISASM-NEXT: 1002: callq 73 +// DISASM-NEXT: 1007: callq 36 +// DISASM-NEXT: 100c: callq 47 +// DISASM-NEXT: 1011: retq // DISASM: f2: -// DISASM-NEXT: 1012: c3 retq +// DISASM-NEXT: 1012: retq // DISASM-EMPTY: // DISASM-NEXT: Disassembly of section .plt: // DISASM-EMPTY: // DISASM-NEXT: .plt: -// DISASM-NEXT: 1020: ff 35 e2 1f 00 00 pushq 8162(%rip) -// DISASM-NEXT: 1026: ff 25 e4 1f 00 00 jmpq *8164(%rip) -// DISASM-NEXT: 102c: 0f 1f 40 00 nopl (%rax) +// DISASM-NEXT: 1020: pushq 8162(%rip) +// DISASM-NEXT: 1026: jmpq *8164(%rip) +// DISASM-NEXT: 102c: nopl (%rax) // DISASM-EMPTY: // DISASM-NEXT: fct2@plt: -// DISASM-NEXT: 1030: ff 25 e2 1f 00 00 jmpq *8162(%rip) -// DISASM-NEXT: 1036: 68 00 00 00 00 pushq $0 -// DISASM-NEXT: 103b: e9 e0 ff ff ff jmp -32 <.plt> +// DISASM-NEXT: 1030: jmpq *8162(%rip) +// DISASM-NEXT: 1036: pushq $0 +// DISASM-NEXT: 103b: jmp -32 <.plt> // DISASM-EMPTY: // DISASM-NEXT: f2@plt: -// DISASM-NEXT: 1040: ff 25 da 1f 00 00 jmpq *8154(%rip) -// DISASM-NEXT: 1046: 68 01 00 00 00 pushq $1 -// DISASM-NEXT: 104b: e9 d0 ff ff ff jmp -48 <.plt> -// DISASM-NEXT: 1050: ff 25 d2 1f 00 00 jmpq *8146(%rip) -// DISASM-NEXT: 1056: 68 00 00 00 00 pushq $0 -// DISASM-NEXT: 105b: e9 e0 ff ff ff jmp -32 +// DISASM-NEXT: 1040: jmpq *8154(%rip) +// DISASM-NEXT: 1046: pushq $1 +// DISASM-NEXT: 104b: jmp -48 <.plt> +// DISASM-NEXT: 1050: jmpq *8146(%rip) +// DISASM-NEXT: 1056: pushq $0 +// DISASM-NEXT: 105b: jmp -32 // CHECK: Relocations [ -// CHECK-NEXT: Section (4) .rela.dyn { +// CHECK-NEXT: Section (5) .rela.dyn { // CHECK-NEXT: 0x3028 R_X86_64_IRELATIVE - 0x1000 // CHECK-NEXT: } -// CHECK-NEXT: Section (5) .rela.plt { +// CHECK-NEXT: Section (6) .rela.plt { // CHECK-NEXT: 0x3018 R_X86_64_JUMP_SLOT fct2 0x0 // CHECK-NEXT: 0x3020 R_X86_64_JUMP_SLOT f2 0x0 // CHECK-NEXT: } diff --git a/lld/test/ELF/local-got-shared.s b/lld/test/ELF/local-got-shared.s index 7a603a3..34da326 100644 --- a/lld/test/ELF/local-got-shared.s +++ b/lld/test/ELF/local-got-shared.s @@ -1,8 +1,8 @@ // REQUIRES: x86 // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o -// RUN: ld.lld --hash-style=sysv %t.o -o %t -shared +// RUN: ld.lld %t.o -o %t -shared // RUN: llvm-readobj -S -r -d %t | FileCheck %s -// RUN: llvm-objdump -d %t | FileCheck --check-prefix=DISASM %s +// RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=DISASM %s bar: call foo@gotpcrel @@ -12,12 +12,12 @@ bar: foo: nop -// 0x20A0 - 0x1000 - 5 = 4251 +// 0x20B0 - 0x1000 - 5 = 4267 // DISASM: bar: -// DISASM-NEXT: 1000: {{.*}} callq 4251 +// DISASM-NEXT: 1000: callq 4267 // DISASM: foo: -// DISASM-NEXT: 1005: {{.*}} nop +// DISASM-NEXT: 1005: nop // CHECK: Name: .got // CHECK-NEXT: Type: SHT_PROGBITS @@ -25,13 +25,13 @@ foo: // CHECK-NEXT: SHF_ALLOC // CHECK-NEXT: SHF_WRITE // CHECK-NEXT: ] -// CHECK-NEXT: Address: 0x20A0 +// CHECK-NEXT: Address: 0x20B0 // CHECK-NEXT: Offset: // CHECK-NEXT: Size: 8 // CHECK: Relocations [ // CHECK-NEXT: Section ({{.*}}) .rela.dyn { -// CHECK-NEXT: 0x20A0 R_X86_64_RELATIVE - 0x1005 +// CHECK-NEXT: 0x20B0 R_X86_64_RELATIVE - 0x1005 // CHECK-NEXT: } // CHECK-NEXT: ] // CHECK: 0x000000006FFFFFF9 RELACOUNT 1 diff --git a/lld/test/ELF/local-got.s b/lld/test/ELF/local-got.s index 3c8882c..0ea1d66 100644 --- a/lld/test/ELF/local-got.s +++ b/lld/test/ELF/local-got.s @@ -1,10 +1,10 @@ // REQUIRES: x86 // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/shared.s -o %t2.o -// RUN: ld.lld -shared %t2.o -o %t2.so -// RUN: ld.lld --hash-style=sysv %t.o %t2.so -o %t +// RUN: ld.lld -shared %t2.o -soname=so -o %t2.so +// RUN: ld.lld %t.o %t2.so -o %t // RUN: llvm-readobj -S -r --section-data %t | FileCheck %s -// RUN: llvm-objdump -d %t | FileCheck --check-prefix=DISASM %s +// RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=DISASM %s .globl _start _start: @@ -15,14 +15,14 @@ _start: foo: nop -// 0x2020B0 - 0x201000 - 5 = 4251 -// 0x2020B8 - 0x201005 - 5 = 4254 +// 0x2020C0 - 0x201000 - 5 = 4283 +// 0x2020C8 - 0x201005 - 5 = 4286 // DISASM: _start: -// DISASM-NEXT: 201000: {{.*}} callq 4267 -// DISASM-NEXT: 201005: {{.*}} callq 4270 - -// DISASM: foo: -// DISASM-NEXT: 20100a: {{.*}} nop +// DISASM-NEXT: 201000: callq 4283 +// DISASM-NEXT: 201005: callq 4286 + +// DISASM: foo: +// DISASM-NEXT: 20100a: nop // CHECK: Name: .got // CHECK-NEXT: Type: SHT_PROGBITS @@ -30,7 +30,7 @@ foo: // CHECK-NEXT: SHF_ALLOC // CHECK-NEXT: SHF_WRITE // CHECK-NEXT: ] -// CHECK-NEXT: Address: 0x2020B0 +// CHECK-NEXT: Address: 0x2020C0 // CHECK-NEXT: Offset: // CHECK-NEXT: Size: 16 // CHECK-NEXT: Link: 0 @@ -38,12 +38,11 @@ foo: // CHECK-NEXT: AddressAlignment: 8 // CHECK-NEXT: EntrySize: 0 // CHECK-NEXT: SectionData ( -// 0x20200a in little endian // CHECK-NEXT: 0000: 00000000 00000000 0A102000 00000000 // CHECK-NEXT: ) // CHECK: Relocations [ // CHECK-NEXT: Section ({{.*}}) .rela.dyn { -// CHECK-NEXT: 0x2020B0 R_X86_64_GLOB_DAT bar 0x0 +// CHECK-NEXT: 0x2020C0 R_X86_64_GLOB_DAT bar 0x0 // CHECK-NEXT: } // CHECK-NEXT: ] diff --git a/lld/test/ELF/pre_init_fini_array.s b/lld/test/ELF/pre_init_fini_array.s index 56daa96..fd60c45 100644 --- a/lld/test/ELF/pre_init_fini_array.s +++ b/lld/test/ELF/pre_init_fini_array.s @@ -1,7 +1,7 @@ // REQUIRES: x86 // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/shared.s -o %t2 -// RUN: ld.lld %t2 -o %t2.so -shared +// RUN: ld.lld %t2 -o %t2.so -shared -soname=so // RUN: ld.lld %t %t2.so -o %t2 // RUN: llvm-readobj -r --symbols --sections --dynamic-table %t2 | FileCheck %s // RUN: llvm-objdump -d %t2 | FileCheck --check-prefix=DISASM %s @@ -63,7 +63,7 @@ _start: // CHECK-NEXT: ] // CHECK: Name: __fini_array_end -// CHECK-NEXT: Value: 0x20201B +// CHECK-NEXT: Value: // CHECK-NEXT: Size: 0 // CHECK-NEXT: Binding: Local // CHECK-NEXT: Type: None @@ -85,7 +85,7 @@ _start: // CHECK-NEXT: } // CHECK-NEXT: Symbol { // CHECK-NEXT: Name: __init_array_end -// CHECK-NEXT: Value: 0x202008 +// CHECK-NEXT: Value: // CHECK-NEXT: Size: 0 // CHECK-NEXT: Binding: Local // CHECK-NEXT: Type: None @@ -107,7 +107,7 @@ _start: // CHECK-NEXT: } // CHECK-NEXT: Symbol { // CHECK-NEXT: Name: __preinit_array_end -// CHECK-NEXT: Value: 0x202011 +// CHECK-NEXT: Value: // CHECK-NEXT: Size: 0 // CHECK-NEXT: Binding: Local // CHECK-NEXT: Type: None @@ -136,17 +136,10 @@ _start: // CHECK: FINI_ARRAY [[FINI_ADDR]] // CHECK: FINI_ARRAYSZ [[FINI_SIZE]] (bytes) - -// 0x202008 - (0x201000 + 5) = 4099 -// 0x202011 - (0x201005 + 5) = 4103 -// 0x202000 - (0x20100a + 5) = 4081 -// 0x202008 - (0x20100f + 5) = 4084 -// 0x202011 - (0x201014 + 5) = 4088 -// 0x20201B - (0x201019 + 5) = 4093 // DISASM: _start: -// DISASM-NEXT: 201000: e8 {{.*}} callq 4099 -// DISASM-NEXT: 201005: e8 {{.*}} callq 4103 -// DISASM-NEXT: 20100a: e8 {{.*}} callq 4081 -// DISASM-NEXT: 20100f: e8 {{.*}} callq 4084 -// DISASM-NEXT: 201014: e8 {{.*}} callq 4088 -// DISASM-NEXT: 201019: e8 {{.*}} callq 4093 +// DISASM-NEXT: callq {{.*}} <__preinit_array_start> +// DISASM-NEXT: callq {{.*}} <__fini_array_start> +// DISASM-NEXT: callq {{.*}} <__init_array_start> +// DISASM-NEXT: callq {{.*}} <__preinit_array_start> +// DISASM-NEXT: callq {{.*}} <__fini_array_start> +// DISASM-NEXT: callq {{.*}} <__fini_array_end> diff --git a/lld/test/ELF/relocation-copy-align-common.s b/lld/test/ELF/relocation-copy-align-common.s index 748f845..5928dfb 100644 --- a/lld/test/ELF/relocation-copy-align-common.s +++ b/lld/test/ELF/relocation-copy-align-common.s @@ -1,10 +1,14 @@ # REQUIRES: x86 + +## Alignment of the copy relocated symbol is respected, even when .bss includes +## other sections (COMMON). + # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux \ # RUN: %p/Inputs/relocation-copy-align-common.s -o %t2.o -# RUN: ld.lld -shared %t2.o -o %t.so -# RUN: ld.lld --hash-style=sysv %t.o %t.so -o %t3 -# RUN: llvm-readobj -S -r --expand-relocs %t3 | FileCheck %s +# RUN: ld.lld -shared %t2.o -soname=so -o %t.so +# RUN: ld.lld %t.o %t.so -o %t3 +# RUN: llvm-readobj -S -r %t3 | FileCheck %s # CHECK: Section { # CHECK: Index: @@ -16,21 +20,16 @@ # CHECK-NEXT: ] # CHECK-NEXT: Address: 0x203000 # CHECK-NEXT: Offset: 0x3000 -# CHECK-NEXT: Size: 16 +# CHECK-NEXT: Size: 64 # CHECK-NEXT: Link: 0 # CHECK-NEXT: Info: 0 -# CHECK-NEXT: AddressAlignment: 8 +# CHECK-NEXT: AddressAlignment: 32 # CHECK-NEXT: EntrySize: 0 # CHECK-NEXT: } # CHECK: Relocations [ # CHECK-NEXT: Section {{.*}} .rela.dyn { -# CHECK-NEXT: Relocation { -# CHECK-NEXT: Offset: 0x203008 -# CHECK-NEXT: Type: R_X86_64_COPY -# CHECK-NEXT: Symbol: foo -# CHECK-NEXT: Addend: 0x0 -# CHECK-NEXT: } +# CHECK-NEXT: 0x203020 R_X86_64_COPY foo 0x0 # CHECK-NEXT: } # CHECK-NEXT: ] diff --git a/lld/test/ELF/relocation-copy-align.s b/lld/test/ELF/relocation-copy-align.s index 78f05d2..c53c099 100644 --- a/lld/test/ELF/relocation-copy-align.s +++ b/lld/test/ELF/relocation-copy-align.s @@ -1,4 +1,7 @@ // REQUIRES: x86 + +/// Alignment of the copy relocated symbol is respected. + // 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/relocation-copy-align.s -o %t2.o // RUN: ld.lld -shared %t2.o -o %t.so diff --git a/lld/test/ELF/relocation-local.s b/lld/test/ELF/relocation-local.s deleted file mode 100644 index 6466604..0000000 --- a/lld/test/ELF/relocation-local.s +++ /dev/null @@ -1,40 +0,0 @@ -// REQUIRES: x86 -// Test that relocation of local symbols is working. -// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t -// RUN: ld.lld %t -o %t2 -// RUN: llvm-objdump -s -d %t2 | FileCheck %s - - -.global _start -_start: - call lulz - -.zero 4 -lulz: - -.section .text2,"ax",@progbits -R_X86_64_32: - movl $R_X86_64_32, %edx - -// FIXME: this would be far more self evident if llvm-objdump printed -// constants in hex. -// CHECK: Disassembly of section .text2: -// CHECK-EMPTY: -// CHECK-NEXT: R_X86_64_32: -// CHECK-NEXT: 201009: {{.*}} movl $2101257, %edx - -.section .R_X86_64_32S,"ax",@progbits -R_X86_64_32S: - movq lulz - 0x100000, %rdx - -// CHECK: Disassembly of section .R_X86_64_32S: -// CHECK-EMPTY: -// CHECK-NEXT: R_X86_64_32S: -// CHECK-NEXT: {{.*}}: {{.*}} movq 1052681, %rdx - -.section .R_X86_64_64,"a",@progbits -R_X86_64_64: - .quad R_X86_64_64 - -// CHECK: Contents of section .R_X86_64_64: -// CHECK-NEXT: 200120 20012000 00000000 diff --git a/lld/test/ELF/relocation-shared.s b/lld/test/ELF/relocation-shared.s deleted file mode 100644 index 40a16c4..0000000 --- a/lld/test/ELF/relocation-shared.s +++ /dev/null @@ -1,36 +0,0 @@ -// REQUIRES: x86 -// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o -// RUN: ld.lld %t.o -shared -o %t.so -// RUN: llvm-readobj -r -S --section-data %t.so | FileCheck %s - -// CHECK: Name: foo -// CHECK-NEXT: Type: SHT_PROGBITS -// CHECK-NEXT: Flags [ -// CHECK-NEXT: SHF_ALLOC -// CHECK-NEXT: ] -// CHECK-NEXT: Address: 0x20D -// CHECK-NEXT: Offset: -// CHECK-NEXT: Size: 8 -// CHECK-NEXT: Link: 0 -// CHECK-NEXT: Info: 0 -// CHECK-NEXT: AddressAlignment: 1 -// CHECK-NEXT: EntrySize: 0 -// CHECK-NEXT: SectionData ( -// CHECK-NEXT: 0000: F30D0000 00000000 -// 0x1000 - 0x20D = 0xDF3 -// CHECK-NEXT: ) - -// CHECK: Name: .text -// CHECK-NEXT: Type: SHT_PROGBITS -// CHECK-NEXT: Flags [ -// CHECK-NEXT: SHF_ALLOC -// CHECK-NEXT: SHF_EXECINSTR -// CHECK-NEXT: ] -// CHECK-NEXT: Address: 0x1000 - -// CHECK: Relocations [ -// CHECK-NEXT: ] - -bar: - .section foo,"a",@progbits - .quad bar - . diff --git a/lld/test/ELF/resolution.s b/lld/test/ELF/resolution.s index 95ddb51..f591505 100644 --- a/lld/test/ELF/resolution.s +++ b/lld/test/ELF/resolution.s @@ -308,7 +308,7 @@ // CHECK-NEXT: } // CHECK-NEXT: Symbol { // CHECK-NEXT: Name: _start -// CHECK-NEXT: Value: 0x201000 +// CHECK-NEXT: Value: // CHECK-NEXT: Size: 0 // CHECK-NEXT: Binding: Global (0x1) // CHECK-NEXT: Type: None (0x0) diff --git a/lld/test/ELF/startstop.s b/lld/test/ELF/startstop.s index efd117b..0ec5893 100644 --- a/lld/test/ELF/startstop.s +++ b/lld/test/ELF/startstop.s @@ -1,25 +1,25 @@ // REQUIRES: x86 // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t -// RUN: ld.lld --hash-style=sysv %t -o %tout -shared -// RUN: llvm-objdump -d %tout | FileCheck -check-prefix=DISASM %s -// RUN: llvm-readobj --symbols -r %tout | FileCheck -check-prefix=SYMBOL %s +// RUN: ld.lld %t -o %t.so -shared +// RUN: llvm-objdump -d --no-show-raw-insn %t.so | FileCheck -check-prefix=DISASM %s +// RUN: llvm-readobj --symbols -r %t.so | FileCheck -check-prefix=SYMBOL %s // DISASM: _start: -// DISASM: 1000: {{.*}} callq 10 -// DISASM: 1005: {{.*}} callq 8 -// DISASM: 100a: {{.*}} callq 3 +// DISASM: 1000: callq 10 <__start_foo> +// DISASM: 1005: callq 8 <__start_bar> +// DISASM: 100a: callq 3 <__start_bar> // DISASM: Disassembly of section foo: // DISASM-EMPTY: // DISASM: __start_foo: -// DISASM: 100f: 90 nop -// DISASM: 1010: 90 nop -// DISASM: 1011: 90 nop +// DISASM: 100f: nop +// DISASM: nop +// DISASM: nop // DISASM: Disassembly of section bar: // DISASM-EMPTY: // DISASM: __start_bar: -// DISASM: 1012: 90 nop -// DISASM: 1013: 90 nop -// DISASM: 1014: 90 nop +// DISASM: 1012: nop +// DISASM: nop +// DISASM: nop // SYMBOL: Relocations [ // SYMBOL-NEXT: Section ({{.*}}) .rela.dyn { diff --git a/lld/test/ELF/tls.s b/lld/test/ELF/tls.s index dc310e0..156b8ae 100644 --- a/lld/test/ELF/tls.s +++ b/lld/test/ELF/tls.s @@ -165,7 +165,7 @@ d: // DIS: Disassembly of section .text: // DIS-EMPTY: // DIS-NEXT: _start: -// DIS-NEXT: 201000: {{.+}} movl %fs:-8, %eax -// DIS-NEXT: 201008: {{.+}} movl %fs:-16, %eax -// DIS-NEXT: 201010: {{.+}} movl %fs:-4, %eax -// DIS-NEXT: 201018: {{.+}} movl %fs:-12, %eax +// DIS-NEXT: movl %fs:-8, %eax +// DIS-NEXT: movl %fs:-16, %eax +// DIS-NEXT: movl %fs:-4, %eax +// DIS-NEXT: movl %fs:-12, %eax diff --git a/lld/test/ELF/x86-64-reloc-size.s b/lld/test/ELF/x86-64-reloc-size.s index 9aa795f..4edc4b7 100644 --- a/lld/test/ELF/x86-64-reloc-size.s +++ b/lld/test/ELF/x86-64-reloc-size.s @@ -20,10 +20,10 @@ # DATA-NEXT: 0x00202030 00001b00 00000000 0000 # DISASM: _start: -# DISASM-NEXT: 201000: movl 25, %eax -# DISASM-NEXT: 201007: movl 27, %eax -# DISASM-NEXT: 20100e: movl 25, %eax -# DISASM-NEXT: 201015: movl 27, %eax +# DISASM-NEXT: movl 25, %eax +# DISASM-NEXT: movl 27, %eax +# DISASM-NEXT: movl 25, %eax +# DISASM-NEXT: movl 27, %eax # RELOC2: Relocations [ # RELOC2-NEXT: Section ({{.*}}) .rela.dyn { @@ -41,10 +41,10 @@ # DATA2-NEXT: 00001b00 00000000 0000 # DISASM2: _start: -# DISASM2-NEXT: 1000: movl 0, %eax -# DISASM2-NEXT: 1007: movl 0, %eax -# DISASM2-NEXT: 100e: movl 25, %eax -# DISASM2-NEXT: 1015: movl 27, %eax +# DISASM2-NEXT: movl 0, %eax +# DISASM2-NEXT: movl 0, %eax +# DISASM2-NEXT: movl 25, %eax +# DISASM2-NEXT: movl 27, %eax .data .global foo, foohidden diff --git a/lld/test/ELF/x86-64-retpoline-znow.s b/lld/test/ELF/x86-64-retpoline-znow.s index 16e883a..061f4c3 100644 --- a/lld/test/ELF/x86-64-retpoline-znow.s +++ b/lld/test/ELF/x86-64-retpoline-znow.s @@ -1,7 +1,7 @@ // REQUIRES: x86 // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/shared.s -o %t2.o -// RUN: ld.lld -shared %t2.o -o %t2.so +// RUN: ld.lld -shared %t2.o -soname=so -o %t2.so // RUN: ld.lld -shared %t1.o %t2.so -o %t.exe -z retpolineplt -z now // RUN: llvm-objdump -d -s --no-show-raw-insn %t.exe | FileCheck %s @@ -10,38 +10,38 @@ // CHECK-EMPTY: // CHECK-NEXT: .plt: // CHECK-NEXT: 1010: callq 11 <.plt+0x10> -// CHECK-NEXT: 1015: pause -// CHECK-NEXT: 1017: lfence -// CHECK-NEXT: 101a: jmp -7 <.plt+0x5> -// CHECK-NEXT: 101c: int3 -// CHECK-NEXT: 101d: int3 -// CHECK-NEXT: 101e: int3 -// CHECK-NEXT: 101f: int3 +// CHECK-NEXT: pause +// CHECK-NEXT: lfence +// CHECK-NEXT: jmp -7 <.plt+0x5> +// CHECK-NEXT: int3 +// CHECK-NEXT: int3 +// CHECK-NEXT: int3 +// CHECK-NEXT: int3 // CHECK-NEXT: 1020: movq %r11, (%rsp) -// CHECK-NEXT: 1024: retq -// CHECK-NEXT: 1025: int3 -// CHECK-NEXT: 1026: int3 -// CHECK-NEXT: 1027: int3 -// CHECK-NEXT: 1028: int3 -// CHECK-NEXT: 1029: int3 -// CHECK-NEXT: 102a: int3 -// CHECK-NEXT: 102b: int3 -// CHECK-NEXT: 102c: int3 -// CHECK-NEXT: 102d: int3 -// CHECK-NEXT: 102e: int3 -// CHECK-NEXT: 102f: int3 +// CHECK-NEXT: retq +// CHECK-NEXT: int3 +// CHECK-NEXT: int3 +// CHECK-NEXT: int3 +// CHECK-NEXT: int3 +// CHECK-NEXT: int3 +// CHECK-NEXT: int3 +// CHECK-NEXT: int3 +// CHECK-NEXT: int3 +// CHECK-NEXT: int3 +// CHECK-NEXT: int3 +// CHECK-NEXT: int3 // CHECK-NEXT: 1030: movq 4289(%rip), %r11 -// CHECK-NEXT: 1037: jmp -44 <.plt> -// CHECK-NEXT: 103c: int3 -// CHECK-NEXT: 103d: int3 -// CHECK-NEXT: 103e: int3 -// CHECK-NEXT: 103f: int3 +// CHECK-NEXT: jmp -44 <.plt> +// CHECK-NEXT: int3 +// CHECK-NEXT: int3 +// CHECK-NEXT: int3 +// CHECK-NEXT: int3 // CHECK-NEXT: 1040: movq 4281(%rip), %r11 -// CHECK-NEXT: 1047: jmp -60 <.plt> -// CHECK-NEXT: 104c: int3 -// CHECK-NEXT: 104d: int3 -// CHECK-NEXT: 104e: int3 -// CHECK-NEXT: 104f: int3 +// CHECK-NEXT: jmp -60 <.plt> +// CHECK-NEXT: int3 +// CHECK-NEXT: int3 +// CHECK-NEXT: int3 +// CHECK-NEXT: int3 // CHECK: Contents of section .got.plt: // CHECK-NEXT: 20e0 00200000 00000000 00000000 00000000 diff --git a/lld/test/ELF/x86-64-retpoline.s b/lld/test/ELF/x86-64-retpoline.s index ef51dd2..8691f75 100644 --- a/lld/test/ELF/x86-64-retpoline.s +++ b/lld/test/ELF/x86-64-retpoline.s @@ -1,7 +1,7 @@ // REQUIRES: x86 // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/shared.s -o %t2.o -// RUN: ld.lld -shared %t2.o -o %t2.so +// RUN: ld.lld -shared %t2.o -soname=so -o %t2.so // RUN: ld.lld -shared %t1.o %t2.so -o %t.exe -z retpolineplt // RUN: llvm-objdump -d -s --no-show-raw-insn %t.exe | FileCheck %s