[lld] [ELF] Make shouldAddProvideSym values consistent when demoted to Undefined (PR #111945)

Peter Smith via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 11 06:33:55 PDT 2024


================
@@ -1811,6 +1811,11 @@ void LinkerScript::addScriptReferencedSymbolsToSymTable() {
 }
 
 bool LinkerScript::shouldAddProvideSym(StringRef symName) {
+  // A Defined may be demoted to Undefined but the return value must stay the
----------------
smithp35 wrote:

I got a bit confused about whether the return value was this function's return value or the symbol's value. After thinking it through it is definitely the former.

A suggestion:

``` 
This function is called before and after garbage collection. To prevent undefined references the result of this function for a symbol must be the same for each call. We use isUsedInRegularObj to
prevent garbage collection demoting a Defined to an Undefnined. The exportDynamic condition, while not so accurate, allows PROVIDE to define a symbol referenced by a DSO.
```

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


More information about the llvm-commits mailing list