[PATCH] Move machine type auto-detection to SymbolTable.
Peter Collingbourne
peter at pcc.me.uk
Fri May 29 13:49:36 PDT 2015
================
Comment at: COFF/SymbolTable.cpp:174-184
@@ -173,2 +173,13 @@
+llvm::COFF::MachineTypes SymbolTable::getInferredMachineType() {
+ for (std::unique_ptr<ObjectFile> &File : ObjectFiles) {
+ // Try to infer machine type from the magic byte of the object file.
+ auto MT =
+ static_cast<llvm::COFF::MachineTypes>(File->getCOFFObj()->getMachine());
+ if (MT != llvm::COFF::IMAGE_FILE_MACHINE_UNKNOWN)
+ return MT;
+ }
+ return llvm::COFF::IMAGE_FILE_MACHINE_UNKNOWN;
+}
+
} // namespace coff
----------------
ruiu wrote:
> I'd make this a non-member function in Writer.cpp which takes vector<unique_ptr<ObjectFile>>& as a parameter, as this function is not that related to symbol resolution. It feels that it belongs Writer. Maybe you need to expose ObjectFiles, but that's fine.
>
> And in the Writer, you can return Config->MachineType as a default value instead of UNKNOWN.
`Config->MachineType` overrides the detected value, doesn't it? That's what the existing logic seems to implement.
http://reviews.llvm.org/D10136
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the llvm-commits
mailing list