xref: /llvm-project/bolt/test/X86/exceptions-compact.s (revision 92301180f7e2d240c560f621f6fc1b07217cac01)
1## Check that llvm-bolt is able to overwrite LSDA in ULEB128 format in-place for
2## all types of binaries.
3
4# REQUIRES: system-linux
5
6# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-linux %s -o %t.o
7# RUN: ld.lld --no-pie %t.o -o %t.exe -q
8# RUN: ld.lld --pie %t.o -o %t.pie -q
9# RUN: ld.lld --shared %t.o -o %t.so -q
10# RUN: llvm-bolt %t.exe -o %t.bolt --strict \
11# RUN:   | FileCheck --check-prefix=CHECK-BOLT %s
12# RUN: llvm-bolt %t.pie -o %t.pie.bolt --strict \
13# RUN:   | FileCheck --check-prefix=CHECK-BOLT %s
14# RUN: llvm-bolt %t.so -o %t.so.bolt --strict \
15# RUN:   | FileCheck --check-prefix=CHECK-BOLT %s
16
17# CHECK-BOLT: rewriting .gcc_except_table in-place
18
19# RUN: llvm-readelf -WS %t.bolt | FileCheck --check-prefix=CHECK-ELF %s
20# RUN: llvm-readelf -WS %t.pie.bolt | FileCheck --check-prefix=CHECK-ELF %s
21# RUN: llvm-readelf -WS %t.so.bolt | FileCheck --check-prefix=CHECK-ELF %s
22
23# CHECK-ELF-NOT: .bolt.org.gcc_except_table
24
25  .text
26  .global foo
27  .type foo, %function
28foo:
29  .cfi_startproc
30  ret
31  .cfi_endproc
32  .size foo, .-foo
33
34  .globl _start
35  .type _start, %function
36_start:
37.Lfunc_begin0:
38  .cfi_startproc
39  .cfi_lsda 27, .Lexception0
40  call foo
41.Ltmp0:
42  call foo
43.Ltmp1:
44  ret
45
46## Landing pads.
47.LLP1:
48  ret
49.LLP0:
50  ret
51
52  .cfi_endproc
53.Lfunc_end0:
54  .size _start, .-_start
55
56## EH table.
57  .section  .gcc_except_table,"a",@progbits
58  .p2align  2
59GCC_except_table0:
60.Lexception0:
61  .byte 255                             # @LPStart Encoding = omit
62  .byte 255                             # @TType Encoding = omit
63  .byte 1                               # Call site Encoding = uleb128
64  .uleb128 .Lcst_end0-.Lcst_begin0
65.Lcst_begin0:
66  .uleb128 .Lfunc_begin0-.Lfunc_begin0  # >> Call Site 1 <<
67  .uleb128 .Ltmp0-.Lfunc_begin0         #   Call between .Lfunc_begin0 and .Ltmp0
68  .uleb128 .LLP0-.Lfunc_begin0          #   jumps to .LLP0
69  .byte 0                               #   On action: cleanup
70  .uleb128 .Ltmp0-.Lfunc_begin0         # >> Call Site 2 <<
71  .uleb128 .Ltmp1-.Ltmp0                #   Call between .Ltmp0 and .Ltmp1
72  .uleb128 .LLP1-.Lfunc_begin0          #     jumps to .LLP1
73  .byte 0                               #   On action: cleanup
74.Lcst_end0:
75
76