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
|
2019-09-07 23:44:40 +08:00
|
|
|
# RUN: echo "SECTIONS { \
|
|
|
|
# RUN: . = 0x10000; .text : { *(.text) } \
|
|
|
|
# RUN: . = 0x70000; .got : { *(.got) } \
|
|
|
|
# RUN: }" > %t.script
|
|
|
|
# RUN: ld.lld -shared -mips-got-size 52 --script %t.script %t0.o %t1.o %t2.o -o %t.so
|
2018-06-11 15:24:31 +08:00
|
|
|
# RUN: llvm-objdump -s -section=.got -t %t.so | FileCheck %s
|
2019-10-03 20:08:04 +08:00
|
|
|
# RUN: llvm-readobj -r --dyn-syms -A %t.so | FileCheck -check-prefix=GOT %s
|
2018-06-11 15:24:31 +08:00
|
|
|
|
[llvm-objdump] Further rearrange llvm-objdump sections for compatability
Summary:
rL371826 rearranged some output from llvm-objdump for GNU objdump compatability, but there still seem to be some more.
I think this rearrangement is a little closer. Overview of the ordering which matches GNU objdump:
* Archive headers
* File headers
* Section headers
* Symbol table
* Dwarf debugging
* Relocations (if `--disassemble` is not used)
* Section contents
* Disassembly
Reviewers: jhenderson, justice_adams, grimar, ychen, espindola
Reviewed By: jhenderson
Subscribers: aprantl, emaste, arichardson, jrtc27, atanasyan, seiya, llvm-commits, MaskRay
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D68066
llvm-svn: 373671
2019-10-04 06:01:08 +08:00
|
|
|
# CHECK: SYMBOL TABLE:
|
|
|
|
# CHECK: 00000000 l O .tdata 00000000 loc0
|
2020-03-05 09:19:18 +08:00
|
|
|
# CHECK: [[FOO0:[0-9a-f]+]] g .text 00000000 foo0
|
[llvm-objdump] Further rearrange llvm-objdump sections for compatability
Summary:
rL371826 rearranged some output from llvm-objdump for GNU objdump compatability, but there still seem to be some more.
I think this rearrangement is a little closer. Overview of the ordering which matches GNU objdump:
* Archive headers
* File headers
* Section headers
* Symbol table
* Dwarf debugging
* Relocations (if `--disassemble` is not used)
* Section contents
* Disassembly
Reviewers: jhenderson, justice_adams, grimar, ychen, espindola
Reviewed By: jhenderson
Subscribers: aprantl, emaste, arichardson, jrtc27, atanasyan, seiya, llvm-commits, MaskRay
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D68066
llvm-svn: 373671
2019-10-04 06:01:08 +08:00
|
|
|
# CHECK: 00000000 g O .tdata 00000000 tls0
|
|
|
|
# CHECK: 00000004 g O .tdata 00000000 tls1
|
2020-03-05 09:19:18 +08:00
|
|
|
# CHECK: [[FOO2:[0-9a-f]+]] g .text 00000000 foo2
|
[llvm-objdump] Further rearrange llvm-objdump sections for compatability
Summary:
rL371826 rearranged some output from llvm-objdump for GNU objdump compatability, but there still seem to be some more.
I think this rearrangement is a little closer. Overview of the ordering which matches GNU objdump:
* Archive headers
* File headers
* Section headers
* Symbol table
* Dwarf debugging
* Relocations (if `--disassemble` is not used)
* Section contents
* Disassembly
Reviewers: jhenderson, justice_adams, grimar, ychen, espindola
Reviewed By: jhenderson
Subscribers: aprantl, emaste, arichardson, jrtc27, atanasyan, seiya, llvm-commits, MaskRay
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D68066
llvm-svn: 373671
2019-10-04 06:01:08 +08:00
|
|
|
|
2018-06-11 15:24:31 +08:00
|
|
|
# CHECK: Contents of section .got:
|
[llvm-objdump] Further rearrange llvm-objdump sections for compatability
Summary:
rL371826 rearranged some output from llvm-objdump for GNU objdump compatability, but there still seem to be some more.
I think this rearrangement is a little closer. Overview of the ordering which matches GNU objdump:
* Archive headers
* File headers
* Section headers
* Symbol table
* Dwarf debugging
* Relocations (if `--disassemble` is not used)
* Section contents
* Disassembly
Reviewers: jhenderson, justice_adams, grimar, ychen, espindola
Reviewed By: jhenderson
Subscribers: aprantl, emaste, arichardson, jrtc27, atanasyan, seiya, llvm-commits, MaskRay
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D68066
llvm-svn: 373671
2019-10-04 06:01:08 +08:00
|
|
|
# CHECK-NEXT: 70000 00000000 80000000 [[FOO0]] [[FOO2]]
|
2019-09-07 23:44:40 +08:00
|
|
|
# CHECK-NEXT: 70010 00000000 00000004 00010000 00020000
|
|
|
|
# CHECK-NEXT: 70020 00030000 00040000 00050000 00060000
|
[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: 70030 00000000 00000000 00000000 00000000
|
|
|
|
# CHECK-NEXT: 70040 00000000 00000000 00000000
|
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
|
2019-05-20 21:05:55 +08:00
|
|
|
# GOT-NEXT: 0x70030 R_MIPS_REL32 foo0 0x0
|
|
|
|
# GOT-NEXT: 0x70034 R_MIPS_REL32 foo2 0x0
|
[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: 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
|
2018-06-11 15:24:31 +08:00
|
|
|
# GOT-NEXT: }
|
|
|
|
# GOT-NEXT: ]
|
|
|
|
|
|
|
|
# GOT: DynamicSymbols [
|
|
|
|
# GOT: Symbol {
|
|
|
|
# GOT: Name: foo0
|
2019-09-07 23:44:40 +08:00
|
|
|
# GOT-NEXT: Value: 0x[[FOO0:[0-9A-F]+]]
|
2018-06-11 15:24:31 +08:00
|
|
|
# GOT: }
|
|
|
|
# GOT-NEXT: Symbol {
|
|
|
|
# GOT-NEXT: Name: foo2
|
2019-09-07 23:44:40 +08:00
|
|
|
# GOT-NEXT: Value: 0x[[FOO2:[0-9A-F]+]]
|
2018-06-11 15:24:31 +08:00
|
|
|
# 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
|
2019-09-07 23:44:40 +08:00
|
|
|
# GOT-NEXT: Initial: 0x[[FOO0]]
|
|
|
|
# GOT-NEXT: Value: 0x[[FOO0]]
|
2018-06-11 15:24:31 +08:00
|
|
|
# GOT-NEXT: Type: None
|
|
|
|
# GOT-NEXT: Section: .text
|
|
|
|
# GOT-NEXT: Name: foo0
|
|
|
|
# GOT-NEXT: }
|
|
|
|
# GOT-NEXT: Entry {
|
|
|
|
# GOT-NEXT: Address:
|
|
|
|
# GOT-NEXT: Access: -32740
|
2019-09-07 23:44:40 +08:00
|
|
|
# GOT-NEXT: Initial: 0x[[FOO2]]
|
|
|
|
# GOT-NEXT: Value: 0x[[FOO2]]
|
2018-06-11 15:24:31 +08:00
|
|
|
# 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
|