Previously, LLD only allows symbols with the same name if all of them are weak.
With this patch, we can allow symbols with the same name if one of them is weak. (This takes care of a TODO)
PR/52372
Differential D112977
[lld-macho] Handle weak vs strong case in symbol resolution oontvoo on Nov 1 2021, 7:13 PM. Authored by
Details
Previously, LLD only allows symbols with the same name if all of them are weak. With this patch, we can allow symbols with the same name if one of them is weak. (This takes care of a TODO) PR/52372
Diff Detail
Event TimelineComment Actions Oh, wait - actually we should just remove the assert Comment Actions This looks wrong to me.
Comment Actions I don't think this has anything to do with ICF. The assert was trying to verify that any subsections associated with a coalesced weak symbol has wasCoalesced = true. But now I see that it's not always true, because of this FIXME: https://github.com/llvm/llvm-project/blob/main/lld/MachO/SymbolTable.cpp#L73 We could *probably* remove the assert with no ill effects; I think the only effect is that we will emit some subsections containing dead code that have their associated compact unwind info dropped. But we should ideally handle the FIXME. @oontvoo do you want to take a stab at it, or should I? Comment Actions handle FIXME, as pointed out by int3 The test attached (and all the existing tests) here should cover it. Comment Actions We can probably just extend weak-definition-gc.s instead of creating a new test. And we should verify that the associated contents are indeed deleted. IMO once we cover that case, I don't think it's particularly important to test that the assert in registerCompactUnwind isn't fired. The "coalesced symbol => coalesced section contents" invariant is the more fundamental thing. cc @thakis since he wrote the original weak symbol GC code
Comment Actions Also we should test that coalescing works correctly regardless of which order we encounter the symbols (i.e. weak first then non-weak, and vice versa)
Comment Actions move the attributes merging back to the weak-weak case to presrve old behaviour - also added some note in case we want to revisit in the future
Comment Actions Hmm I think you missed my earlier comment about the test:
Comment Actions Thanks! Last nits: can we remove the dup-symbols-weak-def.s test now since the new logic is already covered by weak-definition-gc.s, and can we update the commit message to reflect the new approach?
Comment Actions Thanks!
Comment Actions
|
We definitely want to run dead stripping before ICF (no need to spend time ICF'ing code that's dead -- dead-stripping is faster than ICFing). This doesn't lg.