Skip to content

Commit 8e777b9

Browse files
committed
BaseTools: Fix MSVC AARCH64 Building of tools. (#1597)
Latest MSVC update started wanring on zero extending of ~. Add explicit casts to fix AARCH64 build errors. Errors can be viewed in #1587 when attempting to build tools for AARCH64 using MSVC. - [ ] Impacts functionality? - [ ] Impacts security? - [ ] Breaking change? - [ ] Includes tests? - [ ] Includes documentation? Local build to reproduce the errors. Local build succeeds after changes. No integration necessary.
1 parent 688c8a5 commit 8e777b9

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

BaseTools/Source/C/GenFfs/GenFfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ Routine Description:
398398
// Based on section type to adjust offset? Todo
399399
//
400400
if ((InputFileAlign [Index] != 0) && (((Size + HeaderSize + TeOffset) % InputFileAlign [Index]) != 0)) {
401-
Offset = (Size + sizeof (EFI_COMMON_SECTION_HEADER) + HeaderSize + TeOffset + InputFileAlign [Index] - 1) & ~(InputFileAlign [Index] - 1);
401+
Offset = (Size + sizeof (EFI_COMMON_SECTION_HEADER) + HeaderSize + TeOffset + InputFileAlign[Index] - 1) & ~(UINTN)(InputFileAlign[Index] - 1);
402402
Offset = Offset - Size - HeaderSize - TeOffset;
403403

404404
if (FileBuffer != NULL && ((Size + Offset) < *BufferLength)) {

BaseTools/Source/C/GenSec/GenSec.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ Routine Description:
538538
// make sure section data meet its alignment requirement by adding one raw pad section.
539539
//
540540
if ((InputFileAlign [Index] != 0) && (((Size + HeaderSize + TeOffset) % InputFileAlign [Index]) != 0)) {
541-
Offset = (Size + sizeof (EFI_COMMON_SECTION_HEADER) + HeaderSize + TeOffset + InputFileAlign [Index] - 1) & ~(InputFileAlign [Index] - 1);
541+
Offset = (Size + sizeof (EFI_COMMON_SECTION_HEADER) + HeaderSize + TeOffset + InputFileAlign[Index] - 1) & ~(size_t)(InputFileAlign[Index] - 1);
542542
Offset = Offset - Size - HeaderSize - TeOffset;
543543

544544
if (FileBuffer != NULL && ((Size + Offset) < *BufferLength)) {

0 commit comments

Comments
 (0)