This is an archive of the discontinued LLVM Phabricator instance.

Allow context to report errors on files linked in the resolver
ClosedPublic

Authored by pete on Jan 11 2016, 3:45 PM.

Details

Summary

Hi all

I'm trying to find a good place to give errors on files which differ in an unrecoverable way. For example, one file has been linked for the iOS simulator while another is normal x86 code, or perhaps linking arm and x86 code.

I've not yet added the checks for these errors, but wanted to see if you are all happy with the placement of the callback and the plumbing necessary to get the errors through the resolver.

Thanks,
Pete

Diff Detail

Repository
rL LLVM

Event Timeline

pete updated this revision to Diff 44572.Jan 11 2016, 3:45 PM
pete retitled this revision from to Allow context to report errors on files linked in the resolver.
pete updated this object.
pete added reviewers: kledzik, lhames, rafael, ruiu.
pete added a project: lld.
pete added a subscriber: llvm-commits.
lhames edited edge metadata.Jan 13 2016, 3:01 PM

This seems generically useful, but Is there a test case or use case?

include/lld/Core/Resolver.h
53 ↗(On Diff #44572)

handleSharedLibrary doesn't add any undefined symbols, so this can remain 'void'.

lib/Core/Resolver.cpp
113 ↗(On Diff #44572)

I think that it's reasonable to just assert that there was no error or undef added here.

126 ↗(On Diff #44572)

Ditto here - we should just be able to assert no error here.

pete added a comment.Jan 13 2016, 3:10 PM

This seems generically useful, but Is there a test case or use case?

I should be able to add one very soon in a follow up commit. As I said in the comment earlier, I'm hoping to fill in the hook with things like arch, OS checks, but i need to add some code to actually pull that information from the file we are linking and have a copy in the context to compare against.

include/lld/Core/Resolver.h
53 ↗(On Diff #44572)

Good point. I'll make it return std::error_code as its call to handleFile could still get an error from the new hook here.

lib/Core/Resolver.cpp
113 ↗(On Diff #44572)

Yep, will do.

126 ↗(On Diff #44572)

I should have explained the hook better. So what i hope to use it for in upcoming patches is to check that the file we link against has correct architecture, OS, ObjC flags, etc. So i think we could still throw an error here if the dylib is wrong in any of these respects.

lhames accepted this revision.Jan 13 2016, 3:16 PM
lhames edited edge metadata.

Ahh - that makes sense. Thanks Pete - looks good to me.

This revision is now accepted and ready to land.Jan 13 2016, 3:16 PM
This revision was automatically updated to reflect the committed changes.