[PATCH] D16093: Allow context to report errors on files linked in the resolver

Pete Cooper via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 13 15:10:03 PST 2016


pete added a comment.

In http://reviews.llvm.org/D16093#326240, @lhames wrote:

> 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.


================
Comment at: include/lld/Core/Resolver.h:53
@@ -51,3 +52,3 @@
   // Handle a shared library file.
-  void handleSharedLibrary(File &);
+  ErrorOr<bool> handleSharedLibrary(File &);
 
----------------
lhames wrote:
> handleSharedLibrary doesn't add any undefined symbols, so this can remain 'void'.
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.

================
Comment at: lib/Core/Resolver.cpp:113
@@ +112,3 @@
+  auto undefAddedOrError = handleFile(*sharedLibrary);
+  if (undefAddedOrError.getError())
+    return undefAddedOrError;
----------------
lhames wrote:
> I think that it's reasonable to just assert that there was no error or undef added here.
Yep, will do.

================
Comment at: lib/Core/Resolver.cpp:126
@@ +125,3 @@
+
+  if (undefAddedOrError.getError())
+    return undefAddedOrError;
----------------
lhames wrote:
> Ditto here - we should just be able to assert no error here.
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.


http://reviews.llvm.org/D16093





More information about the llvm-commits mailing list