Files
rust/compiler
Guillaume Gomez 0846622465 Rollup merge of #156973 - Darksonn:unwind-tables-module, r=nnethercote
Add uwtable annotation to modules when required

When unwind tables are enabled with `-Cforce-unwind-tables=y`, Rust will annotate all functions with the `uwtable` annotation. However, this annotation is missing on modules, which leads to incorrect unwind tables being generated by LLVM for constructors (such as `asan.module_ctor`).

This was discovered because it leads to a crash in Linux when KASAN and dynamic shadow call stack are both enabled. In this scenario, the kernel uses the unwind tables to locate the `paciasp` and `autiasp` instructions in each function and patches the machine code at boot to use the shadow call stack instructions instead. However, LLVM's AArch64PointerAuth pass emits DWARF info for `paciasp` whenever `-g` is passed, but only emits DWARF info for `autiasp` when the `uwtable` attribute is present. Since the `uwtable` annotation is missing for modules, the relevant directives are generated for only the `autiasp` instruction in `asan.module_ctor`, and not for the `paciasp` instruction. This causes the kernel's dynamic SCS logic to patch the prolouge of `asan.module_ctor`, but not the epilogue. This leads to a crash as the shadow call stack becomes unbalanced.

The fact that LLVM doesn't use the same condition for whether to emit DWARF information for both instructions may be a separate bug in LLVM.

Relevant issue: https://github.com/llvm/llvm-project/issues/188234

AI assistance was used to determine the root cause of this crash from the observed symptoms, and to write the tests. Also thanks to @samitolvanen and @maurer for debugging this issue.

Similar to this previous PR of mine: rust-lang/rust#130824
2026-05-27 20:45:14 +02:00
..
2026-05-04 16:28:58 +00:00
2026-05-20 11:44:04 +02:00
2026-05-04 16:28:58 +00:00
2026-05-22 19:40:22 +09:00
2026-05-18 10:41:15 +03:00
2026-05-11 21:32:42 +02:00
2026-05-26 21:35:25 +08:00
2026-05-22 12:36:19 +03:00
2026-05-12 21:58:50 +02:00