From 3fc3d7bd6bd8485404a936f7354e781dc2be6a5a Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Thu, 4 Oct 2007 18:40:28 +0000 Subject: [PATCH] Build fixes for uninitialized variables. Add some branch prediction. --- libdwfl/ChangeLog | 5 +++++ libdwfl/linux-kernel-modules.c | 3 +++ src/ChangeLog | 6 ++++++ src/readelf.c | 18 +++++++++++------- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index 454d934..d682f8f 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,3 +1,8 @@ +2007-10-04 Ulrich Drepper + + * linux-kernel-modules.c (dwfl_linux_kernel_report_kernel): Fake + initialization of notes variable. + 2007-10-04 Roland McGrath * linux-kernel-modules.c (intuit_kernel_bounds): Take new arg NOTES, diff --git a/libdwfl/linux-kernel-modules.c b/libdwfl/linux-kernel-modules.c index 6164ae7..8954b2f 100644 --- a/libdwfl/linux-kernel-modules.c +++ b/libdwfl/linux-kernel-modules.c @@ -501,6 +501,9 @@ dwfl_linux_kernel_report_kernel (Dwfl *dwfl) /* Try to figure out the bounds of the kernel image without looking for any vmlinux file. */ Dwarf_Addr notes; + /* The compiler cannot deduce that if intuit_kernel_bounds returns + zero NOTES will be initialized. Fake the initialization. */ + asm ("" : "=m" (notes)); int result = intuit_kernel_bounds (&start, &end, ¬es); if (result == 0) { diff --git a/src/ChangeLog b/src/ChangeLog index f4937cf..4d4fa9a 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2007-10-04 Ulrich Drepper + + * readelf.c (dump_archive_index): Avoid warning about uninitialized + variable with older glibc versions. + Add some branch prediction. + 2007-10-04 Roland McGrath * readelf.c (print_archive_index): New variable. diff --git a/src/readelf.c b/src/readelf.c index fee908e..ffcb0a1 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -5888,7 +5888,7 @@ print_strings (Ebl *ebl) { /* Get the section header string table index. */ size_t shstrndx; - if (elf_getshstrndx (ebl->elf, &shstrndx) < 0) + if (unlikely (elf_getshstrndx (ebl->elf, &shstrndx) < 0)) error (EXIT_FAILURE, 0, gettext ("cannot get section header string table index")); @@ -5921,7 +5921,7 @@ dump_archive_index (Elf *elf, const char *fname) if (arsym == NULL) { int result = elf_errno (); - if (result != ELF_E_NO_INDEX) + if (unlikely (result != ELF_E_NO_INDEX)) error (EXIT_FAILURE, 0, gettext ("cannot get symbol index of archive '%s': %s"), fname, elf_errmsg (result)); @@ -5941,11 +5941,15 @@ dump_archive_index (Elf *elf, const char *fname) as_off = s->as_off; Elf *subelf; - if (elf_rand (elf, as_off) == 0 - || (subelf = elf_begin (-1, ELF_C_READ_MMAP, elf)) == NULL) - error (EXIT_FAILURE, 0, - gettext ("cannot extract member at offset %Zu in '%s': %s"), - as_off, fname, elf_errmsg (-1)); + if (unlikely (elf_rand (elf, as_off) == 0) + || unlikely ((subelf = elf_begin (-1, ELF_C_READ_MMAP, elf)) + == NULL)) +#if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 7) + while (1) +#endif + error (EXIT_FAILURE, 0, + gettext ("cannot extract member at offset %Zu in '%s': %s"), + as_off, fname, elf_errmsg (-1)); const Elf_Arhdr *h = elf_getarhdr (subelf); -- 2.7.4