[all-commits] [llvm/llvm-project] 1c6688: [ELF] Make shouldAddProvideSym return values consi...
Fangrui Song via All-commits
all-commits at lists.llvm.org
Fri Oct 11 08:47:30 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 1c6688ae3449da9c8fee1e1c12c892223496fb4c
https://github.com/llvm/llvm-project/commit/1c6688ae3449da9c8fee1e1c12c892223496fb4c
Author: Fangrui Song <i at maskray.me>
Date: 2024-10-11 (Fri, 11 Oct 2024)
Changed paths:
M lld/ELF/LinkerScript.cpp
A lld/test/ELF/linkerscript/provide-defined.s
Log Message:
-----------
[ELF] Make shouldAddProvideSym return values consistent when demoted to Undefined
Case: `PROVIDE(f1 = bar);` when both `f1` and `bar` are in separate
sections that would be discarded by GC.
Due to `demoteDefined`, `shouldAddProvideSym(f1)` may initially return
false (when Defined) and then return true (been demoted to Undefined).
```
addScriptReferencedSymbolsToSymTable
shouldAddProvideSym(f1): false
// the RHS (bar) is not added to `referencedSymbols` and may be GCed
declareSymbols
shouldAddProvideSym(f1): false
markLive
demoteSymbolsAndComputeIsPreemptible
// demoted f1 to Undefined
processSymbolAssignments
addSymbol
shouldAddProvideSym(f1): true
```
The inconsistency can cause `cmd->expression()` in `addSymbol` to be
evaluated, leading to `symbol not found: bar` errors (since `bar` in the
RHS is not in `referencedSymbols` and is GCed) (#111478).
Fix this by adding a `sym->isUsedInRegularObj` condition, making
`shouldAddProvideSym(f1)` values consistent. In addition, we need a
`sym->exportDynamic` condition to keep provide-shared.s working.
Fixes: ebb326a51fec37b5a47e5702e8ea157cd4f835cd
Pull Request: https://github.com/llvm/llvm-project/pull/111945
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list