[PATCH] Move machine type auto-detection to SymbolTable.

Rui Ueyama ruiu at google.com
Fri May 29 13:53:20 PDT 2015


On Fri, May 29, 2015 at 1:49 PM, Peter Collingbourne <peter at pcc.me.uk>
wrote:

> ================
> 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.


Ah, yes, command line takes precedence over the detected value. Actually
it's an error if they conflict.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150529/5ad92229/attachment.html>


More information about the llvm-commits mailing list