elfutils: Update to 0.192

This commit is contained in:
coolsnowwolf 2024-12-03 13:14:16 +08:00
parent 6c2883702c
commit 4ebc73897e
8 changed files with 320 additions and 11 deletions

View File

@ -7,12 +7,13 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=elfutils
PKG_VERSION:=0.188
PKG_VERSION:=0.192
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=https://sourceware.org/$(PKG_NAME)/ftp/$(PKG_VERSION)
PKG_HASH:=fb8b0e8d0802005b9a309c60c1d8de32dd2951b56f0c3a3cb56d21ce01595dff
PKG_SOURCE_URL:=https://sourceware.org/$(PKG_NAME)/ftp/$(PKG_VERSION) \
https://mirrors.kernel.org/sourceware/$(PKG_NAME)/$(PKG_VERSION)
PKG_HASH:=616099beae24aba11f9b63d86ca6cc8d566d968b802391334c91df54eab416b4
PKG_MAINTAINER:=Luiz Angelo Daros de Luca <luizluca@gmail.com>
PKG_LICENSE:=GPL-3.0-or-later
@ -65,6 +66,7 @@ HOST_CONFIGURE_ARGS += \
--disable-nls \
--disable-debuginfod \
--disable-libdebuginfod \
--without-bzlib \
--without-lzma \
--without-zstd
@ -72,6 +74,7 @@ CONFIGURE_ARGS += \
--program-prefix=eu- \
--disable-debuginfod \
--disable-libdebuginfod \
--without-bzlib \
--without-lzma \
--without-zstd
@ -81,9 +84,12 @@ HOST_CONFIGURE_VARS += \
CONFIGURE_VARS += \
ac_cv_search__obstack_free=yes
TARGET_CFLAGS += -D_GNU_SOURCE -Wno-unused-result -Wno-format-nonliteral
TARGET_CFLAGS += \
-D_GNU_SOURCE \
-Wno-unused-result \
-Wno-format-nonliteral
ifneq ($(filter $(GCC_MAJOR_VERSION),12 13),)
ifneq ($(CONFIG_GCC_USE_VERSION_11),y)
TARGET_CFLAGS += \
-Wno-error=use-after-free
endif

View File

@ -8,10 +8,10 @@
+Libs: -L${libdir} -lelf @intl_LDFLAGS@
Cflags: -I${includedir}
Requires.private: zlib
Requires.private: zlib @LIBZSTD@
--- a/configure.ac
+++ b/configure.ac
@@ -652,6 +652,9 @@ dnl AM_GNU_GETTEXT_REQUIRE_VERSION suppo
@@ -728,6 +728,9 @@ dnl AM_GNU_GETTEXT_REQUIRE_VERSION suppo
AM_GNU_GETTEXT_VERSION([0.19.6])
AM_GNU_GETTEXT_REQUIRE_VERSION([0.19.6])

View File

@ -7,5 +7,5 @@
- libasm debuginfod src po doc tests
+ libasm
EXTRA_DIST = elfutils.spec GPG-KEY NOTES CONTRIBUTING \
COPYING COPYING-GPLV2 COPYING-LGPLV3
EXTRA_DIST = elfutils.spec GPG-KEY NOTES CONTRIBUTING SECURITY \
COPYING COPYING-GPLV2 COPYING-LGPLV3 CONDUCT

View File

