[ELF][test] Improve tests

Add file-level comments
Delete insignificant addresses to make them more tolerant to layout changes
Simplify test output

Delete weak-undef-val.s - covered by relocation-undefined-weak.s
Delete weak-undef-export.s - covered by additional test added to weak-undef.s
Delete version-undef-sym.s - covered by undefined-versioned-symbol.s => version-symbol-undef.s
Delete symbol-ordering-file2.s - covered by symbol-ordering-file.s
Delete gotpcrelx.s - covered by gotpc-relax-und-dso.s => x86-64-gotpc-relax-und-dso.s

llvm-svn: 371299
This commit is contained in:
Fangrui Song 2019-09-07 10:42:11 +00:00
parent 84c7904d62
commit 0e79890d9b
33 changed files with 205 additions and 360 deletions

View File

@ -1,3 +0,0 @@
.global bar
bar:
.quad __progname@GOT

View File

@ -4,7 +4,7 @@
# RUN: ld.lld %t.o -o %t
# RUN: llvm-readobj --symbols %t | FileCheck %s
# CHECK: Name: __ehdr_start (1)
# CHECK-NEXT: Value: 0x200000
# CHECK-NEXT: Value: [[ADDR:.*]]
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Binding: Local (0x0)
# CHECK-NEXT: Type: None (0x0)
@ -14,7 +14,7 @@
# CHECK-NEXT: Section: .text (0x1)
# CHECK: Name: __executable_start
# CHECK-NEXT: Value: 0x200000
# CHECK-NEXT: Value: [[ADDR]]
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Binding: Local
# CHECK-NEXT: Type: None

View File

@ -1,13 +1,18 @@
# REQUIRES: x86
## On RELA targets, r_addend may be updated for --emit-relocs.
## With ICF, merged sections do not have output sections assigned.
## Test we don't crash.
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
# RUN: ld.lld --gc-sections --emit-relocs --icf=all %t.o -o %t
# RUN: llvm-readobj -r %t | FileCheck %s
# CHECK: Relocations [
# CHECK-NEXT: Section (3) .rela.text {
# CHECK-NEXT: 0x201000 R_X86_64_64 .text 0x11
# CHECK-NEXT: 0x201008 R_X86_64_64 .text 0x11
# CHECK-NEXT: 0x201011 R_X86_64_64 .rodata 0x0
# CHECK-NEXT: R_X86_64_64 .text 0x11
# CHECK-NEXT: R_X86_64_64 .text 0x11
# CHECK-NEXT: R_X86_64_64 .rodata 0x0
# CHECK-NEXT: }
# CHECK-NEXT: ]

View File

@ -1,9 +1,13 @@
# REQUIRES: x86
## By default local symbols are discarded from SHF_MERGE sections.
## With --emit-relocs we should keep them.
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
# RUN: ld.lld --emit-relocs %t.o -o %t.exe
# RUN: llvm-readelf --relocations %t.exe | FileCheck %s
# RUN: llvm-readobj --relocations %t.exe | FileCheck %s
# CHECK: 0000000000201004 000000010000000b R_X86_64_32S 0000000000200120 .Lfoo + 8
# CHECK: R_X86_64_32S .Lfoo 0x8
.globl _start
_start:

View File

@ -1,31 +0,0 @@
// REQUIRES: x86
// RUN: llvm-mc -filetype=obj -relax-relocations -triple x86_64-pc-linux-gnu \
// RUN: %s -o %t.o
// RUN: llvm-readobj -r %t.o | FileCheck --check-prefix=RELS %s
// RUN: ld.lld --hash-style=sysv %t.o -o %t.so -shared
// RUN: llvm-readobj -S -r %t.so | FileCheck %s
movq foo@GOTPCREL(%rip), %rax
movq bar@GOTPCREL(%rip), %rax
// RELS: Relocations [
// RELS-NEXT: Section ({{.*}}) .rela.text {
// RELS-NEXT: R_X86_64_REX_GOTPCRELX foo 0xFFFFFFFFFFFFFFFC
// RELS-NEXT: R_X86_64_REX_GOTPCRELX bar 0xFFFFFFFFFFFFFFFC
// RELS-NEXT: }
// RELS-NEXT: ]
// CHECK: Name: .got
// CHECK-NEXT: Type: SHT_PROGBITS
// CHECK-NEXT: Flags [
// CHECK-NEXT: SHF_ALLOC
// CHECK-NEXT: SHF_WRITE
// CHECK-NEXT: ]
// CHECK-NEXT: Address: 0x2090
// CHECK: Relocations [
// CHECK-NEXT: Section ({{.*}}) .rela.dyn {
// CHECK-NEXT: 0x2098 R_X86_64_GLOB_DAT bar 0x0
// CHECK-NEXT: 0x2090 R_X86_64_GLOB_DAT foo 0x0
// CHECK-NEXT: }
// CHECK-NEXT: ]

