[X86][MC,LLD][NFC] Rename R_X86_64_REX2_GOTPCRELX (#116737)
[llvm-project.git] / llvm / test / MC / ELF / relocation-alias.s
blob7701f1107e5a6ec7fb63ddc66ac847254732fb63
1 # RUN: llvm-mc -filetype=obj -triple x86_64 %s -o %t
2 # RUN: llvm-objdump --no-print-imm-hex -dr %t | FileCheck %s
3 # RUN: llvm-readelf -s %t | FileCheck %s --check-prefix=SYM
5 # RUN: not llvm-mc -filetype=obj -triple x86_64 --defsym ERR=1 %s 2>&1 | FileCheck %s --check-prefix=ERR
7 ## If a fixup symbol is equated to an undefined symbol, convert the fixup
8 ## to be against the target symbol, even if there is a variant (@PLT).
9 # CHECK: callq {{.*}}
10 # CHECK-NEXT: R_X86_64_PLT32 __GI_memcpy-0x4
11 # CHECK: movabsq $0, %rax
12 # CHECK-NEXT: R_X86_64_64 __GI_memcpy+0x2
13 memcpy = __GI_memcpy
14 call memcpy@PLT
15 movabsq $memcpy+2, %rax
17 # CHECK: movq (%rip), %rax
18 # CHECK-NEXT: R_X86_64_REX_GOTPCRELX abs-0x4
19 # CHECK: movq (%rip), %r16
20 # CHECK-NEXT: R_X86_64_CODE_4_GOTPCRELX abs-0x4
21 movq abs@GOTPCREL(%rip), %rax
22 movq abs@GOTPCREL(%rip), %r16
23 abs = 42
25 # CHECK: movabsq $0, %rbx
26 # CHECK-NEXT: R_X86_64_64 data_alias
27 .globl data_alias
28 .set data_alias, data
29 movabsq $data_alias, %rbx
31 ## A local alias to a defined symbol still references a section symbol.
32 # CHECK: movabsq $0, %rbx
33 # CHECK-NEXT: R_X86_64_64 .data+0x1
34 .set data_alias_l, data
35 movabsq $data_alias_l, %rbx
37 .data
38 .byte 0
39 .globl data
40 data:
42 .ifdef ERR
43 .text
44 ## Note, GNU as emits a relocation for this erroneous fixup.
45 # ERR: {{.*}}.s:[[#@LINE+2]]:1: error: expected relocatable expression
46 memcpy_plus_1 = __GI_memcpy+1
47 call memcpy_plus_1@PLT
48 .endif
50 ## Redirected symbols do not have a symbol table entry.
51 # SYM: NOTYPE LOCAL DEFAULT UND
52 # SYM-NEXT: NOTYPE LOCAL DEFAULT ABS abs
53 # SYM-NEXT: NOTYPE LOCAL DEFAULT 4 data_alias_l
54 # SYM-NEXT: SECTION LOCAL DEFAULT 4 .data
55 # SYM-NEXT: NOTYPE GLOBAL DEFAULT UND __GI_memcpy
56 # SYM-NEXT: NOTYPE GLOBAL DEFAULT 4 data_alias
57 # SYM-NEXT: NOTYPE GLOBAL DEFAULT 4 data
58 # SYM-NOT: {{.}}