llvm.org GIT mirror llvm / 4a22e74
[llvm-cvtres] Add support for ARM64 Also change some default cases into llvm_unreachable in WindowsResourceCOFFWriter, to make it easier to find if they are triggerd from within e.g. lld, which supported ARM64 earlier than llvm-cvtres did. Differential Revision: https://reviews.llvm.org/D39892 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317942 91177308-0d34-0410-b5e6-96231b3b80d8 Martin Storsjo 1 year, 9 months ago
3 changed file(s) with 24 addition(s) and 14 deletion(s). Raw diff Collapse all Expand all
440440 void WindowsResourceCOFFWriter::writeCOFFHeader() {
441441 // Write the COFF header.
442442 auto *Header = reinterpret_cast(BufferStart);
443 switch (MachineType) {
444 case COFF::IMAGE_FILE_MACHINE_ARMNT:
445 Header->Machine = COFF::IMAGE_FILE_MACHINE_ARMNT;
446 break;
447 case COFF::IMAGE_FILE_MACHINE_AMD64:
448 Header->Machine = COFF::IMAGE_FILE_MACHINE_AMD64;
449 break;
450 case COFF::IMAGE_FILE_MACHINE_I386:
451 Header->Machine = COFF::IMAGE_FILE_MACHINE_I386;
452 break;
453 default:
454 Header->Machine = COFF::IMAGE_FILE_MACHINE_UNKNOWN;
455 }
443 Header->Machine = MachineType;
456444 Header->NumberOfSections = 2;
457445 Header->TimeDateStamp = getTime();
458446 Header->PointerToSymbolTable = SymbolTableOffset;
713701 case COFF::IMAGE_FILE_MACHINE_I386:
714702 Reloc->Type = COFF::IMAGE_REL_I386_DIR32NB;
715703 break;
704 case COFF::IMAGE_FILE_MACHINE_ARM64:
705 Reloc->Type = COFF::IMAGE_REL_ARM64_ADDR32NB;
706 break;
716707 default:
717 Reloc->Type = 0;
708 llvm_unreachable("unknown machine type");
718709 }
719710 CurrentOffset += sizeof(coff_relocation);
720711 }
2020
2121 RUN: llvm-cvtres /machine:ARM /out:%t %p/Inputs/test_resource.res
2222 RUN: llvm-readobj -h -relocations %t | FileCheck %s -check-prefix=ARM
23
24 RUN: llvm-cvtres /machine:ARM64 /out:%t %p/Inputs/test_resource.res
25 RUN: llvm-readobj -h -relocations %t | FileCheck %s -check-prefix=ARM64
2326
2427 X86: Machine: IMAGE_FILE_MACHINE_I386 (0x14C)
2528 X86-DAG: Relocations [
5659 ARM-NEXT: 0x1F8 IMAGE_REL_ARM_ADDR32NB $R000708
5760 ARM-NEXT: 0x1B8 IMAGE_REL_ARM_ADDR32NB $R000720
5861 ARM-NEXT: 0x188 IMAGE_REL_ARM_ADDR32NB $R000750
62
63 ARM64: Machine: IMAGE_FILE_MACHINE_ARM64 (0xAA64)
64 ARM64-DAG: Relocations [
65 ARM64-DAG: .rsrc$01 {
66 ARM64-NEXT: 0x1E8 IMAGE_REL_ARM64_ADDR32NB $R000000
67 ARM64-NEXT: 0x198 IMAGE_REL_ARM64_ADDR32NB $R000018
68 ARM64-NEXT: 0x1A8 IMAGE_REL_ARM64_ADDR32NB $R000340
69 ARM64-NEXT: 0x1C8 IMAGE_REL_ARM64_ADDR32NB $R000668
70 ARM64-NEXT: 0x1D8 IMAGE_REL_ARM64_ADDR32NB $R000698
71 ARM64-NEXT: 0x1F8 IMAGE_REL_ARM64_ADDR32NB $R000708
72 ARM64-NEXT: 0x1B8 IMAGE_REL_ARM64_ADDR32NB $R000720
73 ARM64-NEXT: 0x188 IMAGE_REL_ARM64_ADDR32NB $R000750
125125 std::string MachineString = InputArgs.getLastArgValue(OPT_MACHINE).upper();
126126 MachineType = StringSwitch(MachineString)
127127 .Case("ARM", COFF::IMAGE_FILE_MACHINE_ARMNT)
128 .Case("ARM64", COFF::IMAGE_FILE_MACHINE_ARM64)
128129 .Case("X64", COFF::IMAGE_FILE_MACHINE_AMD64)
129130 .Case("X86", COFF::IMAGE_FILE_MACHINE_I386)
130131 .Default(COFF::IMAGE_FILE_MACHINE_UNKNOWN);
154155 if (Verbose) {
155156 outs() << "Machine: ";
156157 switch (MachineType) {
158 case COFF::IMAGE_FILE_MACHINE_ARM64:
159 outs() << "ARM64\n";
160 break;
157161 case COFF::IMAGE_FILE_MACHINE_ARMNT:
158162 outs() << "ARM\n";
159163 break;