2015-10-16 01:11:03 +08:00
|
|
|
// REQUIRES: x86
|
|
|
|
// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
|
2017-10-06 17:37:44 +08:00
|
|
|
// RUN: ld.lld --hash-style=sysv %t -o %tout -shared
|
2015-10-16 01:11:03 +08:00
|
|
|
// RUN: llvm-objdump -d %tout | FileCheck -check-prefix=DISASM %s
|
2015-10-19 23:21:42 +08:00
|
|
|
// RUN: llvm-readobj -symbols -r %tout | FileCheck -check-prefix=SYMBOL %s
|
2015-10-16 01:11:03 +08:00
|
|
|
|
|
|
|
// DISASM: _start:
|
2015-10-19 23:21:42 +08:00
|
|
|
// DISASM: 1000: {{.*}} callq 10
|
|
|
|
// DISASM: 1005: {{.*}} callq 8
|
|
|
|
// DISASM: 100a: {{.*}} callq 3
|
2015-10-16 01:11:03 +08:00
|
|
|
// DISASM: Disassembly of section foo:
|
|
|
|
// DISASM: __start_foo:
|
2015-10-19 23:21:42 +08:00
|
|
|
// DISASM: 100f: 90 nop
|
|
|
|
// DISASM: 1010: 90 nop
|
|
|
|
// DISASM: 1011: 90 nop
|
2015-10-16 01:11:03 +08:00
|
|
|
// DISASM: Disassembly of section bar:
|
|
|
|
// DISASM: __start_bar:
|
2015-10-19 23:21:42 +08:00
|
|
|
// DISASM: 1012: 90 nop
|
|
|
|
// DISASM: 1013: 90 nop
|
|
|
|
// DISASM: 1014: 90 nop
|
|
|
|
|
2016-04-14 00:33:02 +08:00
|
|
|
// SYMBOL: Relocations [
|
|
|
|
// SYMBOL-NEXT: Section ({{.*}}) .rela.dyn {
|
2018-03-20 22:22:10 +08:00
|
|
|
// SYMBOL-NEXT: R_X86_64_RELATIVE
|
|
|
|
// SYMBOL-NEXT: R_X86_64_RELATIVE
|
|
|
|
// SYMBOL-NEXT: R_X86_64_RELATIVE
|
|
|
|
// SYMBOL-NEXT: R_X86_64_RELATIVE
|
2016-04-14 00:33:02 +08:00
|
|
|
// SYMBOL-NEXT: }
|
2015-10-19 23:21:42 +08:00
|
|
|
// SYMBOL-NEXT: ]
|
2015-10-16 01:11:03 +08:00
|
|
|
|
|
|
|
// SYMBOL: Symbol {
|
|
|
|
// SYMBOL: Name: __start_bar
|
2015-10-19 23:21:42 +08:00
|
|
|
// SYMBOL: Value: 0x1012
|
2016-08-19 23:36:32 +08:00
|
|
|
// SYMBOL: STV_HIDDEN
|
2015-10-16 01:11:03 +08:00
|
|
|
// SYMBOL: Section: bar
|
|
|
|
// SYMBOL: }
|
|
|
|
// SYMBOL-NOT: Section: __stop_bar
|
|
|
|
// SYMBOL: Symbol {
|
|
|
|
// SYMBOL: Name: __start_foo
|
2015-10-19 23:21:42 +08:00
|
|
|
// SYMBOL: Value: 0x100F
|
2016-08-19 23:36:32 +08:00
|
|
|
// SYMBOL: STV_HIDDEN
|
2015-10-16 01:11:03 +08:00
|
|
|
// SYMBOL: Section: foo
|
|
|
|
// SYMBOL: }
|
|
|
|
// SYMBOL: Symbol {
|
|
|
|
// SYMBOL: Name: __stop_foo
|
2015-10-19 23:21:42 +08:00
|
|
|
// SYMBOL: Value: 0x1012
|
2018-03-20 22:22:10 +08:00
|
|
|
// SYMBOL: STV_HIDDEN
|
2015-10-19 23:21:42 +08:00
|
|
|
// SYMBOL: Section: foo
|
2015-10-16 01:11:03 +08:00
|
|
|
// SYMBOL: }
|
|
|
|
|
2016-08-19 23:36:32 +08:00
|
|
|
// SYMBOL: Symbol {
|
|
|
|
// SYMBOL: Name: __stop_zed1
|
[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
|
|
|
// SYMBOL: Value: 0x3010
|
2018-03-20 22:22:10 +08:00
|
|
|
// SYMBOL: STV_PROTECTED
|
2016-08-19 23:36:32 +08:00
|
|
|
// SYMBOL: Section: zed1
|
|
|
|
// SYMBOL: }
|
|
|
|
// SYMBOL: Symbol {
|
|
|
|
// SYMBOL: Name: __stop_zed2
|
[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
|
|
|
// SYMBOL: Value: 0x3020
|
2018-03-20 22:22:10 +08:00
|
|
|
// SYMBOL: STV_PROTECTED
|
2016-08-19 23:36:32 +08:00
|
|
|
// SYMBOL: Section: zed2
|
|
|
|
// SYMBOL: }
|
|
|
|
|
2015-10-19 23:21:42 +08:00
|
|
|
.hidden __start_foo
|
|
|
|
.hidden __stop_foo
|
|
|
|
.hidden __start_bar
|
2015-10-16 01:11:03 +08:00
|
|
|
.global _start
|
|
|
|
.text
|
|
|
|
_start:
|
|
|
|
call __start_foo
|
|
|
|
call __stop_foo
|
|
|
|
call __start_bar
|
|
|
|
|
|
|
|
.section foo,"ax"
|
|
|
|
nop
|
|
|
|
nop
|
|
|
|
nop
|
|
|
|
|
|
|
|
.section bar,"ax"
|
|
|
|
nop
|
|
|
|
nop
|
|
|
|
nop
|
2016-04-14 00:33:02 +08:00
|
|
|
|
2016-05-05 04:25:19 +08:00
|
|
|
.section zed1, "aw"
|
2016-04-14 00:33:02 +08:00
|
|
|
.quad __stop_zed2
|
|
|
|
.quad __stop_zed2 + 1
|
|
|
|
|
2016-05-05 04:25:19 +08:00
|
|
|
.section zed2, "aw"
|
2016-04-14 00:33:02 +08:00
|
|
|
.quad __stop_zed1
|
|
|
|
.quad __stop_zed1 + 1
|