MdePkg/AArch64: fix AsmMacroLib signed value handling for MOV32/MOV64

MOV32 and MOV64, defined in AsmMacrolib.h, use a combination of movz and
movk instructions to fill a register with an immediate value. With each
instruction supplying 16 of the bits.

CLANGPDB builds have been reported to fail on the current implementation
when provided with negative values with:
  error: immediate must be an integer in range [0, 65535].

To resolve this, add a mask for the line filling the top 16 bits, like
the other lines already had.

Reported-by: Michael Kubacki <mikuback@linux.microsoft.com>
Signed-off-by: Leif Lindholm <leif.lindholm@oss.qualcomm.com>
This commit is contained in:
Leif Lindholm 2025-02-14 10:04:10 +00:00 committed by mergify[bot]
parent 81803b9eba
commit 3e7e3e2467
1 changed files with 3 additions and 3 deletions

View File

@ -43,12 +43,12 @@
#define ASM_FUNC_ALIGN(Name, Align) \
_ASM_FUNC_ALIGN(ASM_PFX(Name), .text. ## Name, Align)
#define MOV32(Reg, Val) \
movz Reg, (Val) >> 16, lsl #16 ; \
#define MOV32(Reg, Val) \
movz Reg, ((Val) >> 16) & 0xffff, lsl #16 ; \
movk Reg, (Val) & 0xffff
#define MOV64(Reg, Val) \
movz Reg, (Val) >> 48, lsl #48 ; \
movz Reg, ((Val) >> 48) & 0xffff, lsl #48 ; \
movk Reg, ((Val) >> 32) & 0xffff, lsl #32 ; \
movk Reg, ((Val) >> 16) & 0xffff, lsl #16 ; \
movk Reg, (Val) & 0xffff