[PATCH] D62844: lld/macho application_extension support
Carlo Kok via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 4 01:08:42 PDT 2019
carlokok created this revision.
carlokok added a project: lld.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
This adds the application_extension which basically sets a header flag.
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D62844
Files:
include/lld/ReaderWriter/MachOLinkingContext.h
lib/Driver/DarwinLdDriver.cpp
lib/Driver/DarwinLdOptions.td
lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
Index: lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
===================================================================
--- lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
+++ lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
@@ -1571,6 +1573,8 @@
flags |= MH_PIE;
if (_hasTLVDescriptors)
flags |= (MH_PIE | MH_HAS_TLV_DESCRIPTORS);
+ if (_ctx.applicationExtension())
+ flags |= MH_APP_EXTENSION_SAFE;
return flags;
}
}
Index: lib/Driver/DarwinLdOptions.td
===================================================================
--- lib/Driver/DarwinLdOptions.td
+++ lib/Driver/DarwinLdOptions.td
@@ -17,6 +17,8 @@
HelpText<"Create main executable (default)">, Group<grp_kind>;
def preload : Flag<["-"], "preload">,
HelpText<"Create binary for use with embedded systems">, Group<grp_kind>;
+def applicationextension : Flag<["-"], "application_extension">,
+ HelpText<"Mark a library as an application extension">, Group<grp_kind>;
// optimizations
def grp_opts : OptionGroup<"opts">, HelpText<"OPTIMIZATIONS">;
Index: lib/Driver/DarwinLdDriver.cpp
===================================================================
--- lib/Driver/DarwinLdDriver.cpp
+++ lib/Driver/DarwinLdDriver.cpp
@@ -366,6 +366,10 @@
}
}
+ if (llvm::opt::Arg *kind = parsedArgs.getLastArg(OPT_applicationextension)) {
+ ctx.setApplicationExtension(true);
+ }
+
// Handle -arch xxx
MachOLinkingContext::Arch arch = MachOLinkingContext::arch_unknown;
if (llvm::opt::Arg *archStr = parsedArgs.getLastArg(OPT_arch)) {
Index: include/lld/ReaderWriter/MachOLinkingContext.h
===================================================================
--- include/lld/ReaderWriter/MachOLinkingContext.h
+++ include/lld/ReaderWriter/MachOLinkingContext.h
@@ -321,6 +321,8 @@
void setBundleLoader(StringRef loader) { _bundleLoader = loader; }
void setPrintAtoms(bool value=true) { _printAtoms = value; }
+ void setApplicationExtension(bool value = true) { _applicationExtension = value; }
+ bool applicationExtension() const { return _applicationExtension; }
void setTestingFileUsage(bool value = true) {
_testingFileUsage = value;
}
@@ -487,6 +489,7 @@
bool _generateVersionLoadCommand = false;
bool _generateFunctionStartsLoadCommand = false;
bool _generateDataInCodeLoadCommand = false;
+ bool _applicationExtension = false;
StringRef _bundleLoader;
mutable std::unique_ptr<mach_o::ArchHandler> _archHandler;
mutable std::unique_ptr<Writer> _writer;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62844.202869.patch
Type: text/x-patch
Size: 2548 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190604/8d8b77ce/attachment.bin>
More information about the llvm-commits
mailing list