This matches ld64 behavior
Details
- Reviewers
thakis int3 - Group Reviewers
Restricted Project - Commits
- rG1d1aa2d0130c: [lld-macho] Mark aliased symbols as noDeadStrip
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
I didn't investigate the ld64 behavior besides checking that this same test case passes with it
lld/MachO/MarkLive.cpp | ||
---|---|---|
232 | Left this here since we don't support this one yet |
I played around with the test a bit and I realized that ld64 doesn't actually dead-strip _foo if .subsections_via_symbols isn't there (even though _foo and _main are in separate files and therefore separate sections...)
With .subsections_via_symbols added, I noticed that ld64 does actually dead-strip _bar (but not _foo!). I am not really sure that behavior makes sense, presumably an alias exists so that some other library can look up the aliasing symbol name, not the aliased symbol name...
So I think we should add .subsections_via_symbols + add a comment to the test describing this deviation from ld64
I will look into N_INDR shortly...
Oh yeah our alias-symbols.s test case already covers the -dead_strip + N_INDR case so we're good
So I think we should add .subsections_via_symbols + add a comment to the test describing this deviation from ld64
Just for completeness: imitating this behavior isn't the most trivial since we track liveness at the InputSection level rather than at the symbol level. But I don't think it's important to imitate this, so it's all good
yeah add .subsections_via_symbols and a comment about ld64's behavior to the test, then merge :)
Left this here since we don't support this one yet