[PATCH] D93569: [lld-macho] Have order files support filtering by archive member paths
Jez Ng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 18 15:50:24 PST 2020
int3 updated this revision to Diff 312894.
int3 added a comment.
put back TODO
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D93569/new/
https://reviews.llvm.org/D93569
Files:
lld/MachO/Writer.cpp
lld/test/MachO/order-file.s
Index: lld/test/MachO/order-file.s
===================================================================
--- lld/test/MachO/order-file.s
+++ lld/test/MachO/order-file.s
@@ -78,6 +78,19 @@
# RUN: %lld -lSystem -o %t/test-archive-1 %t/foo.a %t/test.o -order_file %t/ord-1
# RUN: llvm-objdump -d %t/test-archive-1 | FileCheck %s --check-prefix=FOO-FIRST
+# RUN: %lld -lSystem -o %t/test-archive-file-no-match %t/test.o %t/foo.a -order_file %t/ord-file-match
+# RUN: llvm-objdump -d %t/test-archive-file-no-match | FileCheck %s --check-prefix=FOO-SECOND
+# RUN: %lld -lSystem -o %t/test-archive %t/foo.a %t/test.o -order_file %t/ord-file-match
+# RUN: llvm-objdump -d %t/test-archive-file-no-match | FileCheck %s --check-prefix=FOO-SECOND
+
+#--- ord-archive-match
+foo.a(foo.o):-[Foo doFoo:andBar:]
+_main
+# RUN: %lld -lSystem -o %t/test-archive-1 %t/test.o %t/foo.a -order_file %t/ord-archive-match
+# RUN: llvm-objdump -d %t/test-archive-1 | FileCheck %s --check-prefix=FOO-FIRST
+# RUN: %lld -lSystem -o %t/test-archive-1 %t/foo.a %t/test.o -order_file %t/ord-archive-match
+# RUN: llvm-objdump -d %t/test-archive-1 | FileCheck %s --check-prefix=FOO-FIRST
+
# RUN: %lld -lSystem -o %t/test-archive-file-no-match %t/test.o %t/foo.a -order_file %t/ord-file-nomatch
# RUN: llvm-objdump -d %t/test-archive-file-no-match | FileCheck %s --check-prefix=FOO-SECOND
# RUN: %lld -lSystem -o %t/test-archive %t/foo.a %t/test.o -order_file %t/ord-file-nomatch
Index: lld/MachO/Writer.cpp
===================================================================
--- lld/MachO/Writer.cpp
+++ lld/MachO/Writer.cpp
@@ -32,6 +32,7 @@
using namespace llvm;
using namespace llvm::MachO;
+using namespace llvm::sys;
using namespace lld;
using namespace lld::macho;
@@ -498,9 +499,16 @@
}
static size_t getSymbolPriority(const SymbolPriorityEntry &entry,
- const InputFile &file) {
- return std::max(entry.objectFiles.lookup(sys::path::filename(file.getName())),
- entry.anyObjectFile);
+ const InputFile *f) {
+ // We don't use toString(InputFile *) here because it returns the full path
+ // for object files, and we only want the basename.
+ StringRef filename;
+ if (f->archiveName.empty())
+ filename = path::filename(f->getName());
+ else
+ filename = saver.save(path::filename(f->archiveName) + "(" +
+ path::filename(f->getName()) + ")");
+ return std::max(entry.objectFiles.lookup(filename), entry.anyObjectFile);
}
// Each section gets assigned the priority of the highest-priority symbol it
@@ -518,12 +526,12 @@
SymbolPriorityEntry &entry = it->second;
size_t &priority = sectionPriorities[sym.isec];
- priority = std::max(priority, getSymbolPriority(entry, *sym.isec->file));
+ priority = std::max(priority, getSymbolPriority(entry, sym.isec->file));
};
// TODO: Make sure this handles weak symbols correctly.
for (InputFile *file : inputFiles)
- if (isa<ObjFile>(file) || isa<ArchiveFile>(file))
+ if (isa<ObjFile>(file))
for (lld::macho::Symbol *sym : file->symbols)
if (auto *d = dyn_cast<Defined>(sym))
addSym(*d);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93569.312894.patch
Type: text/x-patch
Size: 3207 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201218/b641e0b6/attachment.bin>
More information about the llvm-commits
mailing list