2018-06-06 21:56:51 +08:00
|
|
|
// REQUIRES: x86
|
2019-08-07 17:43:54 +08:00
|
|
|
// RUN: llvm-mc -filetype=obj -triple=i686 %p/Inputs/tls-opt-gdiele-i686.s -o %t.o
|
|
|
|
// RUN: llvm-mc -filetype=obj -triple=i686 %s -o %t1.o
|
|
|
|
// RUN: ld.lld -shared %t.o -soname=t.so -o %t.so
|
|
|
|
// RUN: ld.lld --hash-style=sysv %t1.o %t.so -o %tout
|
2015-12-09 17:55:54 +08:00
|
|
|
// RUN: llvm-readobj -r %tout | FileCheck --check-prefix=NORELOC %s
|
2019-08-07 17:43:54 +08:00
|
|
|
// RUN: llvm-objdump -d --no-show-raw-insn %tout | FileCheck --check-prefix=DISASM %s
|
2015-12-09 17:55:54 +08:00
|
|
|
|
|
|
|
// NORELOC: Relocations [
|
|
|
|
// NORELOC-NEXT: Section ({{.*}}) .rel.dyn {
|
Align AArch64 and i386 image base to superpage
Summary:
As for x86_64, the default image base for AArch64 and i386 should be
aligned to a superpage appropriate for the architecture.
On AArch64, this is 2 MiB, on i386 it is 4 MiB.
Reviewers: emaste, grimar, javed.absar, espindola, ruiu, peter.smith, srhines, rprichard
Reviewed By: ruiu, peter.smith
Subscribers: jfb, markj, arichardson, krytarowski, kristof.beyls, llvm-commits
Differential Revision: https://reviews.llvm.org/D50297
llvm-svn: 342746
2018-09-22 00:58:13 +08:00
|
|
|
// NORELOC-NEXT: 0x402058 R_386_TLS_TPOFF tlsshared0 0x0
|
|
|
|
// NORELOC-NEXT: 0x40205C R_386_TLS_TPOFF tlsshared1 0x0
|
2015-12-09 17:55:54 +08:00
|
|
|
// NORELOC-NEXT: }
|
|
|
|
// NORELOC-NEXT: ]
|
|
|
|
|
|
|
|
// DISASM: Disassembly of section .text:
|
2019-05-01 18:40:48 +08:00
|
|
|
// DISASM-EMPTY:
|
2015-12-09 17:55:54 +08:00
|
|
|
// DISASM-NEXT: _start:
|
2019-08-07 17:43:54 +08:00
|
|
|
// DISASM-NEXT: 401000: movl %gs:0, %eax
|
|
|
|
// DISASM-NEXT: addl -4008(%ebx), %eax
|
|
|
|
// DISASM-NEXT: movl %gs:0, %eax
|
|
|
|
// DISASM-NEXT: addl -4004(%ebx), %eax
|
|
|
|
// DISASM-NEXT: movl %gs:0, %eax
|
|
|
|
// DISASM-NEXT: subl $8, %eax
|
|
|
|
// DISASM-NEXT: movl %gs:0, %eax
|
|
|
|
// DISASM-NEXT: subl $4, %eax
|
2015-12-09 17:55:54 +08:00
|
|
|
|
|
|
|
.type tlsexe1,@object
|
|
|
|
.section .tbss,"awT",@nobits
|
|
|
|
.globl tlsexe1
|
|
|
|
.align 4
|
|
|
|
tlsexe1:
|
|
|
|
.long 0
|
|
|
|
.size tlsexe1, 4
|
|
|
|
|
|
|
|
.type tlsexe2,@object
|
|
|
|
.section .tbss,"awT",@nobits
|
|
|
|
.globl tlsexe2
|
|
|
|
.align 4
|
|
|
|
tlsexe2:
|
|
|
|
.long 0
|
|
|
|
.size tlsexe2, 4
|
|
|
|
|
|
|
|
.section .text
|
|
|
|
.globl ___tls_get_addr
|
|
|
|
.type ___tls_get_addr,@function
|
|
|
|
___tls_get_addr:
|
|
|
|
|
|
|
|
.section .text
|
|
|
|
.globl _start
|
|
|
|
_start:
|
|
|
|
//GD->IE
|
|
|
|
leal tlsshared0@tlsgd(,%ebx,1),%eax
|
|
|
|
call ___tls_get_addr@plt
|
|
|
|
leal tlsshared1@tlsgd(,%ebx,1),%eax
|
|
|
|
call ___tls_get_addr@plt
|
[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
|
|
|
//GD->LE
|
2015-12-09 17:55:54 +08:00
|
|
|
leal tlsexe1@tlsgd(,%ebx,1),%eax
|
|
|
|
call ___tls_get_addr@plt
|
|
|
|
leal tlsexe2@tlsgd(,%ebx,1),%eax
|
|
|
|
call ___tls_get_addr@plt
|