llvm.org GIT mirror llvm / 9b6f553
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 Eric Beckmann 2 years ago
3 changed file(s) with 14 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
4242 #include
4343
4444 namespace llvm {
45
4546 namespace object {
4647
4748 class WindowsResource;
49
50 enum class Machine { UNKNOWN, ARM, X64, X86 };
4851
4952 class ResourceEntryRef {
5053 public:
327327 std::unique_ptr OutputBuffer;
328328 char *BufferStart;
329329 uint64_t CurrentOffset = 0;
330 COFF::MachineTypes MachineType;
330 Machine 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
353352 OutputBuffer = MemoryBuffer::getNewMemBuffer(FileSize);
354353 }
355354
119119
120120 bool Verbose = InputArgs.hasArg(OPT_VERBOSE);
121121
122 COFF::MachineTypes MachineType;
122 Machine MachineType;
123123
124124 if (InputArgs.hasArg(OPT_MACHINE)) {
125125 std::string MachineString = InputArgs.getLastArgValue(OPT_MACHINE).upper();
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)
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)
132132 reportError("Unsupported machine architecture");
133133 } else {
134134 if (Verbose)
135135 outs() << "Machine architecture not specified; assumed X64.\n";
136 MachineType = COFF::IMAGE_FILE_MACHINE_AMD64;
136 MachineType = Machine::X64;
137137 }
138138
139139 std::vector InputFiles = InputArgs.getAllArgValues(OPT_INPUT);
154154 if (Verbose) {
155155 outs() << "Machine: ";
156156 switch (MachineType) {
157 case COFF::IMAGE_FILE_MACHINE_ARMNT:
157 case Machine::ARM:
158158 outs() << "ARM\n";
159159 break;
160 case COFF::IMAGE_FILE_MACHINE_I386:
160 case Machine::X86:
161161 outs() << "X86\n";
162162 break;
163163 default:
206206 std::copy(OutputBuffer->getBufferStart(), OutputBuffer->getBufferEnd(),
207207 FileBuffer->getBufferStart());
208208 error(FileBuffer->commit());
209
210209 if (Verbose) {
211210 Expected> BinaryOrErr = createBinary(OutputFile);
212211 if (!BinaryOrErr)