View File

@ -1,14 +1,14 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
# RUN: ld.lld --hash-style=sysv %t.o -o %t --icf=all -shared
# RUN: llvm-readelf --dyn-symbols --sections %t | FileCheck %s
# RUN: ld.lld %t.o -o %t --icf=all -shared
# RUN: llvm-readelf --sections --dyn-symbols %t | FileCheck %s
# We used to mark bar as absolute.
# CHECK: .text PROGBITS 0000000000001000
# CHECK: 0000000000001001 0 NOTYPE GLOBAL DEFAULT 4 bar
# CHECK: 0000000000001001 0 NOTYPE GLOBAL DEFAULT 4 foo
# CHECK: [ 5] .text
# CHECK: [[ADDR:[0-9a-f]+]] 0 NOTYPE GLOBAL DEFAULT 5 bar
# CHECK: [[ADDR]] 0 NOTYPE GLOBAL DEFAULT 5 foo
# The nop makes the test more interesting by making the offset of
# text.f non zero.

View File

@ -7,8 +7,8 @@
# CHECK: selected section {{.*}}:(.text.f1)
# CHECK: removing identical section {{.*}}:(.text.f2)
# ALIGN: 0000000000201000 .text 00000000 _start
# ALIGN: 0000000000201100 .text 00000000 f1
# ALIGN: .text 00000000 _start
# ALIGN: .text 00000000 f1
.globl _start, f1, f2
_start:

View File

@ -16,17 +16,17 @@
# CHECK: [ [[SD:.*]]] .data
# CHECK: [ [[SC:.*]]] .comment
# CHECK: Num: Value Size Type Bind Vis Ndx Name
# CHECK-NEXT: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
# CHECK-NEXT: 1: 0000000000000000 0 FILE LOCAL DEFAULT ABS file1
# CHECK-NEXT: 2: 0000000000201000 0 NOTYPE LOCAL DEFAULT 1 foo1
# CHECK-NEXT: 3: 0000000000201000 0 SECTION LOCAL DEFAULT [[ST]]
# CHECK-NEXT: 4: 0000000000201000 0 NOTYPE LOCAL HIDDEN 1 bar1
# CHECK-NEXT: 5: 0000000000000000 0 FILE LOCAL DEFAULT ABS file2
# CHECK-NEXT: 6: 0000000000201000 0 NOTYPE LOCAL DEFAULT 2 foo2
# CHECK-NEXT: 7: 0000000000201000 0 SECTION LOCAL DEFAULT [[SD]]
# CHECK-NEXT: 8: 0000000000201000 0 NOTYPE LOCAL HIDDEN 2 bar2
# CHECK-NEXT: 9: 0000000000000000 0 SECTION LOCAL DEFAULT [[SC]]
# CHECK: Size Type Bind Vis Ndx Name
# CHECK-NEXT: 0 NOTYPE LOCAL DEFAULT UND
# CHECK-NEXT: 0 FILE LOCAL DEFAULT ABS file1
# CHECK-NEXT: 0 NOTYPE LOCAL DEFAULT 1 foo1
# CHECK-NEXT: 0 SECTION LOCAL DEFAULT [[ST]]
# CHECK-NEXT: 0 NOTYPE LOCAL HIDDEN 1 bar1
# CHECK-NEXT: 0 FILE LOCAL DEFAULT ABS file2
# CHECK-NEXT: 0 NOTYPE LOCAL DEFAULT 2 foo2
# CHECK-NEXT: 0 SECTION LOCAL DEFAULT [[SD]]
# CHECK-NEXT: 0 NOTYPE LOCAL HIDDEN 2 bar2
# CHECK-NEXT: 0 SECTION LOCAL DEFAULT [[SC]]
foo1:

View File

@ -10,8 +10,8 @@
# CHECK: Relocations [
# CHECK-NEXT: Section ({{.*}}) .rela.dyn {
# CHECK-NEXT: 0x2020B0 R_X86_64_GLOB_DAT bar 0x0
# CHECK-NEXT: 0x2020B8 R_X86_64_GLOB_DAT zed 0x0
# CHECK-NEXT: R_X86_64_GLOB_DAT bar 0x0
# CHECK-NEXT: R_X86_64_GLOB_DAT zed 0x0
# CHECK-NEXT: }
# CHECK-NEXT: ]

View File

