94 lines · plain
1# REQUIRES: x862# RUN: split-file %s %t3# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/a.s -o %t/a.o4# RUN: ld.lld -T %t/lds1 %t/a.o -o %t/bin5# RUN: llvm-objdump -d %t/bin | FileCheck --check-prefix=DISASM %s6# RUN: llvm-readelf -S %t/bin | FileCheck --check-prefixes=GOT %s7# RUN: ld.lld -T %t/lds2 %t/a.o -o %t/bin28# RUN: llvm-objdump -d %t/bin2 | FileCheck --check-prefix=DISASM %s9# RUN: llvm-readelf -S %t/bin2 | FileCheck --check-prefixes=GOT %s10# RUN: ld.lld -T %t/lds3 %t/a.o -o %t/bin311# RUN: llvm-readelf -S %t/bin3 | FileCheck --check-prefixes=UNNECESSARY-GOT %s12# RUN: ld.lld -T %t/lds4 %t/a.o -o %t/bin413# RUN: llvm-objdump -d %t/bin4 | FileCheck --check-prefix=DISASM4 %s14 15# DISASM: <_foo>:16# DISASM-NEXT: movl 0x1ffffa(%rip), %eax17# DISASM-NEXT: addq 0x1ffffb(%rip), %rax18# DISASM-NEXT: addq $0x7fffffff, %rax19# DISASM: <_start>:20# DISASM-NEXT: movl 0x10000a(%rip), %eax21# DISASM-NEXT: movq 0x100003(%rip), %rax22# DISASM-NEXT: leaq 0x7ffffff9(%rip), %rax23# DISASM-NEXT: leal 0x7ffffff3(%rip), %eax24 25# DISASM4: <_foo>:26# DISASM4-NEXT: leal 0x7fffeffa(%rip), %eax27# DISASM4-NEXT: addq 0x1ff3(%rip), %rax28# DISASM4-NEXT: addq $0x7fffffff, %rax29 30# In our implementation, .got is retained even if all GOT-generating relocations are optimized.31# Make sure .got still exists with the right size.32# UNNECESSARY-GOT: .got PROGBITS 0000000000300000 101020 000000 00 WA 0 0 833# GOT: .got PROGBITS 0000000000300000 102000 000018 00 WA 0 0 834 35#--- a.s36.section .text.foo,"ax"37.globl _foo38.type _foo, @function39_foo:40 movl __start_data@GOTPCREL(%rip), %eax # out of range41 addq foo_1@GOTPCREL(%rip), %rax # out of range42 addq foo@GOTPCREL(%rip), %rax # in range43 44.section .text,"ax"45.globl _start46.type _start, @function47_start:48 movl __stop_data@GOTPCREL(%rip), %eax # out of range49 movq __stop_data@GOTPCREL(%rip), %rax # out of range50 movq __stop_data@GOTPCREL(%rip), %rax # in range51 movl __stop_data@GOTPCREL(%rip), %eax # in range52 53.section foo,"aw",@progbits54.space 155foo_1:56.space 157 58.section data,"aw",@progbits59.space 1360 61#--- lds162SECTIONS {63 .text.foo 0x100000 : { *(.text.foo) }64 .text 0x200000 : { *(.text) }65 .got 0x300000 : { *(.got) }66 foo 0x7fffffff : { *(foo) }67 data 0x80200000 : { *(data) }68}69#--- lds270SECTIONS {71 .text.foo 0x100000 : { *(.text.foo) }72 .text 0x1ff000 : { . = . + 0x1000 ; *(.text) }73 .got 0x300000 : { *(.got) }74 foo 0x7fffffff : { *(foo) }75 data 0x80200000 : { *(data) }76}77#--- lds378SECTIONS {79 .text.foo 0x100000 : { *(.text.foo) }80 .text 0x200000 : { *(.text) }81 .got 0x300000 : { *(.got) }82 data 0x400000 : { *(data) }83}84 85#--- lds486## Max VA difference < 0x8000000087SECTIONS {88 .text.foo 0x02000 : { *(.text.foo) }89 .text 0x3000 : { *(.text) }90 .got 0x4000 : { *(.got) }91 foo 0x7fffffff : { *(foo) }92 data 0x80001000 : { *(data) }93}94