[lld] [llvm] [LLD][COFF] Make unresolved symbol search behavior compliant with MSVC link.exe (PR #85290)
Jacek Caban via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 24 13:39:28 PDT 2024
================
@@ -93,10 +94,40 @@ static bool ignoredSymbolName(StringRef name) {
return name == "@feat.00" || name == "@comp.id";
}
+static bool compatibleMachineType(COFFLinkerContext &ctx, MachineTypes mt) {
+ if (mt == IMAGE_FILE_MACHINE_UNKNOWN)
+ return true;
+ switch (ctx.config.machine) {
+ case ARM64:
+ return mt == ARM64 || mt == ARM64X;
+ case ARM64EC:
+ return COFF::isArm64EC(mt) || mt == AMD64;
+ case ARM64X:
+ return COFF::isAnyArm64(mt) || mt == AMD64;
+ default:
+ return ctx.config.machine == mt;
+ }
+}
+
+static void setMachine(InputFile *file, COFFLinkerContext &ctx) {
+ MachineTypes mt = file->getMachineType();
+ if (ctx.config.machine == IMAGE_FILE_MACHINE_UNKNOWN) {
+ ctx.config.machine = mt;
+ ctx.driver.addWinSysRootLibSearchPaths();
+ } else if (!compatibleMachineType(ctx, mt)) {
+ error(toString(file) + ": machine type " + machineToStr(mt) +
+ " conflicts with " + machineToStr(ctx.config.machine));
+ return;
+ }
+}
+
ArchiveFile::ArchiveFile(COFFLinkerContext &ctx, MemoryBufferRef m)
- : InputFile(ctx, ArchiveKind, m) {}
+ : InputFile(ctx, ArchiveKind, m, /*lazy=*/true) {
+ static unsigned Order = 0;
----------------
cjacek wrote:
It could be a member of `COFFLinkerContext`.
https://github.com/llvm/llvm-project/pull/85290
More information about the llvm-commits
mailing list