@ -1,9 +1,9 @@
// REQUIRES: x86
// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
// RUN: ld.lld %t -o %t2
// RUN: llvm-objdump -d %t2 | FileCheck %s
// RUN: ld.lld -pie %t -o %t3
// RUN: llvm-objdump -d %t3 | FileCheck --check-prefix=PIE %s
// RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
// RUN: ld.lld %t.o -o %t
// RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s
// RUN: ld.lld -pie %t.o -o %t2
// RUN: llvm-objdump -d --no-show-raw-insn %t2 | FileCheck --check-prefix=PIE %s
.globl _start
_start:
@ -22,21 +22,21 @@ _start:
// CHECK: Disassembly of section .text:
// CHECK-EMPTY:
// CHECK-NEXT: _start:
// CHECK-NEXT: 201000: e8 fb ff ff ff callq -5
// CHECK-NEXT: 201005: e8 f6 ff ff ff callq -10
// CHECK-NEXT: 20100a: e8 f1 ff ff ff callq -15
// CHECK-NEXT: 20100f: e8 ec ff ff ff callq -20
// CHECK-NEXT: 201014: e8 e7 ff ff ff callq -25
// CHECK-NEXT: 201019: e8 e2 ff ff ff callq -30
// CHECK-NEXT: 201000: callq -5
// CHECK-NEXT: callq -10
// CHECK-NEXT: callq -15
// CHECK-NEXT: callq -20
// CHECK-NEXT: callq -25
// CHECK-NEXT: callq -30
// In position-independent binaries, they resolve to .text too.
// PIE: Disassembly of section .text:
// PIE-EMPTY:
// PIE-NEXT: _start:
// PIE-NEXT: 1000: e8 fb ff ff ff callq -5
// PIE-NEXT: 1005: e8 f6 ff ff ff callq -10
// PIE-NEXT: 100a: e8 f1 ff ff ff callq -15
// PIE-NEXT: 100f: e8 ec ff ff ff callq -20
// PIE-NEXT: 1014: e8 e7 ff ff ff callq -25
// PIE-NEXT: 1019: e8 e2 ff ff ff callq -30
// PIE-NEXT: 1000: callq -5
// PIE-NEXT: callq -10
// PIE-NEXT: callq -15
// PIE-NEXT: callq -20
// PIE-NEXT: callq -25
// PIE-NEXT: callq -30

View File

@ -7,8 +7,7 @@
// RUN: llvm-readobj --dyn-syms %t | FileCheck %s
// RUN: echo "VER_1 { global: bar; };" > %t.script
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux \
// RUN: %p/Inputs/progname-ver.s -o %t-ver.o
// RUN: echo '.globl bar; bar: .quad __progname@GOT' | llvm-mc -filetype=obj -triple=x86_64 - -o %t-ver.o
// RUN: ld.lld -shared -o %t.so -version-script %t.script %t-ver.o
// RUN: ld.lld -o %t %t.o %t.so
// RUN: llvm-readobj --dyn-syms %t | FileCheck %s
@ -18,7 +17,7 @@
// RUN: llvm-readobj --dyn-syms %t | FileCheck %s
// CHECK: Name: __progname
// CHECK-NEXT: Value: 0x201000
// CHECK-NEXT: Value:
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Global (0x1)
// CHECK-NEXT: Type: None (0x0)

View File

@ -10,10 +10,10 @@
// CHECK-NEXT: Section ({{.*}}) .rela.dyn {
// CHECK-NEXT: 0x[[FOO_ADDR:.*]] R_X86_64_RELATIVE - 0x[[FOO_ADDR]]
// CHECK-NEXT: 0x[[BAR_ADDR:.*]] R_X86_64_RELATIVE - 0x[[BAR_ADDR]]
// CHECK-NEXT: 0x2010 R_X86_64_RELATIVE - 0x2009
// CHECK-NEXT: 0x{{[0-9A-F]+}} R_X86_64_RELATIVE - 0x{{[0-9A-F]+}}
// CHECK-NEXT: 0x{{.*}} R_X86_64_RELATIVE - 0x[[ZED_ADDR:.*]]
// CHECK-NEXT: 0x{{.*}} R_X86_64_RELATIVE - 0x[[FOO_ADDR]]
// CHECK-NEXT: 0x2028 R_X86_64_64 external 0x0
// CHECK-NEXT: 0x{{[0-9A-F]+}} R_X86_64_64 external 0x0
// CHECK-NEXT: }
// CHECK-NEXT: ]

View File

@ -1,21 +0,0 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
# RUN: echo "bar" > %t.order
# RUN: ld.lld --symbol-ordering-file %t.order -shared %t.o -o %t.so
# RUN: llvm-nm %t.so | FileCheck %s
# CHECK: 0000000000002000 d _DYNAMIC
# CHECK-NEXT: 0000000000001000 T bar
# CHECK-NEXT: 0000000000001004 T foo
.section .text.foo,"ax",@progbits
.align 4
.global foo
foo:
retq
.section .text.bar,"ax",@progbits
.align 4
.global bar
bar:
retq

View File

