Normally when compiling bitcode in a relocatable link, LLD sets
the VisibleToRegularObj flag in the symbol resolution for all
globals, which prevents LTO from dropping globals that may be
needed later. However, in situations where we know which globals
we want to export, LTO could better optimize the code if we
marked only the exported symbols visible. This is the case in the
Linux kernel, for example, where all the bitcode in the kernel
is compiled during a relocatable link, and we have a list of
exported symbols.
Add an --lto-export-symbol-list flag to LLD, which accepts a list
of exported globals in the version script format, and uses the
list to set the bindings for non-exported globals to STB_LOCAL,
and sets the VisibleToRegularObj flag in symbol resolution only
for the exported symbols.
objSym.isExecutable() this condition is strange and does not fit into the spirit that we ignore symbol types for various symbol list features.
Can the user specify all data symbols?