2018-06-27 06:20:04 +08:00
|
|
|
// REQUIRES: x86
|
2016-12-09 17:59:54 +08:00
|
|
|
// RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %S/Inputs/shared2-x86-64.s -o %t1.o
|
2019-08-07 17:43:54 +08:00
|
|
|
// RUN: ld.lld %t1.o --shared --soname=t.so -o %t.so
|
2016-12-09 17:59:54 +08:00
|
|
|
// RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %s -o %t.o
|
2017-10-06 17:37:44 +08:00
|
|
|
// RUN: ld.lld --hash-style=sysv %t.so %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
|
2016-12-09 17:59:54 +08:00
|
|
|
// RUN: llvm-objdump -s %tout | FileCheck %s --check-prefix=GOTPLT
|
2019-05-01 13:49:01 +08:00
|
|
|
// RUN: llvm-readobj -r --dynamic-table %tout | FileCheck %s
|
2016-12-09 17:59:54 +08:00
|
|
|
|
|
|
|
// Check that the IRELATIVE relocations are after the JUMP_SLOT in the plt
|
|
|
|
// CHECK: Relocations [
|
2019-08-03 10:26:52 +08:00
|
|
|
// CHECK-NEXT: Section (4) .rel.dyn {
|
2019-08-20 16:43:47 +08:00
|
|
|
// CHECK-NEXT: 0x4032AC R_386_IRELATIVE
|
|
|
|
// CHECK-NEXT: 0x4032B0 R_386_IRELATIVE
|
2019-08-03 10:26:52 +08:00
|
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK-NEXT: Section (5) .rel.plt {
|
2019-08-20 16:43:47 +08:00
|
|
|
// CHECK-NEXT: 0x4032A4 R_386_JUMP_SLOT bar2
|
|
|
|
// CHECK-NEXT: 0x4032A8 R_386_JUMP_SLOT zed2
|
2019-08-03 10:26:52 +08:00
|
|
|
// CHECK-NEXT: }
|
2016-12-09 17:59:54 +08:00
|
|
|
|
|
|
|
// Check that IRELATIVE .got.plt entries point to ifunc resolver and not
|
|
|
|
// back to the plt entry + 6.
|
|
|
|
// GOTPLT: Contents of section .got.plt:
|
2019-08-20 16:43:47 +08:00
|
|
|
// GOTPLT: 403298 20224000 00000000 00000000 e6114000
|
|
|
|
// GOTPLT-NEXT: 4032a8 f6114000 b4114000 b5114000
|
2016-12-09 17:59:54 +08:00
|
|
|
|
2019-08-03 10:26:52 +08:00
|
|
|
// Check that the PLTRELSZ tag does not include the IRELATIVE relocations
|
2016-12-09 17:59:54 +08:00
|
|
|
// CHECK: DynamicSection [
|
2019-08-03 10:26:52 +08:00
|
|
|
// CHECK: 0x00000012 RELSZ 16 (bytes)
|
|
|
|
// CHECK: 0x00000002 PLTRELSZ 16 (bytes)
|
2016-12-09 17:59:54 +08:00
|
|
|
|
|
|
|
// Check that a PLT header is written and the ifunc entries appear last
|
|
|
|
// DISASM: Disassembly of section .text:
|
2019-05-01 18:40:48 +08:00
|
|
|
// DISASM-EMPTY:
|
2016-12-09 17:59:54 +08:00
|
|
|
// DISASM-NEXT: foo:
|
2019-08-20 16:43:47 +08:00
|
|
|
// DISASM-NEXT: 4011b4: retl
|
2016-12-09 17:59:54 +08:00
|
|
|
// DISASM: bar:
|
2019-08-20 16:43:47 +08:00
|
|
|
// DISASM-NEXT: 4011b5: retl
|
2016-12-09 17:59:54 +08:00
|
|
|
// DISASM: _start:
|
2019-12-15 08:19:03 +08:00
|
|
|
// DISASM-NEXT: 4011b6: calll 69 <zed2+0x401200>
|
|
|
|
// DISASM-NEXT: calll 80 <zed2+0x401210>
|
2019-08-20 16:43:47 +08:00
|
|
|
// DISASM-NEXT: calll 27 <bar2@plt>
|
|
|
|
// DISASM-NEXT: calll 38 <zed2@plt>
|
2019-05-01 18:40:48 +08:00
|
|
|
// DISASM-EMPTY:
|
2016-12-09 17:59:54 +08:00
|
|
|
// DISASM-NEXT: Disassembly of section .plt:
|
2019-05-01 18:40:48 +08:00
|
|
|
// DISASM-EMPTY:
|
2016-12-09 17:59:54 +08:00
|
|
|
// DISASM-NEXT: .plt:
|
2019-08-20 16:43:47 +08:00
|
|
|
// DISASM-NEXT: 4011d0: pushl 4207260
|
|
|
|
// DISASM-NEXT: jmpl *4207264
|
2019-08-07 17:43:54 +08:00
|
|
|
// DISASM-NEXT: nop
|
|
|
|
// DISASM-NEXT: nop
|
|
|
|
// DISASM-NEXT: nop
|
|
|
|
// DISASM-NEXT: nop
|
2018-08-25 00:22:42 +08:00
|
|
|
// DISASM-EMPTY:
|
|
|
|
// DISASM-NEXT: bar2@plt:
|
2019-08-20 16:43:47 +08:00
|
|
|
// DISASM-NEXT: 4011e0: jmpl *4207268
|
2019-08-07 17:43:54 +08:00
|
|
|
// DISASM-NEXT: pushl $0
|
|
|
|
// DISASM-NEXT: jmp -32 <.plt>
|
2018-08-25 00:22:42 +08:00
|
|
|
// DISASM-EMPTY:
|
|
|
|
// DISASM-NEXT: zed2@plt:
|
2019-08-20 16:43:47 +08:00
|
|
|
// DISASM-NEXT: 4011f0: jmpl *4207272
|
2019-08-07 17:43:54 +08:00
|
|
|
// DISASM-NEXT: pushl $8
|
|
|
|
// DISASM-NEXT: jmp -48 <.plt>
|
2019-12-15 08:19:03 +08:00
|
|
|
// DISASM-EMPTY:
|
|
|
|
// DISASM-NEXT: Disassembly of section .iplt:
|
|
|
|
// DISASM-EMPTY:
|
|
|
|
// DISASM-NEXT: .iplt:
|
2019-08-20 16:43:47 +08:00
|
|
|
// DISASM-NEXT: jmpl *4207276
|
2019-12-15 07:09:43 +08:00
|
|
|
// DISASM-NEXT: pushl $0
|
2019-12-15 06:17:35 +08:00
|
|
|
// DISASM-NEXT: jmp -64 <.plt>
|
2019-08-20 16:43:47 +08:00
|
|
|
// DISASM-NEXT: jmpl *4207280
|
2019-12-15 07:09:43 +08:00
|
|
|
// DISASM-NEXT: pushl $8
|
2019-12-15 06:17:35 +08:00
|
|
|
// DISASM-NEXT: jmp -80 <.plt>
|
2016-12-09 17:59:54 +08:00
|
|
|
|
|
|
|
.text
|
|
|
|
.type foo STT_GNU_IFUNC
|
|
|
|
.globl foo
|
|
|
|
foo:
|
|
|
|
ret
|
|
|
|
|
|
|
|
.type bar STT_GNU_IFUNC
|
|
|
|
.globl bar
|
|
|
|
bar:
|
|
|
|
ret
|
|
|
|
|
|
|
|
.globl _start
|
|
|
|
_start:
|
2018-03-13 09:41:49 +08:00
|
|
|
call foo@plt
|
|
|
|
call bar@plt
|
|
|
|
call bar2@plt
|
|
|
|
call zed2@plt
|