@ -22,7 +22,7 @@
# DSO-NEXT: }
# DSO-NEXT: Symbol {
# DSO-NEXT: Name: _Z3bari@@LIBSAMPLE_2.0
# DSO-NEXT: Value: 0x1001
# DSO-NEXT: Value:
# DSO-NEXT: Size: 0
# DSO-NEXT: Binding: Global
# DSO-NEXT: Type: Function
@ -31,7 +31,7 @@
# DSO-NEXT: }
# DSO-NEXT: Symbol {
# DSO-NEXT: Name: _Z3fooi@@LIBSAMPLE_1.0
# DSO-NEXT: Value: 0x1000
# DSO-NEXT: Value:
# DSO-NEXT: Size: 0
# DSO-NEXT: Binding: Global
# DSO-NEXT: Type: Function
@ -40,7 +40,7 @@
# DSO-NEXT: }
# DSO-NEXT: Symbol {
# DSO-NEXT: Name: _Z3zedi@@LIBSAMPLE_1.0
# DSO-NEXT: Value: 0x1002
# DSO-NEXT: Value:
# DSO-NEXT: Size: 0
# DSO-NEXT: Binding: Global (0x1)
# DSO-NEXT: Type: Function (0x2)
@ -49,7 +49,7 @@
# DSO-NEXT: }
# DSO-NEXT: Symbol {
# DSO-NEXT: Name: _ZN3abcC1Ev@@LIBSAMPLE_1.0
# DSO-NEXT: Value: 0x1003
# DSO-NEXT: Value:
# DSO-NEXT: Size: 0
# DSO-NEXT: Binding: Global (0x1)
# DSO-NEXT: Type: Function (0x2)
@ -58,7 +58,7 @@
# DSO-NEXT: }
# DSO-NEXT: Symbol {
# DSO-NEXT: Name: _ZN3abcC2Ev@@LIBSAMPLE_1.0
# DSO-NEXT: Value: 0x1004
# DSO-NEXT: Value:
# DSO-NEXT: Size: 0
# DSO-NEXT: Binding: Global (0x1)
# DSO-NEXT: Type: Function (0x2)
@ -68,8 +68,8 @@
# DSO-NEXT: ]
# DSO-NEXT: Version symbols {
# DSO-NEXT: Section Name: .gnu.version
# DSO-NEXT: Address: 0x258
# DSO-NEXT: Offset: 0x258
# DSO-NEXT: Address:
# DSO-NEXT: Offset:
# DSO-NEXT: Link: 1
# DSO-NEXT: Symbols [
# DSO-NEXT: Symbol {

View File

@ -9,29 +9,14 @@
// 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
// RUN: llvm-readobj --dyn-symbols -r %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@FBSD_1.1 (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@FBSD_1.0 (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@FBSD_1.1 (3)
// CHECK-NEXT: Addend: 0x0
// CHECK-NEXT: }
// CHECK-NEXT: R_X86_64_64 basename@FBSD_1.1 0x0
// CHECK-NEXT: R_X86_64_64 basename@FBSD_1.0 0x0
// CHECK-NEXT: R_X86_64_64 basename@FBSD_1.1 0x0
// CHECK-NEXT: }

View File

@ -1,42 +0,0 @@
// REQUIRES: x86
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
// RUN: llvm-readobj --dyn-symbols %p/Inputs/version-undef-sym.so | FileCheck %s
// Inputs/version-undef-sym.so consists of the assembly file
//
// .global bar
// bar:
// .weak abc1
// .weak abc2
// .weak abc3
// .weak abc4
// .weak abc5
//
// linked into a shared library with the version script
//
// VER_1 {
// global:
// bar;
// };
//
// Assuming we can reproduce the desired property (a few undefined symbols
// before bar) we should create it with lld itself once it supports that.
// Show that the input .so has undefined symbols before bar. That is what would
// get our version parsing out of sync.
// CHECK: Section: Undefined
// CHECK: Section: Undefined
// CHECK: Section: Undefined
// CHECK: Section: Undefined
// CHECK: Section: Undefined
// CHECK: Name: bar
// But now we can successfully find bar.
// RUN: ld.lld %t.o %p/Inputs/version-undef-sym.so -o /dev/null
.global _start
_start:
call bar@plt

View File

@ -1,31 +0,0 @@
# REQUIRES: x86
# Test that we don't fail with foo being undefined.
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
# RUN: ld.lld --export-dynamic %t.o -o %t
# RUN: llvm-readobj --dyn-syms %t | FileCheck %s
# CHECK: DynamicSymbols [
# CHECK-NEXT: Symbol {
# CHECK-NEXT: Name:
# CHECK-NEXT: Value: 0x0
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Binding: Local (0x0)
# CHECK-NEXT: Type: None (0x0)
# CHECK-NEXT: Other: 0
# CHECK-NEXT: Section: Undefined (0x0)
# CHECK-NEXT: }
# CHECK-NEXT: Symbol {
# CHECK-NEXT: Name: foo
# CHECK-NEXT: Value: 0x0
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Binding: Weak (0x2)
# CHECK-NEXT: Type: None (0x0)
# CHECK-NEXT: Other: 0
# CHECK-NEXT: Section: Undefined (0x0)
# CHECK-NEXT: }
# CHECK-NEXT: ]
.weak foo
.quad foo

