2018-06-27 00:58:19 +08:00
|
|
|
# REQUIRES: mips
|
2016-06-23 23:26:31 +08:00
|
|
|
# Check MIPS TLS relocations handling.
|
|
|
|
|
|
|
|
# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \
|
|
|
|
# RUN: %p/Inputs/mips-tls.s -o %t.so.o
|
2019-07-25 15:12:23 +08:00
|
|
|
# RUN: ld.lld -shared %t.so.o -soname=t.so -o %t.so
|
2016-06-23 23:26:31 +08:00
|
|
|
# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t.o
|
2016-09-08 17:07:19 +08:00
|
|
|
|
2019-09-10 06:04:20 +08:00
|
|
|
# RUN: echo "SECTIONS { \
|
|
|
|
# RUN: . = 0x10000; .text : { *(.text) } \
|
|
|
|
# RUN: . = 0x30000; .got : { *(.got) } \
|
|
|
|
# RUN: }" > %t.script
|
|
|
|
|
|
|
|
# RUN: ld.lld %t.o %t.so -script %t.script -o %t.exe
|
2019-10-03 20:08:04 +08:00
|
|
|
# RUN: llvm-objdump -d -s -t --no-show-raw-insn %t.exe \
|
|
|
|
# RUN: | FileCheck -check-prefix=DIS %s
|
|
|
|
# RUN: llvm-readobj -r -A %t.exe | FileCheck %s
|
2016-06-23 23:26:31 +08:00
|
|
|
|
2021-04-28 01:57:47 +08:00
|
|
|
# RUN: ld.lld -pie %t.o %t.so -script %t.script -o %t.pie
|
|
|
|
# RUN: llvm-objdump -d -s -t --no-show-raw-insn %t.pie \
|
|
|
|
# RUN: | FileCheck -check-prefix=DIS %s
|
|
|
|
# RUN: llvm-readobj -r -A %t.pie | FileCheck %s
|
|
|
|
|
2019-09-10 06:04:20 +08:00
|
|
|
# RUN: ld.lld -shared %t.o %t.so -script %t.script -o %t-out.so
|
2019-10-03 20:08:04 +08:00
|
|
|
# RUN: llvm-objdump -d -s -t --no-show-raw-insn %t-out.so \
|
|
|
|
# RUN: | FileCheck -check-prefix=DIS-SO %s
|
|
|
|
# RUN: llvm-readobj -r -A %t-out.so | FileCheck -check-prefix=SO %s
|
2016-09-08 17:07:19 +08:00
|
|
|
|
2021-02-18 15:17:20 +08:00
|
|
|
# DIS: 00000000 l .tdata 00000000 loc
|
|
|
|
# DIS: 00000000 *UND* 00000000 foo
|
|
|
|
# DIS: 00000004 g .tdata 00000000 bar
|
2016-06-23 23:26:31 +08:00
|
|
|
|
|
|
|
# DIS: Contents of section .got:
|
2021-04-28 02:03:57 +08:00
|
|
|
# DIS-NEXT: 30000 00000000 80000000 00000000 ffff9000
|
|
|
|
# DIS-NEXT: 30010 ffff9004 00000000 00000000 00000001
|
|
|
|
# DIS-NEXT: 30020 00000000 00000001 ffff8004
|
2016-06-23 23:26:31 +08:00
|
|
|
|
2020-03-06 06:18:38 +08:00
|
|
|
# DIS: <__start>:
|
2021-04-28 02:03:57 +08:00
|
|
|
# DIS-NEXT: addiu $2, $3, -32732
|
[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
|
|
|
# DIS-NEXT: addiu $2, $3, -32744
|
2021-04-28 02:03:57 +08:00
|
|
|
# DIS-NEXT: addiu $2, $3, -32724
|
[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
|
|
|
# DIS-NEXT: addiu $2, $3, -32740
|
2021-04-28 02:03:57 +08:00
|
|
|
# DIS-NEXT: addiu $2, $3, -32716
|
|
|
|
# DIS-NEXT: addiu $2, $3, -32736
|
2016-06-23 23:26:31 +08:00
|
|
|
|
|
|
|
# CHECK: Relocations [
|
|
|
|
# CHECK-NEXT: Section (7) .rel.dyn {
|
2020-12-10 21:12:26 +08:00
|
|
|
# CHECK-NEXT: 0x30008 R_MIPS_TLS_TPREL32 foo
|
2021-04-28 02:03:57 +08:00
|
|
|
# CHECK-NEXT: 0x30014 R_MIPS_TLS_DTPMOD32 foo
|
|
|
|
# CHECK-NEXT: 0x30018 R_MIPS_TLS_DTPREL32 foo
|
2016-06-23 23:26:31 +08:00
|
|
|
# CHECK-NEXT: }
|
|
|
|
# CHECK-NEXT: ]
|
2019-10-03 20:08:04 +08:00
|
|
|
# CHECK: Primary GOT {
|
2019-09-10 06:04:20 +08:00
|
|
|
# CHECK-NEXT: Canonical gp value: 0x37FF0
|
2016-06-23 23:26:31 +08:00
|
|
|
# CHECK-NEXT: Reserved entries [
|
2016-09-08 17:07:19 +08:00
|
|
|
# CHECK: ]
|
2016-06-23 23:26:31 +08:00
|
|
|
# CHECK-NEXT: Local entries [
|
|
|
|
# CHECK-NEXT: ]
|
|
|
|
# CHECK-NEXT: Global entries [
|
|
|
|
# CHECK-NEXT: ]
|
2021-04-28 02:03:57 +08:00
|
|
|
# CHECK-NEXT: Number of TLS and multi-GOT entries: 9
|
2018-06-11 15:24:31 +08:00
|
|
|
# ^-- -32744 R_MIPS_TLS_GOTTPREL R_MIPS_TLS_TPREL32 foo
|
2021-04-28 02:03:57 +08:00
|
|
|
# ^-- -32740 R_MIPS_TLS_GOTTPREL VA - 0x7000 loc
|
|
|
|
# ^-- -32736 R_MIPS_TLS_GOTTPREL VA - 0x7000 bar
|
|
|
|
# ^-- -32732 R_MIPS_TLS_GD R_MIPS_TLS_DTPMOD32 foo
|
|
|
|
# ^-- -32728 R_MIPS_TLS_DTPREL32 foo
|
|
|
|
# ^-- -32724 R_MIPS_TLS_LDM 1 loc
|
|
|
|
# ^-- -32720 0 loc
|
|
|
|
# ^-- -32716 R_MIPS_TLS_GD 1 bar
|
|
|
|
# ^-- -32712 VA - 0x8000 bar
|
2016-09-08 17:07:19 +08:00
|
|
|
|
|
|
|
# DIS-SO: Contents of section .got:
|
2021-04-28 02:03:57 +08:00
|
|
|
# DIS-SO-NEXT: 30000 00000000 80000000 00000000 00000000
|
|
|
|
# DIS-SO-NEXT: 30010 00000004 00000000 00000000 00000000
|
|
|
|
# DIS-SO-NEXT: 30020 00000000 00000000 00000000
|
2016-09-08 17:07:19 +08:00
|
|
|
|
|
|
|
# SO: Relocations [
|
|
|
|
# SO-NEXT: Section (7) .rel.dyn {
|
2021-04-28 02:03:57 +08:00
|
|
|
# SO-NEXT: 0x3000C R_MIPS_TLS_TPREL32 -
|
|
|
|
# SO-NEXT: 0x3001C R_MIPS_TLS_DTPMOD32 -
|
2020-12-10 21:12:26 +08:00
|
|
|
# SO-NEXT: 0x30008 R_MIPS_TLS_TPREL32 foo
|
2021-04-28 02:03:57 +08:00
|
|
|
# SO-NEXT: 0x30014 R_MIPS_TLS_DTPMOD32 foo
|
|
|
|
# SO-NEXT: 0x30018 R_MIPS_TLS_DTPREL32 foo
|
|
|
|
# SO-NEXT: 0x30010 R_MIPS_TLS_TPREL32 bar
|
|
|
|
# SO-NEXT: 0x30024 R_MIPS_TLS_DTPMOD32 bar
|
|
|
|
# SO-NEXT: 0x30028 R_MIPS_TLS_DTPREL32 bar
|
2016-09-08 17:07:19 +08:00
|
|
|
# SO-NEXT: }
|
|
|
|
# SO-NEXT: ]
|
2019-10-03 20:08:04 +08:00
|
|
|
# SO: 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
|
|
|
# SO-NEXT: Canonical gp value: 0x37FF0
|
2016-09-08 17:07:19 +08:00
|
|
|
# SO-NEXT: Reserved entries [
|
|
|
|
# SO: ]
|
|
|
|
# SO-NEXT: Local entries [
|
|
|
|
# SO-NEXT: ]
|
|
|
|
# SO-NEXT: Global entries [
|
|
|
|
# SO-NEXT: ]
|
2021-04-28 02:03:57 +08:00
|
|
|
# SO-NEXT: Number of TLS and multi-GOT entries: 9
|
2018-06-11 15:24:31 +08:00
|
|
|
# ^-- -32744 R_MIPS_TLS_GOTTPREL R_MIPS_TLS_TPREL32 foo
|
2021-04-28 02:03:57 +08:00
|
|
|
# ^-- -32740 R_MIPS_TLS_GOTTPREL R_MIPS_TLS_TPREL32 loc
|
|
|
|
# ^-- -32736 R_MIPS_TLS_GOTTPREL R_MIPS_TLS_TPREL32 bar
|
|
|
|
# ^-- -32732 R_MIPS_TLS_GD R_MIPS_TLS_DTPMOD32 foo
|
|
|
|
# ^-- -32728 R_MIPS_TLS_DTPREL32 foo
|
|
|
|
# ^-- -32724 R_MIPS_TLS_LDM R_MIPS_TLS_DTPMOD32 loc
|
|
|
|
# ^-- -32720 0 loc
|
|
|
|
# ^-- -32716 R_MIPS_TLS_GD R_MIPS_TLS_DTPMOD32 bar
|
|
|
|
# ^-- -32712 R_MIPS_TLS_DTPREL32 bar
|
2016-06-23 23:26:31 +08:00
|
|
|
|
|
|
|
.text
|
|
|
|
.global __start
|
|
|
|
__start:
|
|
|
|
addiu $2, $3, %tlsgd(foo) # R_MIPS_TLS_GD
|
|
|
|
addiu $2, $3, %gottprel(foo) # R_MIPS_TLS_GOTTPREL
|
2016-09-08 17:07:19 +08:00
|
|
|
addiu $2, $3, %tlsldm(loc) # R_MIPS_TLS_LDM
|
2021-04-28 02:03:57 +08:00
|
|
|
addiu $2, $3, %gottprel(loc) # R_MIPS_TLS_GOTTPREL
|
2016-09-08 17:07:19 +08:00
|
|
|
addiu $2, $3, %tlsgd(bar) # R_MIPS_TLS_GD
|
|
|
|
addiu $2, $3, %gottprel(bar) # R_MIPS_TLS_GOTTPREL
|
2016-06-23 23:26:31 +08:00
|
|
|
|
|
|
|
.section .tdata,"awT",%progbits
|
2016-09-08 17:07:19 +08:00
|
|
|
.global bar
|
2016-06-23 23:26:31 +08:00
|
|
|
loc:
|
|
|
|
.word 0
|
2016-09-08 17:07:19 +08:00
|
|
|
bar:
|
|
|
|
.word 0
|