2018-06-27 06:20:04 +08:00
|
|
|
// REQUIRES: x86
|
2015-12-21 18:12:06 +08:00
|
|
|
// RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %s -o %t.o
|
|
|
|
// RUN: ld.lld -static %t.o -o %tout
|
2019-08-07 17:43:54 +08:00
|
|
|
// RUN: llvm-objdump -d --no-show-raw-insn %tout | FileCheck %s --check-prefix=DISASM
|
2019-05-01 13:49:01 +08:00
|
|
|
// RUN: llvm-readobj -r --symbols --sections %tout | FileCheck %s
|
2015-12-21 18:12:06 +08:00
|
|
|
|
|
|
|
// CHECK: Sections [
|
|
|
|
// CHECK: Section {
|
|
|
|
// CHECK: Index: 1
|
2019-08-03 10:26:52 +08:00
|
|
|
// CHECK-NEXT: Name: .rel.dyn
|
2015-12-21 18:12:06 +08:00
|
|
|
// CHECK-NEXT: Type: SHT_REL
|
|
|
|
// CHECK-NEXT: Flags [
|
|
|
|
// CHECK-NEXT: SHF_ALLOC
|
2020-10-23 00:48:04 +08:00
|
|
|
// CHECK-NEXT: SHF_INFO_LINK
|
2015-12-21 18:12:06 +08:00
|
|
|
// CHECK-NEXT: ]
|
|
|
|
// CHECK-NEXT: Address: [[RELA:.*]]
|
|
|
|
// CHECK-NEXT: Offset: 0xD4
|
|
|
|
// CHECK-NEXT: Size: 16
|
2018-11-02 06:28:58 +08:00
|
|
|
// CHECK-NEXT: Link: 0
|
2018-10-11 16:25:35 +08:00
|
|
|
// CHECK-NEXT: Info: 4
|
2015-12-21 18:12:06 +08:00
|
|
|
// CHECK-NEXT: AddressAlignment: 4
|
|
|
|
// CHECK-NEXT: EntrySize: 8
|
|
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK: Relocations [
|
2019-08-03 10:26:52 +08:00
|
|
|
// CHECK-NEXT: Section ({{.*}}) .rel.dyn {
|
2019-08-20 16:43:47 +08:00
|
|
|
// CHECK-NEXT: 0x402120 R_386_IRELATIVE
|
|
|
|
// CHECK-NEXT: 0x402124 R_386_IRELATIVE
|
2015-12-21 18:12:06 +08:00
|
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK-NEXT: ]
|
|
|
|
|
|
|
|
// CHECK: Symbols [
|
|
|
|
// CHECK-NEXT: Symbol {
|
|
|
|
// CHECK-NEXT: Name:
|
|
|
|
// CHECK-NEXT: Value: 0x0
|
|
|
|
// CHECK-NEXT: Size: 0
|
|
|
|
// CHECK-NEXT: Binding: Local
|
|
|
|
// CHECK-NEXT: Type: None
|
|
|
|
// CHECK-NEXT: Other: 0
|
|
|
|
// CHECK-NEXT: Section: Undefined
|
|
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK-NEXT: Symbol {
|
2021-02-14 02:32:27 +08:00
|
|
|
// CHECK-NEXT: Name: __rel_iplt_start
|
|
|
|
// CHECK-NEXT: Value: [[RELA]]
|
2015-12-21 18:12:06 +08:00
|
|
|
// CHECK-NEXT: Size: 0
|
|
|
|
// CHECK-NEXT: Binding: Local
|
|
|
|
// CHECK-NEXT: Type: None
|
2016-04-04 22:04:16 +08:00
|
|
|
// CHECK-NEXT: Other [
|
|
|
|
// CHECK-NEXT: STV_HIDDEN
|
|
|
|
// CHECK-NEXT: ]
|
2019-08-03 10:26:52 +08:00
|
|
|
// CHECK-NEXT: Section: .rel.dyn
|
2015-12-21 18:12:06 +08:00
|
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK-NEXT: Symbol {
|
2021-02-14 02:32:27 +08:00
|
|
|
// CHECK-NEXT: Name: __rel_iplt_end
|
|
|
|
// CHECK-NEXT: Value: 0x4000E4
|
2015-12-21 18:12:06 +08:00
|
|
|
// CHECK-NEXT: Size: 0
|
|
|
|
// CHECK-NEXT: Binding: Local
|
|
|
|
// CHECK-NEXT: Type: None
|
2016-04-04 22:04:16 +08:00
|
|
|
// CHECK-NEXT: Other [
|
|
|
|
// CHECK-NEXT: STV_HIDDEN
|
|
|
|
// CHECK-NEXT: ]
|
2019-08-03 10:26:52 +08:00
|
|
|
// CHECK-NEXT: Section: .rel.dyn
|
2015-12-21 18:12:06 +08:00
|
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK-NEXT: Symbol {
|
|
|
|
// CHECK-NEXT: Name: bar
|
2019-08-20 16:43:47 +08:00
|
|
|
// CHECK-NEXT: Value: 0x401110
|
2019-02-14 05:49:55 +08:00
|
|
|
// CHECK-NEXT: Size: 0
|
|
|
|
// CHECK-NEXT: Binding: Global
|
|
|
|
// CHECK-NEXT: Type: Function
|
|
|
|
// CHECK-NEXT: Other: 0
|
2019-12-15 08:19:03 +08:00
|
|
|
// CHECK-NEXT: Section: .iplt
|
2019-02-14 05:49:55 +08:00
|
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK-NEXT: Symbol {
|
|
|
|
// CHECK-NEXT: Name: bar_resolver
|
2021-02-14 02:32:27 +08:00
|
|
|
// CHECK-NEXT: Value: 0x4010E4
|
2015-12-21 18:12:06 +08:00
|
|
|
// CHECK-NEXT: Size: 0
|
|
|
|
// CHECK-NEXT: Binding: Global
|
2019-02-14 05:49:55 +08:00
|
|
|
// CHECK-NEXT: Type: Function
|
2015-12-21 18:12:06 +08:00
|
|
|
// CHECK-NEXT: Other: 0
|
|
|
|
// CHECK-NEXT: Section: .text
|
|
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK-NEXT: Symbol {
|
|
|
|
// CHECK-NEXT: Name: foo
|
2019-08-20 16:43:47 +08:00
|
|
|
// CHECK-NEXT: Value: 0x401100
|
2019-02-14 05:49:55 +08:00
|
|
|
// CHECK-NEXT: Size: 0
|
|
|
|
// CHECK-NEXT: Binding: Global
|
|
|
|
// CHECK-NEXT: Type: Function
|
|
|
|
// CHECK-NEXT: Other: 0
|
2019-12-15 08:19:03 +08:00
|
|
|
// CHECK-NEXT: Section: .iplt
|
2019-02-14 05:49:55 +08:00
|
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK-NEXT: Symbol {
|
|
|
|
// CHECK-NEXT: Name: foo_resolver
|
2021-02-14 02:32:27 +08:00
|
|
|
// CHECK-NEXT: Value: 0x4010E5
|
2015-12-21 18:12:06 +08:00
|
|
|
// CHECK-NEXT: Size: 0
|
|
|
|
// CHECK-NEXT: Binding: Global
|
2019-02-14 05:49:55 +08:00
|
|
|
// CHECK-NEXT: Type: Function
|
2015-12-21 18:12:06 +08:00
|
|
|
// CHECK-NEXT: Other: 0
|
|
|
|
// CHECK-NEXT: Section: .text
|
|
|
|
// CHECK-NEXT: }
|
2021-02-14 02:32:27 +08:00
|
|
|
// CHECK-NEXT: Symbol {
|
|
|
|
// CHECK-NEXT: Name: _start
|
|
|
|
// CHECK-NEXT: Value: 0x4010E6
|
|
|
|
// CHECK-NEXT: Size: 0
|
|
|
|
// CHECK-NEXT: Binding: Global
|
|
|
|
// CHECK-NEXT: Type: None
|
|
|
|
// CHECK-NEXT: Other: 0
|
|
|
|
// CHECK-NEXT: Section: .text
|
|
|
|
// CHECK-NEXT: }
|
2015-12-21 18:12:06 +08:00
|
|
|
// CHECK-NEXT:]
|
|
|
|
|
2016-12-08 20:58:55 +08:00
|
|
|
// DISASM: Disassembly of section .text:
|
2019-05-01 18:40:48 +08:00
|
|
|
// DISASM-EMPTY:
|
2021-02-14 02:32:27 +08:00
|
|
|
// DISASM-NEXT: <bar_resolver>:
|
2019-08-20 16:43:47 +08:00
|
|
|
// DISASM-NEXT: 4010e4: retl
|
2021-02-14 02:32:27 +08:00
|
|
|
// DISASM: <foo_resolver>:
|
2019-08-20 16:43:47 +08:00
|
|
|
// DISASM-NEXT: 4010e5: retl
|
2020-03-06 06:18:38 +08:00
|
|
|
// DISASM: <_start>:
|
2020-03-23 06:03:10 +08:00
|
|
|
// DISASM-NEXT: 4010e6: calll 0x401100 <foo>
|
|
|
|
// DISASM-NEXT: calll 0x401110 <bar>
|
2019-08-07 17:43:54 +08:00
|
|
|
// DISASM-NEXT: movl $4194516, %edx
|
|
|
|
// DISASM-NEXT: movl $4194532, %edx
|
2019-05-01 18:40:48 +08:00
|
|
|
// DISASM-EMPTY:
|
2019-12-15 08:19:03 +08:00
|
|
|
// DISASM-NEXT: Disassembly of section .iplt:
|
2019-05-01 18:40:48 +08:00
|
|
|
// DISASM-EMPTY:
|
2020-03-06 06:18:38 +08:00
|
|
|
// DISASM-NEXT: <foo>:
|
2019-08-20 16:43:47 +08:00
|
|
|
// DISASM-NEXT: 401100: jmpl *4202784
|
2019-12-15 07:09:43 +08:00
|
|
|
// DISASM-NEXT: pushl $0
|
2020-03-23 06:03:10 +08:00
|
|
|
// DISASM-NEXT: jmp 0x0
|
2020-03-06 06:18:38 +08:00
|
|
|
// DISASM: <bar>:
|
2019-08-20 16:43:47 +08:00
|
|
|
// DISASM-NEXT: 401110: jmpl *4202788
|
2019-12-15 07:09:43 +08:00
|
|
|
// DISASM-NEXT: pushl $8
|
2020-03-23 06:03:10 +08:00
|
|
|
// DISASM-NEXT: jmp 0x0
|
2015-12-21 18:12:06 +08:00
|
|
|
|
2021-02-14 02:32:27 +08:00
|
|
|
.type bar STT_GNU_IFUNC
|
|
|
|
.globl bar
|
|
|
|
bar:
|
|
|
|
.type bar_resolver STT_FUNC
|
|
|
|
.globl bar_resolver
|
|
|
|
bar_resolver:
|
|
|
|
ret
|
|
|
|
|
2015-12-21 18:12:06 +08:00
|
|
|
.text
|
|
|
|
.type foo STT_GNU_IFUNC
|
|
|
|
.globl foo
|
|
|
|
foo:
|
2019-02-14 05:49:55 +08:00
|
|
|
.type foo_resolver STT_FUNC
|
|
|
|
.globl foo_resolver
|
|
|
|
foo_resolver:
|
2015-12-21 18:12:06 +08:00
|
|
|
ret
|
|
|
|
|
|
|
|
.globl _start
|
|
|
|
_start:
|
|
|
|
call foo
|
|
|
|
call bar
|
|
|
|
movl $__rel_iplt_start,%edx
|
|
|
|
movl $__rel_iplt_end,%edx
|