aboutsummaryrefslogtreecommitdiff
path: root/lld/MachO/SymbolTable.cpp
diff options
context:
space:
mode:
authoralx32 <103613512+alx32@users.noreply.github.com>2024-03-27 17:27:51 -0700
committerGitHub <noreply@github.com>2024-03-27 17:27:51 -0700
commitbbfa50696e43f337f55f8bacf739683b181debd5 (patch)
tree3c5adab8bd050abb569ddd0faebebf780d5e2bef /lld/MachO/SymbolTable.cpp
parent0fda758f26c1ec06809fdc067cd65dc146f867d0 (diff)
downloadllvm-bbfa50696e43f337f55f8bacf739683b181debd5.tar.gz
llvm-bbfa50696e43f337f55f8bacf739683b181debd5.tar.bz2
llvm-bbfa50696e43f337f55f8bacf739683b181debd5.zip
[lld-macho] Fix bug in makeSyntheticInputSection when -dead_strip flag is specified (#86878)
Previously, `makeSyntheticInputSection` would create a new `ConcatInputSection` without setting `live` explicitly for it. Without `-dead_strip` this would be OK since `live` would default to `true`. However, with `-dead_strip`, `live` would default to false, and it would remain set to `false`. This hasn't resulted in any issues so far since no code paths that exposed this issue were present. However a recent change - ObjC relative method lists (https://github.com/llvm/llvm-project/pull/86231) exposes this issue by creating relocations to the `SyntheticInputSection`. When these relocations are attempted to be written, this ends up with a crash(assert), since the `SyntheticInputSection` they refer to is marked as dead (`live` = `false`). With this change, we set the correct behavior - `live` will always be `true`. We add a test case that before this change would trigger an assert in the linker.
Diffstat (limited to 'lld/MachO/SymbolTable.cpp')
-rw-r--r--lld/MachO/SymbolTable.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/lld/MachO/SymbolTable.cpp b/lld/MachO/SymbolTable.cpp
index 825242f2cc72..755ff270e2f7 100644
--- a/lld/MachO/SymbolTable.cpp
+++ b/lld/MachO/SymbolTable.cpp
@@ -377,7 +377,7 @@ static void handleSectionBoundarySymbol(const Undefined &sym, StringRef segSect,
// live. Marking the isec live ensures an OutputSection is created that the
// start/end symbol can refer to.
assert(sym.isLive());
- isec->live = true;
+ assert(isec->live);
// This runs after gatherInputSections(), so need to explicitly set parent
// and add to inputSections.