Hi all,
I’m emitting some global variables in a special section as a way of communicating metadata to some LTO passes and the linker.
These globals need to be preserved until the linker, so I’ve added them to llvm.used
. However, the llvm.used
semantics are not exactly what I want. I would like the metadata to survive till the linker (including through LTO passes), but then should be discardable by the linker.
At first I thought llvm.compiler.used
is what I’m after, but if I understand correctly, LTO passes are permitted to strip llvm.compiler.used
entries.
I’d like a special section, or similar global, that I can use to preserve data until it arrives at the linker. Without having to teach every linker about this special section or data, I’d like those not “familiar” with it to discard it as part of conventional dead stripping.
Does something already exist in LLVM with the semantics I’m after? The notion of an llvm.linker.used
global was alluded to here: D97446. I realize I’ve been vague about the motivation for this metadata, and if it helps, I can elaborate.
Thanks