[PATCH] D86640: [lld-macho] Implement -all_load
Jez Ng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 26 16:03:47 PDT 2020
int3 updated this revision to Diff 288129.
int3 marked an inline comment as done.
int3 added a comment.
add test
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.288129.patch
Type: text/x-patch
Size: 2285 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200826/73379f16/attachment.bin>
More information about the llvm-commits
mailing list