2018-06-27 00:58:19 +08:00
|
|
|
# REQUIRES: mips
|
2018-06-11 15:24:31 +08:00
|
|
|
# Check MIPS multi-GOT layout.
|
|
|
|
|
|
|
|
# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t0.o
|
|
|
|
# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \
|
|
|
|
# RUN: %p/Inputs/mips-mgot-1.s -o %t1.o
|
|
|
|
# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \
|
|
|
|
# RUN: %p/Inputs/mips-mgot-2.s -o %t2.o
|
|
|
|
# RUN: ld.lld -shared -mips-got-size 52 %t0.o %t1.o %t2.o -o %t.so
|
|
|
|
# RUN: llvm-objdump -s -section=.got -t %t.so | FileCheck %s
|
2019-05-01 13:49:01 +08:00
|
|
|
# RUN: llvm-readobj -r --dyn-syms --mips-plt-got %t.so | FileCheck -check-prefix=GOT %s
|
2018-06-11 15:24:31 +08:00
|
|
|
|
|
|
|
# CHECK: Contents of section .got:
|
[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: 70000 00000000 80000000 00010000 00010030
|
|
|
|
# CHECK-NEXT: 70010 00000000 00000004 00030000 00040000
|
|
|
|
# CHECK-NEXT: 70020 00050000 00060000 00070000 00080000
|
|
|
|
# CHECK-NEXT: 70030 00000000 00000000 00000000 00000000
|
|
|
|
# CHECK-NEXT: 70040 00000000 00000000 00000000
|
2018-06-11 15:24:31 +08:00
|
|
|
|
|
|
|
# CHECK: SYMBOL TABLE:
|
2018-11-12 02:49:05 +08:00
|
|
|
# CHECK: 00000000 l O .tdata 00000000 loc0
|
|
|
|
# CHECK: 00010000 .text 00000000 foo0
|
|
|
|
# CHECK: 00000000 g O .tdata 00000000 tls0
|
|
|
|
# CHECK: 00010020 .text 00000000 foo1
|
|
|
|
# CHECK: 00000004 g O .tdata 00000000 tls1
|
|
|
|
# CHECK: 00010030 .text 00000000 foo2
|
|
|
|
# CHECK: 00000008 g O .tdata 00000000 tls2
|
2018-06-11 15:24:31 +08:00
|
|
|
|
|
|
|
# GOT: Relocations [
|
|
|
|
# GOT-NEXT: Section (7) .rel.dyn {
|
[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
|
|
|
# GOT-NEXT: 0x70018 R_MIPS_REL32 - 0x0
|
|
|
|
# GOT-NEXT: 0x7001C R_MIPS_REL32 - 0x0
|
|
|
|
# GOT-NEXT: 0x70020 R_MIPS_REL32 - 0x0
|
|
|
|
# GOT-NEXT: 0x70024 R_MIPS_REL32 - 0x0
|
|
|
|
# GOT-NEXT: 0x70028 R_MIPS_REL32 - 0x0
|
|
|
|
# GOT-NEXT: 0x7002C R_MIPS_REL32 - 0x0
|
|
|
|
# GOT-NEXT: 0x70044 R_MIPS_TLS_DTPMOD32 - 0x0
|
|
|
|
# GOT-NEXT: 0x70010 R_MIPS_TLS_TPREL32 tls0 0x0
|
|
|
|
# GOT-NEXT: 0x70038 R_MIPS_TLS_TPREL32 tls0 0x0
|
|
|
|
# GOT-NEXT: 0x7003C R_MIPS_TLS_DTPMOD32 tls0 0x0
|
|
|
|
# GOT-NEXT: 0x70040 R_MIPS_TLS_DTPREL32 tls0 0x0
|
|
|
|
# GOT-NEXT: 0x70014 R_MIPS_TLS_TPREL32 tls1 0x0
|
2019-05-20 15:22:55 +08:00
|
|
|
# GOT-NEXT: 0x70030 R_MIPS_REL32 foo0 0x0
|
|
|
|
# GOT-NEXT: 0x70034 R_MIPS_REL32 foo2 0x0
|
2018-06-11 15:24:31 +08:00
|
|
|
# GOT-NEXT: }
|
|
|
|
# GOT-NEXT: ]
|
|
|
|
|
|
|
|
# GOT: DynamicSymbols [
|
|
|
|
# GOT: Symbol {
|
|
|
|
# GOT: Name: foo0
|
|
|
|
# GOT-NEXT: Value: 0x10000
|
|
|
|
# GOT: }
|
|
|
|
# GOT-NEXT: Symbol {
|
|
|
|
# GOT-NEXT: Name: foo2
|
|
|
|
# GOT-NEXT: Value: 0x10030
|
|
|
|
# GOT: }
|
|
|
|
# GOT-NEXT: ]
|
|
|
|
|
|
|
|
# GOT: Primary GOT {
|
[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
|
|
|
# GOT-NEXT: Canonical gp value: 0x77FF0
|
2018-06-11 15:24:31 +08:00
|
|
|
# GOT-NEXT: Reserved entries [
|
|
|
|
# GOT-NEXT: Entry {
|
|
|
|
# GOT-NEXT: Address:
|
|
|
|
# GOT-NEXT: Access: -32752
|
|
|
|
# GOT-NEXT: Initial: 0x0
|
|
|
|
# GOT-NEXT: Purpose: Lazy resolver
|
|
|
|
# GOT-NEXT: }
|
|
|
|
# GOT-NEXT: Entry {
|
|
|
|
# GOT-NEXT: Address:
|
|
|
|
# GOT-NEXT: Access: -32748
|
|
|
|
# GOT-NEXT: Initial: 0x80000000
|
|
|
|
# GOT-NEXT: Purpose: Module pointer (GNU extension)
|
|
|
|
# GOT-NEXT: }
|
|
|
|
# GOT-NEXT: ]
|
|
|
|
# GOT-NEXT: Local entries [
|
|
|
|
# GOT-NEXT: ]
|
|
|
|
# GOT-NEXT: Global entries [
|
|
|
|
# GOT-NEXT: Entry {
|
|
|
|
# GOT-NEXT: Address:
|
|
|
|
# GOT-NEXT: Access: -32744
|
|
|
|
# GOT-NEXT: Initial: 0x10000
|
|
|
|
# GOT-NEXT: Value: 0x10000
|
|
|
|
# GOT-NEXT: Type: None
|
|
|
|
# GOT-NEXT: Section: .text
|
|
|
|
# GOT-NEXT: Name: foo0
|
|
|
|
# GOT-NEXT: }
|
|
|
|
# GOT-NEXT: Entry {
|
|
|
|
# GOT-NEXT: Address:
|
|
|
|
# GOT-NEXT: Access: -32740
|
|
|
|
# GOT-NEXT: Initial: 0x10030
|
|
|
|
# GOT-NEXT: Value: 0x10030
|
|
|
|
# GOT-NEXT: Type: None
|
|
|
|
# GOT-NEXT: Section: .text
|
|
|
|
# GOT-NEXT: Name: foo2
|
|
|
|
# GOT-NEXT: }
|
|
|
|
# GOT-NEXT: ]
|
2018-06-20 23:58:48 +08:00
|
|
|
# GOT-NEXT: Number of TLS and multi-GOT entries: 15
|
2018-06-11 15:24:31 +08:00
|
|
|
# GOT-NEXT: }
|
|
|
|
|
|
|
|
.text
|
|
|
|
.global foo0
|
|
|
|
foo0:
|
|
|
|
lw $2, %got(.data)($gp) # page entry
|
|
|
|
addi $2, $2, %lo(.data)
|
|
|
|
lw $2, %call16(foo0)($gp) # global entry
|
|
|
|
addiu $2, $2, %tlsgd(tls0) # tls gd entry
|
|
|
|
addiu $2, $2, %gottprel(tls0) # tls got entry
|
|
|
|
addiu $2, $2, %tlsldm(loc0) # tls ld entry
|
|
|
|
|
|
|
|
.data
|
|
|
|
.space 0x20000
|
|
|
|
|
|
|
|
.section .tdata,"awT",%progbits
|
|
|
|
.global tls0
|
|
|
|
tls0:
|
|
|
|
loc0:
|
|
|
|
.word 0
|