[PATCH] D86640: [lld-macho] Implement -all_load

Jez Ng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 26 19:27:24 PDT 2020


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG62b39b3a0cb2: [lld-macho] Implement -all_load (authored by int3).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86640/new/

https://reviews.llvm.org/D86640

Files:
  lld/MachO/Config.h
  lld/MachO/Driver.cpp
  lld/test/MachO/archive.s


Index: lld/test/MachO/archive.s
===================================================================
--- lld/test/MachO/archive.s
+++ lld/test/MachO/archive.s
@@ -22,11 +22,17 @@
 # ARCHIVE-FIRST: T _boo
 # ARCHIVE-FIRST: T _main
 
-
 # RUN: llvm-nm %t/test.out | FileCheck %s --check-prefix VISIBLE
 # VISIBLE-NOT: T _undefined
 # VISIBLE-NOT: T _unused
 
+# RUN: lld -flavor darwinnew %t/test.a %t/main.o -o %t/all-load -all_load
+# RUN: llvm-nm %t/all-load | FileCheck %s --check-prefix ALL-LOAD
+# ALL-LOAD: T _bar
+# ALL-LOAD: T _boo
+# ALL-LOAD: T _main
+# ALL-LOAD: T _unused
+
 .global _main
 _main:
   callq _boo
Index: lld/MachO/Driver.cpp
===================================================================
--- lld/MachO/Driver.cpp
+++ lld/MachO/Driver.cpp
@@ -248,7 +248,11 @@
     if (!file->isEmpty() && !file->hasSymbolTable())
       error(path + ": archive has no index; run ranlib to add one");
 
-    if (config->forceLoadObjC) {
+    if (config->allLoad) {
+      if (Optional<MemoryBufferRef> buffer = readFile(path))
+        for (MemoryBufferRef member : getArchiveMembers(*buffer))
+          inputFiles.push_back(make<ObjFile>(member));
+    } else if (config->forceLoadObjC) {
       for (const object::Archive::Symbol &sym : file->symbols())
         if (sym.getName().startswith(objc::klass))
           symtab->addUndefined(sym.getName());
@@ -519,6 +523,7 @@
   config->headerPad = args::getHex(args, OPT_headerpad, /*Default=*/32);
   config->outputType = args.hasArg(OPT_dylib) ? MH_DYLIB : MH_EXECUTE;
   config->runtimePaths = args::getStrings(args, OPT_rpath);
+  config->allLoad = args.hasArg(OPT_all_load);
 
   std::vector<StringRef> &roots = config->systemLibraryRoots;
   for (const Arg *arg : args.filtered(OPT_syslibroot))
@@ -583,6 +588,7 @@
     case OPT_platform_version:
       handlePlatformVersion(arg);
       break;
+    case OPT_all_load:
     case OPT_o:
     case OPT_dylib:
     case OPT_e:
Index: lld/MachO/Config.h
===================================================================
--- lld/MachO/Config.h
+++ lld/MachO/Config.h
@@ -33,6 +33,7 @@
 struct Configuration {
   Symbol *entry;
   bool hasReexports = false;
+  bool allLoad = false;
   bool forceLoadObjC = false;
   uint32_t headerPad;
   llvm::StringRef installName;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86640.288168.patch
Type: text/x-patch
Size: 2285 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200827/2cdd8f49/attachment.bin>


More information about the llvm-commits mailing list