[ELF][X86] Allow PT_LOAD to have overlapping p_offset ranges on EM_386

Ported the D64906 technique to EM_386.

If `sh_addralign(.tdata) < sh_addralign(.tbss)`,
we can potentially make `p_vaddr(PT_TLS)%p_align(PT_TLS) != 0`.

ld.so that are known to have problems if p_vaddr%p_align!=0:

* FreeBSD 13.0-CURRENT rtld-elf
* glibc https://sourceware.org/bugzilla/show_bug.cgi?id=24606

New test i386-tls-vaddr-align.s checks our workaround makes p_vaddr%p_align = 0.

Reviewed By: ruiu

Differential Revision: https://reviews.llvm.org/D65865

llvm-svn: 369347
This commit is contained in:
Fangrui Song 2019-08-20 08:43:47 +00:00
parent 36848ff8df
commit 9c371309f3
34 changed files with 449 additions and 437 deletions

View File

@ -2219,8 +2219,9 @@ template <class ELFT> void Writer<ELFT>::fixSectionAlignments() {
// and non-executable segments.
//
// TODO Enable this technique on all targets.
bool enable =
config->emachine == EM_AARCH64 || config->emachine == EM_PPC64;
bool enable = config->emachine == EM_386 ||
config->emachine == EM_AARCH64 ||
config->emachine == EM_PPC64;
if (!enable || (config->zSeparateCode && prev &&
(prev->p_flags & PF_X) != (p->p_flags & PF_X)))

View File

@ -23,9 +23,9 @@ _start:
# CHECK-NEXT: Type: Executable (0x2)
# CHECK-NEXT: Machine: EM_386 (0x3)
# CHECK-NEXT: Version: 1
# CHECK-NEXT: Entry: 0x401000
# CHECK-NEXT: Entry: 0x4010B4
# CHECK-NEXT: ProgramHeaderOffset: 0x34
# CHECK-NEXT: SectionHeaderOffset: 0x1068
# CHECK-NEXT: SectionHeaderOffset: 0x11C
# CHECK-NEXT: Flags [ (0x0)
# CHECK-NEXT: ]
# CHECK-NEXT: HeaderSize: 52
@ -58,8 +58,8 @@ _start:
# CHECK-NEXT: SHF_ALLOC (0x2)
# CHECK-NEXT: SHF_EXECINSTR (0x4)
# CHECK-NEXT: ]
# CHECK-NEXT: Address: 0x401000
# CHECK-NEXT: Offset: 0x1000
# CHECK-NEXT: Address: 0x4010B4
# CHECK-NEXT: Offset: 0xB4
# CHECK-NEXT: Size: 12
# CHECK-NEXT: Link: 0
# CHECK-NEXT: Info: 0
@ -75,7 +75,7 @@ _start:
# CHECK-NEXT: SHF_STRINGS (0x20)
# CHECK-NEXT: ]
# CHECK-NEXT: Address: 0x0
# CHECK-NEXT: Offset: 0x100C
# CHECK-NEXT: Offset: 0xC0
# CHECK-NEXT: Size: 8
# CHECK-NEXT: Link: 0
# CHECK-NEXT: Info: 0
@ -89,7 +89,7 @@ _start:
# CHECK-NEXT: Flags [
# CHECK-NEXT: ]
# CHECK-NEXT: Address: 0x0
# CHECK-NEXT: Offset: 0x1014
# CHECK-NEXT: Offset: 0xC8
# CHECK-NEXT: Size: 32
# CHECK-NEXT: Link: 5
# CHECK-NEXT: Info: 1
@ -103,7 +103,7 @@ _start:
# CHECK-NEXT: Flags [ (0x0)
# CHECK-NEXT: ]
# CHECK-NEXT: Address: 0x0
# CHECK-NEXT: Offset: 0x1034
# CHECK-NEXT: Offset: 0xE8
# CHECK-NEXT: Size: 42
# CHECK-NEXT: Link: 0
# CHECK-NEXT: Info: 0
@ -117,7 +117,7 @@ _start:
# CHECK-NEXT: Flags [ (0x0)
# CHECK-NEXT: ]
# CHECK-NEXT: Address: 0x0
# CHECK-NEXT: Offset: 0x105E
# CHECK-NEXT: Offset: 0x112
# CHECK-NEXT: Size: 8
# CHECK-NEXT: Link: 0
# CHECK-NEXT: Info: 0
@ -129,8 +129,8 @@ _start:
# CHECK-NEXT: ProgramHeader {
# CHECK-NEXT: Type: PT_PHDR (0x6)
# CHECK-NEXT: Offset: 0x34
# CHECK-NEXT: VirtualAddress: 0x400034
# CHECK-NEXT: PhysicalAddress: 0x400034
# CHECK-NEXT: VirtualAddress: 0x401034
# CHECK-NEXT: PhysicalAddress: 0x401034
# CHECK-NEXT: FileSize: 128
# CHECK-NEXT: MemSize: 128
# CHECK-NEXT: Flags [ (0x4)
@ -141,8 +141,8 @@ _start:
# CHECK-NEXT: ProgramHeader {
# CHECK-NEXT: Type: PT_LOAD (0x1)
# CHECK-NEXT: Offset: 0x0
# CHECK-NEXT: VirtualAddress: 0x400000
# CHECK-NEXT: PhysicalAddress: 0x400000
# CHECK-NEXT: VirtualAddress: 0x401000
# CHECK-NEXT: PhysicalAddress: 0x401000
# CHECK-NEXT: FileSize: 180
# CHECK-NEXT: MemSize: 180
# CHECK-NEXT: Flags [
@ -152,9 +152,9 @@ _start:
# CHECK-NEXT: }
# CHECK-NEXT: ProgramHeader {
# CHECK-NEXT: Type: PT_LOAD (0x1)
# CHECK-NEXT: Offset: 0x1000
# CHECK-NEXT: VirtualAddress: 0x401000
# CHECK-NEXT: PhysicalAddress: 0x401000
# CHECK-NEXT: Offset: 0xB4
# CHECK-NEXT: VirtualAddress: 0x4010B4
# CHECK-NEXT: PhysicalAddress: 0x4010B4
# CHECK-NEXT: FileSize: 12
# CHECK-NEXT: MemSize: 12
# CHECK-NEXT: Flags [ (0x5)

View File

@ -17,7 +17,7 @@
// CHECK-NEXT: AddressAlignment:
// CHECK-NEXT: EntrySize:
// CHECK-NEXT: SectionData (
// CHECK-NEXT: 0000: 00200000
// CHECK-NEXT: 0000: 74210000
// CHECK-NEXT: )
// CHECK: Name: .got.plt
@ -34,19 +34,19 @@
// CHECK-NEXT: AddressAlignment:
// CHECK-NEXT: EntrySize:
// CHECK-NEXT: SectionData (
// CHECK-NEXT: 0000: 00200000 00000000 00000000
// CHECK-NEXT: 0000: 74210000 00000000 00000000
// CHECK-NEXT: )
// CHECK: Relocations [
// CHECK-NEXT: Section ({{.*}}) .rel.dyn {
// CHECK-NEXT: 0x2050 R_386_RELATIVE - 0x0
// CHECK-NEXT: 0x21C4 R_386_RELATIVE - 0x0
// CHECK-NEXT: }
// CHECK-NEXT: ]
// CHECK: Type: PT_DYNAMIC
// CHECK-NEXT: Offset: 0x2000
// CHECK-NEXT: VirtualAddress: 0x2000
// CHECK-NEXT: PhysicalAddress: 0x2000
// CHECK-NEXT: Offset: 0x174
// CHECK-NEXT: VirtualAddress: 0x2174
// CHECK-NEXT: PhysicalAddress: 0x2174
calll .L0$pb
.L0$pb:

View File

@ -22,7 +22,7 @@ addl $_GLOBAL_OFFSET_TABLE_, %eax
calll f@PLT
// CHECK: Name: _GLOBAL_OFFSET_TABLE_ (1)
// CHECK-NEXT: Value: 0x3000
// CHECK-NEXT: Value: 0x325C
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Local (0x0)
// CHECK-NEXT: Type: None (0x0)

View File

@ -22,8 +22,8 @@
// CHECK-NEXT: }
// CHECK: Relocations [
// CHECK-NEXT: Section ({{.*}}) .rel.dyn {
// CHECK-NEXT: 0x402000 R_386_IRELATIVE
// CHECK-NEXT: 0x402004 R_386_IRELATIVE
// CHECK-NEXT: 0x402120 R_386_IRELATIVE
// CHECK-NEXT: 0x402124 R_386_IRELATIVE
// CHECK-NEXT: }
// CHECK-NEXT: ]
@ -61,7 +61,7 @@
// CHECK-NEXT: }
// CHECK-NEXT: Symbol {
// CHECK-NEXT: Name: _start
// CHECK-NEXT: Value: 0x401002
// CHECK-NEXT: Value: 0x4010E6
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Global
// CHECK-NEXT: Type: None
@ -70,7 +70,7 @@
// CHECK-NEXT: }
// CHECK-NEXT: Symbol {
// CHECK-NEXT: Name: bar
// CHECK-NEXT: Value: 0x401030
// CHECK-NEXT: Value: 0x401110
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Global
// CHECK-NEXT: Type: Function
@ -79,7 +79,7 @@
// CHECK-NEXT: }
// CHECK-NEXT: Symbol {
// CHECK-NEXT: Name: bar_resolver
// CHECK-NEXT: Value: 0x401001
// CHECK-NEXT: Value: 0x4010E5
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Global
// CHECK-NEXT: Type: Function
@ -88,7 +88,7 @@
// CHECK-NEXT: }
// CHECK-NEXT: Symbol {
// CHECK-NEXT: Name: foo
// CHECK-NEXT: Value: 0x401020
// CHECK-NEXT: Value: 0x401100
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Global
// CHECK-NEXT: Type: Function
@ -97,7 +97,7 @@
// CHECK-NEXT: }
// CHECK-NEXT: Symbol {
// CHECK-NEXT: Name: foo_resolver
// CHECK-NEXT: Value: 0x401000
// CHECK-NEXT: Value: 0x4010E4
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Global
// CHECK-NEXT: Type: Function
@ -109,25 +109,25 @@
// DISASM: Disassembly of section .text:
// DISASM-EMPTY:
// DISASM-NEXT: foo_resolver:
// DISASM-NEXT: 401000: retl
// DISASM-NEXT: 4010e4: retl
// DISASM: bar_resolver:
// DISASM-NEXT: 401001: retl
// DISASM-NEXT: 4010e5: retl
// DISASM: _start:
// DISASM-NEXT: 401002: calll 25
// DISASM-NEXT: calll 36
// DISASM-NEXT: 4010e6: calll 21 <foo>
// DISASM-NEXT: calll 32 <bar>
// DISASM-NEXT: movl $4194516, %edx
// DISASM-NEXT: movl $4194532, %edx
// DISASM-EMPTY:
// DISASM-NEXT: Disassembly of section .plt:
// DISASM-EMPTY:
// DISASM-NEXT: foo:
// DISASM-NEXT: 401020: jmpl *4202496
// DISASM-NEXT: 401100: jmpl *4202784
// DISASM-NEXT: pushl $16
// DISASM-NEXT: jmp -32 <_start+0xe>
// DISASM-NEXT: jmp -32 <_start+0xa>
// DISASM: bar:
// DISASM-NEXT: 401030: jmpl *4202500
// DISASM-NEXT: 401110: jmpl *4202788
// DISASM-NEXT: pushl $24
// DISASM-NEXT: jmp -48 <_start+0xe>
// DISASM-NEXT: jmp -48 <_start+0xa>
.text
.type foo STT_GNU_IFUNC

View File

@ -1,56 +1,56 @@
// REQUIRES: x86
// RUN: llvm-mc -filetype=obj -triple=i686-pc-freebsd %S/Inputs/shared2-x86-64.s -o %t1.o
// RUN: ld.lld %t1.o --shared -o %t.so
// RUN: ld.lld %t1.o --shared --soname=t.so -o %t.so
// RUN: llvm-mc -filetype=obj -triple=i686-pc-freebsd %s -o %t.o
// RUN: ld.lld -z ifunc-noplt -z notext --hash-style=sysv %t.so %t.o -o %tout
// RUN: llvm-objdump -d --no-show-raw-insn %tout | FileCheck %s --check-prefix=DISASM
// RUN: llvm-objdump -d --no-show-raw-insn --print-imm-hex %tout | FileCheck %s --check-prefix=DISASM
// RUN: llvm-readobj -r --dynamic-table %tout | FileCheck %s
// Check that we emitted relocations for the ifunc calls
// CHECK: Relocations [
// CHECK-NEXT: Section (4) .rel.dyn {
// CHECK-NEXT: 0x401008 R_386_PLT32 bar
// CHECK-NEXT: 0x401003 R_386_PLT32 foo
// CHECK-NEXT: 0x4011F4 R_386_PLT32 bar
// CHECK-NEXT: 0x4011EF R_386_PLT32 foo
// CHECK-NEXT: }
// CHECK-NEXT: Section (5) .rel.plt {
// CHECK-NEXT: 0x40300C R_386_JUMP_SLOT bar2
// CHECK-NEXT: 0x403010 R_386_JUMP_SLOT zed2
// CHECK-NEXT: 0x4032D4 R_386_JUMP_SLOT bar2
// CHECK-NEXT: 0x4032D8 R_386_JUMP_SLOT zed2
// CHECK-NEXT: }
// Check that ifunc call sites still require relocation
// DISASM: Disassembly of section .text:
// DISASM-EMPTY:
// DISASM-NEXT: 00401000 foo:
// DISASM-NEXT: 401000: retl
// DISASM-NEXT: 004011ec foo:
// DISASM-NEXT: retl
// DISASM-EMPTY:
// DISASM-NEXT: 00401001 bar:
// DISASM-NEXT: 401001: retl
// DISASM-NEXT: 004011ed bar:
// DISASM-NEXT: retl
// DISASM-EMPTY:
// DISASM-NEXT: 00401002 _start:
// DISASM-NEXT: 401002: calll -4 <_start+0x1>
// DISASM-NEXT: 401007: calll -4 <_start+0x6>
// DISASM-NEXT: 40100c: calll 31 <bar2@plt>
// DISASM-NEXT: 401011: calll 42 <zed2@plt>
// DISASM-NEXT: 004011ee _start:
// DISASM-NEXT: calll -0x4 <_start+0x1>
// DISASM-NEXT: calll -0x4 <_start+0x6>
// DISASM-NEXT: calll 0x23 <bar2@plt>
// DISASM-NEXT: calll 0x2e <zed2@plt>
// DISASM-EMPTY:
// DISASM-NEXT: Disassembly of section .plt:
// DISASM-EMPTY:
// DISASM-NEXT: 00401020 .plt:
// DISASM-NEXT: 401020: pushl 4206596
// DISASM-NEXT: 401026: jmpl *4206600
// DISASM-NEXT: 40102c: nop
// DISASM-NEXT: 40102d: nop
// DISASM-NEXT: 40102e: nop
// DISASM-NEXT: 40102f: nop
// DISASM-NEXT: 00401210 .plt:
// DISASM-NEXT: pushl 0x4032cc
// DISASM-NEXT: jmpl *0x4032d0
// DISASM-NEXT: nop
// DISASM-NEXT: nop
// DISASM-NEXT: nop
// DISASM-NEXT: nop
// DISASM-EMPTY:
// DISASM-NEXT: 00401030 bar2@plt:
// DISASM-NEXT: 401030: jmpl *4206604
// DISASM-NEXT: 401036: pushl $0
// DISASM-NEXT: 40103b: jmp -32 <.plt>
// DISASM-NEXT: 00401220 bar2@plt:
// DISASM-NEXT: jmpl *0x4032d4
// DISASM-NEXT: pushl $0x0
// DISASM-NEXT: jmp -0x20 <.plt>
// DISASM-EMPTY:
// DISASM-NEXT: 00401040 zed2@plt:
// DISASM-NEXT: 401040: jmpl *4206608
// DISASM-NEXT: 401046: pushl $8
// DISASM-NEXT: 40104b: jmp -48 <.plt>
// DISASM-NEXT: 00401230 zed2@plt:
// DISASM-NEXT: jmpl *0x4032d8
// DISASM-NEXT: pushl $0x8
// DISASM-NEXT: jmp -0x30 <.plt>
.text
.type foo STT_GNU_IFUNC

View File

@ -10,19 +10,19 @@
// Check that the IRELATIVE relocations are after the JUMP_SLOT in the plt
// CHECK: Relocations [
// CHECK-NEXT: Section (4) .rel.dyn {
// CHECK-NEXT: 0x403014 R_386_IRELATIVE
// CHECK-NEXT: 0x403018 R_386_IRELATIVE
// CHECK-NEXT: 0x4032AC R_386_IRELATIVE
// CHECK-NEXT: 0x4032B0 R_386_IRELATIVE
// CHECK-NEXT: }
// CHECK-NEXT: Section (5) .rel.plt {
// CHECK-NEXT: 0x40300C R_386_JUMP_SLOT bar2
// CHECK-NEXT: 0x403010 R_386_JUMP_SLOT zed2
// CHECK-NEXT: 0x4032A4 R_386_JUMP_SLOT bar2
// CHECK-NEXT: 0x4032A8 R_386_JUMP_SLOT zed2
// CHECK-NEXT: }
// Check that IRELATIVE .got.plt entries point to ifunc resolver and not
// back to the plt entry + 6.
// GOTPLT: Contents of section .got.plt:
// GOTPLT: 403000 00204000 00000000 00000000 36104000
// GOTPLT-NEXT: 403010 46104000 00104000 01104000
// GOTPLT: 403298 20224000 00000000 00000000 e6114000
// GOTPLT-NEXT: 4032a8 f6114000 b4114000 b5114000
// Check that the PLTRELSZ tag does not include the IRELATIVE relocations
// CHECK: DynamicSection [
@ -33,38 +33,38 @@
// DISASM: Disassembly of section .text:
// DISASM-EMPTY:
// DISASM-NEXT: foo:
// DISASM-NEXT: 401000: retl
// DISASM-NEXT: 4011b4: retl
// DISASM: bar:
// DISASM-NEXT: 401001: retl
// DISASM-NEXT: 4011b5: retl
// DISASM: _start:
// DISASM-NEXT: 401002: calll 73 <zed2@plt+0x10>
// DISASM-NEXT: calll 84 <zed2@plt+0x20>
// DISASM-NEXT: calll 31 <bar2@plt>
// DISASM-NEXT: calll 42 <zed2@plt>
// DISASM-NEXT: 4011b6: calll 69 <zed2@plt+0x10>
// DISASM-NEXT: calll 80 <zed2@plt+0x20>
// DISASM-NEXT: calll 27 <bar2@plt>
// DISASM-NEXT: calll 38 <zed2@plt>
// DISASM-EMPTY:
// DISASM-NEXT: Disassembly of section .plt:
// DISASM-EMPTY:
// DISASM-NEXT: .plt:
// DISASM-NEXT: 401020: pushl 4206596
// DISASM-NEXT: jmpl *4206600
// DISASM-NEXT: 4011d0: pushl 4207260
// DISASM-NEXT: jmpl *4207264
// DISASM-NEXT: nop
// DISASM-NEXT: nop
// DISASM-NEXT: nop
// DISASM-NEXT: nop
// DISASM-EMPTY:
// DISASM-NEXT: bar2@plt:
// DISASM-NEXT: 401030: jmpl *4206604
// DISASM-NEXT: 4011e0: jmpl *4207268
// DISASM-NEXT: pushl $0
// DISASM-NEXT: jmp -32 <.plt>
// DISASM-EMPTY:
// DISASM-NEXT: zed2@plt:
// DISASM-NEXT: 401040: jmpl *4206608
// DISASM-NEXT: 4011f0: jmpl *4207272
// DISASM-NEXT: pushl $8
// DISASM-NEXT: jmp -48 <.plt>
// DISASM-NEXT: jmpl *4206612
// DISASM-NEXT: jmpl *4207276
// DISASM-NEXT: pushl $48
// DISASM-NEXT: jmp -32 <zed2@plt>
// DISASM-NEXT: jmpl *4206616
// DISASM-NEXT: jmpl *4207280
// DISASM-NEXT: pushl $56
// DISASM-NEXT: jmp -48 <zed2@plt>

View File

@ -10,7 +10,7 @@
// CHECK-NEXT: SHF_ALLOC
// CHECK-NEXT: SHF_WRITE
// CHECK-NEXT: ]
// CHECK-NEXT: Address: 0x402000
// CHECK-NEXT: Address: 0x4020F4
// CHECK-NEXT: Offset:
// CHECK-NEXT: Size:
// CHECK-NEXT: Link:
@ -19,7 +19,7 @@
// CHECK: Symbol {
// CHECK: Name: bar
// CHECK-NEXT: Value: 0x40200C
// CHECK-NEXT: Value: 0x402100
// CHECK-NEXT: Size: 10
// CHECK-NEXT: Binding: Global
// CHECK-NEXT: Type: Object
@ -28,7 +28,7 @@
// CHECK-NEXT: }
// CHECK-NEXT: Symbol {
// CHECK-NEXT: Name: obj
// CHECK-NEXT: Value: 0x402016
// CHECK-NEXT: Value: 0x40210A
// CHECK-NEXT: Size: 10
// CHECK-NEXT: Binding: Global
// CHECK-NEXT: Type: Object
@ -42,9 +42,9 @@
// DISASM: Disassembly of section .text:
// DISASM-EMPTY:
// DISASM-NEXT: _start:
// DISASM-NEXT: 401000: c7 81 0c 00 00 00 01 00 00 00 movl $1, 12(%ecx)
// DISASM-NEXT: 40100a: c7 81 16 00 00 00 02 00 00 00 movl $2, 22(%ecx)
// DISASM-NEXT: 401014: c7 81 1b 00 00 00 03 00 00 00 movl $3, 27(%ecx)
// DISASM-NEXT: 4010d4: c7 81 0c 00 00 00 01 00 00 00 movl $1, 12(%ecx)
// DISASM-NEXT: 4010de: c7 81 16 00 00 00 02 00 00 00 movl $2, 22(%ecx)
// DISASM-NEXT: 4010e8: c7 81 1b 00 00 00 03 00 00 00 movl $3, 27(%ecx)
.global _start
_start:

View File

@ -5,9 +5,9 @@
# Unlike bfd and gold we accept this.
# CHECK: .foobar PROGBITS 00001000
# CHECK: .foobar PROGBITS 00002180
# CHECK: .got PROGBITS [[GOT:[0-9a-z]*]]
# CHECK-DAG: 00001002 00000008 R_386_RELATIVE
# CHECK-DAG: 00002182 00000008 R_386_RELATIVE
# CHECK-DAG: [[GOT]] 00000008 R_386_RELATIVE
foo:

View File

@ -14,10 +14,10 @@ _start:
## 73728 == 0x12000 == ADDR(.got)
# CHECK: _start:
# CHECK-NEXT: 401001: 8b 1d {{.*}} movl 4202496, %ebx
# CHECK-NEXT: 4010f5: 8b 1d {{.*}} movl 4202748, %ebx
# CHECK: Sections:
# CHECK: Name Size VMA
# CHECK: .got 00000004 0000000000402000
# CHECK: .got 00000004 00000000004020fc
# RUN: not ld.lld %t.o -o %t -pie 2>&1 | FileCheck %s --check-prefix=ERR
# ERR: error: symbol 'foo' cannot be preempted; recompile with -fPIE

View File

@ -33,13 +33,13 @@
## 73728 == 0x12000 == ADDR(.got)
# CHECK: _start:
# CHECK-NEXT: 401001: 8b 05 {{.*}} movl 4202496, %eax
# CHECK-NEXT: 401007: 8b 1d {{.*}} movl 4202496, %ebx
# CHECK-NEXT: 40100d: 8b 80 {{.*}} movl -4096(%eax), %eax
# CHECK-NEXT: 401013: 8b 83 {{.*}} movl -4096(%ebx), %eax
# CHECK-NEXT: 401115: 8b 05 {{.*}} movl 4202800, %eax
# CHECK-NEXT: 40111b: 8b 1d {{.*}} movl 4202800, %ebx
# CHECK-NEXT: 401121: 8b 80 {{.*}} movl -4100(%eax), %eax
# CHECK-NEXT: 401127: 8b 83 {{.*}} movl -4100(%ebx), %eax
# CHECK: Sections:
# CHECK: Name Size VMA
# CHECK: .got.plt 0000000c 0000000000403000
# CHECK: .got.plt 0000000c 0000000000403134
# RUN: not ld.lld %S/Inputs/i386-got32x-baseless.elf -o %t1 -pie 2>&1 | \
# RUN: FileCheck %s --check-prefix=ERR

View File

@ -8,8 +8,8 @@ bar:
movl bar@GOTOFF(%ebx), %eax
mov bar@GOT, %eax
// CHECK: .got.plt PROGBITS 00003000
// CHECK: .got.plt PROGBITS 000031e0
// 0x1000 - 0x3000 (.got.plt) = -8192
// 0x1178 - 0x31e0 (.got.plt) = -8296
// DISASM: 1000: movl -8192(%ebx), %eax
// DISASM: 1178: movl -8296(%ebx), %eax

View File

@ -4,10 +4,10 @@
# RUN: llvm-readelf -S %t.so | FileCheck %s
# RUN: llvm-objdump -d %t.so | FileCheck --check-prefix=DISASM %s
# CHECK: .got.plt PROGBITS 00003000
# CHECK: .got.plt PROGBITS 00003190
## 0x3000 - 0x1000 = 8192
# DISASM: 1000: {{.*}} movl $8192, %eax
## 0x3190 - 0x1158 = 8248
# DISASM: 1158: {{.*}} movl $8248, %eax
.section .foo,"ax",@progbits
foo:

View File

@ -6,10 +6,10 @@
movl $_GLOBAL_OFFSET_TABLE_, %eax
// CHECK: .got.plt PROGBITS 00003000
// CHECK: .got.plt PROGBITS 00003190
// DISASM: Disassembly of section .text:
// DISASM-EMPTY:
// DISASM-NEXT: .text:
// DISASM-NEXT: 1000: movl $8192, %eax
// ^-- 0x3000 (.got.plt) - 0x1000 = 8192
// DISASM-NEXT: 1158: movl $8248, %eax
// ^-- 0x3190 (.got.plt) - 0x1158 = 8248

View File

@ -27,8 +27,8 @@
// CHECK-NEXT: SHF_ALLOC
// CHECK-NEXT: SHF_WRITE
// CHECK-NEXT: ]
// CHECK-NEXT: Address: 0x2000
// CHECK-NEXT: Offset: 0x2000
// CHECK-NEXT: Address: 0x31D4
// CHECK-NEXT: Offset: 0x1D4
// CHECK-NEXT: Size: 4
// CHECK-NEXT: Link: 0
// CHECK-NEXT: Info: 0

View File

@ -4,11 +4,11 @@
# RUN: ld.lld %t1.o -o %t.out
# RUN: llvm-objdump -s -t %t.out | FileCheck %s
# CHECK: Contents of section .text:
# CHECK-NEXT: 401000 020000
## 0x401003 - 0x401000 + addend(-1) = 0x02
## 0x401003 - 0x401001 + addend(-2) = 0x0000
# CHECK-NEXT: 4010b4 020000
## 0x4010b7 - 0x4010b4 + addend(-1) = 0x02
## 0x4010b7 - 0x4010b5 + addend(-2) = 0x0000
# CHECK: SYMBOL TABLE:
# CHECK: 00401003 .und
# CHECK: 004010b7 .und
.byte und-.-1
.short und-.-2

View File

@ -2,15 +2,14 @@
// RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %s -o %t.o -relax-relocations
// RUN: ld.lld -shared %t.o -o %t.so
// RUN: llvm-readelf -S %t.so | FileCheck --check-prefix=SEC %s
// RUN: llvm-objdump -d %t.so | FileCheck %s
// RUN: llvm-objdump -d --no-show-raw-insn %t.so | FileCheck %s
// SEC: .got PROGBITS 00002050
// SEC-NEXT: .got.plt PROGBITS 00003000
// SEC: .got PROGBITS 000021f0
// SEC-NEXT: .got.plt PROGBITS 000031f4
// 0x2050 - 0x3000 = -4016
// CHECK: foo:
// CHECK-NEXT: movl -4016(%ebx), %eax
// CHECK-NEXT: movl -4008(%ebx), %eax
// CHECK-NEXT: 1194: movl -4100(%ebx), %eax
// CHECK-NEXT: movl -4092(%ebx), %eax
foo:
movl bar@GOT(%ebx), %eax

View File

@ -9,56 +9,56 @@
// CHECK: Disassembly of section .plt:
// CHECK-EMPTY:
// CHECK-NEXT: .plt:
// CHECK-NEXT: 401010: pushl 4206596
// CHECK-NEXT: 401016: pushl %eax
// CHECK-NEXT: 401017: movl 4206600, %eax
// CHECK-NEXT: 40101c: calll 15 <.plt+0x20>
// CHECK-NEXT: 401021: pause
// CHECK-NEXT: 401023: lfence
// CHECK-NEXT: 401026: jmp -7 <.plt+0x11>
// CHECK-NEXT: 401028: int3
// CHECK-NEXT: 401029: int3
// CHECK-NEXT: 40102a: int3
// CHECK-NEXT: 40102b: int3
// CHECK-NEXT: 40102c: int3
// CHECK-NEXT: 40102d: int3
// CHECK-NEXT: 40102e: int3
// CHECK-NEXT: 40102f: int3
// CHECK-NEXT: 401030: movl %ecx, (%esp)
// CHECK-NEXT: 401033: movl 4(%esp), %ecx
// CHECK-NEXT: 401037: movl %eax, 4(%esp)
// CHECK-NEXT: 40103b: movl %ecx, %eax
// CHECK-NEXT: 40103d: popl %ecx
// CHECK-NEXT: 40103e: retl
// CHECK-NEXT: 40103f: int3
// CHECK-NEXT: 401040: pushl %eax
// CHECK-NEXT: 401041: movl 4206604, %eax
// CHECK-NEXT: 401046: calll -27 <.plt+0x20>
// CHECK-NEXT: 40104b: jmp -47 <.plt+0x11>
// CHECK-NEXT: 401050: pushl $0
// CHECK-NEXT: 401055: jmp -74 <.plt>
// CHECK-NEXT: 40105a: int3
// CHECK-NEXT: 40105b: int3
// CHECK-NEXT: 40105c: int3
// CHECK-NEXT: 40105d: int3
// CHECK-NEXT: 40105e: int3
// CHECK-NEXT: 40105f: int3
// CHECK-NEXT: 401060: pushl %eax
// CHECK-NEXT: 401061: movl 4206608, %eax
// CHECK-NEXT: 401066: calll -59 <.plt+0x20>
// CHECK-NEXT: 40106b: jmp -79 <.plt+0x11>
// CHECK-NEXT: 401070: pushl $8
// CHECK-NEXT: 401075: jmp -106 <.plt>
// CHECK-NEXT: 40107a: int3
// CHECK-NEXT: 40107b: int3
// CHECK-NEXT: 40107c: int3
// CHECK-NEXT: 40107d: int3
// CHECK-NEXT: 40107e: int3
// CHECK-NEXT: 40107f: int3
// CHECK-NEXT: 4011d0: pushl 4207276
// CHECK-NEXT: 4011d6: pushl %eax
// CHECK-NEXT: 4011d7: movl 4207280, %eax
// CHECK-NEXT: 4011dc: calll 15 <.plt+0x20>
// CHECK-NEXT: 4011e1: pause
// CHECK-NEXT: 4011e3: lfence
// CHECK-NEXT: 4011e6: jmp -7 <.plt+0x11>
// CHECK-NEXT: 4011e8: int3
// CHECK-NEXT: 4011e9: int3
// CHECK-NEXT: 4011ea: int3
// CHECK-NEXT: 4011eb: int3
// CHECK-NEXT: 4011ec: int3
// CHECK-NEXT: 4011ed: int3
// CHECK-NEXT: 4011ee: int3
// CHECK-NEXT: 4011ef: int3
// CHECK-NEXT: 4011f0: movl %ecx, (%esp)
// CHECK-NEXT: 4011f3: movl 4(%esp), %ecx
// CHECK-NEXT: 4011f7: movl %eax, 4(%esp)
// CHECK-NEXT: 4011fb: movl %ecx, %eax
// CHECK-NEXT: 4011fd: popl %ecx
// CHECK-NEXT: 4011fe: retl
// CHECK-NEXT: 4011ff: int3
// CHECK-NEXT: 401200: pushl %eax
// CHECK-NEXT: 401201: movl 4207284, %eax
// CHECK-NEXT: 401206: calll -27 <.plt+0x20>
// CHECK-NEXT: 40120b: jmp -47 <.plt+0x11>
// CHECK-NEXT: 401210: pushl $0
// CHECK-NEXT: 401215: jmp -74 <.plt>
// CHECK-NEXT: 40121a: int3
// CHECK-NEXT: 40121b: int3
// CHECK-NEXT: 40121c: int3
// CHECK-NEXT: 40121d: int3
// CHECK-NEXT: 40121e: int3
// CHECK-NEXT: 40121f: int3
// CHECK-NEXT: 401220: pushl %eax
// CHECK-NEXT: 401221: movl 4207288, %eax
// CHECK-NEXT: 401226: calll -59 <.plt+0x20>
// CHECK-NEXT: 40122b: jmp -79 <.plt+0x11>
// CHECK-NEXT: 401230: pushl $8
// CHECK-NEXT: 401235: jmp -106 <.plt>
// CHECK-NEXT: 40123a: int3
// CHECK-NEXT: 40123b: int3
// CHECK-NEXT: 40123c: int3
// CHECK-NEXT: 40123d: int3
// CHECK-NEXT: 40123e: int3
// CHECK-NEXT: 40123f: int3
// CHECK: Contents of section .got.plt:
// CHECK-NEXT: 00204000 00000000 00000000 50104000
// CHECK-NEXT: 70104000
// CHECK-NEXT: 40224000 00000000 00000000 10124000
// CHECK-NEXT: 30124000
.global _start
_start:

View File

@ -9,53 +9,53 @@
// CHECK: Disassembly of section .plt:
// CHECK-EMPTY:
// CHECK-NEXT: .plt:
// CHECK-NEXT: 1010: pushl 4(%ebx)
// CHECK-NEXT: 1016: pushl %eax
// CHECK-NEXT: 1017: movl 8(%ebx), %eax
// CHECK-NEXT: 101d: calll 14 <.plt+0x20>
// CHECK-NEXT: 1022: pause
// CHECK-NEXT: 1024: lfence
// CHECK-NEXT: 1027: jmp -7 <.plt+0x12>
// CHECK-NEXT: 1029: int3
// CHECK-NEXT: 102a: int3
// CHECK-NEXT: 102b: int3
// CHECK-NEXT: 102c: int3
// CHECK-NEXT: 102d: int3
// CHECK-NEXT: 102e: int3
// CHECK-NEXT: 102f: int3
// CHECK-NEXT: 1030: movl %ecx, (%esp)
// CHECK-NEXT: 1033: movl 4(%esp), %ecx
// CHECK-NEXT: 1037: movl %eax, 4(%esp)
// CHECK-NEXT: 103b: movl %ecx, %eax
// CHECK-NEXT: 103d: popl %ecx
// CHECK-NEXT: 103e: retl
// CHECK-NEXT: 103f: int3
// CHECK-NEXT: 1040: pushl %eax
// CHECK-NEXT: 1041: movl 12(%ebx), %eax
// CHECK-NEXT: 1047: calll -28 <.plt+0x20>
// CHECK-NEXT: 104c: jmp -47 <.plt+0x12>
// CHECK-NEXT: 1051: pushl $0
// CHECK-NEXT: 1056: jmp -75 <.plt>
// CHECK-NEXT: 105b: int3
// CHECK-NEXT: 105c: int3
// CHECK-NEXT: 105d: int3
// CHECK-NEXT: 105e: int3
// CHECK-NEXT: 105f: int3
// CHECK-NEXT: 1060: pushl %eax
// CHECK-NEXT: 1061: movl 16(%ebx), %eax
// CHECK-NEXT: 1067: calll -60 <.plt+0x20>
// CHECK-NEXT: 106c: jmp -79 <.plt+0x12>
// CHECK-NEXT: 1071: pushl $8
// CHECK-NEXT: 1076: jmp -107 <.plt>
// CHECK-NEXT: 107b: int3
// CHECK-NEXT: 107c: int3
// CHECK-NEXT: 107d: int3
// CHECK-NEXT: 107e: int3
// CHECK-NEXT: 107f: int3
// CHECK-NEXT: 11d0: pushl 4(%ebx)
// CHECK-NEXT: 11d6: pushl %eax
// CHECK-NEXT: 11d7: movl 8(%ebx), %eax
// CHECK-NEXT: 11dd: calll 14 <.plt+0x20>
// CHECK-NEXT: 11e2: pause
// CHECK-NEXT: 11e4: lfence
// CHECK-NEXT: 11e7: jmp -7 <.plt+0x12>
// CHECK-NEXT: 11e9: int3
// CHECK-NEXT: 11ea: int3
// CHECK-NEXT: 11eb: int3
// CHECK-NEXT: 11ec: int3
// CHECK-NEXT: 11ed: int3
// CHECK-NEXT: 11ee: int3
// CHECK-NEXT: 11ef: int3
// CHECK-NEXT: 11f0: movl %ecx, (%esp)
// CHECK-NEXT: 11f3: movl 4(%esp), %ecx
// CHECK-NEXT: 11f7: movl %eax, 4(%esp)
// CHECK-NEXT: 11fb: movl %ecx, %eax
// CHECK-NEXT: 11fd: popl %ecx
// CHECK-NEXT: 11fe: retl
// CHECK-NEXT: 11ff: int3
// CHECK-NEXT: 1200: pushl %eax
// CHECK-NEXT: 1201: movl 12(%ebx), %eax
// CHECK-NEXT: 1207: calll -28 <.plt+0x20>
// CHECK-NEXT: 120c: jmp -47 <.plt+0x12>
// CHECK-NEXT: 1211: pushl $0
// CHECK-NEXT: 1216: jmp -75 <.plt>
// CHECK-NEXT: 121b: int3
// CHECK-NEXT: 121c: int3
// CHECK-NEXT: 121d: int3
// CHECK-NEXT: 121e: int3
// CHECK-NEXT: 121f: int3
// CHECK-NEXT: 1220: pushl %eax
// CHECK-NEXT: 1221: movl 16(%ebx), %eax
// CHECK-NEXT: 1227: calll -60 <.plt+0x20>
// CHECK-NEXT: 122c: jmp -79 <.plt+0x12>
// CHECK-NEXT: 1231: pushl $8
// CHECK-NEXT: 1236: jmp -107 <.plt>
// CHECK-NEXT: 123b: int3
// CHECK-NEXT: 123c: int3
// CHECK-NEXT: 123d: int3
// CHECK-NEXT: 123e: int3
// CHECK-NEXT: 123f: int3
// CHECK: Contents of section .got.plt:
// CHECK-NEXT: 3000 00200000 00000000 00000000 51100000
// CHECK-NEXT: 3010 71100000
// CHECK-NEXT: 32a8 40220000 00000000 00000000 11120000
// CHECK-NEXT: 32b8 31120000
.global _start
_start:

View File

@ -56,8 +56,8 @@ addl tls1@gotntpoff(%ebx),%eax
# CHECK-NEXT: SHF_ALLOC
# CHECK-NEXT: SHF_WRITE
# CHECK-NEXT: ]
# CHECK-NEXT: Address: 0x2078
# CHECK-NEXT: Offset: 0x2078
# CHECK-NEXT: Address: 0x2358
# CHECK-NEXT: Offset: 0x358
# CHECK-NEXT: Size: 32
# CHECK-NEXT: Link: 0
# CHECK-NEXT: Info: 0
@ -66,35 +66,35 @@ addl tls1@gotntpoff(%ebx),%eax
# CHECK: Relocations [
# CHECK: Section ({{.+}}) .rel.dyn {
# CHECK-NEXT: 0x2088 R_386_TLS_DTPMOD32 - 0x0
# CHECK-NEXT: 0x2078 R_386_TLS_DTPMOD32 tls0 0x0
# CHECK-NEXT: 0x207C R_386_TLS_DTPOFF32 tls0 0x0
# CHECK-NEXT: 0x2090 R_386_TLS_TPOFF tls0 0x0
# CHECK-NEXT: 0x2080 R_386_TLS_DTPMOD32 tls1 0x0
# CHECK-NEXT: 0x2084 R_386_TLS_DTPOFF32 tls1 0x0
# CHECK-NEXT: 0x2094 R_386_TLS_TPOFF tls1 0x0
# CHECK-NEXT: 0x2368 R_386_TLS_DTPMOD32 - 0x0
# CHECK-NEXT: 0x2358 R_386_TLS_DTPMOD32 tls0 0x0
# CHECK-NEXT: 0x235C R_386_TLS_DTPOFF32 tls0 0x0
# CHECK-NEXT: 0x2370 R_386_TLS_TPOFF tls0 0x0
# CHECK-NEXT: 0x2360 R_386_TLS_DTPMOD32 tls1 0x0
# CHECK-NEXT: 0x2364 R_386_TLS_DTPOFF32 tls1 0x0
# CHECK-NEXT: 0x2374 R_386_TLS_TPOFF tls1 0x0
# CHECK-NEXT: }
# DIS: Disassembly of section .text:
# DIS-EMPTY:
# DIS-NEXT: _start:
## General dynamic model:
## -3976 and -3968 are first and second GOT entries offsets.
## -4128 and -4120 are first and second GOT entries offsets.
## Each one is a pair of records.
# DIS-NEXT: 1000: leal -3976(,%ebx), %eax
# DIS-NEXT: 1007: calll 100
# DIS-NEXT: 100c: leal -3968(,%ebx), %eax
# DIS-NEXT: 1013: calll 88
# DIS-NEXT: 1260: leal -4128(,%ebx), %eax
# DIS-NEXT: 1267: calll 100
# DIS-NEXT: 126c: leal -4120(,%ebx), %eax
# DIS-NEXT: 1273: calll 88
## Local dynamic model:
## -16 is a local module tls index offset.
# DIS-NEXT: 1018: leal -3960(%ebx), %eax
# DIS-NEXT: 101e: calll 77
# DIS-NEXT: 1023: leal 8(%eax), %edx
# DIS-NEXT: 1029: leal -3960(%ebx), %eax
# DIS-NEXT: 102f: calll 60
# DIS-NEXT: 1034: leal 12(%eax), %edx
# DIS-NEXT: 1278: leal -4112(%ebx), %eax
# DIS-NEXT: 127e: calll 77
# DIS-NEXT: 1283: leal 8(%eax), %edx
# DIS-NEXT: 1289: leal -4112(%ebx), %eax
# DIS-NEXT: 128f: calll 60
# DIS-NEXT: 1294: leal 12(%eax), %edx
## Initial exec model:
# DIS-NEXT: 103a: movl %gs:0, %eax
# DIS-NEXT: 1040: addl -3952(%ebx), %eax
# DIS-NEXT: 1046: movl %gs:0, %eax
# DIS-NEXT: 104c: addl -3948(%ebx), %eax
# DIS-NEXT: 129a: movl %gs:0, %eax
# DIS-NEXT: 12a0: addl -4104(%ebx), %eax
# DIS-NEXT: 12a6: movl %gs:0, %eax
# DIS-NEXT: 12ac: addl -4100(%ebx), %eax

View File

@ -8,18 +8,18 @@
// NORELOC: Relocations [
// NORELOC-NEXT: Section ({{.*}}) .rel.dyn {
// NORELOC-NEXT: 0x402058 R_386_TLS_TPOFF tlsshared0 0x0
// NORELOC-NEXT: 0x40205C R_386_TLS_TPOFF tlsshared1 0x0
// NORELOC-NEXT: 0x402258 R_386_TLS_TPOFF tlsshared0 0x0
// NORELOC-NEXT: 0x40225C R_386_TLS_TPOFF tlsshared1 0x0
// NORELOC-NEXT: }
// NORELOC-NEXT: ]
// DISASM: Disassembly of section .text:
// DISASM-EMPTY:
// DISASM-NEXT: _start:
// DISASM-NEXT: 401000: movl %gs:0, %eax
// DISASM-NEXT: addl -4008(%ebx), %eax
// DISASM-NEXT: 4011d0: movl %gs:0, %eax
// DISASM-NEXT: addl -4104(%ebx), %eax
// DISASM-NEXT: movl %gs:0, %eax
// DISASM-NEXT: addl -4004(%ebx), %eax
// DISASM-NEXT: addl -4100(%ebx), %eax
// DISASM-NEXT: movl %gs:0, %eax
// DISASM-NEXT: subl $8, %eax
// DISASM-NEXT: movl %gs:0, %eax

View File

@ -2,20 +2,19 @@
// RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %s -o %t.o
// RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %p/Inputs/tls-opt-iele-i686-nopic.s -o %tso.o
// RUN: ld.lld -shared -soname=t.so %tso.o -o %tso
// RUN: ld.lld --hash-style=sysv -shared %t.o %tso -o %t1
// RUN: ld.lld -shared %t.o %tso -o %t1
// RUN: llvm-readobj -S -r -d %t1 | FileCheck --check-prefix=GOTRELSHARED %s
// RUN: llvm-objdump -d --no-show-raw-insn %t1 | FileCheck --check-prefix=DISASMSHARED %s
// GOTRELSHARED: Section {
// GOTRELSHARED: Index: 8
// GOTRELSHARED: Name: .got
// GOTRELSHARED-NEXT: Type: SHT_PROGBITS
// GOTRELSHARED-NEXT: Flags [
// GOTRELSHARED-NEXT: SHF_ALLOC
// GOTRELSHARED-NEXT: SHF_WRITE
// GOTRELSHARED-NEXT: ]
// GOTRELSHARED-NEXT: Address: 0x2060
// GOTRELSHARED-NEXT: Offset: 0x2060
// GOTRELSHARED-NEXT: Address: 0x3388
// GOTRELSHARED-NEXT: Offset: 0x388
// GOTRELSHARED-NEXT: Size: 16
// GOTRELSHARED-NEXT: Link: 0
// GOTRELSHARED-NEXT: Info: 0
@ -24,18 +23,18 @@
// GOTRELSHARED-NEXT: }
// GOTRELSHARED: Relocations [
// GOTRELSHARED-NEXT: Section ({{.*}}) .rel.dyn {
// GOTRELSHARED-NEXT: 0x1002 R_386_RELATIVE - 0x0
// GOTRELSHARED-NEXT: 0x100A R_386_RELATIVE - 0x0
// GOTRELSHARED-NEXT: 0x1013 R_386_RELATIVE - 0x0
// GOTRELSHARED-NEXT: 0x101C R_386_RELATIVE - 0x0
// GOTRELSHARED-NEXT: 0x1024 R_386_RELATIVE - 0x0
// GOTRELSHARED-NEXT: 0x102D R_386_RELATIVE - 0x0
// GOTRELSHARED-NEXT: 0x1036 R_386_RELATIVE - 0x0
// GOTRELSHARED-NEXT: 0x103F R_386_RELATIVE - 0x0
// GOTRELSHARED-NEXT: 0x2060 R_386_TLS_TPOFF tlslocal0 0x0
// GOTRELSHARED-NEXT: 0x2064 R_386_TLS_TPOFF tlslocal1 0x0
// GOTRELSHARED-NEXT: 0x2068 R_386_TLS_TPOFF tlsshared0 0x0
// GOTRELSHARED-NEXT: 0x206C R_386_TLS_TPOFF tlsshared1 0x0
// GOTRELSHARED-NEXT: 0x22DA R_386_RELATIVE - 0x0
// GOTRELSHARED-NEXT: 0x22E2 R_386_RELATIVE - 0x0
// GOTRELSHARED-NEXT: 0x22EB R_386_RELATIVE - 0x0
// GOTRELSHARED-NEXT: 0x22F4 R_386_RELATIVE - 0x0
// GOTRELSHARED-NEXT: 0x22FC R_386_RELATIVE - 0x0
// GOTRELSHARED-NEXT: 0x2305 R_386_RELATIVE - 0x0
// GOTRELSHARED-NEXT: 0x230E R_386_RELATIVE - 0x0
// GOTRELSHARED-NEXT: 0x2317 R_386_RELATIVE - 0x0
// GOTRELSHARED-NEXT: 0x3390 R_386_TLS_TPOFF tlsshared0 0x0
// GOTRELSHARED-NEXT: 0x3394 R_386_TLS_TPOFF tlsshared1 0x0
// GOTRELSHARED-NEXT: 0x3388 R_386_TLS_TPOFF tlslocal0 0x0
// GOTRELSHARED-NEXT: 0x338C R_386_TLS_TPOFF tlslocal1 0x0
// GOTRELSHARED-NEXT: }
// GOTRELSHARED-NEXT: ]
// GOTRELSHARED: 0x6FFFFFFA RELCOUNT 8
@ -43,26 +42,26 @@
// DISASMSHARED: Disassembly of section test:
// DISASMSHARED-EMPTY:
// DISASMSHARED-NEXT: _start:
// (.got)[0] = 0x2060 = 8288
// (.got)[1] = 0x2064 = 8292
// (.got)[2] = 0x2068 = 8296
// (.got)[3] = 0x206C = 8300
// DISASMSHARED-NEXT: 1000: movl 8288, %ecx
// DISASMSHARED-NEXT: 1006: movl %gs:(%ecx), %eax
// DISASMSHARED-NEXT: 1009: movl 8288, %eax
// DISASMSHARED-NEXT: 100e: movl %gs:(%eax), %eax
// DISASMSHARED-NEXT: 1011: addl 8288, %ecx
// DISASMSHARED-NEXT: 1017: movl %gs:(%ecx), %eax
// DISASMSHARED-NEXT: 101a: movl 8292, %ecx
// DISASMSHARED-NEXT: 1020: movl %gs:(%ecx), %eax
// DISASMSHARED-NEXT: 1023: movl 8292, %eax
// DISASMSHARED-NEXT: 1028: movl %gs:(%eax), %eax
// DISASMSHARED-NEXT: 102b: addl 8292, %ecx
// DISASMSHARED-NEXT: 1031: movl %gs:(%ecx), %eax
// DISASMSHARED-NEXT: 1034: movl 8296, %ecx
// DISASMSHARED-NEXT: 103a: movl %gs:(%ecx), %eax
// DISASMSHARED-NEXT: 103d: addl 8300, %ecx
// DISASMSHARED-NEXT: 1043: movl %gs:(%ecx), %eax
// (.got)[0] = 0x3388 = 13192
// (.got)[1] = 13196
// (.got)[2] = 13200
// (.got)[3] = 13204
// DISASMSHARED-NEXT: 22d8: movl 13192, %ecx
// DISASMSHARED-NEXT: 22de: movl %gs:(%ecx), %eax
// DISASMSHARED-NEXT: 22e1: movl 13192, %eax
// DISASMSHARED-NEXT: 22e6: movl %gs:(%eax), %eax
// DISASMSHARED-NEXT: 22e9: addl 13192, %ecx
// DISASMSHARED-NEXT: 22ef: movl %gs:(%ecx), %eax
// DISASMSHARED-NEXT: 22f2: movl 13196, %ecx
// DISASMSHARED-NEXT: 22f8: movl %gs:(%ecx), %eax
// DISASMSHARED-NEXT: 22fb: movl 13196, %eax
// DISASMSHARED-NEXT: 2300: movl %gs:(%eax), %eax
// DISASMSHARED-NEXT: 2303: addl 13196, %ecx
// DISASMSHARED-NEXT: 2309: movl %gs:(%ecx), %eax
// DISASMSHARED-NEXT: 230c: movl 13200, %ecx
// DISASMSHARED-NEXT: 2312: movl %gs:(%ecx), %eax
// DISASMSHARED-NEXT: 2315: addl 13204, %ecx
// DISASMSHARED-NEXT: 231b: movl %gs:(%ecx), %eax
.type tlslocal0,@object
.section .tbss,"awT",@nobits

View File

@ -3,7 +3,7 @@
# RUN: ld.lld %t.o -shared -o %t.so
# RUN: llvm-objdump -d --no-show-raw-insn %t.so | FileCheck %s
# CHECK: 100b: movl (%eax), %eax
# CHECK: 11ef: movl (%eax), %eax
# We used to error on R_386_TLS_LDO_32 to preemptable symbols.
# i is STB_GLOBAL and preemptable.

View File

@ -33,16 +33,16 @@ _start:
# DIS: Disassembly of section test:
# DIS-EMPTY:
# DIS-NEXT: _start:
# DIS-NEXT: 401000: movl $8, %edx
# DIS-NEXT: 401005: movl %gs:0, %ecx
# DIS-NEXT: 40100c: subl %edx, %eax
# DIS-NEXT: 40100e: movl $4, %edx
# DIS-NEXT: 401013: movl %gs:0, %ecx
# DIS-NEXT: 40101a: subl %edx, %eax
# DIS-NEXT: 40101c: movl %gs:0, %ecx
# DIS-NEXT: 401023: leal -8(%ecx), %eax
# DIS-NEXT: 401029: movl %gs:0, %ecx
# DIS-NEXT: 401030: leal 119(%ecx), %eax
# DIS-NEXT: 402134: movl $8, %edx
# DIS-NEXT: 402139: movl %gs:0, %ecx
# DIS-NEXT: 402140: subl %edx, %eax
# DIS-NEXT: 402142: movl $4, %edx
# DIS-NEXT: 402147: movl %gs:0, %ecx
# DIS-NEXT: 40214e: subl %edx, %eax
# DIS-NEXT: 402150: movl %gs:0, %ecx
# DIS-NEXT: 402157: leal -8(%ecx), %eax
# DIS-NEXT: 40215d: movl %gs:0, %ecx
# DIS-NEXT: 402164: leal 119(%ecx), %eax
# RELOC: Relocations [
# RELOC-NEXT: ]
@ -50,22 +50,22 @@ _start:
# DISSHARED: Disassembly of section test:
# DISSHARED-EMPTY:
# DISSHARED-NEXT: _start:
# DISSHARED-NEXT: 1000: movl $0, %edx
# DISSHARED-NEXT: 1005: movl %gs:0, %ecx
# DISSHARED-NEXT: 100c: subl %edx, %eax
# DISSHARED-NEXT: 100e: movl $0, %edx
# DISSHARED-NEXT: 1013: movl %gs:0, %ecx
# DISSHARED-NEXT: 101a: subl %edx, %eax
# DISSHARED-NEXT: 101c: movl %gs:0, %ecx
# DISSHARED-NEXT: 1023: leal (%ecx), %eax
# DISSHARED-NEXT: 1029: movl %gs:0, %ecx
# DISSHARED-NEXT: 1030: leal 123(%ecx), %eax
# DISSHARED-NEXT: 2218: movl $0, %edx
# DISSHARED-NEXT: 221d: movl %gs:0, %ecx
# DISSHARED-NEXT: 2224: subl %edx, %eax
# DISSHARED-NEXT: 2226: movl $0, %edx
# DISSHARED-NEXT: 222b: movl %gs:0, %ecx
# DISSHARED-NEXT: 2232: subl %edx, %eax
# DISSHARED-NEXT: 2234: movl %gs:0, %ecx
# DISSHARED-NEXT: 223b: leal (%ecx), %eax
# DISSHARED-NEXT: 2241: movl %gs:0, %ecx
# DISSHARED-NEXT: 2248: leal 123(%ecx), %eax
# RELOCSHARED: Relocations [
# RELOCSHARED-NEXT: Section (5) .rel.dyn {
# RELOCSHARED-NEXT: 0x1001 R_386_TLS_TPOFF32 var 0x0
# RELOCSHARED-NEXT: 0x1025 R_386_TLS_TPOFF var 0x0
# RELOCSHARED-NEXT: 0x100F R_386_TLS_TPOFF32 var1 0x0
# RELOCSHARED-NEXT: 0x1032 R_386_TLS_TPOFF var1 0x0
# RELOCSHARED-NEXT: 0x2219 R_386_TLS_TPOFF32 var 0x0
# RELOCSHARED-NEXT: 0x223D R_386_TLS_TPOFF var 0x0
# RELOCSHARED-NEXT: 0x2227 R_386_TLS_TPOFF32 var1 0x0
# RELOCSHARED-NEXT: 0x224A R_386_TLS_TPOFF var1 0x0
# RELOCSHARED-NEXT: }
# RELOCSHARED-NEXT: ]

View File

@ -1,10 +1,10 @@
// REQUIRES: x86
// RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %s -o %t.o
// RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %p/Inputs/tls-opt-iele-i686-nopic.s -o %tso.o
// RUN: ld.lld -shared %tso.o -o %tso
// RUN: ld.lld -shared %tso.o -soname=t.so -o %tso
// RUN: ld.lld --hash-style=sysv %t.o %tso -o %t1
// RUN: llvm-readobj -S -r %t1 | FileCheck --check-prefix=GOTREL %s
// RUN: llvm-objdump -d %t1 | FileCheck --check-prefix=DISASM %s
// RUN: llvm-objdump -d --no-show-raw-insn --print-imm-hex %t1 | FileCheck --check-prefix=DISASM %s
// GOTREL: Section {
// GOTREL: Index:
@ -14,8 +14,8 @@
// GOTREL-NEXT: SHF_ALLOC
// GOTREL-NEXT: SHF_WRITE
// GOTREL-NEXT: ]
// GOTREL-NEXT: Address: 0x402060
// GOTREL-NEXT: Offset: 0x2060
// GOTREL-NEXT: Address: 0x402258
// GOTREL-NEXT: Offset: 0x258
// GOTREL-NEXT: Size: 8
// GOTREL-NEXT: Link: 0
// GOTREL-NEXT: Info: 0
@ -24,34 +24,32 @@
// GOTREL-NEXT: }
// GOTREL: Relocations [
// GOTREL-NEXT: Section ({{.*}}) .rel.dyn {
// GOTREL-NEXT: 0x402060 R_386_TLS_TPOFF tlsshared0 0x0
// GOTREL-NEXT: 0x402064 R_386_TLS_TPOFF tlsshared1 0x0
// GOTREL-NEXT: 0x402258 R_386_TLS_TPOFF tlsshared0 0x0
// GOTREL-NEXT: 0x40225C R_386_TLS_TPOFF tlsshared1 0x0
// GOTREL-NEXT: }
// GOTREL-NEXT: ]
// DISASM: Disassembly of section .text:
// DISASM-EMPTY:
// DISASM-NEXT: _start:
// 4294967288 = 0xFFFFFFF8
// 4294967292 = 0xFFFFFFFC
// 4202592 = (.got)[0] = 0x402060
// 4202596 = (.got)[1] = 0x402064
// DISASM-NEXT: 401000: {{.*}} movl $4294967288, %ecx
// DISASM-NEXT: 401006: {{.*}} movl %gs:(%ecx), %eax
// DISASM-NEXT: 401009: {{.*}} movl $4294967288, %eax
// DISASM-NEXT: 40100e: {{.*}} movl %gs:(%eax), %eax
// DISASM-NEXT: 401011: {{.*}} addl $4294967288, %ecx
// DISASM-NEXT: 401017: {{.*}} movl %gs:(%ecx), %eax
// DISASM-NEXT: 40101a: {{.*}} movl $4294967292, %ecx
// DISASM-NEXT: 401020: {{.*}} movl %gs:(%ecx), %eax
// DISASM-NEXT: 401023: {{.*}} movl $4294967292, %eax
// DISASM-NEXT: 401028: {{.*}} movl %gs:(%eax), %eax
// DISASM-NEXT: 40102b: {{.*}} addl $4294967292, %ecx
// DISASM-NEXT: 401031: {{.*}} movl %gs:(%ecx), %eax
// DISASM-NEXT: 401034: {{.*}} movl 4202592, %ecx
// DISASM-NEXT: 40103a: {{.*}} movl %gs:(%ecx), %eax
// DISASM-NEXT: 40103d: {{.*}} addl 4202596, %ecx
// DISASM-NEXT: 401043: {{.*}} movl %gs:(%ecx), %eax
// DISASM-NEXT: 4011b0: movl $0xfffffff8, %ecx
// DISASM-NEXT: movl %gs:(%ecx), %eax
// DISASM-NEXT: movl $0xfffffff8, %eax
// DISASM-NEXT: movl %gs:(%eax), %eax
// DISASM-NEXT: addl $0xfffffff8, %ecx
// DISASM-NEXT: movl %gs:(%ecx), %eax
// DISASM-NEXT: movl $0xfffffffc, %ecx
// DISASM-NEXT: movl %gs:(%ecx), %eax
// DISASM-NEXT: movl $0xfffffffc, %eax
// DISASM-NEXT: movl %gs:(%eax), %eax
// DISASM-NEXT: addl $0xfffffffc, %ecx
// DISASM-NEXT: movl %gs:(%ecx), %eax
/// &.got[0]
// DISASM-NEXT: movl 0x402258, %ecx
// DISASM-NEXT: movl %gs:(%ecx), %eax
/// &.got[1]
// DISASM-NEXT: addl 0x40225c, %ecx
// DISASM-NEXT: movl %gs:(%ecx), %eax
.type tlslocal0,@object
.section .tbss,"awT",@nobits

View File

@ -11,25 +11,25 @@
// DISASM-EMPTY:
// DISASM-NEXT: _start:
// LD -> LE:
// DISASM-NEXT: 401000: 65 a1 00 00 00 00 movl %gs:0, %eax
// DISASM-NEXT: 401006: 90 nop
// DISASM-NEXT: 401007: 8d 74 26 00 leal (%esi,%eiz), %esi
// DISASM-NEXT: 40100b: 8d 90 f8 ff ff ff leal -8(%eax), %edx
// DISASM-NEXT: 401011: 65 a1 00 00 00 00 movl %gs:0, %eax
// DISASM-NEXT: 401017: 90 nop
// DISASM-NEXT: 401018: 8d 74 26 00 leal (%esi,%eiz), %esi
// DISASM-NEXT: 40101c: 8d 90 fc ff ff ff leal -4(%eax), %edx
// DISASM-NEXT: 4010f4: 65 a1 00 00 00 00 movl %gs:0, %eax
// DISASM-NEXT: 4010fa: 90 nop
// DISASM-NEXT: 4010fb: 8d 74 26 00 leal (%esi,%eiz), %esi
// DISASM-NEXT: 4010ff: 8d 90 f8 ff ff ff leal -8(%eax), %edx
// DISASM-NEXT: 401105: 65 a1 00 00 00 00 movl %gs:0, %eax
// DISASM-NEXT: 40110b: 90 nop
// DISASM-NEXT: 40110c: 8d 74 26 00 leal (%esi,%eiz), %esi
// DISASM-NEXT: 401110: 8d 90 fc ff ff ff leal -4(%eax), %edx
// IE -> LE:
// 4294967288 == 0xFFFFFFF8
// 4294967292 == 0xFFFFFFFC
// DISASM-NEXT: 401022: 65 a1 00 00 00 00 movl %gs:0, %eax
// DISASM-NEXT: 401028: c7 c0 f8 ff ff ff movl $4294967288, %eax
// DISASM-NEXT: 40102e: 65 a1 00 00 00 00 movl %gs:0, %eax
// DISASM-NEXT: 401034: c7 c0 fc ff ff ff movl $4294967292, %eax
// DISASM-NEXT: 40103a: 65 a1 00 00 00 00 movl %gs:0, %eax
// DISASM-NEXT: 401040: 8d 80 f8 ff ff ff leal -8(%eax), %eax
// DISASM-NEXT: 401046: 65 a1 00 00 00 00 movl %gs:0, %eax
// DISASM-NEXT: 40104c: 8d 80 fc ff ff ff leal -4(%eax), %eax
// DISASM-NEXT: 401116: 65 a1 00 00 00 00 movl %gs:0, %eax
// DISASM-NEXT: 40111c: c7 c0 f8 ff ff ff movl $4294967288, %eax
// DISASM-NEXT: 401122: 65 a1 00 00 00 00 movl %gs:0, %eax
// DISASM-NEXT: 401128: c7 c0 fc ff ff ff movl $4294967292, %eax
// DISASM-NEXT: 40112e: 65 a1 00 00 00 00 movl %gs:0, %eax
// DISASM-NEXT: 401134: 8d 80 f8 ff ff ff leal -8(%eax), %eax
// DISASM-NEXT: 40113a: 65 a1 00 00 00 00 movl %gs:0, %eax
// DISASM-NEXT: 401140: 8d 80 fc ff ff ff leal -4(%eax), %eax
.type tls0,@object
.section .tbss,"awT",@nobits
.globl tls0

View File

@ -0,0 +1,27 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=i386 %s -o %t.o
# RUN: ld.lld %t.o -o %t
# RUN: llvm-readelf -S -l %t | FileCheck --check-prefix=SEC %s
# RUN: llvm-objdump -d %t | FileCheck --check-prefix=DIS %s
# SEC: Name Type Address Off Size ES Flg Lk Inf Al
# SEC: .tdata PROGBITS 00402200 000200 000001 00 WAT 0 0 1
# SEC: .tbss NOBITS 00402300 000201 000008 00 WAT 0 0 256
# SEC: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
# SEC: TLS 0x000200 0x00402200 0x00402200 0x00001 0x00108 R 0x100
## a@tprel = st_value(a) - p_memsz - (-p_vaddr-p_memsz & p_align-1)
## = 0 - 256 - 0 = -256
# DIS: leal -256(%ecx), %eax
lea a@ntpoff(%ecx), %eax
.section .tdata,"awT"
.byte 0
.section .tbss,"awT"
.p2align 8
a:
.quad 0

View File

@ -8,9 +8,9 @@ _start:
nop
// CHECK: VMA LMA Size Align Out In Symbol
// CHECK-NEXT: 401000 401000 1 4 .text
// CHECK-NEXT: 401000 401000 1 4 {{.*}}{{/|\\}}map-file-i686.s.tmp1.o:(.text)
// CHECK-NEXT: 401000 401000 0 1 _start
// CHECK-NEXT: 4010b4 4010b4 1 4 .text
// CHECK-NEXT: 4010b4 4010b4 1 4 {{.*}}{{/|\\}}map-file-i686.s.tmp1.o:(.text)
// CHECK-NEXT: 4010b4 4010b4 0 1 _start
// CHECK-NEXT: 0 0 8 1 .comment
// CHECK-NEXT: 0 0 8 1 <internal>:(.comment)
// CHECK-NEXT: 0 0 20 4 .symtab

View File

@ -4,7 +4,7 @@
// RUN: ld.lld -shared %t2.o -soname=t2.so -o %t2.so
// RUN: ld.lld %t.o %t2.so -o %t
// RUN: llvm-readobj -S -r %t | FileCheck %s
// RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=DISASM %s
// RUN: llvm-objdump -d --no-show-raw-insn --print-imm-hex %t | FileCheck --check-prefix=DISASM %s
// RUN: ld.lld -shared %t.o %t2.so -o %t
// RUN: llvm-readobj -S -r %t | FileCheck --check-prefix=CHECKSHARED %s
// RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=DISASMSHARED %s
@ -17,7 +17,7 @@
// CHECK-NEXT: SHF_ALLOC
// CHECK-NEXT: SHF_EXECINSTR
// CHECK-NEXT: ]
// CHECK-NEXT: Address: 0x401020
// CHECK-NEXT: Address: 0x4011E0
// CHECK-NEXT: Offset:
// CHECK-NEXT: Size: 48
// CHECK-NEXT: Link: 0
@ -30,66 +30,55 @@
// CHECK-NEXT: SHF_ALLOC
// CHECK-NEXT: SHF_WRITE
// CHECK-NEXT: ]
// CHECK-NEXT: Address: 0x403000
// CHECK-NEXT: Offset: 0x3000
// CHECK-NEXT: Address: 0x403278
// CHECK-NEXT: Offset: 0x278
// CHECK-NEXT: Size: 20
// CHECK-NEXT: Link: 0
// CHECK-NEXT: Info: 0
// CHECK-NEXT: AddressAlignment: 4
// CHECK-NEXT: EntrySize: 0
// 0x12000 + got.plt.reserved(12) = 0x1200C
// 0x12000 + got.plt.reserved(12) + 4 = 0x12010
// First 3 slots of .got.plt are reserved.
// &.got.plt[3] = 0x403278 + 12 = 0x403284
// &.got.plt[4] = 0x403278 + 16 = 0x403288
// CHECK: Relocations [
// CHECK-NEXT: Section ({{.*}}) .rel.plt {
// CHECK-NEXT: 0x40300C R_386_JUMP_SLOT bar 0x0
// CHECK-NEXT: 0x403010 R_386_JUMP_SLOT zed 0x0
// CHECK-NEXT: 0x403284 R_386_JUMP_SLOT bar 0x0
// CHECK-NEXT: 0x403288 R_386_JUMP_SLOT zed 0x0
// CHECK-NEXT: }
// CHECK-NEXT: ]
// Unfortunately FileCheck can't do math, so we have to check for explicit
// values:
// 16 is the size of PLT[0]
// (0x401010 + 16) - (0x401000 + 1) - 4 = 27
// (0x401010 + 16) - (0x401005 + 1) - 4 = 22
// (0x401020 + 16) - (0x40100a + 1) - 4 = 33
// DISASM: local:
// DISASM-NEXT: 401000:
// DISASM-NEXT: 401002:
// DISASM-NEXT: 4011bc:
// DISASM-NEXT: 4011be:
// DISASM: _start:
// 0x401013 + 5 - 24 = 0x401000
// DISASM-NEXT: 401004: jmp 39 <bar@plt>
// DISASM-NEXT: 401009: jmp 34 <bar@plt>
// DISASM-NEXT: 40100e: jmp 45 <zed@plt>
// DISASM-NEXT: 401013: jmp -24 <local>
// DISASM-NEXT: 4011c0: jmp 0x2b <bar@plt>
// DISASM-NEXT: 4011c5: jmp 0x26 <bar@plt>
// DISASM-NEXT: 4011ca: jmp 0x31 <zed@plt>
// DISASM-NEXT: 4011cf: jmp -0x18 <local>
// 0x401010 - 0x40102b - 5 = -32
// 0x401010 - 0x40103b - 5 = -48
// 4206596 = 0x403004 = .got.plt (0x403000) + 4
// 4206600 = 0x403008 = .got.plt (0x403000) + 8
// 4206604 = 0x40300C = .got.plt (0x403000) + got.plt.reserved(12)
// 4206608 = 0x403010 = .got.plt (0x403000) + got.plt.reserved(12) + 4
// DISASM: Disassembly of section .plt:
// DISASM-EMPTY:
// DISASM-NEXT: .plt:
// DISASM-NEXT: 401020: pushl 4206596
// DISASM-NEXT: jmpl *4206600
/// Push .got.plt[1], then jump to .got.plt[2]
// DISASM-NEXT: 4011e0: pushl 0x40327c
// DISASM-NEXT: jmpl *0x403280
// DISASM-NEXT: nop
// DISASM-NEXT: nop
// DISASM-NEXT: nop
// DISASM-NEXT: nop
// DISASM-EMPTY:
// DISASM-NEXT: bar@plt:
// DISASM-NEXT: 401030: jmpl *4206604
// DISASM-NEXT: pushl $0
// DISASM-NEXT: jmp -32 <.plt>
/// .got.plt[3] = 0x403278 + 12 = 0x403284
// DISASM-NEXT: 4011f0: jmpl *0x403284
// DISASM-NEXT: pushl $0x0
// DISASM-NEXT: jmp -0x20 <.plt>
// DISASM-EMPTY:
// DISASM-NEXT: zed@plt:
// DISASM-NEXT: 401040: jmpl *4206608
// DISASM-NEXT: pushl $8
// DISASM-NEXT: jmp -48 <.plt>
/// .got.plt[4] = 0x403278 + 16 = 0x403288
// DISASM-NEXT: 401200: jmpl *0x403288
// DISASM-NEXT: pushl $0x8
// DISASM-NEXT: jmp -0x30 <.plt>
// CHECKSHARED: Name: .plt
// CHECKSHARED-NEXT: Type: SHT_PROGBITS
@ -97,8 +86,8 @@
// CHECKSHARED-NEXT: SHF_ALLOC
// CHECKSHARED-NEXT: SHF_EXECINSTR
// CHECKSHARED-NEXT: ]
// CHECKSHARED-NEXT: Address: 0x1020
// CHECKSHARED-NEXT: Offset: 0x1020
// CHECKSHARED-NEXT: Address: 0x1200
// CHECKSHARED-NEXT: Offset: 0x200
// CHECKSHARED-NEXT: Size: 48
// CHECKSHARED-NEXT: Link: 0
// CHECKSHARED-NEXT: Info: 0
@ -111,8 +100,8 @@
// CHECKSHARED-NEXT: SHF_ALLOC
// CHECKSHARED-NEXT: SHF_WRITE
// CHECKSHARED-NEXT: ]
// CHECKSHARED-NEXT: Address: 0x3000
// CHECKSHARED-NEXT: Offset: 0x3000
// CHECKSHARED-NEXT: Address: 0x3290
// CHECKSHARED-NEXT: Offset: 0x290
// CHECKSHARED-NEXT: Size: 20
// CHECKSHARED-NEXT: Link: 0
// CHECKSHARED-NEXT: Info: 0
@ -124,17 +113,16 @@
// 0x3000 + got.plt.reserved(12) + 4 = 0x3010
// CHECKSHARED: Relocations [
// CHECKSHARED-NEXT: Section ({{.*}}) .rel.plt {
// CHECKSHARED-NEXT: 0x300C R_386_JUMP_SLOT bar 0x0
// CHECKSHARED-NEXT: 0x3010 R_386_JUMP_SLOT zed 0x0
// CHECKSHARED-NEXT: 0x329C R_386_JUMP_SLOT bar 0x0
// CHECKSHARED-NEXT: 0x32A0 R_386_JUMP_SLOT zed 0x0
// CHECKSHARED-NEXT: }
// CHECKSHARED-NEXT: ]
// DISASMSHARED: local:
// DISASMSHARED-NEXT: 1000:
// DISASMSHARED-NEXT: 1002:
// DISASMSHARED-NEXT: 11e0:
// DISASMSHARED-NEXT: 11e2:
// DISASMSHARED: _start:
// 0x1013 + 5 - 24 = 0x1000
// DISASMSHARED-NEXT: 1004: jmp 39 <bar@plt>
// DISASMSHARED-NEXT: 11e4: jmp 39 <bar@plt>
// DISASMSHARED-NEXT: jmp 34 <bar@plt>
// DISASMSHARED-NEXT: jmp 45 <zed@plt>
// DISASMSHARED-NEXT: jmp -24 <local>
@ -142,25 +130,25 @@
// DISASMSHARED-NEXT: Disassembly of section .plt:
// DISASMSHARED-EMPTY:
// DISASMSHARED-NEXT: .plt:
// DISASMSHARED-NEXT: 1020: pushl 4(%ebx)
// DISASMSHARED-NEXT: 1200: pushl 4(%ebx)
// DISASMSHARED-NEXT: jmpl *8(%ebx)
// DISASMSHARED-NEXT: nop
// DISASMSHARED-NEXT: nop
// DISASMSHARED-NEXT: nop
// DISASMSHARED-NEXT: nop
// DISASMSHARED: bar@plt:
// DISASMSHARED-NEXT: 1030: jmpl *12(%ebx)
// DISASMSHARED-NEXT: 1210: jmpl *12(%ebx)
// DISASMSHARED-NEXT: pushl $0
// DISASMSHARED-NEXT: jmp -32 <.plt>
// DISASMSHARED: zed@plt:
// DISASMSHARED-NEXT: 1040: jmpl *16(%ebx)
// DISASMSHARED-NEXT: 1220: jmpl *16(%ebx)
// DISASMSHARED-NEXT: pushl $8
// DISASMSHARED-NEXT: jmp -48 <.plt>
// DISASMPIE: Disassembly of section .plt:
// DISASMPIE-EMPTY:
// DISASMPIE-NEXT: .plt:
// DISASMPIE-NEXT: 1020: pushl 4(%ebx)
// DISASMPIE-NEXT: 11e0: pushl 4(%ebx)
// DISASMPIE-NEXT: jmpl *8(%ebx)
// DISASMPIE-NEXT: nop
// DISASMPIE-NEXT: nop
@ -168,12 +156,12 @@
// DISASMPIE-NEXT: nop
// DISASMPIE-EMPTY:
// DISASMPIE-NEXT: bar@plt:
// DISASMPIE-NEXT: 1030: jmpl *12(%ebx)
// DISASMPIE-NEXT: 11f0: jmpl *12(%ebx)
// DISASMPIE-NEXT: pushl $0
// DISASMPIE-NEXT: jmp -32 <.plt>
// DISASMPIE-EMPTY:
// DISASMPIE-NEXT: zed@plt:
// DISASMPIE-NEXT: 1040: jmpl *16(%ebx)
// DISASMPIE-NEXT: 1200: jmpl *16(%ebx)
// DISASMPIE-NEXT: pushl $8
// DISASMPIE-NEXT: jmp -48 <.plt>

View File

@ -1,10 +1,10 @@
// REQUIRES: x86
// RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %s -o %t.o
// RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %p/Inputs/relocation-copy.s -o %t2.o
// RUN: ld.lld -shared %t2.o -o %t.so
// RUN: ld.lld -shared %t2.o -soname=t.so -o %t.so
// RUN: ld.lld -e main %t.o %t.so -o %t3
// RUN: llvm-readobj -S -r --expand-relocs %t3 | FileCheck %s
// RUN: llvm-objdump -d --no-show-raw-insn %t3 | FileCheck -check-prefix=CODE %s
// RUN: llvm-objdump -d --no-show-raw-insn --print-imm-hex %t3 | FileCheck -check-prefix=CODE %s
.text
.globl main
@ -21,7 +21,7 @@ movl $9, z
// CHECK-NEXT: SHF_ALLOC
// CHECK-NEXT: SHF_WRITE
// CHECK-NEXT: ]
// CHECK-NEXT: Address: 0x403000
// CHECK-NEXT: Address: 0x403270
// CHECK-NEXT: Offset:
// CHECK-NEXT: Size: 24
// CHECK-NEXT: Link: 0
@ -52,13 +52,13 @@ movl $9, z
// CHECK-NEXT: }
// CHECK-NEXT: ]
// 4206592 = 0x403000
// 16 is alignment here
// 4206608 = 0x403000 + 16
// 4206612 = 0x403000 + 16 + 4
// CODE: Disassembly of section .text:
// CODE-EMPTY:
// CODE-NEXT: main:
// CODE-NEXT: 401000: movl $5, 4206592
// CODE-NEXT: 40100a: movl $7, 4206608
// CODE-NEXT: 401014: movl $9, 4206612
/// .bss + 0 = 0x403270
// CODE-NEXT: 4011f0: movl $0x5, 0x403270
/// .bss + 16 = 0x403270 + 16 = 0x403280
// CODE-NEXT: 4011fa: movl $0x7, 0x403280
/// .bss + 20 = 0x403270 + 20 = 0x403284
// CODE-NEXT: 401204: movl $0x9, 0x403284

View File

@ -28,7 +28,7 @@ R_386_PC32_2:
// CHECK: Disassembly of section .R_386_32:
// CHECK-EMPTY:
// CHECK-NEXT: R_386_32:
// CHECK-NEXT: movl $4198401, %edx
// CHECK-NEXT: movl $4198829, %edx
// CHECK: Disassembly of section .R_386_PC32:
// CHECK-EMPTY:
@ -47,8 +47,8 @@ movl bar@GOT, %eax
// ADDR-NEXT: SHF_ALLOC
// ADDR-NEXT: SHF_EXECINSTR
// ADDR-NEXT: ]
// ADDR-NEXT: Address: 0x401040
// ADDR-NEXT: Offset: 0x1040
// ADDR-NEXT: Address: 0x4011E0
// ADDR-NEXT: Offset: 0x1E0
// ADDR-NEXT: Size: 32
// ADDR: Name: .got.plt (
@ -57,7 +57,7 @@ movl bar@GOT, %eax
// ADDR-NEXT: SHF_ALLOC
// ADDR-NEXT: SHF_WRITE
// ADDR-NEXT: ]
// ADDR-NEXT: Address: 0x403000
// ADDR-NEXT: Address: 0x403280
// ADDR-NEXT: Offset:
// ADDR-NEXT: Size:
@ -65,20 +65,19 @@ movl bar@GOT, %eax
R_386_GOTPC:
movl $_GLOBAL_OFFSET_TABLE_, %eax
// 0x403000 (.got.plt) - 0x401014 = 8300
// .got.plt - 0x4011c0 = 0x403280 - 0x4011c0 = 8384
// CHECK: Disassembly of section .R_386_GOTPC:
// CHECK-EMPTY:
// CHECK-NEXT: R_386_GOTPC:
// CHECK-NEXT: movl $8172, %eax
// CHECK-NEXT: 4011c0: movl $8384, %eax
.section .dynamic_reloc, "ax",@progbits
call bar
// addr(.plt) + 16 - (0x401019 + 5) = 50
// .plt + 16 - (0x4011c5 + 5) = 0x4011e0 + 16 - 0x4011ca = 38
// CHECK: Disassembly of section .dynamic_reloc:
// CHECK-EMPTY:
// CHECK-NEXT: .dynamic_reloc:
// CHECK-NEXT: 401019: calll 50
// CHECK-NEXT: 4011c5: calll 38 <bar@plt>
.section .R_386_GOT32,"ax",@progbits
.global R_386_GOT32
@ -88,12 +87,13 @@ R_386_GOT32:
movl bar+8@GOT, %eax
movl zed+4@GOT, %eax
// 4294963320 = 0xfffff078 = got[0](0x402078) - .got.plt(0x403000)
// 4294963324 = 0xfffff07c = got[1](0x40207c) - .got(0x403000)
// &.got[0] - .got.plt = 0x402278 - 0x403280 = 4294963192
// &.got[1] - .got.plt = 0x402278 + 4 - 0x403280 = 4294963196
// &.got[2] - .got.plt = 0x402278 + 8 - 0x403280 = 4294963200
// CHECK: Disassembly of section .R_386_GOT32:
// CHECK-EMPTY:
// CHECK-NEXT: R_386_GOT32:
// CHECK-NEXT: 40101e: movl 4294963320, %eax
// CHECK-NEXT: 401023: movl 4294963324, %eax
// CHECK-NEXT: 401028: movl 4294963328, %eax
// CHECK-NEXT: 40102d: movl 4294963328, %eax
// CHECK-NEXT: 4011ca: movl 4294963192, %eax
// CHECK-NEXT: movl 4294963196, %eax
// CHECK-NEXT: movl 4294963200, %eax
// CHECK-NEXT: movl 4294963200, %eax

View File

@ -1,7 +1,7 @@
// REQUIRES: x86
// RUN: llvm-mc -filetype=obj -triple=i686-unknown-linux %s -o %t.o
// RUN: llvm-mc -filetype=obj -triple=i686-unknown-linux %p/Inputs/shared.s -o %t2.o
// RUN: ld.lld --hash-style=sysv -shared %t2.o -o %t2.so
// RUN: ld.lld --hash-style=sysv -shared %t2.o -soname=t2.so -o %t2.so
// RUN: llvm-readobj -S %t2.so | FileCheck --check-prefix=SO %s
// RUN: ld.lld --hash-style=sysv -dynamic-linker /lib64/ld-linux-x86-64.so.2 -rpath foo -rpath bar --export-dynamic %t.o %t2.so -o %t
// RUN: llvm-readobj --program-headers --dynamic-table --symbols -S --dyn-syms --section-data --hash-table %t | FileCheck %s
@ -14,7 +14,7 @@
// SO-NEXT: Flags [
// SO-NEXT: ]
// SO-NEXT: Address:
// SO-NEXT: Offset: 0x1038
// SO-NEXT: Offset: 0x1D0
// SO-NEXT: Size:
// SO-NEXT: Link:
// SO-NEXT: Info:
@ -141,7 +141,7 @@
// CHECK-NEXT: }
// CHECK-NEXT: Symbol {
// CHECK-NEXT: Name: _DYNAMIC
// CHECK-NEXT: Value: 0x402000
// CHECK-NEXT: Value: 0x402210
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Local
// CHECK-NEXT: Type: None
@ -152,7 +152,7 @@
// CHECK-NEXT: }
// CHECK-NEXT: Symbol {
// CHECK-NEXT: Name: _start
// CHECK-NEXT: Value: 0x401000
// CHECK-NEXT: Value: 0x401208
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Global
// CHECK-NEXT: Type: None
@ -191,7 +191,7 @@
// CHECK-NEXT: }
// CHECK-NEXT: Symbol {
// CHECK-NEXT: Name: _start
// CHECK-NEXT: Value: 0x401000
// CHECK-NEXT: Value: 0x401208
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Global
// CHECK-NEXT: Type: Non

View File

@ -18,7 +18,7 @@
// CHECK-NEXT: }
// CHECK-NEXT: Symbol {
// CHECK-NEXT: Name: _start
// CHECK-NEXT: Value: 0x401000
// CHECK-NEXT: Value:
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Global
// CHECK-NEXT: Type: None

View File

@ -1,7 +1,7 @@
// REQUIRES: x86
// RUN: llvm-mc -filetype=obj -triple=i686-unknown-linux %s -o %t.o
// RUN: llvm-mc -filetype=obj -triple=i686-unknown-linux %p/Inputs/undef-with-plt-addr.s -o %t2.o
// RUN: ld.lld %t2.o -o %t2.so -shared
// RUN: ld.lld %t2.o -o %t2.so -shared -soname=t2.so
// RUN: ld.lld %t.o %t2.so -o %t3
// RUN: llvm-readobj --symbols -S %t3 | FileCheck %s
@ -17,7 +17,7 @@ mov $set_data, %eax
// CHECK-NEXT: SHF_ALLOC
// CHECK-NEXT: SHF_EXECINSTR
// CHECK-NEXT: ]
// CHECK-NEXT: Address: 0x401010
// CHECK-NEXT: Address: 0x4011B0
// CHECK: Name: set_data
// CHECK-NEXT: Value: 0x401020
// CHECK-NEXT: Value: 0x4011C0