forked from OSchip/llvm-project
[ELF] Rename .plt to .iplt and decrease EM_PPC{,64} alignment of .glink to 4
GNU ld creates the synthetic section .iplt, and has a built-in linker script that assigns .iplt to the output section .plt . There is no output section named .iplt . Making .iplt an output section actually has a benefit that makes the tricky toolchain feature stand out. Symbolizers don't have to deal with mixed PLT entries (e.g. llvm-objdump -d incorrectly annotates such jump targets). On EM_PPC{,64}, .glink contains a PLT resolver and a series of jump instructions. The 4-byte entry size makes it unnecessary to have an alignment of 16. Mark ppc32-gnu-ifunc.s and ppc32-gnu-ifunc-nonpreemptable.s as `XFAIL: *`. They test IPLT on EM_PPC, which never works. Reviewed By: peter.smith Differential Revision: https://reviews.llvm.org/D71520
This commit is contained in:
parent
ba6f25d7d3
commit
345f59667d
|
@ -2450,6 +2450,7 @@ PltSection::PltSection()
|
|||
headerSize(target->pltHeaderSize) {
|
||||
if (config->emachine == EM_PPC || config->emachine == EM_PPC64) {
|
||||
name = ".glink";
|
||||
alignment = 4;
|
||||
}
|
||||
|
||||
// The PLT needs to be writable on SPARC as the dynamic linker will
|
||||
|
@ -2505,9 +2506,10 @@ void PltSection::addSymbols() {
|
|||
}
|
||||
|
||||
IpltSection::IpltSection()
|
||||
: SyntheticSection(SHF_ALLOC | SHF_EXECINSTR, SHT_PROGBITS, 16, ".plt") {
|
||||
: SyntheticSection(SHF_ALLOC | SHF_EXECINSTR, SHT_PROGBITS, 16, ".iplt") {
|
||||
if (config->emachine == EM_PPC || config->emachine == EM_PPC64) {
|
||||
name = ".glink";
|
||||
alignment = 4;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ main:
|
|||
# PDE-NEXT: 210178: add x8, x8, #384
|
||||
# PDE-NEXT: 21017c: ret
|
||||
# PDE-EMPTY:
|
||||
# PDE-NEXT: Disassembly of section .plt:
|
||||
# PDE-NEXT: Disassembly of section .iplt:
|
||||
# PDE-EMPTY:
|
||||
# PDE-NEXT: myfunc:
|
||||
## page(.got.plt) - page(0x210010) = 65536
|
||||
|
@ -59,7 +59,7 @@ main:
|
|||
# PIE-NEXT: 10268: add x8, x8, #624
|
||||
# PIE-NEXT: 1026c: ret
|
||||
# PIE-EMPTY:
|
||||
# PIE-NEXT: Disassembly of section .plt:
|
||||
# PIE-NEXT: Disassembly of section .iplt:
|
||||
# PIE-EMPTY:
|
||||
# PIE-NEXT: myfunc:
|
||||
# PIE-NEXT: 10270: adrp x16, #131072
|
||||
|
|
|
@ -39,8 +39,8 @@
|
|||
// DISASM: bar:
|
||||
// DISASM-NEXT: 2102dc: ret
|
||||
// DISASM: _start:
|
||||
// DISASM-NEXT: 2102e0: bl #80 <zed2@plt+0x10>
|
||||
// DISASM-NEXT: 2102e4: bl #92 <zed2@plt+0x20>
|
||||
// DISASM-NEXT: 2102e0: bl #80 <zed2+0x210330>
|
||||
// DISASM-NEXT: 2102e4: bl #92 <zed2+0x210340>
|
||||
// DISASM-NEXT: 2102e8: bl #40 <bar2@plt>
|
||||
// DISASM-NEXT: 2102ec: bl #52 <zed2@plt>
|
||||
// DISASM-EMPTY:
|
||||
|
@ -67,6 +67,10 @@
|
|||
// DISASM-NEXT: 210324: ldr x17, [x16, #1120]
|
||||
// DISASM-NEXT: 210328: add x16, x16, #1120
|
||||
// DISASM-NEXT: 21032c: br x17
|
||||
// DISASM-EMPTY:
|
||||
// DISASM-NEXT: Disassembly of section .iplt:
|
||||
// DISASM-EMPTY:
|
||||
// DISASM-NEXT: .iplt:
|
||||
// DISASM-NEXT: 210330: adrp x16, #131072
|
||||
// DISASM-NEXT: 210334: ldr x17, [x16, #1128]
|
||||
// DISASM-NEXT: 210338: add x16, x16, #1128
|
||||
|
|
|
@ -111,9 +111,9 @@
|
|||
// DISASM-NEXT: 210198: add x2, x2, #344
|
||||
// DISASM-NEXT: 21019c: add x2, x2, #392
|
||||
// DISASM-EMPTY:
|
||||
// DISASM-NEXT: Disassembly of section .plt:
|
||||
// DISASM-NEXT: Disassembly of section .iplt:
|
||||
// DISASM-EMPTY:
|
||||
// DISASM-NEXT: .plt:
|
||||
// DISASM-NEXT: .iplt:
|
||||
// DISASM-NEXT: 2101a0: adrp x16, #65536
|
||||
// DISASM-NEXT: 2101a4: ldr x17, [x16, #448]
|
||||
// DISASM-NEXT: 2101a8: add x16, x16, #448
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
# CHECK-NEXT: 210178: ldr x8, [x8, #0x190]
|
||||
# CHECK-NEXT: 21017c: ret
|
||||
|
||||
# CHECK: Disassembly of section .plt:
|
||||
# CHECK: Disassembly of section .iplt:
|
||||
# CHECK-EMPTY:
|
||||
# CHECK-NEXT: .plt:
|
||||
# CHECK-NEXT: .iplt:
|
||||
# .got.plt - page(0x210180) = 0x220190 - 0x210000 = 0x10190
|
||||
# CHECK-NEXT: 210180: adrp x16, #0x10000
|
||||
# CHECK-NEXT: 210184: ldr x17, [x16, #0x190]
|
||||
|
|
|
@ -27,8 +27,10 @@
|
|||
# CHECK-NEXT: add x16, x16, #1280
|
||||
# CHECK-NEXT: br x17
|
||||
# CHECK-NEXT: nop
|
||||
# CHECK-NEXT: ...
|
||||
# CHECK: 00000000000103c0 myfunc:
|
||||
# CHECK-EMPTY:
|
||||
# CHECK: Disassembly of section .iplt:
|
||||
# CHECK-EMPTY:
|
||||
# CHECK-NEXT: 00000000000103c0 myfunc:
|
||||
# CHECK-NEXT: 103c0: bti c
|
||||
# CHECK-NEXT: adrp x16, #131072
|
||||
# CHECK-NEXT: ldr x17, [x16, #1288]
|
||||
|
|
|
@ -37,7 +37,7 @@ _start:
|
|||
// CHECK-NEXT: Size: 16
|
||||
// CHECK-NEXT: Link:
|
||||
// CHECK-NEXT: Info: 4
|
||||
// CHECK: Name: .plt
|
||||
// CHECK: Name: .iplt
|
||||
// CHECK-NEXT: Type: SHT_PROGBITS
|
||||
// CHECK-NEXT: Flags [
|
||||
// CHECK-NEXT: SHF_ALLOC
|
||||
|
@ -128,7 +128,7 @@ _start:
|
|||
// DISASM-NEXT: 1111c: movw r0, #260
|
||||
// DISASM-NEXT: 11120: movt r0, #1
|
||||
// DISASM-EMPTY:
|
||||
// DISASM-NEXT: Disassembly of section .plt:
|
||||
// DISASM-NEXT: Disassembly of section .iplt:
|
||||
// DISASM-EMPTY:
|
||||
// DISASM-NEXT: $a:
|
||||
// DISASM-NEXT: 11130: add r12, pc, #0, #12
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
// IREL1-REL3-NOT: R_X86_64_
|
||||
|
||||
// Make sure the static relocations look right, both with and without headers.
|
||||
// DUMP: Contents of section .plt:
|
||||
// DUMP: Contents of section .iplt:
|
||||
// DUMP-NEXT: 2011f0
|
||||
// DUMP: Contents of section .got:
|
||||
// DUMP-NEXT: 202200 f0112000 00000000
|
||||
|
|
|
@ -75,7 +75,7 @@
|
|||
// CHECK-NEXT: Binding: Global
|
||||
// CHECK-NEXT: Type: Function
|
||||
// CHECK-NEXT: Other: 0
|
||||
// CHECK-NEXT: Section: .plt
|
||||
// CHECK-NEXT: Section: .iplt
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: Symbol {
|
||||
// CHECK-NEXT: Name: bar_resolver
|
||||
|
@ -93,7 +93,7 @@
|
|||
// CHECK-NEXT: Binding: Global
|
||||
// CHECK-NEXT: Type: Function
|
||||
// CHECK-NEXT: Other: 0
|
||||
// CHECK-NEXT: Section: .plt
|
||||
// CHECK-NEXT: Section: .iplt
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: Symbol {
|
||||
// CHECK-NEXT: Name: foo_resolver
|
||||
|
@ -118,16 +118,16 @@
|
|||
// DISASM-NEXT: movl $4194516, %edx
|
||||
// DISASM-NEXT: movl $4194532, %edx
|
||||
// DISASM-EMPTY:
|
||||
// DISASM-NEXT: Disassembly of section .plt:
|
||||
// DISASM-NEXT: Disassembly of section .iplt:
|
||||
// DISASM-EMPTY:
|
||||
// DISASM-NEXT: foo:
|
||||
// DISASM-NEXT: 401100: jmpl *4202784
|
||||
// DISASM-NEXT: pushl $0
|
||||
// DISASM-NEXT: jmp -16 <foo>
|
||||
// DISASM-NEXT: jmp -4198672
|
||||
// DISASM: bar:
|
||||
// DISASM-NEXT: 401110: jmpl *4202788
|
||||
// DISASM-NEXT: pushl $8
|
||||
// DISASM-NEXT: jmp -32 <foo>
|
||||
// DISASM-NEXT: jmp -4198688
|
||||
|
||||
.text
|
||||
.type foo STT_GNU_IFUNC
|
||||
|
|
|
@ -37,8 +37,8 @@
|
|||
// DISASM: bar:
|
||||
// DISASM-NEXT: 4011b5: retl
|
||||
// DISASM: _start:
|
||||
// DISASM-NEXT: 4011b6: calll 69 <zed2@plt+0x10>
|
||||
// DISASM-NEXT: calll 80 <zed2@plt+0x20>
|
||||
// DISASM-NEXT: 4011b6: calll 69 <zed2+0x401200>
|
||||
// DISASM-NEXT: calll 80 <zed2+0x401210>
|
||||
// DISASM-NEXT: calll 27 <bar2@plt>
|
||||
// DISASM-NEXT: calll 38 <zed2@plt>
|
||||
// DISASM-EMPTY:
|
||||
|
@ -61,6 +61,10 @@
|
|||
// DISASM-NEXT: 4011f0: jmpl *4207272
|
||||
// DISASM-NEXT: pushl $8
|
||||
// DISASM-NEXT: jmp -48 <.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 -64 <.plt>
|
||||
|
|
|
@ -62,6 +62,10 @@
|
|||
// DISASM-NEXT: 201310: jmpq *8506(%rip)
|
||||
// DISASM-NEXT: 201316: pushq $1
|
||||
// DISASM-NEXT: 20131b: jmp -48 <.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 -64 <.plt>
|
||||
|
|
|
@ -39,6 +39,9 @@
|
|||
// DISASM-NEXT: 1340: jmpq *8474(%rip)
|
||||
// DISASM-NEXT: 1346: pushq $1
|
||||
// DISASM-NEXT: 134b: jmp -48 <.plt>
|
||||
// DISASM: Disassembly of section .iplt:
|
||||
// DISASM-EMPTY:
|
||||
// DISASM: .iplt:
|
||||
// DISASM-NEXT: 1350: jmpq *8466(%rip)
|
||||
// DISASM-NEXT: 1356: pushq $0
|
||||
// DISASM-NEXT: 135b: jmp -64 <.plt>
|
||||
|
|
|
@ -102,15 +102,15 @@
|
|||
// DISASM-NEXT: 201199: {{.*}} movl $2097544, %edx
|
||||
// DISASM-NEXT: 20119e: {{.*}} movl $2097545, %edx
|
||||
// DISASM-EMPTY:
|
||||
// DISASM-NEXT: Disassembly of section .plt:
|
||||
// DISASM-NEXT: Disassembly of section .iplt:
|
||||
// DISASM-EMPTY:
|
||||
// DISASM-NEXT: .plt:
|
||||
// DISASM-NEXT: .iplt:
|
||||
// DISASM-NEXT: 2011b0: {{.*}} jmpq *4122(%rip)
|
||||
// DISASM-NEXT: 2011b6: {{.*}} pushq $0
|
||||
// DISASM-NEXT: 2011bb: {{.*}} jmp -16 <.plt>
|
||||
// DISASM-NEXT: 2011bb: {{.*}} jmp -2101696
|
||||
// DISASM-NEXT: 2011c0: {{.*}} jmpq *4114(%rip)
|
||||
// DISASM-NEXT: 2011c6: {{.*}} pushq $1
|
||||
// DISASM-NEXT: 2011cb: {{.*}} jmp -32 <.plt>
|
||||
// DISASM-NEXT: 2011cb: {{.*}} jmp -2101712
|
||||
|
||||
.text
|
||||
.type foo STT_GNU_IFUNC
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
# REPORT-NEXT: <internal>:(.rela.plt) is being placed in '.rela.plt'
|
||||
# REPORT-NEXT: <internal>:(.rela.dyn) is being placed in '.rela.dyn'
|
||||
# REPORT-NEXT: <internal>:(.plt) is being placed in '.plt'
|
||||
# REPORT-NEXT: <internal>:(.plt) is being placed in '.plt'
|
||||
# REPORT-NEXT: <internal>:(.iplt) is being placed in '.iplt'
|
||||
# REPORT-NEXT: <internal>:(.symtab) is being placed in '.symtab'
|
||||
# REPORT-NEXT: <internal>:(.symtab_shndx) is being placed in '.symtab_shndx'
|
||||
# REPORT-NEXT: <internal>:(.shstrtab) is being placed in '.shstrtab'
|
||||
|
|
|
@ -28,18 +28,18 @@
|
|||
# RELOC-NEXT: R_PPC_JMP_SLOT h 0x0
|
||||
# RELOC-NEXT: }
|
||||
|
||||
# SEC: .got PROGBITS 00020374
|
||||
# DYN: PPC_GOT 0x20374
|
||||
# SEC: .got PROGBITS 00020368
|
||||
# DYN: PPC_GOT 0x20368
|
||||
|
||||
## .got2+0x8000-0x10004 = 0x30000+0x8000-0x10004 = 65536*2+32764
|
||||
# CHECK-LABEL: _start:
|
||||
# CHECK-NEXT: bcl 20, 31, .+4
|
||||
# PIE-NEXT: 10210: mflr 30
|
||||
# PIE-NEXT: addis 30, 30, 3
|
||||
# PIE-NEXT: addi 30, 30, -32400
|
||||
# PIE-NEXT: addi 30, 30, -32412
|
||||
# SHARED-NEXT: 10230: mflr 30
|
||||
# SHARED-NEXT: addis 30, 30, 3
|
||||
# SHARED-NEXT: addi 30, 30, -32408
|
||||
# SHARED-NEXT: addi 30, 30, -32420
|
||||
|
||||
## Two bl 00008000.got2.plt_pic32.f
|
||||
# CHECK-NEXT: bl .+40
|
||||
|
@ -94,11 +94,11 @@
|
|||
# CHECK-NEXT: 00008000.got2.plt_pic32.f:
|
||||
|
||||
## In Secure PLT ABI, .plt stores function pointers to first instructions of .glink
|
||||
# HEX: 0x00040378 000102a0 000102a4 000102a8
|
||||
# HEX: 0x0004036c 00010294 00010298 0001029c
|
||||
|
||||
## These instructions are referenced by .plt entries.
|
||||
# PIE: 000102a0 .glink:
|
||||
# SHARED: 000102c0 .glink:
|
||||
# PIE: 00010294 .glink:
|
||||
# SHARED: 000102b4 .glink:
|
||||
# CHECK-NEXT: b .+12
|
||||
# CHECK-NEXT: b .+8
|
||||
# CHECK-NEXT: b .+4
|
||||
|
@ -108,8 +108,8 @@
|
|||
# CHECK-NEXT: addis 11, 11, 0
|
||||
# CHECK-NEXT: mflr 0
|
||||
# CHECK-NEXT: bcl 20, 31, .+4
|
||||
# PIE-NEXT: 102b8: addi 11, 11, 24
|
||||
# SHARED-NEXT: 102d8: addi 11, 11, 24
|
||||
# PIE-NEXT: 102ac: addi 11, 11, 24
|
||||
# SHARED-NEXT: 102cc: addi 11, 11, 24
|
||||
|
||||
# CHECK-NEXT: mflr 12
|
||||
# CHECK-NEXT: mtlr 0
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# REQUIRES: ppc
|
||||
# REQUIRES: ppc, asserts
|
||||
# XFAIL: *
|
||||
# RUN: llvm-mc -filetype=obj -triple=powerpc %s -o %t.o
|
||||
# RUN: ld.lld %t.o -o %t
|
||||
# RUN: llvm-readobj -r %t | FileCheck --check-prefix=RELOC %s
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# REQUIRES: ppc
|
||||
# XFAIL: *
|
||||
# RUN: llvm-mc -filetype=obj -triple=powerpc %s -o %t.o
|
||||
# RUN: ld.lld %t.o -o %t
|
||||
# RUN: llvm-readobj -r %t | FileCheck --check-prefix=RELOC %s
|
||||
|
|
|
@ -18,15 +18,15 @@
|
|||
# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=IE %s
|
||||
|
||||
## DT_PPC_GOT represents the address of _GLOBAL_OFFSET_TABLE_.
|
||||
# GD-DYN: PPC_GOT 0x2035C
|
||||
# GD-DYN: PPC_GOT 0x20358
|
||||
|
||||
# GD-REL: .rela.dyn {
|
||||
# GD-REL-NEXT: 0x2035C R_PPC_DTPMOD32 a 0x0
|
||||
# GD-REL-NEXT: 0x20360 R_PPC_DTPREL32 a 0x0
|
||||
# GD-REL-NEXT: 0x20364 R_PPC_DTPMOD32 b 0x0
|
||||
# GD-REL-NEXT: 0x20368 R_PPC_DTPREL32 b 0x0
|
||||
# GD-REL-NEXT: 0x2036C R_PPC_DTPMOD32 c 0x0
|
||||
# GD-REL-NEXT: 0x20370 R_PPC_DTPREL32 c 0x0
|
||||
# GD-REL-NEXT: 0x20358 R_PPC_DTPMOD32 a 0x0
|
||||
# GD-REL-NEXT: 0x2035C R_PPC_DTPREL32 a 0x0
|
||||
# GD-REL-NEXT: 0x20360 R_PPC_DTPMOD32 b 0x0
|
||||
# GD-REL-NEXT: 0x20364 R_PPC_DTPREL32 b 0x0
|
||||
# GD-REL-NEXT: 0x20368 R_PPC_DTPMOD32 c 0x0
|
||||
# GD-REL-NEXT: 0x2036C R_PPC_DTPREL32 c 0x0
|
||||
# GD-REL-NEXT: }
|
||||
|
||||
## &DTPMOD(a) - _GLOBAL_OFFSET_TABLE_ = 0x20078 - 0x20078 = 0
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=LE %s
|
||||
|
||||
# LD-REL: .rela.dyn {
|
||||
# LD-REL-NEXT: 0x202CC R_PPC_DTPMOD32 - 0x0
|
||||
# LD-REL-NEXT: 0x202C4 R_PPC_DTPMOD32 - 0x0
|
||||
# LD-REL-NEXT: }
|
||||
|
||||
## .got - _GLOBAL_OFFSET_TABLE_ = 0
|
||||
|
|
|
@ -140,12 +140,12 @@ k:
|
|||
// The got entry for i is at .got+8*1 = 0x4209e0
|
||||
// i@dtprel = 1024 - 0x8000 = -31744 = 0xffffffffffff8400
|
||||
// HEX-LE: section '.got':
|
||||
// HEX-LE-NEXT: 4209d8 d8894200 00000000 00000000 00000000
|
||||
// HEX-LE-NEXT: 4209e8 00000000 00000000
|
||||
// HEX-LE-NEXT: 4209d0 d0894200 00000000 00000000 00000000
|
||||
// HEX-LE-NEXT: 4209e0 00000000 00000000
|
||||
|
||||
// HEX-BE: section '.got':
|
||||
// HEX-BE-NEXT: 4209d8 00000000 004289d8 00000000 00000000
|
||||
// HEX-BE-NEXT: 4209e8 00000000 00000000
|
||||
// HEX-BE-NEXT: 4209d0 00000000 004289d0 00000000 00000000
|
||||
// HEX-BE-NEXT: 4209e0 00000000 00000000
|
||||
|
||||
// Dis: test:
|
||||
// Dis: addi 4, 3, -31744
|
||||
|
|
|
@ -14,15 +14,15 @@
|
|||
## to the address of the canonical PLT is fixed.
|
||||
|
||||
# SEC: .text PROGBITS 00000000100101e0
|
||||
# SEC: .plt NOBITS 0000000010030200
|
||||
# SEC: 00000000100101f0 0 FUNC GLOBAL DEFAULT 3 ifunc
|
||||
# SEC: .plt NOBITS 00000000100301f8
|
||||
# SEC: 00000000100101e8 0 FUNC GLOBAL DEFAULT 3 ifunc
|
||||
|
||||
## .toc[0] stores the address of the canonical PLT.
|
||||
# HEX: section '.toc':
|
||||
# HEX-NEXT: 0x100201f8 f0010110 00000000
|
||||
# HEX-NEXT: 0x100201f0 e8010110 00000000
|
||||
|
||||
# REL: .rela.dyn {
|
||||
# REL-NEXT: 0x10030200 R_PPC64_IRELATIVE - 0x100101e8
|
||||
# REL-NEXT: 0x100301f8 R_PPC64_IRELATIVE - 0x100101e8
|
||||
# REL-NEXT: }
|
||||
|
||||
# DIS: addi 3, 3,
|
||||
|
|
Loading…
Reference in New Issue