[PATCH] D97209: [lld-macho] Check for arch compatibility when loading ObjFiles and TBDs

Nico Weber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 23 07:00:57 PST 2021


thakis accepted this revision.
thakis added a comment.
This revision is now accepted and ready to land.

ELF and COFF do this a bit earlier, COFF in SymbolTable::addFile() which has the nicer diag I suggest below -- but otherwise I don't like the COFF approach much, since it parses the whole InputFile, which adds its symbols, and only after that it checks the arch. Checking the arch first and returning early if it doens't match, like this does, seems better. ELF does it in doParseFile(), with a similar timing to this patch. Maybe we could make it look a bit more like the ELF port, to keep the different lld ports consistent in parts where they don't need to be different?



================
Comment at: lld/MachO/InputFiles.cpp:487
+    error(toString(this) + " is incompatible with " +
+          getArchitectureName(config->arch));
+    return;
----------------
should the diag mention the arch of the source file too? "file has architecture x86 which is incompatible with output architecture x64" or similar?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97209



More information about the llvm-commits mailing list