In Writer::includeInDynSym(), exportDynamic is used by a Defined with
protected or default visibility, to record whether it is required to be
exported into .dynsym. It is set when any of the following conditions
hold:
- There is an interposable symbol from a DSO (Undefined or SharedSymbol with default visibility)
- If -shared or --export-dynamic is specified, any symbol in an object file/bitcode sets this property, unless suppressed by canBeOmittedFromSymbolTable().
- --dynamic-list when producing an executable
Bullet 3) does not play well with 1) and 2). When -shared is specified,
exportDynamic of most symbols is true. This makes it incapable to record
--dynamic-list marked symbols. We thus have obscure:
if (!config->shared) b->exportDynamic = true; else if (b->includeInDynsym()) b->isPreemptible = true;
This patch adds another bit Symbol::inDynamicList to record
3). We can thus simplify handleDynamicList() by unifying the DSO and
executable cases. It also allows us to simplify isPreemptible - now
the field is only used in finalizeSections() and later stages.
I've struggled with the name and comment here. I think it is because this is really the union of two separate properties that have a similar effect, with a similar name to a command line option that has a related but different effect. The two separate properties are:
Separate from this we have --export-dynamic which affects whether all symbols of the appropriate visibility defined in an executable should be put into the dynamic symbol table. The presence of --export-dynamic on the command line does not affect the exportDynamic flag in Symbol even though the name suggests that it should.
The best I can come up with for alternative is something like requiresDynamic or forceDynamic.