2018-06-27 06:20:04 +08:00
|
|
|
// REQUIRES: x86
|
2015-08-28 07:15:56 +08:00
|
|
|
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t
|
2015-09-30 07:22:16 +08:00
|
|
|
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/shared.s -o %t2
|
2018-05-16 01:02:35 +08:00
|
|
|
// RUN: ld.lld %t2 -soname fixed-length-string.so -o %t2.so -shared
|
2017-10-06 17:37:44 +08:00
|
|
|
// RUN: ld.lld --hash-style=sysv %t %t2.so -o %t3
|
2019-05-01 13:49:01 +08:00
|
|
|
// RUN: llvm-readobj -S %t3 | FileCheck --check-prefix=SEC %s
|
2015-09-30 07:22:16 +08:00
|
|
|
// RUN: llvm-objdump -s -d %t3 | FileCheck %s
|
2015-08-28 07:15:56 +08:00
|
|
|
|
2015-10-02 05:15:02 +08:00
|
|
|
// SEC: Name: .plt
|
|
|
|
// SEC-NEXT: Type: SHT_PROGBITS
|
|
|
|
// SEC-NEXT: Flags [
|
|
|
|
// SEC-NEXT: SHF_ALLOC
|
|
|
|
// SEC-NEXT: SHF_EXECINSTR
|
|
|
|
// SEC-NEXT: ]
|
2016-11-24 01:44:02 +08:00
|
|
|
// SEC-NEXT: Address: 0x201030
|
2015-10-15 00:15:46 +08:00
|
|
|
// SEC-NEXT: Offset: 0x1030
|
2016-02-25 00:37:47 +08:00
|
|
|
// SEC-NEXT: Size: 48
|
2015-10-02 05:15:02 +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
|
|
|
// SEC: Name: .got
|
2015-09-24 04:08:25 +08:00
|
|
|
// SEC-NEXT: Type: SHT_PROGBITS
|
|
|
|
// SEC-NEXT: Flags [
|
|
|
|
// SEC-NEXT: SHF_ALLOC
|
|
|
|
// SEC-NEXT: SHF_WRITE
|
|
|
|
// SEC-NEXT: ]
|
[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
|
|
|
// SEC-NEXT: Address: 0x2020F0
|
|
|
|
// SEC-NEXT: Offset:
|
|
|
|
// SEC-NEXT: Size: 8
|
2015-09-24 04:08:25 +08:00
|
|
|
// SEC-NEXT: Link: 0
|
|
|
|
// SEC-NEXT: Info: 0
|
|
|
|
// SEC-NEXT: AddressAlignment: 8
|
|
|
|
// SEC-NEXT: EntrySize: 0
|
[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
|
|
|
// SEC-NEXT: }
|
2015-08-28 07:15:56 +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
|
|
|
// SEC: Name: .got.plt
|
2015-10-20 16:54:27 +08:00
|
|
|
// SEC-NEXT: Type: SHT_PROGBITS
|
|
|
|
// SEC-NEXT: Flags [
|
|
|
|
// SEC-NEXT: SHF_ALLOC
|
|
|
|
// SEC-NEXT: SHF_WRITE
|
|
|
|
// SEC-NEXT: ]
|
[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
|
|
|
// SEC-NEXT: Address: 0x203000
|
|
|
|
// SEC-NEXT: Offset: 0x3000
|
|
|
|
// SEC-NEXT: Size: 40
|
2015-10-20 16:54:27 +08:00
|
|
|
// SEC-NEXT: Link: 0
|
|
|
|
// SEC-NEXT: Info: 0
|
|
|
|
// SEC-NEXT: AddressAlignment: 8
|
|
|
|
// SEC-NEXT: EntrySize: 0
|
[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
|
|
|
// SEC-NEXT: }
|
2015-10-20 16:54:27 +08:00
|
|
|
|
2015-08-28 07:15:56 +08:00
|
|
|
.section .text,"ax",@progbits,unique,1
|
|
|
|
.global _start
|
|
|
|
_start:
|
|
|
|
call lulz
|
|
|
|
|
|
|
|
.section .text,"ax",@progbits,unique,2
|
|
|
|
.zero 4
|
|
|
|
.global lulz
|
|
|
|
lulz:
|
2015-09-15 21:30:08 +08:00
|
|
|
nop
|
|
|
|
|
|
|
|
// CHECK: Disassembly of section .text:
|
2019-05-01 18:40:48 +08:00
|
|
|
// CHECK-EMPTY:
|
2015-09-15 21:30:08 +08:00
|
|
|
// CHECK-NEXT: _start:
|
2016-11-24 01:44:02 +08:00
|
|
|
// CHECK-NEXT: 201000: e8 04 00 00 00 callq 4
|
|
|
|
// CHECK-NEXT: 201005:
|
2015-09-15 21:30:08 +08:00
|
|
|
|
|
|
|
// CHECK: lulz:
|
2016-11-24 01:44:02 +08:00
|
|
|
// CHECK-NEXT: 201009: 90 nop
|
2015-09-15 21:30:08 +08:00
|
|
|
|
2015-08-28 07:15:56 +08:00
|
|
|
|
2015-09-15 21:30:08 +08:00
|
|
|
.section .text2,"ax",@progbits
|
2015-09-15 21:52:06 +08:00
|
|
|
.global R_X86_64_32
|
|
|
|
R_X86_64_32:
|
|
|
|
movl $R_X86_64_32, %edx
|
2015-08-29 21:15:42 +08:00
|
|
|
|
2015-09-15 21:30:08 +08:00
|
|
|
// FIXME: this would be far more self evident if llvm-objdump printed
|
|
|
|
// constants in hex.
|
|
|
|
// CHECK: Disassembly of section .text2:
|
2019-05-01 18:40:48 +08:00
|
|
|
// CHECK-EMPTY:
|
2015-09-15 21:52:06 +08:00
|
|
|
// CHECK-NEXT: R_X86_64_32:
|
2016-11-24 01:44:02 +08:00
|
|
|
// CHECK-NEXT: 20100a: {{.*}} movl $2101258, %edx
|
2015-09-15 21:52:06 +08:00
|
|
|
|
2015-09-16 08:24:19 +08:00
|
|
|
.section .R_X86_64_32S,"ax",@progbits
|
|
|
|
.global R_X86_64_32S
|
|
|
|
R_X86_64_32S:
|
|
|
|
movq lulz - 0x100000, %rdx
|
|
|
|
|
|
|
|
// CHECK: Disassembly of section .R_X86_64_32S:
|
2019-05-01 18:40:48 +08:00
|
|
|
// CHECK-EMPTY:
|
2015-09-16 08:24:19 +08:00
|
|
|
// CHECK-NEXT: R_X86_64_32S:
|
2016-11-24 01:44:02 +08:00
|
|
|
// CHECK-NEXT: {{.*}}: {{.*}} movq 1052681, %rdx
|
2015-09-16 08:24:19 +08:00
|
|
|
|
2015-09-30 07:22:16 +08:00
|
|
|
.section .R_X86_64_PC32,"ax",@progbits
|
|
|
|
.global R_X86_64_PC32
|
|
|
|
R_X86_64_PC32:
|
|
|
|
call bar
|
2015-10-15 00:15:46 +08:00
|
|
|
movl $bar, %eax
|
2015-10-20 16:54:27 +08:00
|
|
|
//16 is a size of PLT[0]
|
2016-11-24 01:44:02 +08:00
|
|
|
// 0x201030 + 16 - (0x201017 + 5) = 20
|
2015-09-30 07:22:16 +08:00
|
|
|
// CHECK: Disassembly of section .R_X86_64_PC32:
|
2019-05-01 18:40:48 +08:00
|
|
|
// CHECK-EMPTY:
|
2015-09-30 07:22:16 +08:00
|
|
|
// CHECK-NEXT: R_X86_64_PC32:
|
2016-11-24 01:44:02 +08:00
|
|
|
// CHECK-NEXT: 201017: {{.*}} callq 36
|
|
|
|
// CHECK-NEXT: 20101c: {{.*}} movl $2101312, %eax
|
2015-09-30 07:22:16 +08:00
|
|
|
|
2016-02-25 00:37:47 +08:00
|
|
|
.section .R_X86_64_32S_2,"ax",@progbits
|
|
|
|
.global R_X86_64_32S_2
|
|
|
|
R_X86_64_32S_2:
|
|
|
|
mov bar2, %eax
|
2016-11-24 01:44:02 +08:00
|
|
|
// plt is at 0x201030. The second plt entry is at 0x201050 == 69712
|
2016-02-25 00:37:47 +08:00
|
|
|
// CHECK: Disassembly of section .R_X86_64_32S_2:
|
2019-05-01 18:40:48 +08:00
|
|
|
// CHECK-EMPTY:
|
2016-02-25 00:37:47 +08:00
|
|
|
// CHECK-NEXT: R_X86_64_32S_2:
|
2016-11-24 01:44:02 +08:00
|
|
|
// CHECK-NEXT: 201021: {{.*}} movl 2101328, %eax
|
2016-02-25 00:37:47 +08:00
|
|
|
|
2015-09-15 21:52:06 +08:00
|
|
|
.section .R_X86_64_64,"a",@progbits
|
|
|
|
.global R_X86_64_64
|
|
|
|
R_X86_64_64:
|
|
|
|
.quad R_X86_64_64
|
|
|
|
|
|
|
|
// CHECK: Contents of section .R_X86_64_64:
|
[ELF] Split RW PT_LOAD on the PT_GNU_RELRO boundary
Summary:
Based on Peter Collingbourne's suggestion in D56828.
Before D56828: PT_LOAD(.data PT_GNU_RELRO(.data.rel.ro .bss.rel.ro) .bss)
Old: PT_LOAD(PT_GNU_RELRO(.data.rel.ro .bss.rel.ro) .data .bss)
New: PT_LOAD(PT_GNU_RELRO(.data.rel.ro .bss.rel.ro)) PT_LOAD(.data. .bss)
The new layout reflects the runtime memory mappings.
By having two PT_LOAD segments, we can utilize the NOBITS part of the
first PT_LOAD and save bytes for .bss.rel.ro.
.bss.rel.ro is currently small and only used by copy relocations of
symbols in read-only segments, but it can be used for other purposes in
the future, e.g. if a relro section's statically relocated data is all
zeros, we can move it to .bss.rel.ro.
Reviewers: espindola, ruiu, pcc
Reviewed By: ruiu
Subscribers: nemanjai, jvesely, nhaehnle, javed.absar, kbarton, emaste, arichardson, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D58892
llvm-svn: 356226
2019-03-15 09:29:57 +08:00
|
|
|
// CHECK-NEXT: 2002f8 f8022000 00000000
|
2015-09-24 04:08:25 +08:00
|
|
|
|
|
|
|
.section .R_X86_64_GOTPCREL,"a",@progbits
|
|
|
|
.global R_X86_64_GOTPCREL
|
|
|
|
R_X86_64_GOTPCREL:
|
2015-10-07 05:52:48 +08:00
|
|
|
.long zed@gotpcrel
|
2015-09-24 04:08:25 +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
|
|
|
// 0x2020F0(.got) - 0x2002c8(.R_X86_64_GOTPCREL) = 0x1e28
|
2015-09-24 04:08:25 +08:00
|
|
|
// CHECK: Contents of section .R_X86_64_GOTPCREL
|
[ELF] Split RW PT_LOAD on the PT_GNU_RELRO boundary
Summary:
Based on Peter Collingbourne's suggestion in D56828.
Before D56828: PT_LOAD(.data PT_GNU_RELRO(.data.rel.ro .bss.rel.ro) .bss)
Old: PT_LOAD(PT_GNU_RELRO(.data.rel.ro .bss.rel.ro) .data .bss)
New: PT_LOAD(PT_GNU_RELRO(.data.rel.ro .bss.rel.ro)) PT_LOAD(.data. .bss)
The new layout reflects the runtime memory mappings.
By having two PT_LOAD segments, we can utilize the NOBITS part of the
first PT_LOAD and save bytes for .bss.rel.ro.
.bss.rel.ro is currently small and only used by copy relocations of
symbols in read-only segments, but it can be used for other purposes in
the future, e.g. if a relro section's statically relocated data is all
zeros, we can move it to .bss.rel.ro.
Reviewers: espindola, ruiu, pcc
Reviewed By: ruiu
Subscribers: nemanjai, jvesely, nhaehnle, javed.absar, kbarton, emaste, arichardson, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D58892
llvm-svn: 356226
2019-03-15 09:29:57 +08:00
|
|
|
// CHECK-NEXT: 200300 f01d0000
|
2016-04-18 20:58:59 +08:00
|
|
|
|
|
|
|
.section .R_X86_64_GOT32,"a",@progbits
|
|
|
|
.global R_X86_64_GOT32
|
|
|
|
R_X86_64_GOT32:
|
|
|
|
.long zed@got
|
|
|
|
|
|
|
|
// CHECK: Contents of section .R_X86_64_GOT32:
|
[ELF] Change GOT*_FROM_END (relative to end(.got)) to GOTPLT* (start(.got.plt))
Summary:
This should address remaining issues discussed in PR36555.
Currently R_GOT*_FROM_END are exclusively used by x86 and x86_64 to
express relocations types relative to the GOT base. We have
_GLOBAL_OFFSET_TABLE_ (GOT base) = start(.got.plt) but end(.got) !=
start(.got.plt)
This can have problems when _GLOBAL_OFFSET_TABLE_ is used as a symbol, e.g.
glibc dl_machine_dynamic assumes _GLOBAL_OFFSET_TABLE_ is start(.got.plt),
which is not true.
extern const ElfW(Addr) _GLOBAL_OFFSET_TABLE_[] attribute_hidden;
return _GLOBAL_OFFSET_TABLE_[0]; // R_X86_64_GOTPC32
In this patch, we
* Change all GOT*_FROM_END to GOTPLT* to fix the problem.
* Add HasGotPltOffRel to denote whether .got.plt should be kept even if
the section is empty.
* Simplify GotSection::empty and GotPltSection::empty by setting
HasGotOffRel and HasGotPltOffRel according to GlobalOffsetTable early.
The change of R_386_GOTPC makes X86::writePltHeader simpler as we don't
have to compute the offset start(.got.plt) - Ebx (it is constant 0).
We still diverge from ld.bfd (at least in most cases) and gold in that
.got.plt and .got are not adjacent, but the advantage doing that is
unclear.
Reviewers: ruiu, sivachandra, espindola
Subscribers: emaste, mehdi_amini, arichardson, dexonsmith, jdoerfert, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D59594
llvm-svn: 356968
2019-03-26 07:46:19 +08:00
|
|
|
// CHECK-NEXT: f0f0ffff
|
2016-12-10 05:46:39 +08:00
|
|
|
|
|
|
|
|
|
|
|
// CHECK: Contents of section .R_X86_64_GOT64:
|
[ELF] Change GOT*_FROM_END (relative to end(.got)) to GOTPLT* (start(.got.plt))
Summary:
This should address remaining issues discussed in PR36555.
Currently R_GOT*_FROM_END are exclusively used by x86 and x86_64 to
express relocations types relative to the GOT base. We have
_GLOBAL_OFFSET_TABLE_ (GOT base) = start(.got.plt) but end(.got) !=
start(.got.plt)
This can have problems when _GLOBAL_OFFSET_TABLE_ is used as a symbol, e.g.
glibc dl_machine_dynamic assumes _GLOBAL_OFFSET_TABLE_ is start(.got.plt),
which is not true.
extern const ElfW(Addr) _GLOBAL_OFFSET_TABLE_[] attribute_hidden;
return _GLOBAL_OFFSET_TABLE_[0]; // R_X86_64_GOTPC32
In this patch, we
* Change all GOT*_FROM_END to GOTPLT* to fix the problem.
* Add HasGotPltOffRel to denote whether .got.plt should be kept even if
the section is empty.
* Simplify GotSection::empty and GotPltSection::empty by setting
HasGotOffRel and HasGotPltOffRel according to GlobalOffsetTable early.
The change of R_386_GOTPC makes X86::writePltHeader simpler as we don't
have to compute the offset start(.got.plt) - Ebx (it is constant 0).
We still diverge from ld.bfd (at least in most cases) and gold in that
.got.plt and .got are not adjacent, but the advantage doing that is
unclear.
Reviewers: ruiu, sivachandra, espindola
Subscribers: emaste, mehdi_amini, arichardson, dexonsmith, jdoerfert, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D59594
llvm-svn: 356968
2019-03-26 07:46:19 +08:00
|
|
|
// CHECK-NEXT: f0f0ffff ffffffff
|
2016-12-10 05:46:39 +08:00
|
|
|
.section .R_X86_64_GOT64,"a",@progbits
|
|
|
|
.global R_X86_64_GOT64
|
|
|
|
R_X86_64_GOT64:
|
|
|
|
.quad zed@got
|