[lld] [lld][COFF] Don't truncate .llvm. and llvm_ section names (PR #229112)

Martin Storsjö via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 6 01:44:46 PDT 2026


mstorsjo wrote:

> @dpaoliello We are experimenting with putting GPU bitcode into shared libraries for consumption at runtime. LLVM uses .llvm.offloading sections for that purpose. On ELF we can call object::extractOffloadBinaries to read these sections at runtime, but on COFF that doesn't work because of the section name truncation.

Unfortunately, it's not quite that easy on PE-COFF...

If you include the full long section name in the final DLL/EXE, the section header (which is mapped into memory at runtime) contains byte offsets into the string table, which is _not_ mapped into memory. So it's not very straightforward to figure out what it means at runtime. When you have a `HMODULE` handle for a loaded DLL/EXE, you would need to map this back to a file on disk, manually read that and find the string table and read/extract it.

Due to this we intentionally truncate the non-discardable sections, like `.eh_frame`, which we locate at runtime in libunwind.


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


More information about the llvm-commits mailing list