View File

@ -1,26 +0,0 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
# RUN: ld.lld %t.o -o %t --export-dynamic
# RUN: llvm-readobj -S --section-data %t | FileCheck %s
# CHECK: Name: .text
# CHECK-NEXT: Type: SHT_PROGBITS
# CHECK-NEXT: Flags [
# CHECK-NEXT: SHF_ALLOC
# CHECK-NEXT: SHF_EXECINSTR
# CHECK-NEXT: ]
# CHECK-NEXT: Address: 0x201000
# CHECK-NEXT: Offset:
# CHECK-NEXT: Size:
# CHECK-NEXT: Link:
# CHECK-NEXT: Info:
# CHECK-NEXT: AddressAlignment:
# CHECK-NEXT: EntrySize:
# CHECK-NEXT: SectionData (
# CHECK-NEXT: 0000: 00F0DFFF |
# CHECK-NEXT: )
.global _start
_start:
.weak foobar
.long foobar - .

View File

@ -1,7 +1,10 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/dummy-shared.s -o %t1.o
# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
# RUN: ld.lld %t.o -o %t --export-dynamic
# RUN: llvm-readobj --dyn-syms %t | FileCheck %s
# RUN: llvm-mc -filetype=obj -triple=x86_64 %p/Inputs/dummy-shared.s -o %t1.o
# RUN: ld.lld %t1.o -shared -o %t1.so
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
# RUN: ld.lld %t.o -o %t %t1.so -pie
# RUN: llvm-readobj --dyn-syms %t | FileCheck %s
@ -28,8 +31,5 @@
.weak foo
.globl _start
_start:
.data
.dc.a foo

View File

@ -6,7 +6,7 @@
# RUN: llvm-readelf --symbols -r %t | FileCheck %s
# CHECK: R_X86_64_JUMP_SLOT {{.*}} foo + 0
# CHECK: 0000000000201010 0 FUNC GLOBAL DEFAULT UND foo
# CHECK: 0 FUNC GLOBAL DEFAULT UND foo
.section .bar,"awx"
.global _start

View File

@ -1,10 +1,10 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -relax-relocations -triple=x86_64-unknown-linux %s -o %t.o
# RUN: llvm-mc -filetype=obj -relax-relocations -triple=x86_64-pc-linux %S/Inputs/gotpc-relax-und-dso.s -o %tdso.o
# RUN: ld.lld -shared %tdso.o -o %t.so
# RUN: ld.lld --hash-style=sysv -shared %t.o %t.so -o %tout
# RUN: llvm-readobj -r -S %tout | FileCheck --check-prefix=RELOC %s
# RUN: llvm-objdump -d %tout | FileCheck --check-prefix=DISASM %s
# RUN: ld.lld -shared %tdso.o -soname=t.so -o %t.so
# RUN: ld.lld --hash-style=sysv -shared %t.o %t.so -o %t
# RUN: llvm-readobj -r -S %t | FileCheck --check-prefix=RELOC %s
# RUN: llvm-objdump -d %t | FileCheck --check-prefix=DISASM %s
# RELOC: Relocations [
# RELOC-NEXT: Section ({{.*}}) .rela.dyn {

View File

@ -1,13 +1,13 @@
// REQUIRES: x86
// RUN: llvm-mc -filetype=obj -relax-relocations -triple=x86_64-pc-linux %s \
// RUN: -o %t.o
// RUN: ld.lld --hash-style=sysv %t.o -o %t.so -shared
// RUN: llvm-objdump -d %t.so | FileCheck %s
# REQUIRES: x86
// We used to fail trying to relax this into a pc relocation to an absolute
// value.
## Don't relax R_X86_64_GOTPCRELX to an absolute symbol.
## In -no-pie mode, it can be relaxed, but it may not worth it.
// CHECK: movq 4185(%rip), %rax
# RUN: llvm-mc -filetype=obj -relax-relocations -triple=x86_64 %s -o %t.o
# RUN: ld.lld %t.o -o %t.so -shared
# RUN: llvm-objdump -d %t.so | FileCheck %s
# CHECK: movq 4201(%rip), %rax
movq bar@GOTPCREL(%rip), %rax
.data

View File

