Files
clang-p2996/lld/test/COFF/arm64-thunks.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

44 lines
1.3 KiB
ArmAsm

// REQUIRES: aarch64
// RUN: llvm-mc -filetype=obj -triple=aarch64-windows %s -o %t.obj
// RUN: lld-link -entry:main -subsystem:console %t.obj -out:%t.exe -verbose 2>&1 | FileCheck -check-prefix=VERBOSE %s
// RUN: llvm-objdump -d %t.exe | FileCheck --check-prefix=DISASM %s
// VERBOSE: Added 2 thunks with margin {{.*}} in 1 passes
.globl main
.globl func1
.globl func2
.text
main:
tbz w0, #0, func1
ret
.section .text$a, "xr"
.space 0x8000
.section .text$b, "xr"
func1:
tbz w0, #0, func2
ret
.space 1
.section .text$c, "xr"
.space 0x8000
.section .text$d, "xr"
.align 2
func2:
ret
// DISASM: 0000000140001000 <.text>:
// DISASM: 140001000: 40 00 00 36 tbz w0, #0, 0x140001008 <.text+0x8>
// DISASM: 140001004: c0 03 5f d6 ret
// DISASM: 140001008: 50 00 00 90 adrp x16, 0x140009000
// DISASM: 14000100c: 10 52 00 91 add x16, x16, #20
// DISASM: 140001010: 00 02 1f d6 br x16
// DISASM: 140009014: 60 00 00 36 tbz w0, #0, 0x140009020 <.text+0x8020>
// DISASM: 140009018: c0 03 5f d6 ret
// DISASM: 140009020: 50 00 00 90 adrp x16, 0x140011000
// DISASM: 140009024: 10 b2 00 91 add x16, x16, #44
// DISASM: 140009028: 00 02 1f d6 br x16
// DISASM: 14001102c: c0 03 5f d6 ret