https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=9626d20f0151c1b34d511c82796d7b34aabc5939
commit 9626d20f0151c1b34d511c82796d7b34aabc5939
Author: Paul Floyd <pj...@wa...>
Date: Sat Sep 28 08:20:25 2024 +0200
Compiler warning in ML_(check_elf_and_get_rw_loads)
GCC 12.2 complains that
previous_rw_a_phdr.p_vaddr + previous_rw_a_phdr.p_filesz
may be using p_filesz uninitialized
That's only possible if ML_(img_get) somehow fails to read all
of a program header such that p_memsz is greater than 0 but
p_filesz remains uninitialized. Hardly likely since p_memsz
comes after p_filesz in the structure.
Diff:
---
coregrind/m_debuginfo/readelf.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/coregrind/m_debuginfo/readelf.c b/coregrind/m_debuginfo/readelf.c
index b037b9201a..1d6ec55a0b 100644
--- a/coregrind/m_debuginfo/readelf.c
+++ b/coregrind/m_debuginfo/readelf.c
@@ -3902,6 +3902,8 @@ Bool ML_(check_elf_and_get_rw_loads) ( Int fd, const HChar* filename,
/* Sets p_memsz to 0 to indicate we have not yet a previous a_phdr. */
previous_rw_a_phdr.p_memsz = 0;
+ /* and silence compiler warnings */
+ previous_rw_a_phdr.p_filesz = 0;
for (i = 0U; i < phdr_mnent; i++) {
ElfXX_Phdr a_phdr;
|