[lld] [lld][ELF] Introduce an option to keep data section prefix. (PR #148985)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 20 22:46:40 PDT 2025


MaskRay wrote:

> When `-keep-data-section-prefix` is enabled in linker, this change will map a `.hot`-prefixed input section to `.hot`-prefixed output section; I'm currently evaluating two options internally to keep the desired mapping -- we prefer to update the linker script to achieve that as long as the binary linking time remains reasonable, and have a back-up plan to update the [codegen pass](https://github.com/llvm/llvm-project/blob/main/llvm/lib/CodeGen/StaticDataAnnotator.cpp) to optionally (by an LLVM option) not emit `.hot`-prefixed input sections in the first place. Will try to land this in the next few days.

On the linker side, the option should be generic, treating .hot and .unlikely uniformly. In LLVM CodeGen, a cl::opt option can be used to manage `.hot` and `.unlikely` settings.

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


More information about the llvm-commits mailing list