Page MenuHomePhabricator

[lld/mac] Implement -u flag
Needs ReviewPublic

Authored by thakis on Sat, Jan 9, 7:22 PM.

Details

Reviewers
None
Group Reviewers
Restricted Project
Summary

Since we emit diagnostics for undefineds in Writer::scanRelocations()
and symbols referenced by -u flags aren't referenced by any relocations,
this needs some manual code (similar to the entry point).

Diff Detail

Event Timeline

thakis created this revision.Sat, Jan 9, 7:22 PM
thakis requested review of this revision.Sat, Jan 9, 7:22 PM
MaskRay added a subscriber: MaskRay.Sat, Jan 9, 9:08 PM
MaskRay added inline comments.
lld/test/MachO/u.s
22

Would be nice to check the interaction with .weak_reference

thakis added inline comments.Sun, Jan 10, 6:19 AM
lld/test/MachO/u.s
22

As far as I understand, .weak_reference only affects which opcodes are written to the import bind FSA description and doesn't interact with symbol lookup. Are you thinking of -U instead of -u maybe? Or do you mean a test that checks if a -u resolved against a dylib pulls in the dylib (independent of weak_ref)?

int3 added a subscriber: int3.Tue, Jan 12, 11:37 AM

Since we emit diagnostics for undefineds in Writer::scanRelocations()

I've been wondering whether this is the right way to do it... in particular, we end up emitting one error message per relocation to an undefined, even if they all point to the same undefined. I made a brief attempt to scan the symbol table instead, but that creates spurious errors for things like .globl unused_and_undefined. I suppose we could always just dedup the symbols when scanning through the relocations though. Do you know how LLD-ELF handles this?

lld/test/MachO/u.s
22

yeah I don't see how weak_reference would need to be tested here either