From 14ec199bd190d11f5d141ae93be95aa53acbf7f0 Mon Sep 17 00:00:00 2001 From: HC Yen Date: Thu, 22 Jan 2015 09:57:34 +0800 Subject: [PATCH] cbfstool: fix address truncated problem In parse_elf_to_stage(), it uses 32-bit variable to handle address. The correct address type is Elf64_Addr. Use uint64_t to prevent address to be truncated. BUG=none TEST=emerge-oak coreboot BRANCH=none Change-Id: I1abcd16899a69b18dd10e9678e767b0564b2846e Signed-off-by: Patrick Georgi Original-Commit-Id: ebc1aae0ae4ca30802a80a4a4e2ae0c0dad4d88a Original-Change-Id: I21f8057ddf13e442f1cf55da6702c3449ba0cc35 Original-Reviewed-on: https://chromium-review.googlesource.com/292553 Original-Commit-Ready: Yidi Lin Original-Tested-by: Yidi Lin Original-Reviewed-by: Aaron Durbin Original-Reviewed-by: Julius Werner Reviewed-on: https://review.coreboot.org/12927 Tested-by: build bot (Jenkins) Reviewed-by: Martin Roth --- util/cbfstool/cbfs-mkstage.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/util/cbfstool/cbfs-mkstage.c b/util/cbfstool/cbfs-mkstage.c index b1563500bf..9d8865828e 100644 --- a/util/cbfstool/cbfs-mkstage.c +++ b/util/cbfstool/cbfs-mkstage.c @@ -121,7 +121,7 @@ int parse_elf_to_stage(const struct buffer *input, struct buffer *output, int headers; int i, outlen; - uint32_t data_start, data_end, mem_end; + uint64_t data_start, data_end, mem_end; comp_func_ptr compress = compression_function(algo); if (!compress) @@ -159,7 +159,7 @@ int parse_elf_to_stage(const struct buffer *input, struct buffer *output, virt_to_phys = 0; for (i = 0; i < headers; i++) { - unsigned int start, mend, rend; + uint64_t start, mend, rend; if (phdr[i].p_type != PT_LOAD) continue; @@ -210,7 +210,7 @@ int parse_elf_to_stage(const struct buffer *input, struct buffer *output, /* Copy the file data into the buffer */ for (i = 0; i < headers; i++) { - unsigned int l_start, l_offset = 0; + uint64_t l_start, l_offset = 0; if (phdr[i].p_type != PT_LOAD) continue;