1// REQUIRES: x86 2// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o 3// RUN: ld.lld -static %t.o -o %tout 4// RUN: llvm-objdump -d %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: [[GOTPLT:.*]] 21// CHECK-NEXT: AddressAlignment: 8 22// CHECK-NEXT: EntrySize: 24 23// CHECK-NEXT: } 24// CHECK: Index: [[GOTPLT]] 25// CHECK-NEXT: Name: .got.plt 26// CHECK: Relocations [ 27// CHECK-NEXT: Section ({{.*}}) .rela.dyn { 28// CHECK-NEXT: 0x2021D0 R_X86_64_IRELATIVE 29// CHECK-NEXT: 0x2021D8 R_X86_64_IRELATIVE 30// CHECK-NEXT: } 31// CHECK-NEXT: ] 32// CHECK: Symbols [ 33// CHECK-NEXT: Symbol { 34// CHECK-NEXT: Name: 35// CHECK-NEXT: Value: 0x0 36// CHECK-NEXT: Size: 0 37// CHECK-NEXT: Binding: Local 38// CHECK-NEXT: Type: None 39// CHECK-NEXT: Other: 0 40// CHECK-NEXT: Section: Undefined 41// CHECK-NEXT: } 42// CHECK-NEXT: Symbol { 43// CHECK-NEXT: Name: __rela_iplt_end 44// CHECK-NEXT: Value: 0x200188 45// CHECK-NEXT: Size: 0 46// CHECK-NEXT: Binding: Local 47// CHECK-NEXT: Type: None 48// CHECK-NEXT: Other [ 49// CHECK-NEXT: STV_HIDDEN 50// CHECK-NEXT: ] 51// CHECK-NEXT: Section: .rela.dyn 52// CHECK-NEXT: } 53// CHECK-NEXT: Symbol { 54// CHECK-NEXT: Name: __rela_iplt_start 55// CHECK-NEXT: Value: [[RELA]] 56// CHECK-NEXT: Size: 0 57// CHECK-NEXT: Binding: Local 58// CHECK-NEXT: Type: None 59// CHECK-NEXT: Other [ 60// CHECK-NEXT: STV_HIDDEN 61// CHECK-NEXT: ] 62// CHECK-NEXT: Section: .rela.dyn 63// CHECK-NEXT: } 64// CHECK-NEXT: Symbol { 65// CHECK-NEXT: Name: _start 66// CHECK-NEXT: Value: 0x20118A 67// CHECK-NEXT: Size: 0 68// CHECK-NEXT: Binding: Global 69// CHECK-NEXT: Type: None 70// CHECK-NEXT: Other: 0 71// CHECK-NEXT: Section: .text 72// CHECK-NEXT: } 73// CHECK-NEXT: Symbol { 74// CHECK-NEXT: Name: bar 75// CHECK-NEXT: Value: 0x201189 76// CHECK-NEXT: Size: 0 77// CHECK-NEXT: Binding: Global 78// CHECK-NEXT: Type: GNU_IFunc 79// CHECK-NEXT: Other: 0 80// CHECK-NEXT: Section: .text 81// CHECK-NEXT: } 82// CHECK-NEXT: Symbol { 83// CHECK-NEXT: Name: foo 84// CHECK-NEXT: Value: 0x201188 85// CHECK-NEXT: Size: 0 86// CHECK-NEXT: Binding: Global 87// CHECK-NEXT: Type: GNU_IFunc 88// CHECK-NEXT: Other: 0 89// CHECK-NEXT: Section: .text 90// CHECK-NEXT: } 91// CHECK-NEXT: ] 92 93// DISASM: Disassembly of section .text: 94// DISASM-EMPTY: 95// DISASM-NEXT: <foo>: 96// DISASM-NEXT: 201188: {{.*}} retq 97// DISASM: <bar>: 98// DISASM-NEXT: 201189: {{.*}} retq 99// DISASM: <_start>: 100// DISASM-NEXT: 20118a: {{.*}} callq 0x2011b0 101// DISASM-NEXT: 20118f: {{.*}} callq 0x2011c0 102// DISASM-NEXT: 201194: {{.*}} movl $2097496, %edx 103// DISASM-NEXT: 201199: {{.*}} movl $2097544, %edx 104// DISASM-NEXT: 20119e: {{.*}} movl $2097545, %edx 105// DISASM-EMPTY: 106// DISASM-NEXT: Disassembly of section .iplt: 107// DISASM-EMPTY: 108// DISASM-NEXT: <.iplt>: 109// DISASM-NEXT: 2011b0: {{.*}} jmpq *4122(%rip) 110// DISASM-NEXT: 2011b6: {{.*}} pushq $0 111// DISASM-NEXT: 2011bb: {{.*}} jmp 0x0 112// DISASM-NEXT: 2011c0: {{.*}} jmpq *4114(%rip) 113// DISASM-NEXT: 2011c6: {{.*}} pushq $1 114// DISASM-NEXT: 2011cb: {{.*}} jmp 0x0 115 116.text 117.type foo STT_GNU_IFUNC 118.globl foo 119foo: 120 ret 121 122.type bar STT_GNU_IFUNC 123.globl bar 124bar: 125 ret 126 127.globl _start 128_start: 129 call foo 130 call bar 131 movl $__rela_iplt_start,%edx 132 movl $__rela_iplt_end,%edx 133 movl $__rela_iplt_end + 1,%edx 134