brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.2 KiB · 58fae80 Raw
112 lines · plain
1// REQUIRES: x862 3/// For non-preemptable ifunc, place ifunc PLT entries to the .iplt section.4 5// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/shared2-x86-64.s -o %t1.o6// RUN: ld.lld %t1.o --shared -soname=so -o %t.so7// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o8// RUN: ld.lld --hash-style=sysv %t.so %t.o -o %tout9// RUN: llvm-objdump -d --no-show-raw-insn --print-imm-hex %tout | FileCheck %s --check-prefix=DISASM10// RUN: llvm-objdump -s %tout | FileCheck %s --check-prefix=GOTPLT11// RUN: llvm-readobj -r --dynamic-table %tout | FileCheck %s12 13/// Check that the PLTRELSZ tag does not include the IRELATIVE relocations14// CHECK: DynamicSection [15// CHECK:   0x0000000000000008 RELASZ               72 (bytes)16// CHECK:   0x0000000000000002 PLTRELSZ             48 (bytes)17 18/// Check that the IRELATIVE relocations are placed to the .rela.dyn section after19/// other regular relocations (e.g. GLOB_DAT).20// CHECK:      Relocations [21// CHECK-NEXT:   Section (4) .rela.dyn {22// CHECK-NEXT:     0x202480 R_X86_64_GLOB_DAT bar3 0x023// CHECK-NEXT:     0x2034B0 R_X86_64_IRELATIVE - 0x20131824// CHECK-NEXT:     0x2034B8 R_X86_64_IRELATIVE - 0x20131925// CHECK-NEXT:   }26// CHECK-NEXT:   Section (5) .rela.plt {27// CHECK-NEXT:     0x2034A0 R_X86_64_JUMP_SLOT bar2 0x028// CHECK-NEXT:     0x2034A8 R_X86_64_JUMP_SLOT zed2 0x029// CHECK-NEXT:   }30 31/// Check that .got.plt entries point back to PLT header32// GOTPLT: Contents of section .got.plt:33// GOTPLT-NEXT:  203488 90232000 00000000 00000000 0000000034// GOTPLT-NEXT:  203498 00000000 00000000 56132000 0000000035// GOTPLT-NEXT:  2034a8 66132000 00000000 00000000 0000000036// GOTPLT-NEXT:  2034b8 00000000 0000000037 38/// Check that we have 2 PLT sections: one regular .plt section and one39/// .iplt section for ifunc entries.40// DISASM: Disassembly of section .text:41// DISASM-EMPTY:42// DISASM-NEXT: <foo>:43// DISASM-NEXT:   201318:       retq44// DISASM:      <bar>:45// DISASM-NEXT:   201319:       retq46// DISASM:      <_start>:47// DISASM-NEXT:   20131a:       callq   0x20137048// DISASM-NEXT:   20131f:       callq   0x20138049// DISASM-NEXT:                 callq   {{.*}} <bar2@plt>50// DISASM-NEXT:                 callq   {{.*}} <zed2@plt>51// DISASM-NEXT:                 jmpq    *0x114c(%rip)52// DISASM-EMPTY:53// DISASM-NEXT: Disassembly of section .plt:54// DISASM-EMPTY:55// DISASM-NEXT: <.plt>:56// DISASM-NEXT:   201340:       pushq   0x214a(%rip)57// DISASM-NEXT:   201346:       jmpq    *0x214c(%rip)58// DISASM-NEXT:   20134c:       nopl    (%rax)59// DISASM-EMPTY:60// DISASM-NEXT:   <bar2@plt>:61// DISASM-NEXT:   201350:       jmpq    *0x214a(%rip)62// DISASM-NEXT:   201356:       pushq   $0x063// DISASM-NEXT:   20135b:       jmp     0x201340 <.plt>64// DISASM-EMPTY:65// DISASM-NEXT:   <zed2@plt>:66// DISASM-NEXT:   201360:       jmpq    *0x2142(%rip)67// DISASM-NEXT:   201366:       pushq   $0x168// DISASM-NEXT:   20136b:       jmp     0x201340 <.plt>69// DISASM-EMPTY:70// DISASM-NEXT: Disassembly of section .iplt:71// DISASM-EMPTY:72// DISASM-NEXT: <.iplt>:73// DISASM-NEXT:   201370:       jmpq    *0x213a(%rip)74// DISASM-NEXT:   201376:       pushq   $0x075// DISASM-NEXT:   20137b:       jmp     0x201340 <.plt>76// DISASM-NEXT:   201380:       jmpq    *0x2132(%rip)77// DISASM-NEXT:   201386:       pushq   $0x178// DISASM-NEXT:   20138b:       jmp     0x201340 <.plt>79 80// Test that --shuffle-sections does not affect the order of relocations and that81// we still place IRELATIVE relocations last. Check both random seed (0) and an82// arbitrary seed that was known to break the order of relocations previously (3).83// RUN: ld.lld --shuffle-sections='*=3' %t.so %t.o -o %tout284// RUN: llvm-readobj --relocations %tout2 | FileCheck %s --check-prefix=SHUFFLE85// RUN: ld.lld --shuffle-sections='*=0' %t.so %t.o -o %tout386// RUN: llvm-readobj --relocations %tout3 | FileCheck %s --check-prefix=SHUFFLE87 88// SHUFFLE:      Section {{.*}} .rela.dyn {89// SHUFFLE-NEXT:   R_X86_64_GLOB_DAT90// SHUFFLE-NEXT:   R_X86_64_IRELATIVE91// SHUFFLE-NEXT:   R_X86_64_IRELATIVE92// SHUFFLE-NEXT: }93 94.text95.type foo STT_GNU_IFUNC96.globl foo97foo:98 ret99 100.type bar STT_GNU_IFUNC101.globl bar102bar:103 ret104 105.globl _start106_start:107 call foo108 call bar109 call bar2110 call zed2111 jmp *bar3@GOTPCREL(%rip)112