This is an archive of the discontinued LLVM Phabricator instance.

[lld]Non-MachO references shouldn't assert when checking for TLV.
AcceptedPublic

Authored by grosbach on Jan 8 2016, 12:43 PM.

Details

Reviewers
pete
lhames
Summary
Early exit identified as not being a TLV access is correct. In particular
the 'all' namespace is completely valid here for things like layout-after
references.

Diff Detail

Repository
rL LLVM

Event Timeline

grosbach updated this revision to Diff 44365.Jan 8 2016, 12:43 PM
grosbach retitled this revision from to [lld]Non-MachO references shouldn't assert when checking for TLV..
grosbach updated this object.
grosbach added reviewers: lhames, pete.
grosbach set the repository for this revision to rL LLVM.
grosbach added a project: lld.
grosbach added a subscriber: llvm-commits.
echristo added inline comments.
lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp
63

Can you add a comment explaining how you could get here? That said, is the check worth it now? i.e. do we really need the early exit?

lhames accepted this revision.Jan 8 2016, 5:20 PM
lhames edited edge metadata.

LGTM. Thanks Jim!

lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp
63

This is consistent with how GOT references (which are handled very similarly) are checked. We may try to improve on it in the future for performance reasons, but I'm happy with it for now.

This revision is now accepted and ready to land.Jan 8 2016, 5:20 PM
grosbach added inline comments.Jan 8 2016, 6:07 PM
lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp
63

A comment to that effect in the code seems a totally reasonable thing. The very fact that this patch is necessary is evidence that it's not completely obvious.

lhames added inline comments.Jan 8 2016, 6:44 PM
lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp
63

There are two things going on here:

  1. When you check the kindValue you need to interpret it in the context of the kindNamespace and kindArch. We should have something to encapsulate that check so that it can't be accidentally dropped (causing another bug like this). There may already be something like this, I haven't gone looking for it yet.
  1. I think ripRel32Tlv is generic, but currently its namespace and arch are getting set to mach_o x86_64 . They should probably be set to all/all instead (though I'll have to sanity check that), in which case we wouldn't need to query the ArchHandler about this at all.

Given how common this kind of check is, commenting this here probably isn't the right option. I'll file bugs to look into (1) and (2) instead.

lhames added inline comments.Jan 8 2016, 10:48 PM
lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp
63

For reference (though unfortunately it'll be primarily useful only to Apple people) I've filed rdar://problem/24119407 to track the issues above.