@ -32,8 +32,8 @@ Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
+# include <sys/uio.h>
# include <sys/user.h>
# include <sys/ptrace.h>
/* Deal with old glibc defining user_pt_regs instead of user_regs_struct. */
@@ -82,7 +82,7 @@ aarch64_set_initial_registers_tid (pid_t
# include <asm/ptrace.h>
@@ -94,7 +94,7 @@ aarch64_set_initial_registers_tid (pid_t
Dwarf_Word dwarf_fregs[32];
for (int r = 0; r < 32; r++)

View File

@ -0,0 +1,31 @@
From f5d6e088f84dd05278c4698a21cbf1ff4569978d Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Tue, 22 Oct 2024 15:03:42 +0200
Subject: [PATCH] libelf: Add libeu objects to libelf.a static archive
libelf might use some symbols from libeu.a, specifically the eu-search
wrappers. But we don't ship libeu.a separately. So include the libeu
objects in the libelf.a archive to facilitate static linking.
* libelf/Makefile.am (libeu_objects): New variable.
(libelf_a_LIBADD): New, add libeu_objects.
https://sourceware.org/bugzilla/show_bug.cgi?id=32293
Signed-off-by: Mark Wielaard <mark@klomp.org>
---
libelf/Makefile.am | 3 +++
1 file changed, 3 insertions(+)
--- a/libelf/Makefile.am
+++ b/libelf/Makefile.am
@@ -122,6 +122,9 @@ libelf.so: $(srcdir)/libelf.map $(libelf
@$(textrel_check)
$(AM_V_at)ln -fs $@ $@.$(VERSION)
+libeu_objects = $(shell $(AR) t ../lib/libeu.a)
+libelf_a_LIBADD = $(addprefix ../lib/,$(libeu_objects))
+
install: install-am libelf.so
$(mkinstalldirs) $(DESTDIR)$(libdir)
$(INSTALL_PROGRAM) libelf.so $(DESTDIR)$(libdir)/libelf-$(PACKAGE_VERSION).so

View File

@ -0,0 +1,24 @@
From f3c664d069d81a4872a1ec8241ee709f37c53e9c Mon Sep 17 00:00:00 2001
From: Aaron Merey <amerey@redhat.com>
Date: Tue, 29 Oct 2024 14:16:57 -0400
Subject: [PATCH] configure.ac: Fix ENABLE_IMA_VERIFICATION conditional
Fix test statement for ENABLE_IMA_VERIFICATION always evalutating to
false due to a missing 'x'.
Signed-off-by: Aaron Merey <amerey@redhat.com>
---
configure.ac | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/configure.ac
+++ b/configure.ac
@@ -895,7 +895,7 @@ AS_IF([test "x$enable_debuginfod" != "xn
AM_CONDITIONAL([DEBUGINFOD],[test "x$enable_debuginfod" = "xyes"])
AS_IF([test "x$enable_debuginfod_ima_verification" = "xyes"],AC_DEFINE([ENABLE_IMA_VERIFICATION],[1],[Build IMA verification]))
AS_IF([test "x$have_libarchive" = "xyes"],AC_DEFINE([HAVE_LIBARCHIVE],[1],[Define to 1 if libarchive is available]))
-AM_CONDITIONAL([ENABLE_IMA_VERIFICATION],[test "$enable_debuginfod_ima_verification" = "xyes"])
+AM_CONDITIONAL([ENABLE_IMA_VERIFICATION],[test "x$enable_debuginfod_ima_verification" = "xyes"])
AM_CONDITIONAL([OLD_LIBMICROHTTPD],[test "x$old_libmicrohttpd" = "xyes"])
dnl for /etc/profile.d/elfutils.{csh,sh}

View File

@ -0,0 +1,193 @@
From 8707194a9f2f0b13e53041b03ebfdbdbd2942e43 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Tue, 5 Nov 2024 23:31:14 +0100
Subject: [PATCH 1/1] libelf: Only fetch shdr once in elf_compress[_gnu]
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.
* libelf/elf_compress_gnu.c (): Likewise
https://sourceware.org/bugzilla/show_bug.cgi?id=32311
Signed-off-by: Mark Wielaard <mark@klomp.org>
---
libelf/elf_compress.c | 55 +++++++++++++++++++++------------------
libelf/elf_compress_gnu.c | 45 ++++++++++++++------------------
2 files changed, 48 insertions(+), 52 deletions(-)
--- a/libelf/elf_compress.c
+++ b/libelf/elf_compress.c
@@ -584,25 +584,30 @@ elf_compress (Elf_Scn *scn, int type, un
Elf64_Xword sh_flags;
Elf64_Word sh_type;
Elf64_Xword sh_addralign;
+ union shdr
+ {
+ Elf32_Shdr *s32;
+ Elf64_Shdr *s64;
+ } shdr;
if (elfclass == ELFCLASS32)
{
- Elf32_Shdr *shdr = elf32_getshdr (scn);
- if (shdr == NULL)
+ shdr.s32 = elf32_getshdr (scn);
+ if (shdr.s32 == NULL)
return -1;
- sh_flags = shdr->sh_flags;
- sh_type = shdr->sh_type;
- sh_addralign = shdr->sh_addralign;
+ sh_flags = shdr.s32->sh_flags;
+ sh_type = shdr.s32->sh_type;
+ sh_addralign = shdr.s32->sh_addralign;
}
else
{
- Elf64_Shdr *shdr = elf64_getshdr (scn);
- if (shdr == NULL)
+ shdr.s64 = elf64_getshdr (scn);
+ if (shdr.s64 == NULL)
return -1;
- sh_flags = shdr->sh_flags;
- sh_type = shdr->sh_type;
- sh_addralign = shdr->sh_addralign;
+ sh_flags = shdr.s64->sh_flags;
+ sh_type = shdr.s64->sh_type;
+ sh_addralign = shdr.s64->sh_addralign;
}
if ((sh_flags & SHF_ALLOC) != 0)
@@ -679,17 +684,17 @@ elf_compress (Elf_Scn *scn, int type, un
correctly and ignored when SHF_COMPRESSED is set. */
if (elfclass == ELFCLASS32)
{
- Elf32_Shdr *shdr = elf32_getshdr (scn);
- shdr->sh_size = new_size;
- shdr->sh_addralign = __libelf_type_align (ELFCLASS32, ELF_T_CHDR);
- shdr->sh_flags |= SHF_COMPRESSED;
+ shdr.s32->sh_size = new_size;
+ shdr.s32->sh_addralign = __libelf_type_align (ELFCLASS32,
+ ELF_T_CHDR);
+ shdr.s32->sh_flags |= SHF_COMPRESSED;
}
else
{
- Elf64_Shdr *shdr = elf64_getshdr (scn);
- shdr->sh_size = new_size;
- shdr->sh_addralign = __libelf_type_align (ELFCLASS64, ELF_T_CHDR);
- shdr->sh_flags |= SHF_COMPRESSED;
+ shdr.s64->sh_size = new_size;
+ shdr.s64->sh_addralign = __libelf_type_align (ELFCLASS64,
+ ELF_T_CHDR);
+ shdr.s64->sh_flags |= SHF_COMPRESSED;
}
__libelf_reset_rawdata (scn, out_buf, new_size, 1, ELF_T_CHDR);
@@ -731,17 +736,15 @@ elf_compress (Elf_Scn *scn, int type, un
correctly and ignored when SHF_COMPRESSED is set. */
if (elfclass == ELFCLASS32)
{
- Elf32_Shdr *shdr = elf32_getshdr (scn);
- shdr->sh_size = scn->zdata_size;
- shdr->sh_addralign = scn->zdata_align;
- shdr->sh_flags &= ~SHF_COMPRESSED;
+ shdr.s32->sh_size = scn->zdata_size;
+ shdr.s32->sh_addralign = scn->zdata_align;
+ shdr.s32->sh_flags &= ~SHF_COMPRESSED;
}
else
{
- Elf64_Shdr *shdr = elf64_getshdr (scn);
- shdr->sh_size = scn->zdata_size;
- shdr->sh_addralign = scn->zdata_align;
- shdr->sh_flags &= ~SHF_COMPRESSED;
+ shdr.s64->sh_size = scn->zdata_size;
+ shdr.s64->sh_addralign = scn->zdata_align;
+ shdr.s64->sh_flags &= ~SHF_COMPRESSED;
}
__libelf_reset_rawdata (scn, scn->zdata_base,
--- a/libelf/elf_compress_gnu.c
+++ b/libelf/elf_compress_gnu.c
@@ -59,25 +59,30 @@ elf_compress_gnu (Elf_Scn *scn, int infl
Elf64_Xword sh_flags;
Elf64_Word sh_type;
Elf64_Xword sh_addralign;
+ union shdr
+ {
+ Elf32_Shdr *s32;
+ Elf64_Shdr *s64;
+ } shdr;
if (elfclass == ELFCLASS32)
{
- Elf32_Shdr *shdr = elf32_getshdr (scn);
- if (shdr == NULL)
+ shdr.s32 = elf32_getshdr (scn);
+ if (shdr.s32 == NULL)
return -1;
- sh_flags = shdr->sh_flags;
- sh_type = shdr->sh_type;
- sh_addralign = shdr->sh_addralign;
+ sh_flags = shdr.s32->sh_flags;
+ sh_type = shdr.s32->sh_type;
+ sh_addralign = shdr.s32->sh_addralign;
}
else
{
- Elf64_Shdr *shdr = elf64_getshdr (scn);
- if (shdr == NULL)
+ shdr.s64 = elf64_getshdr (scn);
+ if (shdr.s64 == NULL)
return -1;
- sh_flags = shdr->sh_flags;
- sh_type = shdr->sh_type;
- sh_addralign = shdr->sh_addralign;
+ sh_flags = shdr.s64->sh_flags;
+ sh_type = shdr.s64->sh_type;
+ sh_addralign = shdr.s64->sh_addralign;
}
/* Allocated sections, or sections that are already are compressed
@@ -122,15 +127,9 @@ elf_compress_gnu (Elf_Scn *scn, int infl
sh_flags won't have a SHF_COMPRESSED hint in the GNU format.
Just adjust the sh_size. */
if (elfclass == ELFCLASS32)
- {
- Elf32_Shdr *shdr = elf32_getshdr (scn);
- shdr->sh_size = new_size;
- }
+ shdr.s32->sh_size = new_size;
else
- {
- Elf64_Shdr *shdr = elf64_getshdr (scn);
- shdr->sh_size = new_size;
- }
+ shdr.s64->sh_size = new_size;
__libelf_reset_rawdata (scn, out_buf, new_size, 1, ELF_T_BYTE);
@@ -187,15 +186,9 @@ elf_compress_gnu (Elf_Scn *scn, int infl
sh_flags won't have a SHF_COMPRESSED hint in the GNU format.
Just adjust the sh_size. */
if (elfclass == ELFCLASS32)
- {
- Elf32_Shdr *shdr = elf32_getshdr (scn);
- shdr->sh_size = size;
- }
+ shdr.s32->sh_size = size;
else
- {
- Elf64_Shdr *shdr = elf64_getshdr (scn);
- shdr->sh_size = size;
- }
+ shdr.s64->sh_size = size;
__libelf_reset_rawdata (scn, buf_out, size, sh_addralign,
__libelf_data_type (&ehdr, sh_type,

View File

@ -0,0 +1,55 @@
strip.c: Pointer `arhdr` created at strip.c:2741 and then dereferenced without NULL-check.
The same situation for the `arhdr` pointer at the objdump.c:313 and
the `h` pointer at the readelf.c:13545.
Triggers found by static analyzer Svace.
Signed-off-by: Maks Mishin <maks.mishinFZ@gmail.com>
---
src/objdump.c | 5 +++++
src/readelf.c | 5 +++++
src/strip.c | 5 +++++
3 files changed, 15 insertions(+)
--- a/src/objdump.c
+++ b/src/objdump.c
@@ -311,6 +311,11 @@ handle_ar (int fd, Elf *elf, const char
{
/* The the header for this element. */
Elf_Arhdr *arhdr = elf_getarhdr (subelf);
+ if (arhdr == NULL)
+ {
+ printf ("cannot get arhdr: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
/* Skip over the index entries. */
if (strcmp (arhdr->ar_name, "/") != 0
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -13543,6 +13543,11 @@ dump_archive_index (Elf *elf, const char
as_off, fname, elf_errmsg (-1));
const Elf_Arhdr *h = elf_getarhdr (subelf);
+ if (h == NULL)
+ {
+ printf ("cannot get arhdr: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
printf (_("Archive member '%s' contains:\n"), h->ar_name);
--- a/src/strip.c
+++ b/src/strip.c
@@ -2739,6 +2739,11 @@ handle_ar (int fd, Elf *elf, const char
{
/* The the header for this element. */
Elf_Arhdr *arhdr = elf_getarhdr (subelf);
+ if (arhdr == NULL)
+ {
+ printf ("cannot get arhdr: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
if (elf_kind (subelf) == ELF_K_ELF)
result |= handle_elf (fd, subelf, new_prefix, arhdr->ar_name, 0, NULL);