diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2023-05-24 22:05:58 +0800 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2023-06-01 10:53:35 +0000 |
commit | c15941a643e2e82bdf516a27ef7e3a15ebc2686c (patch) | |
tree | 0966e4b119b85f2331718e9005819fd63ba34e92 /BaseTools | |
parent | fdc6288f81f6e4cd20c75768d6e968467cbc07bf (diff) | |
download | edk2-c15941a643e2e82bdf516a27ef7e3a15ebc2686c.tar.gz edk2-c15941a643e2e82bdf516a27ef7e3a15ebc2686c.tar.bz2 edk2-c15941a643e2e82bdf516a27ef7e3a15ebc2686c.zip |
BaseTools: switch from EFI_IMAGE_MACHINE_* to IMAGE_FILE_MACHINE_*
Use the newer versions of the machine #defines.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Chao Li <lichao@loongson.cn>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Rebecca Cran <rebecca@bsdio.com>
Diffstat (limited to 'BaseTools')
-rw-r--r-- | BaseTools/Source/C/Common/BasePeCoff.c | 28 | ||||
-rw-r--r-- | BaseTools/Source/C/EfiRom/EfiRom.h | 10 | ||||
-rw-r--r-- | BaseTools/Source/C/GenFv/GenFvInternalLib.c | 42 | ||||
-rw-r--r-- | BaseTools/Source/C/GenFw/Elf32Convert.c | 6 | ||||
-rw-r--r-- | BaseTools/Source/C/GenFw/Elf64Convert.c | 10 | ||||
-rw-r--r-- | BaseTools/Source/C/GenFw/GenFw.c | 8 | ||||
-rw-r--r-- | BaseTools/Source/C/Include/IndustryStandard/PeImage.h | 1 |
7 files changed, 50 insertions, 55 deletions
diff --git a/BaseTools/Source/C/Common/BasePeCoff.c b/BaseTools/Source/C/Common/BasePeCoff.c index 0172370174..038bb054e5 100644 --- a/BaseTools/Source/C/Common/BasePeCoff.c +++ b/BaseTools/Source/C/Common/BasePeCoff.c @@ -169,13 +169,13 @@ PeCoffLoaderCheckImageType ( ImageContext->Machine = TeHdr->Machine;
}
- if (ImageContext->Machine != EFI_IMAGE_MACHINE_IA32 && \
- ImageContext->Machine != EFI_IMAGE_MACHINE_X64 && \
- ImageContext->Machine != EFI_IMAGE_MACHINE_ARMT && \
- ImageContext->Machine != EFI_IMAGE_MACHINE_EBC && \
- ImageContext->Machine != EFI_IMAGE_MACHINE_AARCH64 && \
- ImageContext->Machine != EFI_IMAGE_MACHINE_RISCV64 && \
- ImageContext->Machine != EFI_IMAGE_MACHINE_LOONGARCH64) {
+ if (ImageContext->Machine != IMAGE_FILE_MACHINE_I386 && \
+ ImageContext->Machine != IMAGE_FILE_MACHINE_X64 && \
+ ImageContext->Machine != IMAGE_FILE_MACHINE_ARMTHUMB_MIXED && \
+ ImageContext->Machine != IMAGE_FILE_MACHINE_EBC && \
+ ImageContext->Machine != IMAGE_FILE_MACHINE_ARM64 && \
+ ImageContext->Machine != IMAGE_FILE_MACHINE_RISCV64 && \
+ ImageContext->Machine != IMAGE_FILE_MACHINE_LOONGARCH64) {
//
// unsupported PeImage machine type
//
@@ -759,16 +759,16 @@ PeCoffLoaderRelocateImage ( default:
switch (MachineType) {
- case EFI_IMAGE_MACHINE_IA32:
+ case IMAGE_FILE_MACHINE_I386:
Status = PeCoffLoaderRelocateIa32Image (Reloc, Fixup, &FixupData, Adjust);
break;
- case EFI_IMAGE_MACHINE_ARMT:
+ case IMAGE_FILE_MACHINE_ARMTHUMB_MIXED:
Status = PeCoffLoaderRelocateArmImage (&Reloc, Fixup, &FixupData, Adjust);
break;
- case EFI_IMAGE_MACHINE_RISCV64:
+ case IMAGE_FILE_MACHINE_RISCV64:
Status = PeCoffLoaderRelocateRiscVImage (Reloc, Fixup, &FixupData, Adjust);
break;
- case EFI_IMAGE_MACHINE_LOONGARCH64:
+ case IMAGE_FILE_MACHINE_LOONGARCH64:
Status = PeCoffLoaderRelocateLoongArch64Image (Reloc, Fixup, &FixupData, Adjust);
break;
default:
@@ -1255,14 +1255,14 @@ PeCoffLoaderGetPdbPointer ( // generate PE32+ image with PE32 Magic.
//
switch (Hdr.Pe32->FileHeader.Machine) {
- case EFI_IMAGE_MACHINE_IA32:
- case EFI_IMAGE_MACHINE_ARMT:
+ case IMAGE_FILE_MACHINE_I386:
+ case IMAGE_FILE_MACHINE_ARMTHUMB_MIXED:
//
// Assume PE32 image with IA32 Machine field.
//
Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC;
break;
- case EFI_IMAGE_MACHINE_X64:
+ case IMAGE_FILE_MACHINE_X64:
//
// Assume PE32+ image with X64 Machine field
//
diff --git a/BaseTools/Source/C/EfiRom/EfiRom.h b/BaseTools/Source/C/EfiRom/EfiRom.h index 0b39e2af2e..887a6a51e2 100644 --- a/BaseTools/Source/C/EfiRom/EfiRom.h +++ b/BaseTools/Source/C/EfiRom/EfiRom.h @@ -108,11 +108,11 @@ typedef struct { // Machine Types
//
static STRING_LOOKUP mMachineTypes[] = {
- { EFI_IMAGE_MACHINE_IA32, "IA32" },
- { EFI_IMAGE_MACHINE_X64, "X64" },
- { EFI_IMAGE_MACHINE_EBC, "EBC" },
- { EFI_IMAGE_MACHINE_ARMT, "ARM" },
- { EFI_IMAGE_MACHINE_AARCH64, "AA64" },
+ { IMAGE_FILE_MACHINE_I386, "IA32" },
+ { IMAGE_FILE_MACHINE_X64, "X64" },
+ { IMAGE_FILE_MACHINE_EBC, "EBC" },
+ { IMAGE_FILE_MACHINE_ARMTHUMB_MIXED, "ARM" },
+ { IMAGE_FILE_MACHINE_ARM64, "AA64" },
{ 0, NULL }
};
diff --git a/BaseTools/Source/C/GenFv/GenFvInternalLib.c b/BaseTools/Source/C/GenFv/GenFvInternalLib.c index c8d5cac8e2..f466324d61 100644 --- a/BaseTools/Source/C/GenFv/GenFvInternalLib.c +++ b/BaseTools/Source/C/GenFv/GenFvInternalLib.c @@ -1655,8 +1655,8 @@ Returns: if (
Vtf0Detected &&
- (MachineType == EFI_IMAGE_MACHINE_IA32 ||
- MachineType == EFI_IMAGE_MACHINE_X64)
+ (MachineType == IMAGE_FILE_MACHINE_I386 ||
+ MachineType == IMAGE_FILE_MACHINE_X64)
) {
//
// If the SEC core code is IA32 or X64 and the VTF-0 signature
@@ -1714,7 +1714,7 @@ Returns: DebugMsg (NULL, 0, 9, "PeiCore physical entry point address", "Address = 0x%llX", (unsigned long long) PeiCorePhysicalAddress);
}
-if (MachineType == EFI_IMAGE_MACHINE_IA32 || MachineType == EFI_IMAGE_MACHINE_X64) {
+if (MachineType == IMAGE_FILE_MACHINE_I386 || MachineType == IMAGE_FILE_MACHINE_X64) {
if (PeiCorePhysicalAddress != 0) {
//
// Get the location to update
@@ -1804,12 +1804,12 @@ if (MachineType == EFI_IMAGE_MACHINE_IA32 || MachineType == EFI_IMAGE_MACHINE_X6 //
Ia32ResetAddressPtr = (UINT32 *) ((UINTN) FvImage->Eof - 8);
*Ia32ResetAddressPtr = IpiVector;
- } else if (MachineType == EFI_IMAGE_MACHINE_ARMT) {
+ } else if (MachineType == IMAGE_FILE_MACHINE_ARMTHUMB_MIXED) {
//
// Since the ARM reset vector is in the FV Header you really don't need a
// Volume Top File, but if you have one for some reason don't crash...
//
- } else if (MachineType == EFI_IMAGE_MACHINE_AARCH64) {
+ } else if (MachineType == IMAGE_FILE_MACHINE_ARM64) {
//
// Since the AArch64 reset vector is in the FV Header you really don't need a
// Volume Top File, but if you have one for some reason don't crash...
@@ -2204,7 +2204,7 @@ Returns: return EFI_SUCCESS;
}
- if (MachineType == EFI_IMAGE_MACHINE_ARMT) {
+ if (MachineType == IMAGE_FILE_MACHINE_ARMTHUMB_MIXED) {
// ARM: Array of 4 UINT32s:
// 0 - is branch relative to SEC entry point
// 1 - PEI Entry Point
@@ -2258,7 +2258,7 @@ Returns: //
memcpy(FvImage->FileImage, ResetVector, sizeof (ResetVector));
- } else if (MachineType == EFI_IMAGE_MACHINE_AARCH64) {
+ } else if (MachineType == IMAGE_FILE_MACHINE_ARM64) {
// AArch64: Used as UINT64 ResetVector[2]
// 0 - is branch relative to SEC entry point
// 1 - PEI Entry Point
@@ -2377,7 +2377,7 @@ Returns: return EFI_ABORTED;
}
- if (MachineType != EFI_IMAGE_MACHINE_RISCV64) {
+ if (MachineType != IMAGE_FILE_MACHINE_RISCV64) {
Error(NULL, 0, 3000, "Invalid", "Could not update SEC core because Machine type is not RiscV.");
return EFI_ABORTED;
}
@@ -2478,7 +2478,7 @@ Returns: if (!UpdateVectorSec)
return EFI_SUCCESS;
- if (MachineType == EFI_IMAGE_MACHINE_LOONGARCH64) {
+ if (MachineType == IMAGE_FILE_MACHINE_LOONGARCH64) {
UINT32 ResetVector[1];
memset(ResetVector, 0, sizeof (ResetVector));
@@ -2595,9 +2595,9 @@ Returns: //
// Verify machine type is supported
//
- if ((*MachineType != EFI_IMAGE_MACHINE_IA32) && (*MachineType != EFI_IMAGE_MACHINE_X64) && (*MachineType != EFI_IMAGE_MACHINE_EBC) &&
- (*MachineType != EFI_IMAGE_MACHINE_ARMT) && (*MachineType != EFI_IMAGE_MACHINE_AARCH64) &&
- (*MachineType != EFI_IMAGE_MACHINE_RISCV64) && (*MachineType != EFI_IMAGE_MACHINE_LOONGARCH64)) {
+ if ((*MachineType != IMAGE_FILE_MACHINE_I386) && (*MachineType != IMAGE_FILE_MACHINE_X64) && (*MachineType != IMAGE_FILE_MACHINE_EBC) &&
+ (*MachineType != IMAGE_FILE_MACHINE_ARMTHUMB_MIXED) && (*MachineType != IMAGE_FILE_MACHINE_ARM64) &&
+ (*MachineType != IMAGE_FILE_MACHINE_RISCV64) && (*MachineType != IMAGE_FILE_MACHINE_LOONGARCH64)) {
Error (NULL, 0, 3000, "Invalid", "Unrecognized machine type in the PE32 file.");
return EFI_UNSUPPORTED;
}
@@ -3547,13 +3547,13 @@ Returns: }
// machine type is ARM, set a flag so ARM reset vector processing occurs
- if ((MachineType == EFI_IMAGE_MACHINE_ARMT) || (MachineType == EFI_IMAGE_MACHINE_AARCH64)) {
+ if ((MachineType == IMAGE_FILE_MACHINE_ARMTHUMB_MIXED) || (MachineType == IMAGE_FILE_MACHINE_ARM64)) {
VerboseMsg("Located ARM/AArch64 SEC/PEI core in child FV");
mArm = TRUE;
}
// Machine type is LOONGARCH64, set a flag so LoongArch64 reset vector processed.
- if (MachineType == EFI_IMAGE_MACHINE_LOONGARCH64) {
+ if (MachineType == IMAGE_FILE_MACHINE_LOONGARCH64) {
VerboseMsg("Located LoongArch64 SEC core in child FV");
mLoongArch = TRUE;
}
@@ -3706,16 +3706,16 @@ Returns: return Status;
}
- if ( (ImageContext.Machine == EFI_IMAGE_MACHINE_ARMT) ||
- (ImageContext.Machine == EFI_IMAGE_MACHINE_AARCH64) ) {
+ if ( (ImageContext.Machine == IMAGE_FILE_MACHINE_ARMTHUMB_MIXED) ||
+ (ImageContext.Machine == IMAGE_FILE_MACHINE_ARM64) ) {
mArm = TRUE;
}
- if (ImageContext.Machine == EFI_IMAGE_MACHINE_RISCV64) {
+ if (ImageContext.Machine == IMAGE_FILE_MACHINE_RISCV64) {
mRiscV = TRUE;
}
- if (ImageContext.Machine == EFI_IMAGE_MACHINE_LOONGARCH64) {
+ if (ImageContext.Machine == IMAGE_FILE_MACHINE_LOONGARCH64) {
mLoongArch = TRUE;
}
@@ -3991,12 +3991,12 @@ Returns: return Status;
}
- if ( (ImageContext.Machine == EFI_IMAGE_MACHINE_ARMT) ||
- (ImageContext.Machine == EFI_IMAGE_MACHINE_AARCH64) ) {
+ if ( (ImageContext.Machine == IMAGE_FILE_MACHINE_ARMTHUMB_MIXED) ||
+ (ImageContext.Machine == IMAGE_FILE_MACHINE_ARM64) ) {
mArm = TRUE;
}
- if (ImageContext.Machine == EFI_IMAGE_MACHINE_LOONGARCH64) {
+ if (ImageContext.Machine == IMAGE_FILE_MACHINE_LOONGARCH64) {
mLoongArch = TRUE;
}
diff --git a/BaseTools/Source/C/GenFw/Elf32Convert.c b/BaseTools/Source/C/GenFw/Elf32Convert.c index e9fb3593a9..de198e58db 100644 --- a/BaseTools/Source/C/GenFw/Elf32Convert.c +++ b/BaseTools/Source/C/GenFw/Elf32Convert.c @@ -553,16 +553,16 @@ ScanSections32 ( switch (mEhdr->e_machine) {
case EM_386:
- NtHdr->Pe32.FileHeader.Machine = EFI_IMAGE_MACHINE_IA32;
+ NtHdr->Pe32.FileHeader.Machine = IMAGE_FILE_MACHINE_I386;
NtHdr->Pe32.OptionalHeader.Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC;
break;
case EM_ARM:
- NtHdr->Pe32.FileHeader.Machine = EFI_IMAGE_MACHINE_ARMT;
+ NtHdr->Pe32.FileHeader.Machine = IMAGE_FILE_MACHINE_ARMTHUMB_MIXED;
NtHdr->Pe32.OptionalHeader.Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC;
break;
default:
VerboseMsg ("%s unknown e_machine type %hu. Assume IA-32", mInImageName, mEhdr->e_machine);
- NtHdr->Pe32.FileHeader.Machine = EFI_IMAGE_MACHINE_IA32;
+ NtHdr->Pe32.FileHeader.Machine = IMAGE_FILE_MACHINE_I386;
NtHdr->Pe32.OptionalHeader.Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC;
}
diff --git a/BaseTools/Source/C/GenFw/Elf64Convert.c b/BaseTools/Source/C/GenFw/Elf64Convert.c index dfcb100a59..d53ecb1767 100644 --- a/BaseTools/Source/C/GenFw/Elf64Convert.c +++ b/BaseTools/Source/C/GenFw/Elf64Convert.c @@ -1137,25 +1137,25 @@ ScanSections64 ( switch (mEhdr->e_machine) {
case EM_X86_64:
- NtHdr->Pe32Plus.FileHeader.Machine = EFI_IMAGE_MACHINE_X64;
+ NtHdr->Pe32Plus.FileHeader.Machine = IMAGE_FILE_MACHINE_X64;
NtHdr->Pe32Plus.OptionalHeader.Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;
break;
case EM_AARCH64:
- NtHdr->Pe32Plus.FileHeader.Machine = EFI_IMAGE_MACHINE_AARCH64;
+ NtHdr->Pe32Plus.FileHeader.Machine = IMAGE_FILE_MACHINE_ARM64;
NtHdr->Pe32Plus.OptionalHeader.Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;
break;
case EM_RISCV64:
- NtHdr->Pe32Plus.FileHeader.Machine = EFI_IMAGE_MACHINE_RISCV64;
+ NtHdr->Pe32Plus.FileHeader.Machine = IMAGE_FILE_MACHINE_RISCV64;
NtHdr->Pe32Plus.OptionalHeader.Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;
break;
case EM_LOONGARCH:
- NtHdr->Pe32Plus.FileHeader.Machine = EFI_IMAGE_MACHINE_LOONGARCH64;
+ NtHdr->Pe32Plus.FileHeader.Machine = IMAGE_FILE_MACHINE_LOONGARCH64;
NtHdr->Pe32Plus.OptionalHeader.Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;
break;
default:
VerboseMsg ("%u unknown e_machine type. Assume X64", (UINTN)mEhdr->e_machine);
- NtHdr->Pe32Plus.FileHeader.Machine = EFI_IMAGE_MACHINE_X64;
+ NtHdr->Pe32Plus.FileHeader.Machine = IMAGE_FILE_MACHINE_X64;
NtHdr->Pe32Plus.OptionalHeader.Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;
}
diff --git a/BaseTools/Source/C/GenFw/GenFw.c b/BaseTools/Source/C/GenFw/GenFw.c index 0da25fd055..0289c8ef8a 100644 --- a/BaseTools/Source/C/GenFw/GenFw.c +++ b/BaseTools/Source/C/GenFw/GenFw.c @@ -2197,12 +2197,6 @@ Returns: }
}
- if (PeHdr->Pe32.FileHeader.Machine == IMAGE_FILE_MACHINE_ARM) {
- // Some tools kick out IMAGE_FILE_MACHINE_ARM (0x1c0) vs IMAGE_FILE_MACHINE_ARMT (0x1c2)
- // so patch back to the official UEFI value.
- PeHdr->Pe32.FileHeader.Machine = IMAGE_FILE_MACHINE_ARMT;
- }
-
//
// Set new base address into image
//
@@ -3117,7 +3111,7 @@ Returns: // Get Debug, Export and Resource EntryTable RVA address.
// Resource Directory entry need to review.
//
- if (FileHdr->Machine == EFI_IMAGE_MACHINE_IA32) {
+ if (FileHdr->Machine == IMAGE_FILE_MACHINE_I386) {
Optional32Hdr = (EFI_IMAGE_OPTIONAL_HEADER32 *) ((UINT8*) FileHdr + sizeof (EFI_IMAGE_FILE_HEADER));
SectionHeader = (EFI_IMAGE_SECTION_HEADER *) ((UINT8 *) Optional32Hdr + FileHdr->SizeOfOptionalHeader);
if (Optional32Hdr->NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_EXPORT && \
diff --git a/BaseTools/Source/C/Include/IndustryStandard/PeImage.h b/BaseTools/Source/C/Include/IndustryStandard/PeImage.h index 22161edf44..fb867b5660 100644 --- a/BaseTools/Source/C/Include/IndustryStandard/PeImage.h +++ b/BaseTools/Source/C/Include/IndustryStandard/PeImage.h @@ -42,6 +42,7 @@ #define IMAGE_FILE_MACHINE_X64 0x8664
#define IMAGE_FILE_MACHINE_ARM 0x01c0 // Thumb only
#define IMAGE_FILE_MACHINE_ARMT 0x01c2 // 32bit Mixed ARM and Thumb/Thumb 2 Little Endian
+#define IMAGE_FILE_MACHINE_ARMTHUMB_MIXED IMAGE_FILE_MACHINE_ARMT
#define IMAGE_FILE_MACHINE_ARM64 0xAA64 // 64bit ARM Architecture, Little Endian
#define IMAGE_FILE_MACHINE_RISCV64 0x5064 // 64bit RISC-V ISA
#define IMAGE_FILE_MACHINE_LOONGARCH64 0x6264 // 64bit LoongArch Architecture
|