Reviewed-by: Maurice Ma <[email protected]> > -----Original Message----- > From: Jiang, Guomin <[email protected]> > Sent: Wednesday, February 9, 2022 19:03 > To: [email protected] > Cc: Dong, Guo <[email protected]>; Ni, Ray <[email protected]>; Ma, > Maurice <[email protected]>; You, Benjamin <[email protected]> > Subject: [Patch V2 1/1] UefiPayloadPkg/PayloadLoaderPeim: Force UINTN > before save Ptr > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3818 > > It will have some potential issue when memory larger than 2G because the high > memory address will be fill with 0xFFFFFFFF when do the operation of UINT64 + > INTN. > > V2: > 1. Force the data type to UINTN to avoid high dword be filled with 0xFFFFFFFF > 2. > Keep INTN because the offset may postive or negative. > > Cc: Guo Dong <[email protected]> > Cc: Ray Ni <[email protected]> > Cc: Maurice Ma <[email protected]> > Cc: Benjamin You <[email protected]> > Signed-off-by: Guomin Jiang <[email protected]> > --- > UefiPayloadPkg/PayloadLoaderPeim/ElfLib/Elf64Lib.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/UefiPayloadPkg/PayloadLoaderPeim/ElfLib/Elf64Lib.c > b/UefiPayloadPkg/PayloadLoaderPeim/ElfLib/Elf64Lib.c > index dc47a05c6e4a..68200fcadd3f 100644 > --- a/UefiPayloadPkg/PayloadLoaderPeim/ElfLib/Elf64Lib.c > +++ b/UefiPayloadPkg/PayloadLoaderPeim/ElfLib/Elf64Lib.c > @@ -143,7 +143,7 @@ ProcessRelocation64 ( > DEBUG ((DEBUG_INFO, "Unsupported relocation type %02X\n", Type)); > ASSERT (FALSE); > } else { > - *Ptr += Delta; > + *Ptr = *(UINTN *)Ptr + Delta; > } > > break; > @@ -177,12 +177,12 @@ ProcessRelocation64 ( > // Calculation: B + A > // > if (RelaType == SHT_RELA) { > - *Ptr = Delta + Rela->r_addend; > + *Ptr = Delta + (UINTN)Rela->r_addend; > } else { > // > // A is stored in the field of relocation for REL type. > // > - *Ptr = Delta + *Ptr; > + *Ptr = Delta + *(UINTN *)Ptr; > } > } else { > // > -- > 2.30.0.windows.2
-=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#86562): https://edk2.groups.io/g/devel/message/86562 Mute This Topic: https://groups.io/mt/89038278/21656 Group Owner: [email protected] Unsubscribe: https://edk2.groups.io/g/devel/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
