[llvm] [BOLT] Update LSDA encoding for x86-64 large code model (PR #190685)

Farid Zakaria via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 7 15:41:34 PDT 2026


================
@@ -0,0 +1,91 @@
+## Test that BOLT detects large code model binaries via .ltext sections
+## and updates the LSDA encoding to 8-byte pointers. Also test the
+## --large-code-model flag for manual override.
+
+# REQUIRES: system-linux
+
+# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-linux %s -o %t.o
+# RUN: ld.lld --no-pie %t.o -o %t.exe -q -e _start
+
+## Test 1: Auto-detection via .ltext section.
+# RUN: llvm-bolt %t.exe -o %t.bolt --reorder-blocks=none 2>&1 \
+# RUN:   | FileCheck %s --check-prefix=CHECK-BOLT
+# CHECK-BOLT: large code model detected
+
+# RUN: llvm-dwarfdump --eh-frame %t.bolt \
+# RUN:   | FileCheck %s --check-prefix=CHECK-EH
+
+## Test 2: Manual --large-code-model flag.
+# RUN: llvm-bolt %t.exe -o %t.bolt2 --reorder-blocks=none \
+# RUN:   --large-code-model 2>&1 \
+# RUN:   | FileCheck %s --check-prefix=CHECK-BOLT
+
+# RUN: llvm-dwarfdump --eh-frame %t.bolt2 \
+# RUN:   | FileCheck %s --check-prefix=CHECK-EH
+
+## Verify the BOLT-emitted CIE uses 8-byte LSDA encoding (DW_EH_PE_absptr
+## = 0x00) instead of the default 4-byte encoding (DW_EH_PE_sdata4 = 0x1B).
+## In the "zLR" augmentation data: [L-enc] [R-enc].
+# CHECK-EH:      Augmentation:          "zLR"
+# CHECK-EH:      Augmentation data:     00 1B
+
+  .text
+  .globl foo
+  .type foo, @function
+foo:
+  .cfi_startproc
+  ret
+  .cfi_endproc
+  .size foo, .-foo
+
+  .globl _start
+  .type _start, @function
+_start:
+.Lfunc_begin0:
+  .cfi_startproc
+  .cfi_lsda 27, .Lexception0
+  call foo
+.Ltmp0:
+  call foo
+.Ltmp1:
+  ret
+
+## Landing pads.
+.LLP0:
+  ret
+.LLP1:
+  ret
+
+  .cfi_endproc
+.Lfunc_end0:
+  .size _start, .Lfunc_end0-_start
+
+## Exception table.
+  .section .gcc_except_table,"a", at progbits
+  .p2align 2
+.Lexception0:
+  .byte 255                             # @LPStart Encoding = omit
+  .byte 255                             # @TType Encoding = omit
+  .byte 1                               # Call site Encoding = uleb128
+  .uleb128 .Lcst_end0-.Lcst_begin0
+.Lcst_begin0:
+  .uleb128 .Lfunc_begin0-.Lfunc_begin0  # Call Site 1
+  .uleb128 .Ltmp0-.Lfunc_begin0
+  .uleb128 .LLP0-.Lfunc_begin0          # landing pad
+  .byte 0                               # action: cleanup
+  .uleb128 .Ltmp0-.Lfunc_begin0         # Call Site 2
+  .uleb128 .Ltmp1-.Ltmp0
+  .uleb128 .LLP1-.Lfunc_begin0          # landing pad
+  .byte 0                               # action: cleanup
+.Lcst_end0:
+
+## Large code model function — triggers SHF_X86_64_LARGE detection.
----------------
fzakaria wrote:

fixed

https://github.com/llvm/llvm-project/pull/190685


More information about the llvm-commits mailing list