llvm.org GIT mirror llvm / 1efceea
Revert "Revert "Switch external cvtres.exe for llvm's own resource library."" This reverts commit 165e578e47f1cd38191120aad23a9020fb5476dd. Forgot to run tests on this. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307190 91177308-0d34-0410-b5e6-96231b3b80d8 Eric Beckmann 2 years ago
3 changed file(s) with 13 addition(s) and 14 deletion(s). Raw diff Collapse all Expand all
4242 #include
4343
4444 namespace llvm {
45
4645 namespace object {
4746
4847 class WindowsResource;
49
50 enum class Machine { UNKNOWN, ARM, X64, X86 };
5148
5249 class ResourceEntryRef {
5350 public:
327327 std::unique_ptr OutputBuffer;
328328 char *BufferStart;
329329 uint64_t CurrentOffset = 0;
330 Machine MachineType;
330 COFF::MachineTypes MachineType;
331331 const WindowsResourceParser::TreeNode &Resources;
332332 const ArrayRef> Data;
333333 uint64_t FileSize;
349349 : MachineType(MachineType), Resources(Parser.getTree()),
350350 Data(Parser.getData()), StringTable(Parser.getStringTable()) {
351351 performFileLayout();
352
352353 OutputBuffer = MemoryBuffer::getNewMemBuffer(FileSize);
353354 }
354355
119119
120120 bool Verbose = InputArgs.hasArg(OPT_VERBOSE);
121121
122 Machine MachineType;
122 COFF::MachineTypes MachineType;
123123
124124 if (InputArgs.hasArg(OPT_MACHINE)) {
125125 std::string MachineString = InputArgs.getLastArgValue(OPT_MACHINE).upper();
126 MachineType = StringSwitch(MachineString)
127 .Case("ARM", Machine::ARM)
128 .Case("X64", Machine::X64)
129 .Case("X86", Machine::X86)
130 .Default(Machine::UNKNOWN);
131 if (MachineType == Machine::UNKNOWN)
126 MachineType = StringSwitch(MachineString)
127 .Case("ARM", COFF::IMAGE_FILE_MACHINE_ARMNT)
128 .Case("X64", COFF::IMAGE_FILE_MACHINE_AMD64)
129 .Case("X86", COFF::IMAGE_FILE_MACHINE_I386)
130 .Default(COFF::IMAGE_FILE_MACHINE_UNKNOWN);
131 if (MachineType == COFF::IMAGE_FILE_MACHINE_UNKNOWN)
132132 reportError("Unsupported machine architecture");
133133 } else {
134134 if (Verbose)
135135 outs() << "Machine architecture not specified; assumed X64.\n";
136 MachineType = Machine::X64;
136 MachineType = COFF::IMAGE_FILE_MACHINE_AMD64;
137137 }
138138
139139 std::vector InputFiles = InputArgs.getAllArgValues(OPT_INPUT);
154154 if (Verbose) {
155155 outs() << "Machine: ";
156156 switch (MachineType) {
157 case Machine::ARM:
157 case COFF::IMAGE_FILE_MACHINE_ARMNT:
158158 outs() << "ARM\n";
159159 break;
160 case Machine::X86:
160 case COFF::IMAGE_FILE_MACHINE_I386:
161161 outs() << "X86\n";
162162 break;
163163 default:
206206 std::copy(OutputBuffer->getBufferStart(), OutputBuffer->getBufferEnd(),
207207 FileBuffer->getBufferStart());
208208 error(FileBuffer->commit());
209
209210 if (Verbose) {
210211 Expected> BinaryOrErr = createBinary(OutputFile);
211212 if (!BinaryOrErr)