@ -1,4 +1,8 @@
// REQUIRES: x86
/// Test we use input r_offset when deciding if R_X86_64_GOTPCRELX
/// relaxation is applicable.
// RUN: llvm-mc -filetype=obj -relax-relocations -triple=x86_64-pc-linux %s \
// RUN: -o %t.o
// RUN: llvm-mc -filetype=obj -relax-relocations -triple=x86_64-pc-linux \
@ -9,5 +13,5 @@
mov foo@gotpcrel(%rip), %rax
nop
// CHECK: 1004: {{.*}} leaq -11(%rip), %rax
// CHECK-NEXT: 100b: {{.*}} nop
// CHECK: leaq -11(%rip), %rax
// CHECK-NEXT: nop

View File

@ -4,44 +4,44 @@
// RUN: ld.lld -shared %t2.o -o %t2.so
// RUN: ld.lld -shared %t1.o %t2.so -o %t.exe -z retpolineplt -z now
// RUN: llvm-objdump -d -s %t.exe | FileCheck %s
// RUN: llvm-objdump -d -s --no-show-raw-insn %t.exe | FileCheck %s
// CHECK: Disassembly of section .plt:
// CHECK-EMPTY:
// CHECK-NEXT: .plt:
// CHECK-NEXT: 1010: e8 0b 00 00 00 callq 11 <.plt+0x10>
// CHECK-NEXT: 1015: f3 90 pause
// CHECK-NEXT: 1017: 0f ae e8 lfence
// CHECK-NEXT: 101a: eb f9 jmp -7 <.plt+0x5>
// CHECK-NEXT: 101c: cc int3
// CHECK-NEXT: 101d: cc int3
// CHECK-NEXT: 101e: cc int3
// CHECK-NEXT: 101f: cc int3
// CHECK-NEXT: 1020: 4c 89 1c 24 movq %r11, (%rsp)
// CHECK-NEXT: 1024: c3 retq
// CHECK-NEXT: 1025: cc int3
// CHECK-NEXT: 1026: cc int3
// CHECK-NEXT: 1027: cc int3
// CHECK-NEXT: 1028: cc int3
// CHECK-NEXT: 1029: cc int3
// CHECK-NEXT: 102a: cc int3
// CHECK-NEXT: 102b: cc int3
// CHECK-NEXT: 102c: cc int3
// CHECK-NEXT: 102d: cc int3
// CHECK-NEXT: 102e: cc int3
// CHECK-NEXT: 102f: cc int3
// CHECK-NEXT: 1030: 4c 8b 1d c1 10 00 00 movq 4289(%rip), %r11
// CHECK-NEXT: 1037: e9 d4 ff ff ff jmp -44 <.plt>
// CHECK-NEXT: 103c: cc int3
// CHECK-NEXT: 103d: cc int3
// CHECK-NEXT: 103e: cc int3
// CHECK-NEXT: 103f: cc int3
// CHECK-NEXT: 1040: 4c 8b 1d b9 10 00 00 movq 4281(%rip), %r11
// CHECK-NEXT: 1047: e9 c4 ff ff ff jmp -60 <.plt>
// CHECK-NEXT: 104c: cc int3
// CHECK-NEXT: 104d: cc int3
// CHECK-NEXT: 104e: cc int3
// CHECK-NEXT: 104f: cc int3
// 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: 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: 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: 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: Contents of section .got.plt:
// CHECK-NEXT: 20e0 00200000 00000000 00000000 00000000

View File

