[Bug,libelf/32311] elf_compress_gnu.c: gcc warns null-dereference with lto

Message ID bug-32311-10460-f8uT0lVjzx@http.sourceware.org/bugzilla/
State Superseded
Headers
Series [Bug,libelf/32311] elf_compress_gnu.c: gcc warns null-dereference with lto |

Commit Message

amerey at redhat dot com Nov. 6, 2024, 7:10 p.m. UTC
  https://sourceware.org/bugzilla/show_bug.cgi?id=32311

--- Comment #6 from Mark Wielaard <mark at klomp dot org> ---
(In reply to User441669 from comment #4)
> Just one more step!
> 

Indeed! There was one typo in the patch (forgot to remove one line):


Good to see your compiler version/setup caught that.

I'll post an updated patch. If you could test that one to see if it resolves
all compiler warnings that would be appreciated.
  

Patch

diff --git a/libelf/elf_compress.c b/libelf/elf_compress.c
index 3870fc0e729e..a2fa1f087658 100644
--- a/libelf/elf_compress.c
+++ b/libelf/elf_compress.c
@@ -691,7 +691,6 @@  elf_compress (Elf_Scn *scn, int type, unsigned int flags)
        }
       else
        {
-         shdr.s64 = elf64_getshdr (scn);
          shdr.s64->sh_size = new_size;
          shdr.s64->sh_addralign = __libelf_type_align (ELFCLASS64,
                                                        ELF_T_CHDR);