forked from OSchip/llvm-project
[LLD][ELF] - Update and fix gnu-ifunc* tests.
It turns that gnu-ifunc-plt-i386.s and gnu-ifunc-plt.s tests are broken. Initially they were implemented in D27581 and tested that `IRELATIVE` relocations are placed after other relocations in `.rel.plt`. Later, we started to place `IRELATIVE` relocations to `.rela.dyn` (D65651). Also, at some point `.plt` was renamed to `.iplt` (D71520). Now, `gnu-ifunc*` tests mentioned do not test what they intended to test initially: they should test that `IRELATIVE` relocations are placed after other ones in `.rela.dyn`. Also, comments needs to be updated accordingly after changes performed. This patch updates them. Differential revision: https://reviews.llvm.org/D85642
This commit is contained in:
parent
455ed56d48
commit
026e0bf984
|
@ -7,3 +7,8 @@ bar2:
|
|||
.type zed2, @function
|
||||
zed2:
|
||||
ret
|
||||
|
||||
.global bar3
|
||||
.type bar3, @function
|
||||
bar3:
|
||||
ret
|
||||
|
|
|
@ -3,74 +3,80 @@
|
|||
// RUN: ld.lld %t1.o --shared --soname=t.so -o %t.so
|
||||
// RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %s -o %t.o
|
||||
// RUN: ld.lld --hash-style=sysv %t.so %t.o -o %tout
|
||||
// RUN: llvm-objdump -d --no-show-raw-insn %tout | FileCheck %s --check-prefix=DISASM
|
||||
// RUN: llvm-objdump -d --no-show-raw-insn --print-imm-hex %tout | FileCheck %s --check-prefix=DISASM
|
||||
// RUN: llvm-objdump -s %tout | FileCheck %s --check-prefix=GOTPLT
|
||||
// RUN: llvm-readobj -r --dynamic-table %tout | FileCheck %s
|
||||
|
||||
/// Check that the PLTRELSZ tag does not include the IRELATIVE relocations
|
||||
// CHECK: DynamicSection [
|
||||
// CHECK: 0x00000012 RELSZ 16 (bytes)
|
||||
// CHECK: 0x00000012 RELSZ 24 (bytes)
|
||||
// CHECK: 0x00000002 PLTRELSZ 16 (bytes)
|
||||
|
||||
// Check that the IRELATIVE relocations are after the JUMP_SLOT in the plt
|
||||
/// Check that the IRELATIVE relocations are placed to the .rel.dyn section after
|
||||
/// other regular relocations (e.g. GLOB_DAT).
|
||||
// CHECK: Relocations [
|
||||
// CHECK-NEXT: Section (4) .rel.dyn {
|
||||
// CHECK-NEXT: 0x4032AC R_386_IRELATIVE
|
||||
// CHECK-NEXT: 0x4032B0 R_386_IRELATIVE
|
||||
// CHECK-NEXT: 0x4022C8 R_386_GLOB_DAT bar3 0x0
|
||||
// CHECK-NEXT: 0x4032E0 R_386_IRELATIVE - 0x0
|
||||
// CHECK-NEXT: 0x4032E4 R_386_IRELATIVE - 0x0
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: Section (5) .rel.plt {
|
||||
// CHECK-NEXT: 0x4032A4 R_386_JUMP_SLOT bar2
|
||||
// CHECK-NEXT: 0x4032A8 R_386_JUMP_SLOT zed2
|
||||
// CHECK-NEXT: 0x4032D8 R_386_JUMP_SLOT bar2 0x0
|
||||
// CHECK-NEXT: 0x4032DC R_386_JUMP_SLOT zed2 0x0
|
||||
// CHECK-NEXT: }
|
||||
|
||||
// Check that IRELATIVE .got.plt entries point to ifunc resolver and not
|
||||
// back to the plt entry + 6.
|
||||
// GOTPLT: Contents of section .got.plt:
|
||||
// GOTPLT: 403298 20224000 00000000 00000000 e6114000
|
||||
// GOTPLT-NEXT: 4032a8 f6114000 b4114000 b5114000
|
||||
// GOTPLT: 4032cc 50224000 00000000 00000000 16124000
|
||||
// GOTPLT-NEXT: 4032dc 26124000 dc114000 dd114000
|
||||
// ^ ^-- <bar> (0x4011dd)
|
||||
// -- <foo> (0x4011dcd)
|
||||
|
||||
// Check that a PLT header is written and the ifunc entries appear last
|
||||
/// Check that we have 2 PLT sections: one regular .plt section and one
|
||||
/// .iplt section for ifunc entries.
|
||||
// DISASM: Disassembly of section .text:
|
||||
// DISASM-EMPTY:
|
||||
// DISASM-NEXT: <foo>:
|
||||
// DISASM-NEXT: 4011b4: retl
|
||||
// DISASM-NEXT: 4011dc: retl
|
||||
// DISASM: <bar>:
|
||||
// DISASM-NEXT: 4011b5: retl
|
||||
// DISASM-NEXT: 4011dd: retl
|
||||
// DISASM: <_start>:
|
||||
// DISASM-NEXT: 4011b6: calll 0x401200 <zed2+0x401200>
|
||||
// DISASM-NEXT: calll 0x401210 <zed2+0x401210>
|
||||
// DISASM-NEXT: calll 0x4011e0 <bar2@plt>
|
||||
// DISASM-NEXT: calll 0x4011f0 <zed2@plt>
|
||||
// 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
|
||||
// DISASM-EMPTY:
|
||||
// DISASM-NEXT: Disassembly of section .plt:
|
||||
// DISASM-EMPTY:
|
||||
// DISASM-NEXT: <.plt>:
|
||||
// DISASM-NEXT: 4011d0: pushl 4207260
|
||||
// DISASM-NEXT: jmpl *4207264
|
||||
// DISASM-NEXT: 401200: pushl 0x4032d0
|
||||
// DISASM-NEXT: jmpl *0x4032d4
|
||||
// DISASM-NEXT: nop
|
||||
// DISASM-NEXT: nop
|
||||
// DISASM-NEXT: nop
|
||||
// DISASM-NEXT: nop
|
||||
// DISASM-EMPTY:
|
||||
// DISASM-NEXT: <bar2@plt>:
|
||||
// DISASM-NEXT: 4011e0: jmpl *4207268
|
||||
// DISASM-NEXT: pushl $0
|
||||
// DISASM-NEXT: jmp 0x4011d0 <.plt>
|
||||
// DISASM-NEXT: 401210: jmpl *0x4032d8
|
||||
// DISASM-NEXT: pushl $0x0
|
||||
// DISASM-NEXT: jmp 0x401200 <.plt>
|
||||
// DISASM-EMPTY:
|
||||
// DISASM-NEXT: <zed2@plt>:
|
||||
// DISASM-NEXT: 4011f0: jmpl *4207272
|
||||
// DISASM-NEXT: pushl $8
|
||||
// DISASM-NEXT: jmp 0x4011d0 <.plt>
|
||||
// DISASM-NEXT: 401220: jmpl *0x4032dc
|
||||
// DISASM-NEXT: pushl $0x8
|
||||
// DISASM-NEXT: jmp 0x401200 <.plt>
|
||||
// DISASM-EMPTY:
|
||||
// DISASM-NEXT: Disassembly of section .iplt:
|
||||
// DISASM-EMPTY:
|
||||
// DISASM-NEXT: <.iplt>:
|
||||
// DISASM-NEXT: jmpl *4207276
|
||||
// DISASM-NEXT: pushl $0
|
||||
// DISASM-NEXT: jmp 0x4011d0 <.plt>
|
||||
// DISASM-NEXT: jmpl *4207280
|
||||
// DISASM-NEXT: pushl $8
|
||||
// DISASM-NEXT: jmp 0x4011d0 <.plt>
|
||||
// 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>
|
||||
|
||||
.text
|
||||
.type foo STT_GNU_IFUNC
|
||||
|
@ -89,3 +95,4 @@ _start:
|
|||
call bar@plt
|
||||
call bar2@plt
|
||||
call zed2@plt
|
||||
movl bar3@GOT(%eax), %eax
|
||||
|
|
|
@ -1,77 +1,81 @@
|
|||
// REQUIRES: x86
|
||||
|
||||
/// For non-preemptable ifunc, place ifunc PLT entries after regular PLT entries.
|
||||
/// For non-preemptable ifunc, place ifunc PLT entries to the .iplt section.
|
||||
|
||||
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/shared2-x86-64.s -o %t1.o
|
||||
// RUN: ld.lld %t1.o --shared -soname=so -o %t.so
|
||||
// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
|
||||
// RUN: ld.lld --hash-style=sysv %t.so %t.o -o %tout
|
||||
// RUN: llvm-objdump -d --no-show-raw-insn %tout | FileCheck %s --check-prefix=DISASM
|
||||
// RUN: llvm-objdump -d --no-show-raw-insn --print-imm-hex %tout | FileCheck %s --check-prefix=DISASM
|
||||
// RUN: llvm-objdump -s %tout | FileCheck %s --check-prefix=GOTPLT
|
||||
// RUN: llvm-readobj -r --dynamic-table %tout | FileCheck %s
|
||||
|
||||
/// Check that the PLTRELSZ tag does not include the IRELATIVE relocations
|
||||
// CHECK: DynamicSection [
|
||||
// CHECK: 0x0000000000000008 RELASZ 48 (bytes)
|
||||
// CHECK: 0x0000000000000008 RELASZ 72 (bytes)
|
||||
// CHECK: 0x0000000000000002 PLTRELSZ 48 (bytes)
|
||||
|
||||
// Check that the IRELATIVE relocations are after the JUMP_SLOT in the plt
|
||||
// CHECK: Relocations [
|
||||
/// Check that the IRELATIVE relocations are placed to the .rela.dyn section after
|
||||
/// other regular relocations (e.g. GLOB_DAT).
|
||||
// CHECK: Relocations [
|
||||
// CHECK-NEXT: Section (4) .rela.dyn {
|
||||
// CHECK-NEXT: 0x203458 R_X86_64_IRELATIVE - 0x2012D8
|
||||
// CHECK-NEXT: 0x203460 R_X86_64_IRELATIVE - 0x2012D9
|
||||
// CHECK-NEXT: 0x202480 R_X86_64_GLOB_DAT bar3 0x0
|
||||
// CHECK-NEXT: 0x2034B0 R_X86_64_IRELATIVE - 0x201318
|
||||
// CHECK-NEXT: 0x2034B8 R_X86_64_IRELATIVE - 0x201319
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: Section (5) .rela.plt {
|
||||
// CHECK-NEXT: 0x203448 R_X86_64_JUMP_SLOT bar2 0x0
|
||||
// CHECK-NEXT: 0x203450 R_X86_64_JUMP_SLOT zed2 0x0
|
||||
// CHECK-NEXT: 0x2034A0 R_X86_64_JUMP_SLOT bar2 0x0
|
||||
// CHECK-NEXT: 0x2034A8 R_X86_64_JUMP_SLOT zed2 0x0
|
||||
// CHECK-NEXT: }
|
||||
|
||||
// Check that .got.plt entries point back to PLT header
|
||||
/// Check that .got.plt entries point back to PLT header
|
||||
// GOTPLT: Contents of section .got.plt:
|
||||
// GOTPLT-NEXT: 203430 40232000 00000000 00000000 00000000
|
||||
// GOTPLT-NEXT: 203440 00000000 00000000 06132000 00000000
|
||||
// GOTPLT-NEXT: 203450 16132000 00000000 00000000 00000000
|
||||
// GOTPLT-NEXT: 203460 00000000 00000000
|
||||
// GOTPLT-NEXT: 203488 90232000 00000000 00000000 00000000
|
||||
// GOTPLT-NEXT: 203498 00000000 00000000 56132000 00000000
|
||||
// GOTPLT-NEXT: 2034a8 66132000 00000000 00000000 00000000
|
||||
// GOTPLT-NEXT: 2034b8 00000000 00000000
|
||||
|
||||
// Check that a PLT header is written and the ifunc entries appear last
|
||||
/// Check that we have 2 PLT sections: one regular .plt section and one
|
||||
/// .iplt section for ifunc entries.
|
||||
// DISASM: Disassembly of section .text:
|
||||
// DISASM-EMPTY:
|
||||
// DISASM-NEXT: <foo>:
|
||||
// DISASM-NEXT: 2012d8: retq
|
||||
// DISASM-NEXT: 201318: retq
|
||||
// DISASM: <bar>:
|
||||
// DISASM-NEXT: 2012d9: retq
|
||||
// DISASM-NEXT: 201319: retq
|
||||
// DISASM: <_start>:
|
||||
// DISASM-NEXT: 2012da: callq 0x201320
|
||||
// DISASM-NEXT: 2012df: callq 0x201330
|
||||
// DISASM-NEXT: 20131a: callq 0x201370
|
||||
// DISASM-NEXT: 20131f: callq 0x201380
|
||||
// DISASM-NEXT: callq {{.*}} <bar2@plt>
|
||||
// DISASM-NEXT: callq {{.*}} <zed2@plt>
|
||||
// DISASM-NEXT: jmpq *0x114c(%rip)
|
||||
// DISASM-EMPTY:
|
||||
// DISASM-NEXT: Disassembly of section .plt:
|
||||
// DISASM-EMPTY:
|
||||
// DISASM-NEXT: <.plt>:
|
||||
// DISASM-NEXT: 2012f0: pushq 8514(%rip)
|
||||
// DISASM-NEXT: 2012f6: jmpq *8516(%rip)
|
||||
// DISASM-NEXT: 2012fc: nopl (%rax)
|
||||
// DISASM-NEXT: 201340: pushq 0x214a(%rip)
|
||||
// DISASM-NEXT: 201346: jmpq *0x214c(%rip)
|
||||
// DISASM-NEXT: 20134c: nopl (%rax)
|
||||
// DISASM-EMPTY:
|
||||
// DISASM-NEXT: <bar2@plt>:
|
||||
// DISASM-NEXT: 201300: jmpq *8514(%rip)
|
||||
// DISASM-NEXT: 201306: pushq $0
|
||||
// DISASM-NEXT: 20130b: jmp 0x2012f0 <.plt>
|
||||
// DISASM-NEXT: 201350: jmpq *0x214a(%rip)
|
||||
// DISASM-NEXT: 201356: pushq $0x0
|
||||
// DISASM-NEXT: 20135b: jmp 0x201340 <.plt>
|
||||
// DISASM-EMPTY:
|
||||
// DISASM-NEXT: <zed2@plt>:
|
||||
// DISASM-NEXT: 201310: jmpq *8506(%rip)
|
||||
// DISASM-NEXT: 201316: pushq $1
|
||||
// DISASM-NEXT: 20131b: jmp 0x2012f0 <.plt>
|
||||
// DISASM-NEXT: 201360: jmpq *0x2142(%rip)
|
||||
// DISASM-NEXT: 201366: pushq $0x1
|
||||
// DISASM-NEXT: 20136b: jmp 0x201340 <.plt>
|
||||
// DISASM-EMPTY:
|
||||
// DISASM-NEXT: Disassembly of section .iplt:
|
||||
// DISASM-EMPTY:
|
||||
// DISASM-NEXT: <.iplt>:
|
||||
// DISASM-NEXT: 201320: jmpq *8498(%rip)
|
||||
// DISASM-NEXT: 201326: pushq $0
|
||||
// DISASM-NEXT: 20132b: jmp 0x2012f0 <.plt>
|
||||
// DISASM-NEXT: 201330: jmpq *8490(%rip)
|
||||
// DISASM-NEXT: 201336: pushq $1
|
||||
// DISASM-NEXT: 20133b: jmp 0x2012f0 <.plt>
|
||||
// DISASM-NEXT: 201370: jmpq *0x213a(%rip)
|
||||
// DISASM-NEXT: 201376: pushq $0x0
|
||||
// DISASM-NEXT: 20137b: jmp 0x201340 <.plt>
|
||||
// DISASM-NEXT: 201380: jmpq *0x2132(%rip)
|
||||
// DISASM-NEXT: 201386: pushq $0x1
|
||||
// DISASM-NEXT: 20138b: jmp 0x201340 <.plt>
|
||||
|
||||
.text
|
||||
.type foo STT_GNU_IFUNC
|
||||
|
@ -90,3 +94,4 @@ _start:
|
|||
call bar
|
||||
call bar2
|
||||
call zed2
|
||||
jmp *bar3@GOTPCREL(%rip)
|
||||
|
|
Loading…
Reference in New Issue