commonlib/fsp_relocate.c: Fix cbfstool build on 32-bit host

On a 32-bit host, uintptr_t is defined as 'unsigned int' instead of
'unsigend long int' like on a 64-bit host. When cbfstool is built on a
32-bit host, the printk format specifier '%lx' expects a 'long int'
while new_addr is of type 'uintptr_t', aka 'unsigned int'.
This in the end leads to a build error.

To fix this and make it build on both, 32- and 64-bit hosts, use PRIxPTR
as the format specifier. This macro will be resolved at compile time in
the right way on both, 32- and 64-bit hosts.

Test=Build cbfstool on 32- and 64-bit hosts.

Change-Id: Ia917d2ed31778f3a29c0a6c7368f74c15319b099
Signed-off-by: Werner Zeh <werner.zeh@siemens.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/69682
Reviewed-by: Mario Scheithauer <mario.scheithauer@siemens.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Felix Held <felix-coreboot@felixheld.de>
This commit is contained in:
Werner Zeh 2022-11-16 07:56:38 +01:00 committed by Felix Held
parent a45ed44724
commit 314f280aac
1 changed files with 2 additions and 1 deletions

View File

@ -3,6 +3,7 @@
#include <console/console.h> #include <console/console.h>
#include <commonlib/endian.h> #include <commonlib/endian.h>
#include <commonlib/fsp.h> #include <commonlib/fsp.h>
#include <inttypes.h>
/* /*
* Intel's code does not have a handle on changing global packing state. * Intel's code does not have a handle on changing global packing state.
* Therefore, one needs to protect against packing policies that are set * Therefore, one needs to protect against packing policies that are set
@ -219,7 +220,7 @@ static int pe_relocate(uintptr_t new_addr, void *pe, void *fsp, size_t fih_off)
delta, image_base, img_base_off, delta, image_base, img_base_off,
(uint32_t)((uint8_t *)&ophdr->ImageBase - pe_base)); (uint32_t)((uint8_t *)&ophdr->ImageBase - pe_base));
printk(FSP_DBG_LVL, "relocating PE32 image at addr - 0x%lx\n", new_addr); printk(FSP_DBG_LVL, "relocating PE32 image at addr - 0x%" PRIxPTR "\n", new_addr);
rsize = read_le32(&ophdr->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC].Size); rsize = read_le32(&ophdr->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC].Size);
roffset = read_le32(&ophdr->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC].VirtualAddress); roffset = read_le32(&ophdr->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC].VirtualAddress);
printk(FSP_DBG_LVL, "relocation table at offset-%x,size=%x\n", roffset, rsize); printk(FSP_DBG_LVL, "relocation table at offset-%x,size=%x\n", roffset, rsize);