1// REQUIRES: aarch64 2// RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux-gnu %s -o %t.o 3// RUN: ld.lld -static %t.o -o %tout 4// RUN: llvm-objdump -d --no-show-raw-insn %tout | FileCheck %s --check-prefix=DISASM 5// RUN: llvm-readobj -r --symbols --sections %tout | FileCheck %s 6 7// CHECK: Sections [ 8// CHECK: Section { 9// CHECK: Index: 1 10// CHECK-NEXT: Name: .rela.dyn 11// CHECK-NEXT: Type: SHT_RELA 12// CHECK-NEXT: Flags [ 13// CHECK-NEXT: SHF_ALLOC 14// CHECK-NEXT: SHF_INFO_LINK 15// CHECK-NEXT: ] 16// CHECK-NEXT: Address: [[RELA:.*]] 17// CHECK-NEXT: Offset: 0x158 18// CHECK-NEXT: Size: 48 19// CHECK-NEXT: Link: 0 20// CHECK-NEXT: Info: 4 21// CHECK-NEXT: AddressAlignment: 8 22// CHECK-NEXT: EntrySize: 24 23// CHECK-NEXT: } 24// CHECK: Relocations [ 25// CHECK-NEXT: Section ({{.*}}) .rela.dyn { 26// CHECK-NEXT: 0x2201C0 R_AARCH64_IRELATIVE 27// CHECK-NEXT: 0x2201C8 R_AARCH64_IRELATIVE 28// CHECK-NEXT: } 29// CHECK-NEXT: ] 30// CHECK: Symbols [ 31// CHECK-NEXT: Symbol { 32// CHECK-NEXT: Name: 33// CHECK-NEXT: Value: 0x0 34// CHECK-NEXT: Size: 0 35// CHECK-NEXT: Binding: Local 36// CHECK-NEXT: Type: None 37// CHECK-NEXT: Other: 0 38// CHECK-NEXT: Section: Undefined 39// CHECK-NEXT: } 40// CHECK-NEXT: Symbol { 41// CHECK-NEXT: Name: $x.0 42// CHECK-NEXT: Value: 0x210188 43// CHECK-NEXT: Size: 0 44// CHECK-NEXT: Binding: Local 45// CHECK-NEXT: Type: None 46// CHECK-NEXT: Other: 0 47// CHECK-NEXT: Section: .text 48// CHECK-NEXT: } 49// CHECK-NEXT: Symbol { 50// CHECK-NEXT: Name: __rela_iplt_end 51// CHECK-NEXT: Value: 0x200188 52// CHECK-NEXT: Size: 0 53// CHECK-NEXT: Binding: Local 54// CHECK-NEXT: Type: None 55// CHECK-NEXT: Other [ 56// CHECK-NEXT: STV_HIDDEN 57// CHECK-NEXT: ] 58// CHECK-NEXT: Section: .rela.dyn 59// CHECK-NEXT: } 60// CHECK-NEXT: Symbol { 61// CHECK-NEXT: Name: __rela_iplt_start 62// CHECK-NEXT: Value: 0x200158 63// CHECK-NEXT: Size: 0 64// CHECK-NEXT: Binding: Local 65// CHECK-NEXT: Type: None 66// CHECK-NEXT: Other [ 67// CHECK-NEXT: STV_HIDDEN 68// CHECK-NEXT: ] 69// CHECK-NEXT: Section: .rela.dyn 70// CHECK-NEXT: } 71// CHECK-NEXT: Symbol { 72// CHECK-NEXT: Name: _start 73// CHECK-NEXT: Value: 0x210190 74// CHECK-NEXT: Size: 0 75// CHECK-NEXT: Binding: Global 76// CHECK-NEXT: Type: None 77// CHECK-NEXT: Other: 0 78// CHECK-NEXT: Section: .text 79// CHECK-NEXT: } 80// CHECK-NEXT: Symbol { 81// CHECK-NEXT: Name: bar 82// CHECK-NEXT: Value: 0x21018C 83// CHECK-NEXT: Size: 0 84// CHECK-NEXT: Binding: Global 85// CHECK-NEXT: Type: GNU_IFunc 86// CHECK-NEXT: Other: 0 87// CHECK-NEXT: Section: .text 88// CHECK-NEXT: } 89// CHECK-NEXT: Symbol { 90// CHECK-NEXT: Name: foo 91// CHECK-NEXT: Value: 0x210188 92// CHECK-NEXT: Size: 0 93// CHECK-NEXT: Binding: Global 94// CHECK-NEXT: Type: GNU_IFunc 95// CHECK-NEXT: Other: 0 96// CHECK-NEXT: Section: .text 97// CHECK-NEXT: } 98// CHECK-NEXT: ] 99 100// 344 = 0x158 101// 392 = 0x188 102 103// DISASM: Disassembly of section .text: 104// DISASM-EMPTY: 105// DISASM-NEXT: <foo>: 106// DISASM-NEXT: 210188: ret 107// DISASM: <bar>: 108// DISASM-NEXT: 21018c: ret 109// DISASM: <_start>: 110// DISASM-NEXT: 210190: bl 0x2101a0 111// DISASM-NEXT: 210194: bl 0x2101b0 112// DISASM-NEXT: 210198: add x2, x2, #344 113// DISASM-NEXT: 21019c: add x2, x2, #392 114// DISASM-EMPTY: 115// DISASM-NEXT: Disassembly of section .iplt: 116// DISASM-EMPTY: 117// DISASM-NEXT: <.iplt>: 118// DISASM-NEXT: 2101a0: adrp x16, #65536 119// DISASM-NEXT: 2101a4: ldr x17, [x16, #448] 120// DISASM-NEXT: 2101a8: add x16, x16, #448 121// DISASM-NEXT: 2101ac: br x17 122// DISASM-NEXT: 2101b0: adrp x16, #65536 123// DISASM-NEXT: 2101b4: ldr x17, [x16, #456] 124// DISASM-NEXT: 2101b8: add x16, x16, #456 125// DISASM-NEXT: 2101bc: br x17 126 127.text 128.type foo STT_GNU_IFUNC 129.globl foo 130foo: 131 ret 132 133.type bar STT_GNU_IFUNC 134.globl bar 135bar: 136 ret 137 138.globl _start 139_start: 140 bl foo 141 bl bar 142 add x2, x2, :lo12:__rela_iplt_start 143 add x2, x2, :lo12:__rela_iplt_end 144