2019-02-14 05:49:55 +08:00
|
|
|
// REQUIRES: x86
|
|
|
|
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
|
|
|
|
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/gnu-ifunc-canon-ro-pcrel.s -o %t-ro-pcrel.o
|
|
|
|
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/gnu-ifunc-canon-ro-abs.s -o %t-ro-abs.o
|
|
|
|
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/gnu-ifunc-canon-rw-addend.s -o %t-rw-addend.o
|
|
|
|
// RUN: ld.lld %t.o -o %t1
|
2019-08-13 17:43:40 +08:00
|
|
|
// RUN: llvm-readobj -r %t1 | FileCheck --check-prefix=IREL1 %s
|
2019-02-14 05:49:55 +08:00
|
|
|
// RUN: ld.lld %t.o %t-ro-pcrel.o -o %t2
|
2019-05-01 13:49:01 +08:00
|
|
|
// RUN: llvm-readobj -r %t2 | FileCheck --check-prefix=IREL1 %s
|
2019-02-14 05:49:55 +08:00
|
|
|
// RUN: ld.lld %t.o %t-ro-abs.o -o %t3
|
2019-05-01 13:49:01 +08:00
|
|
|
// RUN: llvm-readobj -r %t3 | FileCheck --check-prefix=IREL1 %s
|
2019-02-14 05:49:55 +08:00
|
|
|
// RUN: ld.lld %t.o %t-rw-addend.o -o %t4
|
2019-05-01 13:49:01 +08:00
|
|
|
// RUN: llvm-readobj -r %t4 | FileCheck --check-prefix=IREL1 %s
|
2019-02-14 05:49:55 +08:00
|
|
|
// RUN: llvm-objdump -s %t4 | FileCheck --check-prefix=DUMP %s
|
|
|
|
// RUN: ld.lld %t.o %t-rw-addend.o -o %t4a -z retpolineplt
|
2019-05-01 13:49:01 +08:00
|
|
|
// RUN: llvm-readobj -r %t4a | FileCheck --check-prefix=IREL1 %s
|
2019-02-14 05:49:55 +08:00
|
|
|
// RUN: llvm-objdump -s %t4a | FileCheck --check-prefix=DUMP2 %s
|
|
|
|
// RUN: ld.lld %t-ro-pcrel.o %t.o -o %t5
|
2019-05-01 13:49:01 +08:00
|
|
|
// RUN: llvm-readobj -r %t5 | FileCheck --check-prefix=IREL1 %s
|
2019-02-14 05:49:55 +08:00
|
|
|
// RUN: ld.lld %t-ro-abs.o %t.o -o %t6
|
2019-05-01 13:49:01 +08:00
|
|
|
// RUN: llvm-readobj -r %t6 | FileCheck --check-prefix=IREL1 %s
|
2019-02-14 05:49:55 +08:00
|
|
|
// RUN: ld.lld %t-rw-addend.o %t.o -o %t7
|
2019-05-01 13:49:01 +08:00
|
|
|
// RUN: llvm-readobj -r %t7 | FileCheck --check-prefix=IREL1 %s
|
2019-02-14 05:49:55 +08:00
|
|
|
// RUN: ld.lld %t.o -o %t8 -pie
|
2019-08-13 17:43:40 +08:00
|
|
|
// RUN: llvm-readobj -r %t8 | FileCheck --check-prefix=IREL1-REL2 %s
|
2019-02-14 05:49:55 +08:00
|
|
|
// RUN: ld.lld %t.o %t-ro-pcrel.o -o %t9 -pie
|
2019-05-01 13:49:01 +08:00
|
|
|
// RUN: llvm-readobj -r %t9 | FileCheck --check-prefix=IREL1-REL2 %s
|
2019-02-14 05:49:55 +08:00
|
|
|
// RUN: ld.lld %t.o %t-rw-addend.o -o %t10 -pie
|
2019-05-01 13:49:01 +08:00
|
|
|
// RUN: llvm-readobj -r %t10 | FileCheck --check-prefix=IREL1-REL3 %s
|
2019-02-14 05:49:55 +08:00
|
|
|
// RUN: ld.lld %t-ro-pcrel.o %t.o -o %t11 -pie
|
2019-05-01 13:49:01 +08:00
|
|
|
// RUN: llvm-readobj -r %t11 | FileCheck --check-prefix=IREL1-REL2 %s
|
2019-02-14 05:49:55 +08:00
|
|
|
// RUN: ld.lld %t-rw-addend.o %t.o -o %t12 -pie
|
2019-05-01 13:49:01 +08:00
|
|
|
// RUN: llvm-readobj -r %t12 | FileCheck --check-prefix=IREL1-REL3 %s
|
2019-02-14 05:49:55 +08:00
|
|
|
|
|
|
|
// One reloc for the canonical PLT.
|
|
|
|
// IREL1-NOT: R_X86_64_
|
2019-08-03 10:26:52 +08:00
|
|
|
// IREL1: .rela.dyn
|
2019-02-14 05:49:55 +08:00
|
|
|
// IREL1-NEXT: R_X86_64_IRELATIVE
|
|
|
|
// IREL1-NOT: R_X86_64_
|
|
|
|
|
|
|
|
// One reloc for the canonical PLT and two RELATIVE relocations pointing to it,
|
|
|
|
// one in the GOT and one in .data.
|
|
|
|
// IREL1-REL2-NOT: R_X86_64_
|
|
|
|
// IREL1-REL2: .rela.dyn
|
|
|
|
// IREL1-REL2-NEXT: R_X86_64_RELATIVE
|
|
|
|
// IREL1-REL2-NEXT: R_X86_64_RELATIVE
|
|
|
|
// IREL1-REL2-NEXT: R_X86_64_IRELATIVE
|
|
|
|
// IREL1-REL2-NOT: R_X86_64_
|
|
|
|
|
|
|
|
// One reloc for the canonical PLT and three RELATIVE relocations pointing to it,
|
|
|
|
// one in the GOT and two in .data.
|
|
|
|
// IREL1-REL3-NOT: R_X86_64_
|
|
|
|
// IREL1-REL3: .rela.dyn
|
|
|
|
// IREL1-REL3-NEXT: R_X86_64_RELATIVE
|
|
|
|
// IREL1-REL3-NEXT: R_X86_64_RELATIVE
|
|
|
|
// IREL1-REL3-NEXT: R_X86_64_RELATIVE
|
|
|
|
// IREL1-REL3-NEXT: R_X86_64_IRELATIVE
|
|
|
|
// IREL1-REL3-NOT: R_X86_64_
|
|
|
|
|
|
|
|
// Make sure the static relocations look right, both with and without headers.
|
2019-12-15 08:19:03 +08:00
|
|
|
// DUMP: Contents of section .iplt:
|
2019-09-16 15:05:34 +08:00
|
|
|
// DUMP-NEXT: 2011f0
|
2019-02-14 05:49:55 +08:00
|
|
|
// DUMP: Contents of section .got:
|
2019-09-16 15:05:34 +08:00
|
|
|
// DUMP-NEXT: 202200 f0112000 00000000
|
[ELF] Simplify RelRo, TLS, NOBITS section ranks and make RW PT_LOAD start with RelRo
Old: PT_LOAD(.data | PT_GNU_RELRO(.data.rel.ro .bss.rel.ro) | .bss)
New: PT_LOAD(PT_GNU_RELRO(.data.rel.ro .bss.rel.ro) | .data .bss)
The placement of | indicates page alignment caused by PT_GNU_RELRO. The
new layout has simpler rules and saves space for many cases.
Old size: roundup(.data) + roundup(.data.rel.ro)
New size: roundup(.data.rel.ro + .bss.rel.ro) + .data
Other advantages:
* At runtime the 3 memory mappings decrease to 2.
* start(PT_TLS) = start(PT_GNU_RELRO) = start(RW PT_LOAD). This
simplifies binary manipulation tools.
GNU strip before 2.31 discards PT_GNU_RELRO if its
address is not equal to the start of its associated PT_LOAD.
This has been fixed by https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f2731e0c374e5323ce4cdae2bcc7b7fe22da1a6f
But with this change, we will be compatible with GNU strip before 2.31
* Before, .got.plt (non-relro by default) was placed before .got (relro
by default), which made it impossible to have _GLOBAL_OFFSET_TABLE_
(start of .got.plt on x86-64) equal to the end of .got (R_GOT*_FROM_END)
(https://bugs.llvm.org/show_bug.cgi?id=36555). With the new ordering, we
can improve on this regard if we'd like to.
Reviewers: ruiu, espindola, pcc
Subscribers: emaste, arichardson, llvm-commits, joerg, jdoerfert
Differential Revision: https://reviews.llvm.org/D56828
llvm-svn: 356117
2019-03-14 11:47:45 +08:00
|
|
|
// DUMP: Contents of section .data:
|
2019-09-16 15:05:34 +08:00
|
|
|
// DUMP-NEXT: 203208 f0112000 00000000 f1112000 00000000
|
2019-02-14 05:49:55 +08:00
|
|
|
|
|
|
|
// DUMP2: Contents of section .plt:
|
2019-09-16 15:05:34 +08:00
|
|
|
// DUMP2-NEXT: 2011f0
|
2019-02-14 05:49:55 +08:00
|
|
|
// DUMP2: Contents of section .got:
|
2019-09-16 15:05:34 +08:00
|
|
|
// DUMP2-NEXT: 202240 20122000 00000000
|
[ELF] Simplify RelRo, TLS, NOBITS section ranks and make RW PT_LOAD start with RelRo
Old: PT_LOAD(.data | PT_GNU_RELRO(.data.rel.ro .bss.rel.ro) | .bss)
New: PT_LOAD(PT_GNU_RELRO(.data.rel.ro .bss.rel.ro) | .data .bss)
The placement of | indicates page alignment caused by PT_GNU_RELRO. The
new layout has simpler rules and saves space for many cases.
Old size: roundup(.data) + roundup(.data.rel.ro)
New size: roundup(.data.rel.ro + .bss.rel.ro) + .data
Other advantages:
* At runtime the 3 memory mappings decrease to 2.
* start(PT_TLS) = start(PT_GNU_RELRO) = start(RW PT_LOAD). This
simplifies binary manipulation tools.
GNU strip before 2.31 discards PT_GNU_RELRO if its
address is not equal to the start of its associated PT_LOAD.
This has been fixed by https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f2731e0c374e5323ce4cdae2bcc7b7fe22da1a6f
But with this change, we will be compatible with GNU strip before 2.31
* Before, .got.plt (non-relro by default) was placed before .got (relro
by default), which made it impossible to have _GLOBAL_OFFSET_TABLE_
(start of .got.plt on x86-64) equal to the end of .got (R_GOT*_FROM_END)
(https://bugs.llvm.org/show_bug.cgi?id=36555). With the new ordering, we
can improve on this regard if we'd like to.
Reviewers: ruiu, espindola, pcc
Subscribers: emaste, arichardson, llvm-commits, joerg, jdoerfert
Differential Revision: https://reviews.llvm.org/D56828
llvm-svn: 356117
2019-03-14 11:47:45 +08:00
|
|
|
// DUMP2: Contents of section .data:
|
2019-09-16 15:05:34 +08:00
|
|
|
// DUMP2-NEXT: 203248 20122000 00000000 21122000 00000000
|
2019-02-14 05:49:55 +08:00
|
|
|
|
|
|
|
lea ifunc@gotpcrel(%rip), %rbx
|
|
|
|
|
|
|
|
.type ifunc STT_GNU_IFUNC
|
|
|
|
.globl ifunc
|
|
|
|
ifunc:
|
|
|
|
ret
|
|
|
|
|
|
|
|
.data
|
|
|
|
.8byte ifunc
|