@ -4,57 +4,57 @@
// RUN: ld.lld -shared %t2.o -o %t2.so
// RUN: ld.lld -shared %t1.o %t2.so -o %t.exe -z retpolineplt
// RUN: llvm-objdump -d -s %t.exe | FileCheck %s
// RUN: llvm-objdump -d -s --no-show-raw-insn %t.exe | FileCheck %s
// CHECK: Disassembly of section .plt:
// CHECK-EMPTY:
// CHECK-NEXT: .plt:
// CHECK-NEXT: 1010: ff 35 f2 1f 00 00 pushq 8178(%rip)
// CHECK-NEXT: 1016: 4c 8b 1d f3 1f 00 00 movq 8179(%rip), %r11
// CHECK-NEXT: 101d: e8 0e 00 00 00 callq 14 <.plt+0x20>
// CHECK-NEXT: 1022: f3 90 pause
// CHECK-NEXT: 1024: 0f ae e8 lfence
// CHECK-NEXT: 1027: eb f9 jmp -7 <.plt+0x12>
// CHECK-NEXT: 1029: cc int3
// CHECK-NEXT: 102a: cc int3
// CHECK-NEXT: 102b: cc int3
// CHECK-NEXT: 102c: cc int3
// CHECK-NEXT: 102d: cc int3
// CHECK-NEXT: 102e: cc int3
// CHECK-NEXT: 102f: cc int3
// CHECK-NEXT: 1030: 4c 89 1c 24 movq %r11, (%rsp)
// CHECK-NEXT: 1034: c3 retq
// CHECK-NEXT: 1035: cc int3
// CHECK-NEXT: 1036: cc int3
// CHECK-NEXT: 1037: cc int3
// CHECK-NEXT: 1038: cc int3
// CHECK-NEXT: 1039: cc int3
// CHECK-NEXT: 103a: cc int3
// CHECK-NEXT: 103b: cc int3
// CHECK-NEXT: 103c: cc int3
// CHECK-NEXT: 103d: cc int3
// CHECK-NEXT: 103e: cc int3
// CHECK-NEXT: 103f: cc int3
// CHECK-NEXT: 1040: 4c 8b 1d d1 1f 00 00 movq 8145(%rip), %r11
// CHECK-NEXT: 1047: e8 e4 ff ff ff callq -28 <.plt+0x20>
// CHECK-NEXT: 104c: e9 d1 ff ff ff jmp -47 <.plt+0x12>
// CHECK-NEXT: 1051: 68 00 00 00 00 pushq $0
// CHECK-NEXT: 1056: e9 b5 ff ff ff jmp -75 <.plt>
// CHECK-NEXT: 105b: cc int3
// CHECK-NEXT: 105c: cc int3
// CHECK-NEXT: 105d: cc int3
// CHECK-NEXT: 105e: cc int3
// CHECK-NEXT: 105f: cc int3
// CHECK-NEXT: 1060: 4c 8b 1d b9 1f 00 00 movq 8121(%rip), %r11
// CHECK-NEXT: 1067: e8 c4 ff ff ff callq -60 <.plt+0x20>
// CHECK-NEXT: 106c: e9 b1 ff ff ff jmp -79 <.plt+0x12>
// CHECK-NEXT: 1071: 68 01 00 00 00 pushq $1
// CHECK-NEXT: 1076: e9 95 ff ff ff jmp -107 <.plt>
// CHECK-NEXT: 107b: cc int3
// CHECK-NEXT: 107c: cc int3
// CHECK-NEXT: 107d: cc int3
// CHECK-NEXT: 107e: cc int3
// CHECK-NEXT: 107f: cc int3
// CHECK-NEXT: 1010: pushq 8178(%rip)
// CHECK-NEXT: movq 8179(%rip), %r11
// CHECK-NEXT: callq 14 <.plt+0x20>
// CHECK-NEXT: pause
// CHECK-NEXT: lfence
// CHECK-NEXT: jmp -7 <.plt+0x12>
// 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 %r11, (%rsp)
// 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: 1040: movq 8145(%rip), %r11
// CHECK-NEXT: callq -28 <.plt+0x20>
// CHECK-NEXT: jmp -47 <.plt+0x12>
// CHECK-NEXT: pushq $0
// CHECK-NEXT: jmp -75 <.plt>
// CHECK-NEXT: int3
// CHECK-NEXT: int3
// CHECK-NEXT: int3
// CHECK-NEXT: int3
// CHECK-NEXT: int3
// CHECK-NEXT: 1060: movq 8121(%rip), %r11
// CHECK-NEXT: callq -60 <.plt+0x20>
// CHECK-NEXT: jmp -79 <.plt+0x12>
// CHECK-NEXT: pushq $1
// CHECK-NEXT: jmp -107 <.plt>
// CHECK-NEXT: int3
// CHECK-NEXT: int3
// CHECK-NEXT: int3
// CHECK-NEXT: int3
// CHECK-NEXT: int3
// CHECK: Contents of section .got.plt:
// CHECK-NEXT: 3000 00200000 00000000 00000000 00000000

View File

@ -69,20 +69,20 @@ c:
// DIS-EMPTY:
// DIS-NEXT: .text:
// DIS-NEXT: 1000: {{.+}} leaq 4313(%rip), %rdi
// DIS-NEXT: 1007: {{.+}} callq
// DIS-NEXT: {{.+}} callq
// DIS-NEXT: 100c: {{.+}} leaq 4301(%rip), %rdi
// DIS-NEXT: 1013: {{.+}} callq
// DIS-NEXT: 1018: {{.+}} leaq (%rax), %rcx
// DIS-NEXT: 101f: {{.+}} leaq 4(%rax), %rcx
// DIS-NEXT: 1026: 04 00
// DIS-NEXT: 1028: 00 00
// DIS-NEXT: 102a: 00 00
// DIS-NEXT: 102c: 00 00
// DIS-NEXT: {{.+}} callq
// DIS-NEXT: {{.+}} leaq (%rax), %rcx
// DIS-NEXT: {{.+}} leaq 4(%rax), %rcx
// DIS-NEXT: 04 00
// DIS-NEXT: 00 00
// DIS-NEXT: 00 00
// DIS-NEXT: 00 00
// DIS-NEXT: 102e: {{.+}} leaq 4283(%rip), %rdi
// DIS-NEXT: 1035: {{.+}} callq
// DIS-NEXT: 103b: {{.+}} leaq (%rax), %rcx
// DIS-NEXT: {{.+}} callq
// DIS-NEXT: {{.+}} leaq (%rax), %rcx
// DIS-NEXT: 1042: {{.+}} movq 4279(%rip), %rax
// DIS-NEXT: 1049: {{.+}} movq %fs:(%rax), %rax
// DIS-NEXT: 104d: {{.+}} movabsq $0, %rax
// DIS-NEXT: 1057: {{.+}} movabsq $4, %rax
// DIS-NEXT: 1061: {{.+}} movabsq $0, %rax
// DIS-NEXT: {{.+}} movq %fs:(%rax), %rax
// DIS-NEXT: {{.+}} movabsq $0, %rax
// DIS-NEXT: {{.+}} movabsq $4, %rax
// DIS-NEXT: {{.+}} movabsq $0, %rax

