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)