brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.8 KiB · c5bc7ac Raw
84 lines · plain
1# REQUIRES: system-linux2 3## Check that BOLT correctly handles different types of instructions with4## R_X86_64_GOTPCRELX or R_X86_64_REX_GOTPCRELX relocations and different5## kinds of handling of the relocation by the linker (no relaxation, pic, and6## non-pic).7 8# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-linux %s -o %t.o9# RUN: ld.lld %t.o -o %t.exe -q10# RUN: ld.lld %t.o -o %t.pie.exe -q -pie11# RUN: ld.lld %t.o -o %t.no-relax.exe -q --no-relax12# RUN: llvm-bolt %t.exe --relocs -o %t.out --print-cfg --print-only=_start \13# RUN:   2>&1 | FileCheck --check-prefix=BOLT %s14# RUN: llvm-bolt %t.pie.exe -o %t.null --print-cfg --print-only=_start \15# RUN:   2>&1 | FileCheck --check-prefix=PIE-BOLT %s16# RUN: llvm-bolt %t.no-relax.exe -o %t.null --print-cfg --print-only=_start \17# RUN:   2>&1 | FileCheck --check-prefix=NO-RELAX-BOLT %s18# RUN: llvm-objdump -d --no-show-raw-insn --print-imm-hex \19# RUN:   %t.out | FileCheck --check-prefix=DISASM %s20 21## Relocate foo only and check that code references from _start (that is22## otherwise preserved) are updated.23 24# RUN: llvm-bolt %t.exe --relocs -o %t.lite.out --funcs=foo25# RUN: llvm-objdump -d --no-show-raw-insn --print-imm-hex \26# RUN:   %t.lite.out | FileCheck --check-prefix=DISASM %s27 28  .text29  .globl _start30  .type _start, %function31_start:32  .cfi_startproc33# DISASM: <_start>:34 35                      call *foo@GOTPCREL(%rip)36# NO-RELAX-BOLT:      callq *{{.*}}(%rip)37# BOLT:               callq foo38# PIE-BOLT:           callq foo39# DISASM-NEXT:        callq 0x[[#%x,ADDR:]]40 41                      movq foo@GOTPCREL(%rip), %rdi42# NO-RELAX-BOLT-NEXT: movq {{.*}}(%rip), %rdi43# BOLT-NEXT:          leaq foo(%rip), %rdi44# PIE-BOLT-NEXT:      leaq foo(%rip), %rdi45# DISASM-NEXT:        leaq {{.*}}(%rip), %rdi # 0x[[#ADDR]]46 47                      movl foo@GOTPCREL+4(%rip), %edi48# NO-RELAX-BOLT-NEXT: movl {{.*}}(%rip), %edi49# BOLT-NEXT:          movl {{.*}}(%rip), %edi50# PIE-BOLT-NEXT:      movl {{.*}}(%rip), %edi51# DISASM-NEXT:        movl {{.*}}(%rip), %edi52 53                      test %rdi, foo@GOTPCREL(%rip)54# NO-RELAX-BOLT-NEXT: testq %rdi, DATA{{.*}}(%rip)55# BOLT-NEXT:          testq $foo, %rdi56# PIE-BOLT-NEXT:      testq %rdi, DATA{{.*}}(%rip)57# DISASM-NEXT:        testq $0x[[#ADDR]], %rdi58 59                      cmpq foo@GOTPCREL(%rip), %rax60# NO-RELAX-BOLT-NEXT: cmpq DATA{{.*}}(%rip), %rax61# BOLT-NEXT:          cmpq $foo, %rax62# PIE-BOLT-NEXT:      cmpq DATA{{.*}}(%rip), %rax63# DISASM-NEXT:        cmpq $0x[[#ADDR]], %rax64 65                      jmp *foo@GOTPCREL(%rip)66# NO-RELAX-BOLT-NEXT: jmpq *DATA{{.*}}(%rip)67# BOLT-NEXT:          jmp foo68# PIE-BOLT-NEXT:      jmp foo69# DISASM-NEXT:        jmp 0x[[#ADDR]]70 71# DISASM: [[#ADDR]] <foo>:72 73  ret74  .cfi_endproc75  .size _start, .-_start76 77  .globl foo78  .type foo, %function79foo:80  .cfi_startproc81  ret82  .cfi_endproc83  .size foo, .-foo84