brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · 63b7733 Raw
57 lines · plain
1# This reproduces a bug triggered by a relocation referencing a section symbol2# plus a negative reloc. BOLT handles such cases specially, but while doing so,3# it was failing to sign extend a negative result for the relocation (encoded4# in the immediate operand of an LEA instruction).5# Originally triggered by https://fossies.org/linux/glib/glib/guniprop.c6# Line 550: const gchar *p = special_case_table + val - 0x1000000;7 8# REQUIRES: system-linux9 10# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown \11# RUN:   %s -o %t.o12# Delete our BB symbols so BOLT doesn't mark them as entry points13# RUN: llvm-strip --strip-unneeded %t.o14# RUN: %clang %cflags -no-pie %t.o -o %t.exe -Wl,-q15 16# RUN: llvm-bolt %t.exe --print-finalized --print-only=main -o %t.out \17# RUN:   2>&1 | FileCheck %s18 19# RUN: %t.out 1 2 | FileCheck --check-prefix=CHECK-RT %s20 21  .text22  .globl  main23  .type main, %function24  .p2align  425main:26  pushq %rbp27  movq  %rsp, %rbp28  subq  $0x10, %rsp29  cmpl  $0x2, %edi30  jb    .BBend31.BB2:32 33# CHECK: leaq34# CHECK-SAME: {{.*}}-{{.*}}35  leaq mystring-0x1000000, %rsi  # Use a large negative addend to cause a36                                 # negative result to be encoded in LEA37  addq $0x1000000, %rsi          # Eventually program logic compensates to get38                                 # a real address39  movq $2, %rbx40  xorq %rax, %rax41  movb (%rsi), %al42  addq %rbx, %rax43  movb %al, (%rsi)44  leaq mystring, %rdi45  callq puts46 47.BBend:48  xorq %rax, %rax49  leaveq50  retq51  .size main, .-main52 53  .data54 55# CHECK-RT: {{.*}} is rbx mod 10 contents in decimal56mystring: .asciz "0 is rbx mod 10 contents in decimal\n"57