2018-06-27 06:20:04 +08:00
|
|
|
// REQUIRES: x86
|
2015-09-21 23:11:29 +08:00
|
|
|
// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
|
|
|
|
// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/shared.s -o %t2.o
|
2015-11-18 14:11:01 +08:00
|
|
|
// RUN: ld.lld -shared %t2.o -o %t2.so
|
|
|
|
// RUN: ld.lld -shared %t.o %t2.so -o %t
|
|
|
|
// RUN: ld.lld %t.o %t2.so -o %t3
|
2019-05-01 13:49:01 +08:00
|
|
|
// RUN: llvm-readobj -S -r %t | FileCheck %s
|
2015-09-21 23:11:29 +08:00
|
|
|
// RUN: llvm-objdump -d %t | FileCheck --check-prefix=DISASM %s
|
2019-05-01 13:49:01 +08:00
|
|
|
// RUN: llvm-readobj -S -r %t3 | FileCheck --check-prefix=CHECK2 %s
|
2015-10-17 07:52:24 +08:00
|
|
|
// RUN: llvm-objdump -d %t3 | FileCheck --check-prefix=DISASM2 %s
|
|
|
|
|
2015-09-21 23:11:29 +08:00
|
|
|
// CHECK: Name: .plt
|
|
|
|
// CHECK-NEXT: Type: SHT_PROGBITS
|
|
|
|
// CHECK-NEXT: Flags [
|
|
|
|
// CHECK-NEXT: SHF_ALLOC
|
|
|
|
// CHECK-NEXT: SHF_EXECINSTR
|
|
|
|
// CHECK-NEXT: ]
|
2015-10-11 07:25:39 +08:00
|
|
|
// CHECK-NEXT: Address: 0x1020
|
2015-09-21 23:11:29 +08:00
|
|
|
// CHECK-NEXT: Offset:
|
2015-10-20 16:54:27 +08:00
|
|
|
// CHECK-NEXT: Size: 64
|
2015-09-21 23:11:29 +08:00
|
|
|
// CHECK-NEXT: Link: 0
|
|
|
|
// CHECK-NEXT: Info: 0
|
|
|
|
// CHECK-NEXT: AddressAlignment: 16
|
|
|
|
|
|
|
|
// CHECK: Relocations [
|
2015-10-20 16:54:27 +08:00
|
|
|
// CHECK-NEXT: Section ({{.*}}) .rela.plt {
|
[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
|
|
|
// CHECK-NEXT: 0x3018 R_X86_64_JUMP_SLOT bar 0x0
|
|
|
|
// CHECK-NEXT: 0x3020 R_X86_64_JUMP_SLOT zed 0x0
|
|
|
|
// CHECK-NEXT: 0x3028 R_X86_64_JUMP_SLOT _start 0x0
|
2015-09-21 23:11:29 +08:00
|
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK-NEXT: ]
|
|
|
|
|
2015-10-17 07:52:24 +08:00
|
|
|
// CHECK2: Name: .plt
|
|
|
|
// CHECK2-NEXT: Type: SHT_PROGBITS
|
|
|
|
// CHECK2-NEXT: Flags [
|
|
|
|
// CHECK2-NEXT: SHF_ALLOC
|
|
|
|
// CHECK2-NEXT: SHF_EXECINSTR
|
|
|
|
// CHECK2-NEXT: ]
|
2016-11-24 01:44:02 +08:00
|
|
|
// CHECK2-NEXT: Address: 0x201020
|
2015-10-17 07:52:24 +08:00
|
|
|
// CHECK2-NEXT: Offset:
|
2015-10-20 16:54:27 +08:00
|
|
|
// CHECK2-NEXT: Size: 48
|
2015-10-17 07:52:24 +08:00
|
|
|
// CHECK2-NEXT: Link: 0
|
|
|
|
// CHECK2-NEXT: Info: 0
|
|
|
|
// CHECK2-NEXT: AddressAlignment: 16
|
|
|
|
|
|
|
|
// CHECK2: Relocations [
|
2015-10-20 16:54:27 +08:00
|
|
|
// CHECK2-NEXT: Section ({{.*}}) .rela.plt {
|
[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
|
|
|
// CHECK2-NEXT: 0x203018 R_X86_64_JUMP_SLOT bar 0x0
|
|
|
|
// CHECK2-NEXT: 0x203020 R_X86_64_JUMP_SLOT zed 0x0
|
2015-10-17 07:52:24 +08:00
|
|
|
// CHECK2-NEXT: }
|
|
|
|
// CHECK2-NEXT: ]
|
|
|
|
|
2015-09-21 23:11:29 +08:00
|
|
|
// Unfortunately FileCheck can't do math, so we have to check for explicit
|
|
|
|
// values:
|
|
|
|
|
2015-10-20 16:54:27 +08:00
|
|
|
// 0x1030 - (0x1000 + 5) = 43
|
|
|
|
// 0x1030 - (0x1005 + 5) = 38
|
|
|
|
// 0x1040 - (0x100a + 5) = 49
|
|
|
|
// 0x1048 - (0x100a + 5) = 60
|
2015-09-21 23:11:29 +08:00
|
|
|
|
|
|
|
// DISASM: _start:
|
2015-10-20 16:54:27 +08:00
|
|
|
// DISASM-NEXT: 1000: e9 {{.*}} jmp 43
|
|
|
|
// DISASM-NEXT: 1005: e9 {{.*}} jmp 38
|
|
|
|
// DISASM-NEXT: 100a: e9 {{.*}} jmp 49
|
|
|
|
// DISASM-NEXT: 100f: e9 {{.*}} jmp 60
|
2015-09-21 23:11:29 +08:00
|
|
|
|
[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
|
|
|
// 0x3018 - 0x1036 = 8162
|
|
|
|
// 0x3020 - 0x1046 = 8154
|
|
|
|
// 0x3028 - 0x1056 = 8146
|
2015-09-21 23:11:29 +08:00
|
|
|
|
|
|
|
// DISASM: Disassembly of section .plt:
|
2019-05-01 18:40:48 +08:00
|
|
|
// DISASM-EMPTY:
|
2015-09-21 23:11:29 +08:00
|
|
|
// DISASM-NEXT: .plt:
|
[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
|
|
|
// DISASM-NEXT: 1020: ff 35 e2 1f 00 00 pushq 8162(%rip)
|
|
|
|
// DISASM-NEXT: 1026: ff 25 e4 1f 00 00 jmpq *8164(%rip)
|
2015-10-20 16:54:27 +08:00
|
|
|
// DISASM-NEXT: 102c: 0f 1f 40 00 nopl (%rax)
|
2018-08-25 00:22:42 +08:00
|
|
|
// DISASM-EMPTY:
|
|
|
|
// DISASM-NEXT: bar@plt:
|
[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
|
|
|
// DISASM-NEXT: 1030: ff 25 e2 1f 00 00 jmpq *8162(%rip)
|
2015-10-20 16:54:27 +08:00
|
|
|
// DISASM-NEXT: 1036: 68 00 00 00 00 pushq $0
|
2015-11-18 12:37:23 +08:00
|
|
|
// DISASM-NEXT: 103b: e9 e0 ff ff ff jmp -32 <.plt>
|
2018-08-25 00:22:42 +08:00
|
|
|
// DISASM-EMPTY:
|
|
|
|
// DISASM-NEXT: zed@plt:
|
[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
|
|
|
// DISASM-NEXT: 1040: ff 25 da 1f 00 00 jmpq *8154(%rip)
|
2015-10-20 16:54:27 +08:00
|
|
|
// DISASM-NEXT: 1046: 68 01 00 00 00 pushq $1
|
2015-11-18 12:37:23 +08:00
|
|
|
// DISASM-NEXT: 104b: e9 d0 ff ff ff jmp -48 <.plt>
|
2018-08-25 00:22:42 +08:00
|
|
|
// DISASM-EMPTY:
|
|
|
|
// DISASM-NEXT: _start@plt:
|
[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
|
|
|
// DISASM-NEXT: 1050: ff 25 d2 1f 00 00 jmpq *8146(%rip)
|
2015-10-20 16:54:27 +08:00
|
|
|
// DISASM-NEXT: 1056: 68 02 00 00 00 pushq $2
|
2015-11-18 12:37:23 +08:00
|
|
|
// DISASM-NEXT: 105b: e9 c0 ff ff ff jmp -64 <.plt>
|
2015-10-17 07:52:24 +08:00
|
|
|
|
2016-11-24 01:44:02 +08:00
|
|
|
// 0x201030 - (0x201000 + 1) - 4 = 43
|
|
|
|
// 0x201030 - (0x201005 + 1) - 4 = 38
|
|
|
|
// 0x201040 - (0x20100a + 1) - 4 = 49
|
|
|
|
// 0x201000 - (0x20100f + 1) - 4 = -20
|
2015-10-17 07:52:24 +08:00
|
|
|
|
|
|
|
// DISASM2: _start:
|
2016-11-24 01:44:02 +08:00
|
|
|
// DISASM2-NEXT: 201000: e9 {{.*}} jmp 43
|
|
|
|
// DISASM2-NEXT: 201005: e9 {{.*}} jmp 38
|
|
|
|
// DISASM2-NEXT: 20100a: e9 {{.*}} jmp 49
|
|
|
|
// DISASM2-NEXT: 20100f: e9 {{.*}} jmp -20
|
2015-10-17 07:52:24 +08:00
|
|
|
|
2017-01-10 09:21:30 +08:00
|
|
|
// 0x202018 - 0x201036 = 4066
|
|
|
|
// 0x202020 - 0x201046 = 4058
|
2015-10-20 16:54:27 +08:00
|
|
|
|
2015-10-17 07:52:24 +08:00
|
|
|
// DISASM2: Disassembly of section .plt:
|
2019-05-01 18:40:48 +08:00
|
|
|
// DISASM2-EMPTY:
|
2015-10-17 07:52:24 +08:00
|
|
|
// DISASM2-NEXT: .plt:
|
[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
|
|
|
// DISASM2-NEXT: 201020: ff 35 e2 1f 00 00 pushq 8162(%rip)
|
|
|
|
// DISASM2-NEXT: 201026: ff 25 e4 1f 00 00 jmpq *8164(%rip)
|
2016-11-24 01:44:02 +08:00
|
|
|
// DISASM2-NEXT: 20102c: 0f 1f 40 00 nopl (%rax)
|
2018-08-25 00:22:42 +08:00
|
|
|
// DISASM2-EMPTY:
|
|
|
|
// DISASM2-NEXT: bar@plt:
|
[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
|
|
|
// DISASM2-NEXT: 201030: ff 25 e2 1f 00 00 jmpq *8162(%rip)
|
2016-11-24 01:44:02 +08:00
|
|
|
// DISASM2-NEXT: 201036: 68 00 00 00 00 pushq $0
|
|
|
|
// DISASM2-NEXT: 20103b: e9 e0 ff ff ff jmp -32 <.plt>
|
2018-08-25 00:22:42 +08:00
|
|
|
// DISASM2-EMPTY:
|
|
|
|
// DISASM2-NEXT: zed@plt:
|
[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
|
|
|
// DISASM2-NEXT: 201040: ff 25 da 1f 00 00 jmpq *8154(%rip)
|
2016-11-24 01:44:02 +08:00
|
|
|
// DISASM2-NEXT: 201046: 68 01 00 00 00 pushq $1
|
|
|
|
// DISASM2-NEXT: 20104b: e9 d0 ff ff ff jmp -48 <.plt>
|
|
|
|
// DISASM2-NOT: 2010C0
|
2015-09-21 23:11:29 +08:00
|
|
|
|
|
|
|
.global _start
|
|
|
|
_start:
|
|
|
|
jmp bar@PLT
|
|
|
|
jmp bar@PLT
|
|
|
|
jmp zed@PLT
|
2015-09-29 03:48:34 +08:00
|
|
|
jmp _start@plt
|