diff --git a/lld/COFF/Writer.cpp b/lld/COFF/Writer.cpp index cbb7f8b9f506..bf3c0af67407 100644 --- a/lld/COFF/Writer.cpp +++ b/lld/COFF/Writer.cpp @@ -375,17 +375,6 @@ void Writer::assignAddresses() { RoundUpToAlignment(FileOff - SizeOfHeaders, FileAlignment); } -static MachineTypes -inferMachineType(const std::vector &Files) { - for (ObjectFile *F : Files) { - // Try to infer machine type from the magic byte of the object file. - auto MT = static_cast(F->getCOFFObj()->getMachine()); - if (MT != IMAGE_FILE_MACHINE_UNKNOWN) - return MT; - } - return IMAGE_FILE_MACHINE_UNKNOWN; -} - template void Writer::writeHeader() { // Write DOS stub uint8_t *Buf = Buffer->getBufferStart(); @@ -400,15 +389,10 @@ template void Writer::writeHeader() { memcpy(Buf, PEMagic, sizeof(PEMagic)); Buf += sizeof(PEMagic); - // Determine machine type, infer if needed. TODO: diagnose conflicts. - MachineTypes MachineType = Config->MachineType; - if (MachineType == IMAGE_FILE_MACHINE_UNKNOWN) - MachineType = inferMachineType(Symtab->ObjectFiles); - // Write COFF header auto *COFF = reinterpret_cast(Buf); Buf += sizeof(*COFF); - COFF->Machine = MachineType; + COFF->Machine = Config->MachineType; COFF->NumberOfSections = OutputSections.size(); COFF->Characteristics = IMAGE_FILE_EXECUTABLE_IMAGE; if (Is64)