[PATCH] D62568: lld/mach-o should set MH_NO_REEXPORTED_DYLIBS if there are no REEXPORT_DYLIB libraries
Carlo Kok via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 28 22:30:20 PDT 2019
carlokok created this revision.
carlokok added a project: lld.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Currently it doesn't ever set that, this patch sets it unless there are reexported libraries. When this happens ld64 doesn't like linking to it, failing with the error that MH_NO_REEXPORTED_DYLIBS should have been set.
(Thanks to @LemonBoy for helping me with this patch)
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D62568
Files:
lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
Index: lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
===================================================================
--- lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
+++ lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
@@ -1631,6 +1631,18 @@
normFile.pageSize = context.pageSize();
normFile.rpaths = context.rpaths();
util.addDependentDylibs(atomFile, normFile);
+ if (context.outputMachOType() == MH_DYLIB) {
+ // If we're not re-exporting any dylib set MH_NO_REEXPORTED_DYLIBS
+ size_t numExportedDylibs = normFile.dependentDylibs.size();
+ normFile.flags = normFile.flags | MH_NO_REEXPORTED_DYLIBS;
+ for (DependentDylib § : normFile.dependentDylibs) {
+ if (sect.kind == llvm::MachO::LC_REEXPORT_DYLIB) {
+ normFile.flags = normFile.flags &~ MH_NO_REEXPORTED_DYLIBS;
+ break;
+ }
+ }
+ }
+
util.copySegmentInfo(normFile);
util.copySectionInfo(normFile);
util.assignAddressesToSections(normFile);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62568.201823.patch
Type: text/x-patch
Size: 998 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190529/9042cdd3/attachment.bin>
More information about the llvm-commits
mailing list