brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.7 KiB · bc5830b Raw
149 lines · plain
1# REQUIRES: x862## Test R_X86_64_GOTPCRELX and R_X86_64_REX_GOTPCRELX/R_X86_64_CODE_4_GOTPCRELX GOT optimization.3 4# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o5# RUN: ld.lld %t.o -o %t1 --no-apply-dynamic-relocs6# RUN: llvm-readelf -S -r -x .got.plt %t1 | FileCheck --check-prefixes=CHECK,NOAPPLY %s7# RUN: ld.lld %t.o -o %t1 --apply-dynamic-relocs8# RUN: llvm-readelf -S -r -x .got.plt %t1 | FileCheck --check-prefixes=CHECK,APPLY %s9# RUN: ld.lld %t.o -o %t110# RUN: llvm-objdump --no-print-imm-hex -d %t1 | FileCheck --check-prefix=DISASM %s11 12## --no-relax disables GOT optimization.13# RUN: ld.lld --no-relax %t.o -o %t214# RUN: llvm-objdump --no-print-imm-hex -d %t2 | FileCheck --check-prefix=NORELAX %s15 16## In our implementation, .got is retained even if all GOT-generating relocations are optimized.17# CHECK:      Name              Type            Address          Off    Size   ES Flg Lk Inf Al18# CHECK:      .iplt             PROGBITS        00000000002012e0 0002e0 000010 00  AX  0   0 1619# CHECK-NEXT: .got              PROGBITS        00000000002022f0 0002f0 000000 00  WA  0   0  820 21## There is one R_X86_64_IRELATIVE relocations.22# RELOC-LABEL: Relocation section '.rela.dyn' at offset {{.*}} contains 1 entry:23# CHECK:           Offset             Info             Type               Symbol's Value  Symbol's Name + Addend24# CHECK:       00000000002032f0  0000000000000025 R_X86_64_IRELATIVE                        2011e225# CHECK-LABEL: Hex dump of section '.got.plt':26# NOAPPLY-NEXT:  0x002032f0 00000000 0000000027# APPLY-NEXT:    0x002032f0 e2112000 0000000028 29# 0x201173 + 7 - 10 = 0x20117030# 0x20117a + 7 - 17 = 0x20117031# 0x201181 + 7 - 23 = 0x20117132# 0x201188 + 7 - 30 = 0x20117133# DISASM:      Disassembly of section .text:34# DISASM-EMPTY:35# DISASM-NEXT: <foo>:36# DISASM-NEXT:   2011e0: 90 nop37# DISASM:      <hid>:38# DISASM-NEXT:   2011e1: 90 nop39# DISASM:      <ifunc>:40# DISASM-NEXT:   2011e2: c3 retq41# DISASM:      <_start>:42# DISASM-NEXT: leaq -10(%rip), %rax43# DISASM-NEXT: leaq -17(%rip), %rax44# DISASM-NEXT: leaq -23(%rip), %rax45# DISASM-NEXT: leaq -30(%rip), %rax46# DISASM-NEXT: movq 8426(%rip), %rax47# DISASM-NEXT: movq 8419(%rip), %rax48# DISASM-NEXT: leaq -52(%rip), %rax49# DISASM-NEXT: leaq -59(%rip), %rax50# DISASM-NEXT: leaq -65(%rip), %rax51# DISASM-NEXT: leaq -72(%rip), %rax52# DISASM-NEXT: movq 8384(%rip), %rax53# DISASM-NEXT: movq 8377(%rip), %rax54# DISASM-NEXT: callq 0x2011e0 <foo>55# DISASM-NEXT: callq 0x2011e0 <foo>56# DISASM-NEXT: callq 0x2011e1 <hid>57# DISASM-NEXT: callq 0x2011e1 <hid>58# DISASM-NEXT: callq *8347(%rip)59# DISASM-NEXT: callq *8341(%rip)60# DISASM-NEXT: jmp   0x2011e0 <foo>61# DISASM-NEXT: nop62# DISASM-NEXT: jmp   0x2011e0 <foo>63# DISASM-NEXT: nop64# DISASM-NEXT: jmp   0x2011e1 <hid>65# DISASM-NEXT: nop66# DISASM-NEXT: jmp   0x2011e1 <hid>67# DISASM-NEXT: nop68# DISASM-NEXT: jmpq  *8311(%rip)69# DISASM-NEXT: jmpq  *8305(%rip)70# DISASM-NEXT: leaq -167(%rip), %r1671# DISASM-NEXT: leaq -175(%rip), %r1672# DISASM-NEXT: leaq -182(%rip), %r1673# DISASM-NEXT: leaq -190(%rip), %r1674# DISASM-NEXT: movq 8265(%rip), %r1675# DISASM-NEXT: movq 8257(%rip), %r1676# DISASM-NEXT: leaq -215(%rip), %r1677# DISASM-NEXT: leaq -223(%rip), %r1678# DISASM-NEXT: leaq -230(%rip), %r1679# DISASM-NEXT: leaq -238(%rip), %r1680# DISASM-NEXT: movq 8217(%rip), %r1681# DISASM-NEXT: movq 8209(%rip), %r1682 83# NORELAX-LABEL: <_start>:84# NORELAX-COUNT-12: movq85# NORELAX-COUNT-6:  callq *86# NORELAX-COUNT-6:  jmpq *87# NORELAX-COUNT-12: movq88 89.text90.globl foo91.type foo, @function92foo:93 nop94 95.globl hid96.hidden hid97.type hid, @function98hid:99 nop100 101.text102.type ifunc STT_GNU_IFUNC103.globl ifunc104.type ifunc, @function105ifunc:106 ret107 108.globl _start109.type _start, @function110_start:111 movq foo@GOTPCREL(%rip), %rax112 movq foo@GOTPCREL(%rip), %rax113 movq hid@GOTPCREL(%rip), %rax114 movq hid@GOTPCREL(%rip), %rax115 movq ifunc@GOTPCREL(%rip), %rax116 movq ifunc@GOTPCREL(%rip), %rax117 movq foo@GOTPCREL(%rip), %rax118 movq foo@GOTPCREL(%rip), %rax119 movq hid@GOTPCREL(%rip), %rax120 movq hid@GOTPCREL(%rip), %rax121 movq ifunc@GOTPCREL(%rip), %rax122 movq ifunc@GOTPCREL(%rip), %rax123 124 call *foo@GOTPCREL(%rip)125 call *foo@GOTPCREL(%rip)126 call *hid@GOTPCREL(%rip)127 call *hid@GOTPCREL(%rip)128 call *ifunc@GOTPCREL(%rip)129 call *ifunc@GOTPCREL(%rip)130 jmp *foo@GOTPCREL(%rip)131 jmp *foo@GOTPCREL(%rip)132 jmp *hid@GOTPCREL(%rip)133 jmp *hid@GOTPCREL(%rip)134 jmp *ifunc@GOTPCREL(%rip)135 jmp *ifunc@GOTPCREL(%rip)136 137 movq foo@GOTPCREL(%rip), %r16138 movq foo@GOTPCREL(%rip), %r16139 movq hid@GOTPCREL(%rip), %r16140 movq hid@GOTPCREL(%rip), %r16141 movq ifunc@GOTPCREL(%rip), %r16142 movq ifunc@GOTPCREL(%rip), %r16143 movq foo@GOTPCREL(%rip), %r16144 movq foo@GOTPCREL(%rip), %r16145 movq hid@GOTPCREL(%rip), %r16146 movq hid@GOTPCREL(%rip), %r16147 movq ifunc@GOTPCREL(%rip), %r16148 movq ifunc@GOTPCREL(%rip), %r16149