1# RUN: llvm-mc -filetype=obj -triple x86_64 %s -o %t 2# RUN: llvm-objdump -dr %t | FileCheck %s 3# RUN: llvm-readelf -s %t | FileCheck %s --check-prefix=SYM 4 5# RUN: not llvm-mc -filetype=obj -triple x86_64 --defsym ERR=1 %s 2>&1 | FileCheck %s --check-prefix=ERR 6 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 13memcpy = __GI_memcpy 14call memcpy@PLT 15movabsq $memcpy+2, %rax 16 17# CHECK: movq (%rip), %rax 18# CHECK-NEXT: R_X86_64_REX_GOTPCRELX abs-0x4 19movq abs@GOTPCREL(%rip), %rax 20abs = 42 21 22# CHECK: movabsq $0, %rbx 23# CHECK-NEXT: R_X86_64_64 data_alias 24.globl data_alias 25.set data_alias, data 26movabsq $data_alias, %rbx 27 28## A local alias to a defined symbol still references a section symbol. 29# CHECK: movabsq $0, %rbx 30# CHECK-NEXT: R_X86_64_64 .data+0x1 31.set data_alias_l, data 32movabsq $data_alias_l, %rbx 33 34.data 35.byte 0 36.globl data 37data: 38 39.ifdef ERR 40.text 41## Note, GNU as emits a relocation for this erroneous fixup. 42# ERR: {{.*}}.s:[[#@LINE+2]]:1: error: expected relocatable expression 43memcpy_plus_1 = __GI_memcpy+1 44call memcpy_plus_1@PLT 45.endif 46 47## Redirected symbols do not have a symbol table entry. 48# SYM: NOTYPE LOCAL DEFAULT UND 49# SYM-NEXT: NOTYPE LOCAL DEFAULT ABS abs 50# SYM-NEXT: NOTYPE LOCAL DEFAULT 4 data_alias_l 51# SYM-NEXT: SECTION LOCAL DEFAULT 4 .data 52# SYM-NEXT: NOTYPE GLOBAL DEFAULT UND __GI_memcpy 53# SYM-NEXT: NOTYPE GLOBAL DEFAULT 4 data 54# SYM-NEXT: NOTYPE GLOBAL DEFAULT 4 data_alias 55# SYM-NOT: {{.}} 56