From dcb46d6a74ba8b04408afa6c088e529a4254a95c Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Wed, 8 Jul 2015 20:35:29 +0000 Subject: [PATCH] COFF: Remove dead code. r241647 made Driver to infer machine type, so this code is not actually in use. llvm-svn: 241720 --- lld/COFF/Writer.cpp | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) 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)