[clang-repl] [codegen] Reduce the state in TBAA. NFC for static compilation. (#98138)
[llvm-project.git] / bolt / test / runtime / X86 / section-reloc-with-addend.s
blob63b7733e3e9e5e4940908b7dc840bd629ab21c6f
1 # This reproduces a bug triggered by a relocation referencing a section symbol
2 # 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 (encoded
4 # in the immediate operand of an LEA instruction).
5 # Originally triggered by https://fossies.org/linux/glib/glib/guniprop.c
6 # Line 550: const gchar *p = special_case_table + val - 0x1000000;
8 # REQUIRES: system-linux
10 # RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown \
11 # RUN: %s -o %t.o
12 # Delete our BB symbols so BOLT doesn't mark them as entry points
13 # RUN: llvm-strip --strip-unneeded %t.o
14 # RUN: %clang %cflags -no-pie %t.o -o %t.exe -Wl,-q
16 # RUN: llvm-bolt %t.exe --print-finalized --print-only=main -o %t.out \
17 # RUN: 2>&1 | FileCheck %s
19 # RUN: %t.out 1 2 | FileCheck --check-prefix=CHECK-RT %s
21 .text
22 .globl main
23 .type main, %function
24 .p2align 4
25 main:
26 pushq %rbp
27 movq %rsp, %rbp
28 subq $0x10, %rsp
29 cmpl $0x2, %edi
30 jb .BBend
31 .BB2:
33 # CHECK: leaq
34 # CHECK-SAME: {{.*}}-{{.*}}
35 leaq mystring-0x1000000, %rsi # Use a large negative addend to cause a
36 # negative result to be encoded in LEA
37 addq $0x1000000, %rsi # Eventually program logic compensates to get
38 # a real address
39 movq $2, %rbx
40 xorq %rax, %rax
41 movb (%rsi), %al
42 addq %rbx, %rax
43 movb %al, (%rsi)
44 leaq mystring, %rdi
45 callq puts
47 .BBend:
48 xorq %rax, %rax
49 leaveq
50 retq
51 .size main, .-main
53 .data
55 # CHECK-RT: {{.*}} is rbx mod 10 contents in decimal
56 mystring: .asciz "0 is rbx mod 10 contents in decimal\n"