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
|
2020-08-10 20:30:08 +08:00
|
|
|
// RUN: llvm-objdump -d --no-show-raw-insn --print-imm-hex %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
|
|
|
|
2020-03-04 11:49:14 +08:00
|
|
|
/// Check that the PLTRELSZ tag does not include the IRELATIVE relocations
|
|
|
|
// CHECK: DynamicSection [
|
2020-08-10 20:30:08 +08:00
|
|
|
// CHECK: 0x00000012 RELSZ 24 (bytes)
|
2020-03-04 11:49:14 +08:00
|
|
|
// CHECK: 0x00000002 PLTRELSZ 16 (bytes)
|
|
|
|
|
2020-08-10 20:30:08 +08:00
|
|
|
/// Check that the IRELATIVE relocations are placed to the .rel.dyn section after
|
|
|
|
/// other regular relocations (e.g. GLOB_DAT).
|
2016-12-09 17:59:54 +08:00
|
|
|
// CHECK: Relocations [
|
2019-08-03 10:26:52 +08:00
|
|
|
// CHECK-NEXT: Section (4) .rel.dyn {
|
2020-12-10 21:12:26 +08:00
|
|
|
// CHECK-NEXT: 0x4022C8 R_386_GLOB_DAT bar3
|
|
|
|
// CHECK-NEXT: 0x4032E0 R_386_IRELATIVE -
|
|
|
|
// CHECK-NEXT: 0x4032E4 R_386_IRELATIVE -
|
2019-08-03 10:26:52 +08:00
|
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK-NEXT: Section (5) .rel.plt {
|
2020-12-10 21:12:26 +08:00
|
|
|
// CHECK-NEXT: 0x4032D8 R_386_JUMP_SLOT bar2
|
|
|
|
// CHECK-NEXT: 0x4032DC 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:
|
2020-08-10 20:30:08 +08:00
|
|
|
// GOTPLT: 4032cc 50224000 00000000 00000000 16124000
|
|
|
|
// GOTPLT-NEXT: 4032dc 26124000 dc114000 dd114000
|
|
|
|
// ^ ^-- <bar> (0x4011dd)
|
|
|
|
// -- <foo> (0x4011dcd)
|
2016-12-09 17:59:54 +08:00
|
|
|
|
2020-08-10 20:30:08 +08:00
|
|
|
/// Check that we have 2 PLT sections: one regular .plt section and one
|
|
|
|
/// .iplt section for ifunc entries.
|
2016-12-09 17:59:54 +08:00
|
|
|
// DISASM: Disassembly of section .text:
|
2019-05-01 18:40:48 +08:00
|
|
|
// DISASM-EMPTY:
|
2020-03-06 06:18:38 +08:00
|
|
|
// DISASM-NEXT: <foo>:
|
2020-08-10 20:30:08 +08:00
|
|
|
// DISASM-NEXT: 4011dc: retl
|
2020-03-06 06:18:38 +08:00
|
|
|
// DISASM: <bar>:
|
2020-08-10 20:30:08 +08:00
|
|
|
// DISASM-NEXT: 4011dd: retl
|
2020-03-06 06:18:38 +08:00
|
|
|
// DISASM: <_start>:
|
2020-08-10 20:30:08 +08:00
|
|
|
// DISASM-NEXT: 4011de: calll 0x401230
|
|
|
|
// DISASM-NEXT: calll 0x401240
|
|
|
|
// DISASM-NEXT: calll 0x401210 <bar2@plt>
|
|
|
|
// DISASM-NEXT: calll 0x401220 <zed2@plt>
|
|
|
|
// DISASM-NEXT: movl -0x1004(%eax), %eax
|
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:
|
2020-03-06 06:18:38 +08:00
|
|
|
// DISASM-NEXT: <.plt>:
|
2020-08-10 20:30:08 +08:00
|
|
|
// DISASM-NEXT: 401200: pushl 0x4032d0
|
|
|
|
// DISASM-NEXT: jmpl *0x4032d4
|
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:
|
2020-03-06 06:18:38 +08:00
|
|
|
// DISASM-NEXT: <bar2@plt>:
|
2020-08-10 20:30:08 +08:00
|
|
|
// DISASM-NEXT: 401210: jmpl *0x4032d8
|
|
|
|
// DISASM-NEXT: pushl $0x0
|
|
|
|
// DISASM-NEXT: jmp 0x401200 <.plt>
|
2018-08-25 00:22:42 +08:00
|
|
|
// DISASM-EMPTY:
|
2020-03-06 06:18:38 +08:00
|
|
|
// DISASM-NEXT: <zed2@plt>:
|
2020-08-10 20:30:08 +08:00
|
|
|
// DISASM-NEXT: 401220: jmpl *0x4032dc
|
|
|
|
// DISASM-NEXT: pushl $0x8
|
|
|
|
// DISASM-NEXT: jmp 0x401200 <.plt>
|
2019-12-15 08:19:03 +08:00
|
|
|
// DISASM-EMPTY:
|
|
|
|
// DISASM-NEXT: Disassembly of section .iplt:
|
|
|
|
// DISASM-EMPTY:
|
2020-03-06 06:18:38 +08:00
|
|
|
// DISASM-NEXT: <.iplt>:
|
2020-08-10 20:30:08 +08:00
|
|
|
// DISASM-NEXT: jmpl *0x4032e0
|
|
|
|
// DISASM-NEXT: pushl $0x0
|
|
|
|
// DISASM-NEXT: jmp 0x401200 <.plt>
|
|
|
|
// DISASM-NEXT: jmpl *0x4032e4
|
|
|
|
// DISASM-NEXT: pushl $0x8
|
|
|
|
// DISASM-NEXT: jmp 0x401200 <.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
|
2020-08-10 20:30:08 +08:00
|
|
|
movl bar3@GOT(%eax), %eax
|