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

2024-11-06 Thread the.ra2.ifv at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=32311 --- Comment #9 from User441669 --- Compilation successfully! I plan to close this issue as fixed, and send this patch to the OpenWrt project (named `007-fix-null-dereference-with-lto.patch` in the attachments) linker prints some warnings, loo

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

2024-11-06 Thread the.ra2.ifv at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=32311 --- Comment #8 from User441669 --- Created attachment 15783 --> https://sourceware.org/bugzilla/attachment.cgi?id=15783&action=edit elfutils-success.log The full log after a successful compilation. -- You are receiving this mail because:

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

2024-11-06 Thread the.ra2.ifv at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=32311 --- Comment #7 from User441669 --- Created attachment 15782 --> https://sourceware.org/bugzilla/attachment.cgi?id=15782&action=edit 007-fix-null-dereference-with-lto.patch The patch that fixes everything -- You are receiving this mail bec

Re: [PATCH] strip: Ignore --reloc-debug-sections-only for non-ET_REL files.

2024-11-06 Thread Mark Wielaard
Hi Aaron, On Wed, Nov 06, 2024 at 04:15:30PM -0500, Aaron Merey wrote: > On Wed, Nov 6, 2024 at 2:35 PM Mark Wielaard wrote: > > >if (reloc_debug_only) > > > { > > > + if (ehdr->e_type != ET_REL) > > > + { > > > + /* Only ET_REL files should have debug relocations to remov

Re: [PATCH] strip: Ignore --reloc-debug-sections-only for non-ET_REL files.

2024-11-06 Thread Aaron Merey
Hi Mark, On Wed, Nov 6, 2024 at 2:35 PM Mark Wielaard wrote: > >if (reloc_debug_only) > > { > > + if (ehdr->e_type != ET_REL) > > + { > > + /* Only ET_REL files should have debug relocations to remove. */ > > + error (0, 0, _("Ignoring --reloc-debug-sections-only fo

Re: [PATCH] strip: Ignore --reloc-debug-sections-only for non-ET_REL files.

2024-11-06 Thread Mark Wielaard
Hi Aaron, On Tue, Nov 05, 2024 at 05:53:38PM -0500, Aaron Merey wrote: > strip --reloc-debug-sections-only is expected to be a no-op for > non-ET_REL files. This was not enforced in the code. Sections > were copied over to a new output file and normally its contents > would be identical to the i

Re: [PATCH] Обновить patches/0001-sparc_attrs.c-Prevent-buffer-overflow-in-sparc_check.patch

2024-11-06 Thread Mark Wielaard
Hi Anton, > +#define NAME_MAX_SIZE (32 * 17 + 32 + 1) > +static_assert(NAME_MAX_SIZE == (32 * 17 + 32 + 1), "Buffer size for 'name' > is insufficient"); This is indeed a static_assert. But doesn't really add any value. It just checks the calculation one line above. But doesn't explain or check w

[PATCH] libelf: Only fetch shdr once in elf_compress[_gnu]

2024-11-06 Thread Mark Wielaard
Some compilers assume the second call to elf[32|64]_getshdr can fail and produce error: potential null pointer dereference. Just store the result of the first call and reuse (when not NULL). * libelf/elf_compress.c (elf_compress): Store getshdr result in a shdr union var. * li

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

2024-11-06 Thread mark at klomp dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=32311 --- Comment #6 from Mark Wielaard --- (In reply to User441669 from comment #4) > Just one more step! > Indeed! There was one typo in the patch (forgot to remove one line): diff --git a/libelf/elf_compress.c b/libelf/elf_compress.c index 387

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

2024-11-06 Thread the.ra2.ifv at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=32311 --- Comment #5 from User441669 --- (In reply to Mark Wielaard from comment #3) > Unfortunately I cannot replicate the warning/error even with -flto. I have no ideas about this. It might be related to the compiler version or musl libc -- You

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

2024-11-06 Thread the.ra2.ifv at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=32311 --- Comment #4 from User441669 --- Just one more step! Error log: ```text aarch64-openwrt-linux-musl-gcc-ranlib libelf_pic.a ccache aarch64-openwrt-linux-musl-gcc -std=gnu99 -Wall -Wshadow -Wformat=2 -Wold-style-definition -Wstrict-prototype

[PATCH] FIX #74: DEREF_OF_NULL.RET.STAT in ar.c

2024-11-06 Thread Anton Moryakov
Report of the static analyzer: Pointer, returned from function 'elf_getarhdr' at ar.c:498, may be NULL and is dereferenced at ar.c:500. Corrections explained: The issue is that the pointer returned by elf_getarhdr(subelf) may be NULL, but it is directly dereferenced without a NULL check. This f

[PATCH] FIX #90: STRING_OVERFLOW in sparc_attrs.c

2024-11-06 Thread Anton Moryakov
From: AntonMoryakov first report of the static analyzer: A string is copied into the buffer 's' of size 577 without checking its length first at sparc_attrs.c:95. Corrections explained: Added static_assert to check the size of the name buffer at compile time. This static_assert will assert tha