View File

@ -1,13 +1,15 @@
# REQUIRES: x86
## Allow local-dynamic R_X86_64_DTPOFF32 and R_X86_64_DTPOFF64 to preemptable symbols.
# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
# RUN: ld.lld %t.o -shared -o %t.so
# RUN: llvm-objdump -d --no-show-raw-insn %t.so | FileCheck %s
# CHECK: 100c: leaq (%rax), %rax
# CHECK-NEXT: 1013: movabsq 0, %rax
# CHECK: leaq (%rax), %rax
# CHECK-NEXT: movabsq 0, %rax
# We used to error on R_X86_64_DTPOFF{32,64} to preemptable symbols.
# i is STB_GLOBAL and preemptable.
## i is STB_GLOBAL and preemptable.
leaq i@TLSLD(%rip), %rdi
callq __tls_get_addr@PLT
leaq i@DTPOFF(%rax), %rax # R_X86_64_DTPOFF32

View File

@ -5,10 +5,10 @@
// 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/tls-opt-gdie.s -o %tso.o
// RUN: ld.lld -shared %tso.o -o %t.so
// RUN: ld.lld -shared %tso.o -soname=t.so -o %t.so
// RUN: ld.lld %t.o %t.so -o %t1
// RUN: llvm-readobj -r %t1 | FileCheck --check-prefix=RELOC %s
// RUN: llvm-objdump -d %t1 | FileCheck --check-prefix=DISASM %s
// RUN: llvm-objdump -d --no-show-raw-insn %t1 | FileCheck --check-prefix=DISASM %s
// RELOC: Relocations [
// RELOC-NEXT: Section {{.*}} .rela.dyn {
@ -20,21 +20,21 @@
// DISASM: _start:
// Table 11.5: GD -> IE Code Transition (LP64)
// DISASM-NEXT: 201000: 64 48 8b 04 25 00 00 00 00 movq %fs:0, %rax
// DISASM-NEXT: 201009: 48 03 05 b0 10 00 00 addq 4272(%rip), %rax
// DISASM-NEXT: 201010: 64 48 8b 04 25 00 00 00 00 movq %fs:0, %rax
// DISASM-NEXT: 201019: 48 03 05 a8 10 00 00 addq 4264(%rip), %rax
// DISASM-NEXT: movq %fs:0, %rax
// DISASM-NEXT: 201009: addq 4272(%rip), %rax
// DISASM-NEXT: movq %fs:0, %rax
// DISASM-NEXT: 201019: addq 4264(%rip), %rax
// Table 11.7: GD -> LE Code Transition (LP64)
// DISASM-NEXT: 201020: 64 48 8b 04 25 00 00 00 00 movq %fs:0, %rax
// DISASM-NEXT: 201029: 48 8d 80 f8 ff ff ff leaq -8(%rax), %rax
// DISASM-NEXT: 201030: 64 48 8b 04 25 00 00 00 00 movq %fs:0, %rax
// DISASM-NEXT: 201039: 48 8d 80 fc ff ff ff leaq -4(%rax), %rax
// DISASM-NEXT: movq %fs:0, %rax
// DISASM-NEXT: leaq -8(%rax), %rax
// DISASM-NEXT: movq %fs:0, %rax
// DISASM-NEXT: leaq -4(%rax), %rax
// Table 11.9: LD -> LE Code Transition (LP64)
// DISASM-NEXT: 201040: 66 66 66 66 64 48 8b 04 25 00 00 00 00 movq %fs:0, %rax
// DISASM-NEXT: 20104d: 66 66 66 66 64 48 8b 04 25 00 00 00 00 movq %fs:0, %rax
// DISASM-NEXT: movq %fs:0, %rax
// DISASM-NEXT: movq %fs:0, %rax
.type tls0,@object
.section .tbss,"awT",@nobits