From 9b6f55389ebd0cf048faa7375a3a74fade4f87e8 Mon Sep 17 00:00:00 2001 From: Eric Beckmann Date: Wed, 5 Jul 2017 18:59:16 +0000 Subject: [PATCH] Revert "Switch external cvtres.exe for llvm's own resource library." This reverts commit 600d52c278e123dd08bee24c1f00932b55add8de. This patch still seems to break CrWinClangLLD, reverting until I can find root problem. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307189 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Object/WindowsResource.h | 3 +++ lib/Object/WindowsResource.cpp | 3 +-- tools/llvm-cvtres/llvm-cvtres.cpp | 21 ++++++++++----------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/include/llvm/Object/WindowsResource.h b/include/llvm/Object/WindowsResource.h index 844256478cf..1ef00e2909f 100644 --- a/include/llvm/Object/WindowsResource.h +++ b/include/llvm/Object/WindowsResource.h @@ -43,10 +43,13 @@ #include namespace llvm { + namespace object { class WindowsResource; +enum class Machine { UNKNOWN, ARM, X64, X86 }; + class ResourceEntryRef { public: Error moveNext(bool &End); diff --git a/lib/Object/WindowsResource.cpp b/lib/Object/WindowsResource.cpp index f675a8389e6..7d1da37a634 100644 --- a/lib/Object/WindowsResource.cpp +++ b/lib/Object/WindowsResource.cpp @@ -328,7 +328,7 @@ private: std::unique_ptr OutputBuffer; char *BufferStart; uint64_t CurrentOffset = 0; - COFF::MachineTypes MachineType; + Machine MachineType; const WindowsResourceParser::TreeNode &Resources; const ArrayRef> Data; uint64_t FileSize; @@ -350,7 +350,6 @@ WindowsResourceCOFFWriter::WindowsResourceCOFFWriter( : MachineType(MachineType), Resources(Parser.getTree()), Data(Parser.getData()), StringTable(Parser.getStringTable()) { performFileLayout(); - OutputBuffer = MemoryBuffer::getNewMemBuffer(FileSize); } diff --git a/tools/llvm-cvtres/llvm-cvtres.cpp b/tools/llvm-cvtres/llvm-cvtres.cpp index 36c15925e84..b331566d41c 100644 --- a/tools/llvm-cvtres/llvm-cvtres.cpp +++ b/tools/llvm-cvtres/llvm-cvtres.cpp @@ -120,21 +120,21 @@ int main(int argc_, const char *argv_[]) { bool Verbose = InputArgs.hasArg(OPT_VERBOSE); - COFF::MachineTypes MachineType; + Machine MachineType; if (InputArgs.hasArg(OPT_MACHINE)) { std::string MachineString = InputArgs.getLastArgValue(OPT_MACHINE).upper(); - MachineType = StringSwitch(MachineString) - .Case("ARM", COFF::IMAGE_FILE_MACHINE_ARMNT) - .Case("X64", COFF::IMAGE_FILE_MACHINE_AMD64) - .Case("X86", COFF::IMAGE_FILE_MACHINE_I386) - .Default(COFF::IMAGE_FILE_MACHINE_UNKNOWN); - if (MachineType == COFF::IMAGE_FILE_MACHINE_UNKNOWN) + MachineType = StringSwitch(MachineString) + .Case("ARM", Machine::ARM) + .Case("X64", Machine::X64) + .Case("X86", Machine::X86) + .Default(Machine::UNKNOWN); + if (MachineType == Machine::UNKNOWN) reportError("Unsupported machine architecture"); } else { if (Verbose) outs() << "Machine architecture not specified; assumed X64.\n"; - MachineType = COFF::IMAGE_FILE_MACHINE_AMD64; + MachineType = Machine::X64; } std::vector InputFiles = InputArgs.getAllArgValues(OPT_INPUT); @@ -155,10 +155,10 @@ int main(int argc_, const char *argv_[]) { if (Verbose) { outs() << "Machine: "; switch (MachineType) { - case COFF::IMAGE_FILE_MACHINE_ARMNT: + case Machine::ARM: outs() << "ARM\n"; break; - case COFF::IMAGE_FILE_MACHINE_I386: + case Machine::X86: outs() << "X86\n"; break; default: @@ -207,7 +207,6 @@ int main(int argc_, const char *argv_[]) { std::copy(OutputBuffer->getBufferStart(), OutputBuffer->getBufferEnd(), FileBuffer->getBufferStart()); error(FileBuffer->commit()); - if (Verbose) { Expected> BinaryOrErr = createBinary(OutputFile); if (!BinaryOrErr)