[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
Sun Dec 20 10:50:03 PST 2020
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG64e475720020: [lld-macho] Have order files support filtering by archive member paths (authored by int3).
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
@@ -55,6 +55,16 @@
# 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
+
+# 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
@@ -104,6 +114,10 @@
foo.o:-[Foo doFoo:andBar:]
_main
+#--- ord-archive-match
+foo.a(foo.o):-[Foo doFoo:andBar:]
+_main
+
#--- ord-file-nomatch
bar.o:-[Foo doFoo:andBar:]
_main
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;
@@ -497,9 +498,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
@@ -517,12 +525,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.312993.patch
Type: text/x-patch
Size: 3325 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201220/3628525a/attachment.bin>
More information about the llvm-commits
mailing list