Files
clang-p2996/lld/test/ELF/aarch64-gnu-ifunc2.s
Fangrui Song 66bcbdbc9c [AArch64InstPrinter] Change printADRPLabel to print the target address in hexadecimal form
Similar to D77853. Change ADRP to print the target address in hex, instead of the raw immediate.
The behavior is similar to GNU objdump but we also include `0x`.

Note: GNU objdump is not consistent whether or not to emit `0x` for different architectures. We try emitting 0x consistently for all targets.

```
GNU objdump:       adrp x16, 10000000
Old llvm-objdump:  adrp x16, #0
New llvm-objdump:  adrp x16, 0x10000000
```

`adrp Xd, 0x...` assembles to a relocation referencing `*ABS*+0x10000` which is not intended. We need to use a linker or use yaml2obj.
The main test is `test/tools/llvm-objdump/ELF/AArch64/pcrel-address.yaml`

Differential Revision: https://reviews.llvm.org/D93241
2020-12-16 09:20:55 -08:00

49 lines
1.3 KiB
ArmAsm

# REQUIRES: aarch64
# RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux-gnu %s -o %t.o
# RUN: ld.lld %t.o -o %t
# RUN: llvm-objdump -d --no-show-raw-insn --print-imm-hex %t | FileCheck %s
# RUN: llvm-readelf -S %t | FileCheck %s --check-prefix=SEC
# RUN: llvm-readobj -r %t | FileCheck %s --check-prefix=RELOC
# CHECK: Disassembly of section .text:
# CHECK-EMPTY:
# CHECK-NEXT: <myfunc>:
# CHECK-NEXT: 210170:
# CHECK: <main>:
# .got.plt - page(0x210174) = 0x220190 - 0x210000 = 0x10190
# CHECK-NEXT: 210174: adrp x8, 0x220000
# CHECK-NEXT: 210178: ldr x8, [x8, #0x190]
# CHECK-NEXT: 21017c: ret
# CHECK: Disassembly of section .iplt:
# CHECK-EMPTY:
# CHECK-NEXT: <.iplt>:
# .got.plt - page(0x210180) = 0x220190 - 0x210000 = 0x10190
# CHECK-NEXT: 210180: adrp x16, 0x220000
# CHECK-NEXT: 210184: ldr x17, [x16, #0x190]
# CHECK-NEXT: 210188: add x16, x16, #0x190
# CHECK-NEXT: 21018c: br x17
# SEC: .got.plt PROGBITS 0000000000220190 000190 000008 00 WA 0 0 8
# RELOC: Relocations [
# RELOC-NEXT: Section {{.*}} .rela.dyn {
# RELOC-NEXT: 0x220190 R_AARCH64_IRELATIVE - 0x210170
# RELOC-NEXT: }
# RELOC-NEXT: ]
.text
.globl myfunc
.type myfunc,@gnu_indirect_function
myfunc:
ret
.text
.globl main
.type main,@function
main:
adrp x8, :got:myfunc
ldr x8, [x8, :got_lo12:myfunc]
ret