1 // RUN: llvm-mc -triple=aarch64-none-linux-gnu -filetype=obj %s -o -| llvm-objdump -r - | FileCheck %s 2 3 // CHECK: RELOCATION RECORDS FOR [.rela.text] 4 5 .file "/home/espindola/llvm/llvm/test/CodeGen/AArch64/basic-pic.ll" 6 .text 7 .globl get_globalvar 8 .type get_globalvar,@function 9 get_globalvar: // @get_globalvar 10 .cfi_startproc 11 // %bb.0: 12 adrp x0, :got:var 13 ldr x0, [x0, #:got_lo12:var] 14 ldr w0, [x0] 15 ret 16 .Ltmp0: 17 .size get_globalvar, .Ltmp0-get_globalvar 18 .cfi_endproc 19 20 // CHECK: R_AARCH64_ADR_GOT_PAGE var 21 // CHECK: R_AARCH64_LD64_GOT_LO12_NC var 22 23 .globl get_globalvaraddr 24 .type get_globalvaraddr,@function 25 get_globalvaraddr: // @get_globalvaraddr 26 .cfi_startproc 27 // %bb.0: 28 adrp x0, :got:var 29 ldr x0, [x0, #:got_lo12:var] 30 ret 31 .Ltmp1: 32 .size get_globalvaraddr, .Ltmp1-get_globalvaraddr 33 .cfi_endproc 34 // CHECK: R_AARCH64_ADR_GOT_PAGE var 35 // CHECK: R_AARCH64_LD64_GOT_LO12_NC var 36 37 .globl get_hiddenvar 38 .type get_hiddenvar,@function 39 get_hiddenvar: // @get_hiddenvar 40 .cfi_startproc 41 // %bb.0: 42 adrp x0, hiddenvar 43 ldr w0, [x0, #:lo12:hiddenvar] 44 ret 45 .Ltmp2: 46 .size get_hiddenvar, .Ltmp2-get_hiddenvar 47 .cfi_endproc 48 // CHECK: R_AARCH64_ADR_PREL_PG_HI21 hiddenvar 49 // CHECK: R_AARCH64_LDST32_ABS_LO12_NC hiddenvar 50 51 .globl get_hiddenvaraddr 52 .type get_hiddenvaraddr,@function 53 get_hiddenvaraddr: // @get_hiddenvaraddr 54 .cfi_startproc 55 // %bb.0: 56 adrp x0, hiddenvar 57 add x0, x0, #:lo12:hiddenvar 58 ret 59 .Ltmp3: 60 .size get_hiddenvaraddr, .Ltmp3-get_hiddenvaraddr 61 .cfi_endproc 62 // CHECK: R_AARCH64_ADR_PREL_PG_HI21 hiddenvar 63 // CHECK: R_AARCH64_ADD_ABS_LO12_NC hiddenvar 64 65 .globl get_func 66 .type get_func,@function 67 get_func: // @get_func 68 .cfi_startproc 69 // %bb.0: 70 adrp x0, :got:get_func 71 ldr x0, [x0, #:got_lo12:get_func] 72 ret 73 .Ltmp4: 74 .size get_func, .Ltmp4-get_func 75 .cfi_endproc 76 77 // Particularly important that the ADRP gets a relocation, LLVM tends to think 78 // it can relax it because it knows where get_func is. It can't! 79 // CHECK: R_AARCH64_ADR_GOT_PAGE get_func 80 // CHECK: R_AARCH64_LD64_GOT_LO12_NC get_func 81 82 .type var,@object // @var 83 .bss 84 .globl var 85 .align 2 86 var: 87 .word 0 // 0x0 88 .size var, 4 89 90 .hidden hiddenvar // @hiddenvar 91 .type hiddenvar,@object 92 .globl hiddenvar 93 .align 2 94 hiddenvar: 95 .word 0 // 0x0 96 .size hiddenvar, 4 97 98 99