aboutsummaryrefslogtreecommitdiffstats
path: root/main/elfutils
diff options
context:
space:
mode:
authorLeo <thinkabit.ukim@gmail.com>2019-12-26 05:13:06 +0100
committerNatanael Copa <ncopa@alpinelinux.org>2019-12-26 11:29:26 +0000
commit2e3d4976eeffb4704cf83e2cc3306293b7c7b2e9 (patch)
tree291b55a671c9856d1e90ce17cfe25313bab04e28 /main/elfutils
parent1a1cbf4ee2c744a9b31f9c97f6eb1b28b7424065 (diff)
downloadaports-2e3d4976eeffb4704cf83e2cc3306293b7c7b2e9.tar.bz2
aports-2e3d4976eeffb4704cf83e2cc3306293b7c7b2e9.tar.xz
main/elfutils: upgrade to 0.178
Diffstat (limited to 'main/elfutils')
-rw-r--r--main/elfutils/0001-Fix-TEMP_FAILURE_RETRY-definition-when-not-defined.patch108
-rw-r--r--main/elfutils/APKBUILD127
-rw-r--r--main/elfutils/CVE-2017-7607.patch34
-rw-r--r--main/elfutils/CVE-2017-7608.patch95
-rw-r--r--main/elfutils/CVE-2018-18310.patch53
-rw-r--r--main/elfutils/error.h27
-rw-r--r--main/elfutils/fix-aarch64_fregs.patch8
-rw-r--r--main/elfutils/musl-accessperms.patch13
-rw-r--r--main/elfutils/musl-asm-ptrace-h.patch10
-rw-r--r--main/elfutils/musl-canonicalize_file_name.patch22
-rw-r--r--main/elfutils/musl-fts-obstack.patch87
-rw-r--r--main/elfutils/musl-macros.patch19
-rw-r--r--main/elfutils/musl-qsort_r.patch25
-rw-r--r--main/elfutils/musl-strndupa.patch18
-rw-r--r--main/elfutils/no-werror.patch32
15 files changed, 234 insertions, 444 deletions
diff --git a/main/elfutils/0001-Fix-TEMP_FAILURE_RETRY-definition-when-not-defined.patch b/main/elfutils/0001-Fix-TEMP_FAILURE_RETRY-definition-when-not-defined.patch
deleted file mode 100644
index 5a1182d80a..0000000000
--- a/main/elfutils/0001-Fix-TEMP_FAILURE_RETRY-definition-when-not-defined.patch
+++ /dev/null
@@ -1,108 +0,0 @@
-From 925f67e86d127c8917f92bde1cf5abd5b07d0768 Mon Sep 17 00:00:00 2001
-From: Luiz Angelo Daros de Luca <luizluca@gmail.com>
-Date: Thu, 29 Dec 2016 21:02:57 -0200
-Subject: [PATCH] Fix TEMP_FAILURE_RETRY definition when not defined.
-
-https://sourceware.org/bugzilla/show_bug.cgi?id=21001
-
-Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
----
- lib/ChangeLog | 5 +++++
- lib/crc32_file.c | 1 +
- lib/system.h | 2 +-
- libdwfl/ChangeLog | 6 ++++++
- libdwfl/dwfl_build_id_find_elf.c | 1 +
- libdwfl/dwfl_module_getdwarf.c | 1 +
- libdwfl/libdwfl_crc32_file.c | 1 -
- 7 files changed, 15 insertions(+), 2 deletions(-)
-
-diff --git a/lib/ChangeLog b/lib/ChangeLog
-index 1fe59067..fcf5b105 100644
---- a/lib/ChangeLog
-+++ b/lib/ChangeLog
-@@ -1,3 +1,8 @@
-+2016-12-29 Luiz Angelo Daros de Luca <luizluca@gmail.com>
-+
-+ * crc32_file.c: Include system.h.
-+ * system.h: Remove semi-colon after TEMP_FAILURE_RETRY definition.
-+
- 2016-12-24 Mark Wielaard <mark@klomp.org>
-
- * version.c: New source file.
-diff --git a/lib/crc32_file.c b/lib/crc32_file.c
-index a8434d42..57e42980 100644
---- a/lib/crc32_file.c
-+++ b/lib/crc32_file.c
-@@ -35,6 +35,7 @@
- #include <unistd.h>
- #include <sys/stat.h>
- #include <sys/mman.h>
-+#include "system.h"
-
- int
- crc32_file (int fd, uint32_t *resp)
-diff --git a/lib/system.h b/lib/system.h
-index ccd99d63..dde7c4a2 100644
---- a/lib/system.h
-+++ b/lib/system.h
-@@ -81,7 +81,7 @@
- do \
- __res = expression; \
- while (__res == -1 && errno == EINTR); \
-- __res; });
-+ __res; })
- #endif
-
- static inline ssize_t __attribute__ ((unused))
-diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
-index bc627fee..57671eaf 100644
---- a/libdwfl/ChangeLog
-+++ b/libdwfl/ChangeLog
-@@ -1,3 +1,9 @@
-+2016-12-29 Luiz Angelo Daros de Luca <luizluca@gmail.com>
-+
-+ * dwfl_build_id_find_elf.c: Include system.h.
-+ * dwfl_module_getdwarf.c: Likewise.
-+ * libdwfl_crc32_file.c: Don't define LIB_SYSTEM_H.
-+
- 2016-11-23 Mark Wielaard <mjw@redhat.com>
-
- * linux-kernel-modules.c: Only include fts.h early if BAD_FTS is
-diff --git a/libdwfl/dwfl_build_id_find_elf.c b/libdwfl/dwfl_build_id_find_elf.c
-index 903e1931..d4737c9f 100644
---- a/libdwfl/dwfl_build_id_find_elf.c
-+++ b/libdwfl/dwfl_build_id_find_elf.c
-@@ -30,6 +30,7 @@
- #include <inttypes.h>
- #include <fcntl.h>
- #include <unistd.h>
-+#include "system.h"
-
-
- int
-diff --git a/libdwfl/dwfl_module_getdwarf.c b/libdwfl/dwfl_module_getdwarf.c
-index 0e8810b1..46caece5 100644
---- a/libdwfl/dwfl_module_getdwarf.c
-+++ b/libdwfl/dwfl_module_getdwarf.c
-@@ -33,6 +33,7 @@
- #include <unistd.h>
- #include "../libdw/libdwP.h" /* DWARF_E_* values are here. */
- #include "../libelf/libelfP.h"
-+#include "system.h"
-
- static inline Dwfl_Error
- open_elf_file (Elf **elf, int *fd, char **name)
-diff --git a/libdwfl/libdwfl_crc32_file.c b/libdwfl/libdwfl_crc32_file.c
-index 6b6b7d3f..f849128d 100644
---- a/libdwfl/libdwfl_crc32_file.c
-+++ b/libdwfl/libdwfl_crc32_file.c
-@@ -31,6 +31,5 @@
-
- #define crc32_file attribute_hidden __libdwfl_crc32_file
- #define crc32 __libdwfl_crc32
--#define LIB_SYSTEM_H 1
- #include <libdwflP.h>
- #include "../lib/crc32_file.c"
---
-2.11.1
-
diff --git a/main/elfutils/APKBUILD b/main/elfutils/APKBUILD
index be8a28fd47..6fc613e8b6 100644
--- a/main/elfutils/APKBUILD
+++ b/main/elfutils/APKBUILD
@@ -1,84 +1,65 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=elfutils
-pkgver=0.168
-pkgrel=2
+pkgver=0.178
+pkgrel=0
pkgdesc="A collection of utilities and DSOs to handle ELF files and DWARF data"
url="http://elfutils.org/"
arch="all"
license="GPL-3.0-or-later and (GPL-2.0-or-later or LGPL-3.0-or-later)"
-depends=""
makedepends="bison flex-dev zlib-dev bzip2-dev xz-dev argp-standalone
- bsd-compat-headers autoconf automake libtool"
-install=""
-subpackages="$pkgname-dev $pkgname-libelf"
+ bsd-compat-headers autoconf automake libtool fts-dev musl-obstack-dev
+ linux-headers"
+subpackages="libelf libelf-static $pkgname-dev $pkgname-doc"
source="https://sourceware.org/elfutils/ftp/$pkgver/elfutils-$pkgver.tar.bz2
- 0001-Fix-TEMP_FAILURE_RETRY-definition-when-not-defined.patch
+ error.h
fix-aarch64_fregs.patch
fix-uninitialized.patch
- musl-accessperms.patch
- musl-canonicalize_file_name.patch
musl-cdefs.patch
+ musl-fts-obstack.patch
musl-macros.patch
musl-qsort_r.patch
musl-strerror_r.patch
- no-werror.patch
- CVE-2017-7607.patch
- CVE-2017-7608.patch
- CVE-2018-18310.patch
+ musl-strndupa.patch
+ musl-asm-ptrace-h.patch
"
-builddir="$srcdir/elfutils-$pkgver"
# secfixes:
+# 0.176-r0:
+# - CVE-2019-7146
+# - CVE-2019-7148
+# - CVE-2019-7149
+# - CVE-2019-7150
+# - CVE-2019-7664
+# - CVE-2019-7665
+# 0.175-r0:
+# - CVE-2019-18310
+# - CVE-2019-18520
+# - CVE-2019-18521
+# 0.174-r0:
+# - CVE-2019-16062
+# - CVE-2019-16402
+# - CVE-2019-16403
# 0.168-r1:
-# - CVE-2017-7607
-# - CVE-2017-7608
+# - CVE-2017-7607
+# - CVE-2017-7608
prepare() {
- cd "$builddir"
- default_prepare || return 1
- autoreconf -vif || return 1
+ default_prepare
+ autoreconf -vif
- cat > src/error.h <<-EOF
- #ifndef _ERROR_H_
- #define _ERROR_H_
+ cp "$srcdir"/error.h "$builddir"/lib
+ cp "$srcdir"/error.h "$builddir"/src
- #include <stdarg.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <errno.h>
-
- static unsigned int error_message_count = 0;
-
- static inline void error(int status, int errnum, const char* format, ...)
- {
- va_list ap;
- fprintf(stderr, "%s: ", program_invocation_name);
- va_start(ap, format);
- vfprintf(stderr, format, ap);
- va_end(ap);
- if (errnum)
- fprintf(stderr, ": %s", strerror(errnum));
- fprintf(stderr, "\n");
- error_message_count++;
- if (status)
- exit(status);
- }
-
- #endif /* _ERROR_H_ */
-EOF
- cp src/error.h lib/ || return 1
cat > lib/libintl.h <<-EOF
- #ifndef LIBINTL_H
- #define LIBINTL_H
- #define _(x) (x)
- #endif
-EOF
-
+ #ifndef LIBINTL_H
+ #define LIBINTL_H
+ #define _(x) (x)
+ #endif
+ EOF
}
+
build() {
- cd "$builddir"
- CFLAGS="$CFLAGS -Wno-null-dereference" \
+ CFLAGS="$CFLAGS -Wno-error -Wno-null-dereference" \
./configure \
--build=$CBUILD \
--host=$CHOST \
@@ -87,34 +68,36 @@ build() {
--mandir=/usr/share/man \
--localstatedir=/var \
--disable-werror \
+ --program-prefix=eu- \
+ --enable-deterministic-archives \
--disable-nls \
- || return 1
+ --disable-debuginfod
# for now we only build libelf
- cd libelf && make || return 1
+ make
}
package() {
- cd "$builddir"/libelf
make DESTDIR="$pkgdir" install
}
libelf() {
- pkgdesc="libelf from elfutils"
+ replaces="$pkgname-libelf"
+ provides="$pkgname-libelf=$pkgver-r$pkgrel"
+
+ pkgdesc="$pkgdesc - runtime libraries"
mkdir -p "$subpkgdir"/usr/lib
- mv "$pkgdir"/usr/lib/libelf*.so* "$subpkgdir"/usr/lib/
+ mv "$pkgdir"/usr/lib/*.so.* "$subpkgdir"/usr/lib/
+ mv "$pkgdir"/usr/lib/*-*.so "$subpkgdir"/usr/lib/
}
-sha512sums="c8f2077ffe6877ad9e9d2f553bf0576361799c601d246f53e1d99a6f7046794c5916e1087b97ad1d1e5f59f9debc20384f864d507ef6c4c75a8e767d15d6eb91 elfutils-0.168.tar.bz2
-eb77cb7712d74a67bbaca83ed2ccf169ba3095b423068176dd26bf340964c89b02574315f42bd4be0e4e4890c647b74a813657e890fbc719296508c625cd396c 0001-Fix-TEMP_FAILURE_RETRY-definition-when-not-defined.patch
-61d38d47e557b54a2dc35b081a80af1b4e56172cf2d16843299506384e8062078edbef116eca5047021b37eb49a5cb364016f7bb6426942f772ec94f91cb02a1 fix-aarch64_fregs.patch
+sha512sums="356656ad0db8f6877b461de1a11280de16a9cc5d8dde4381a938a212e828e32755135e5e3171d311c4c9297b728fbd98123048e2e8fbf7fe7de68976a2daabe5 elfutils-0.178.tar.bz2
+8b650bc78cea66f30f0ff66357005890ac8a1b04a8dcc50209cb10a4b4c5ede849505cb68463beca8316ace0fbd53bbc484cfb597805b55616f3b3fc2b864e9a error.h
+c3676b0b8b40d6e437f5d88c0d658dc0829ec97d1955e4bbf96f4cff9ee9001b8f2f06174450ae7aa5858b91c7905bdbd49073b561c346416132338a9c94731b fix-aarch64_fregs.patch
b9ba55e1b56a8abf694b6d02f022d9a3a0ae6ab53a8c4a71e49552e32411ef410d3a7512fbd1a729696bc2046ac11586829816f0fa3b8226ee77c9dc4b741e58 fix-uninitialized.patch
-0d9858c8437b5185975bb6be1340bcd718a5e723c7f9d683be91c8b14e87dc9b94fc620d752d07a655c602cc2e35d85d62b829a91d43d930d8f0b3ffde6e0e32 musl-accessperms.patch
-46f53041fcbc8b82190c253faecfed1cbdced465923336925088915824a07140a9bc846d5498b22ee54f0dc4e74f19522bce102a162b79b2b4674cf0c58c14eb musl-canonicalize_file_name.patch
0198194976782ab13bba59491d2d6bbe6189cba1edab174ca61cc7b942564f03b5d61feb6b787c5d09e66b3b493f08a330a8612e04de02d261b72b7996cc50c3 musl-cdefs.patch
-886ab23301f1872d94bcfc3590621196c811252c9a993738e5e480e666c7c3359f25e94c0e873c8fe16dc283e193dba0532a7ced3951e673185dcbb1d062b7c6 musl-macros.patch
-f025d6479c8782275090783ff4dd09eb70a7c3eec1126d3176c02d01124f22864d81e08cb96ac4d255e0316205658459b617f5b661b16dbaf1636591720605f4 musl-qsort_r.patch
+3b9fb4ebb5b33d4c7fb1e1f7e476a3ea4eba796bd9c89b9c920ef8c879638fb70abb1d83a0039b5b95558ba9597fb9cdb0fd6983498a11bb8dbdd50738c925c8 musl-fts-obstack.patch
+952109b1e0a2ccf435f5a7825ca3514d526161dae32e3d734f93d76b5693c469a889a488cb05cf423a006e9df550e7aae68697cc09d2c48fee1acd38163e5750 musl-macros.patch
+ce1a25387865ff96ecc5104810acc225dd64c28571ee5473ab732f7b63b927e4a260ebe74f17d3d8ba0c917cce233b9f902dd35c149d6d8317eecbc71f8d2da6 musl-qsort_r.patch
a0d986100c8ff2ef0595645ec1b2eeb1d517b7442aef5f349ebf27fcb66c76e51fadeda25bed5f04b4bb16a61aa23ac6e86a1f34a0087d2136acf0f64c3fa4d1 musl-strerror_r.patch
-26aff757de8c0c67ae7922888c4a842939fb9b4022f3d2fa916591b44921c109f74154175afd431a0e31cf7c876f6d4fbaae26ef283985ae98d96854ea02dce0 no-werror.patch
-81c6f19ed3e39aa6f2437e2da09be2952627efccda4769cccdd2616c728205ecdac1ece8a97ead7614a528d161c3885a050980a07436de7bdbc6f2988b348784 CVE-2017-7607.patch
-20088019a3cb17d1d9155c421b20e47907d2bdbea31fdd0e469f02c03f8dfe1e7da5c29f0bb0a35be79470a40d7c2df92d2402e32b20d090526bb1f8a71e0707 CVE-2017-7608.patch
-f8654b29eea3777f0a1c752ec927a09163dc711ad52520e01b64e5976f2943b7141868cbe4ce4b8af8cc2fbfba4a98e8d4840d605067186532f4142298c1fc73 CVE-2018-18310.patch"
+1728376b8408e9ae97f048d54bc6faae889bca197cc0500a952e64683835dfca66465aa4bce8e57d1ce7a81dcba0bbeeb4bd1e1026d3c4bd196ef4ffe536a509 musl-strndupa.patch
+7c529f88dc248f657a8d690044560c20a222c5b37d0d7dcb057bf2eea8938c406cccd6129bce19542088511a026b233234c9a83933a525c4691810be9ca712bf musl-asm-ptrace-h.patch"
diff --git a/main/elfutils/CVE-2017-7607.patch b/main/elfutils/CVE-2017-7607.patch
deleted file mode 100644
index b4af2fe3db..0000000000
--- a/main/elfutils/CVE-2017-7607.patch
+++ /dev/null
@@ -1,34 +0,0 @@
-From: Mark Wielaard <mark at klomp dot org>
-To: elfutils-devel at sourceware dot org
-Cc: Mark Wielaard <mark at klomp dot org>
-Subject: [PATCH] readelf: Fix off by one sanity check in handle_gnu_hash.
-Date: Fri, 24 Mar 2017 12:15:02 +0100
-Message-Id: <1490354102-21353-1-git-send-email-mark@klomp.org>
-X-Mailer: git-send-email 1.8.3.1
-
-We sanity check to make sure we don't index outside the chain array
-by testing inner > max_nsyms. But inner is a zero-based index, while
-max_nsyms is the maximum number. Change the check to inner >= max_nsyms.
-
-https://sourceware.org/bugzilla/show_bug.cgi?id=21299
-
-Signed-off-by: Mark Wielaard <mark@klomp.org>
----
- src/readelf.c | 2 +-
- 2 files changed, 6 insertions(+), 1 deletion(-)
-
-diff --git a/src/readelf.c b/src/readelf.c
-index 8d96ba3..490b6d5 100644
---- a/src/readelf.c
-+++ b/src/readelf.c
-@@ -3263,7 +3263,7 @@ handle_gnu_hash (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr, size_t shstrndx)
- ++nsyms;
- if (maxlength < ++lengths[cnt])
- ++maxlength;
-- if (inner > max_nsyms)
-+ if (inner >= max_nsyms)
- goto invalid_data;
- }
- while ((chain[inner++] & 1) == 0);
---
-1.8.3.1
diff --git a/main/elfutils/CVE-2017-7608.patch b/main/elfutils/CVE-2017-7608.patch
deleted file mode 100644
index dc3223605b..0000000000
--- a/main/elfutils/CVE-2017-7608.patch
+++ /dev/null
@@ -1,95 +0,0 @@
-From: Mark Wielaard <mark at klomp dot org>
-To: elfutils-devel at sourceware dot org
-Cc: Mark Wielaard <mark at klomp dot org>
-Subject: [PATCH] Use the empty string for note names with zero size (without any data).
-Date: Fri, 24 Mar 2017 14:10:26 +0100
-Message-Id: <1490361026-7608-1-git-send-email-mark@klomp.org>
-X-Mailer: git-send-email 1.8.3.1
-
-ELF notes can have a zero sized name. In which case there is no data at
-all (so also no zero terminator). Make sure to use the empty string for
-such notes if the code does not otherwise explicitly check n_namesz.
-
-https://sourceware.org/bugzilla/show_bug.cgi?id=21300
-
-Signed-off-by: Mark Wielaard <mark@klomp.org>
----
- libdwfl/linux-core-attach.c | 9 ++++++---
- src/elfcmp.c | 6 ++++--
- src/readelf.c | 2 +-
- 5 files changed, 23 insertions(+), 6 deletions(-)
-
-diff --git a/libdwfl/linux-core-attach.c b/libdwfl/linux-core-attach.c
-index 93d0e46..f82ed03 100644
---- a/libdwfl/linux-core-attach.c
-+++ b/libdwfl/linux-core-attach.c
-@@ -125,7 +125,8 @@ core_next_thread (Dwfl *dwfl __attribute__ ((unused)), void *dwfl_arg,
- &desc_offset)) > 0)
- {
- /* Do not check NAME for now, help broken Linux kernels. */
-- const char *name = note_data->d_buf + name_offset;
-+ const char *name = (nhdr.n_namesz == 0
-+ ? "" : note_data->d_buf + name_offset);
- const char *desc = note_data->d_buf + desc_offset;
- GElf_Word regs_offset;
- size_t nregloc;
-@@ -178,7 +179,8 @@ core_set_initial_registers (Dwfl_Thread *thread, void *thread_arg_voidp)
- /* __libdwfl_attach_state_for_core already verified the note is there. */
- assert (getnote_err != 0);
- /* Do not check NAME for now, help broken Linux kernels. */
-- const char *name = note_data->d_buf + name_offset;
-+ const char *name = (nhdr.n_namesz == 0
-+ ? "" : note_data->d_buf + name_offset);
- const char *desc = note_data->d_buf + desc_offset;
- GElf_Word regs_offset;
- size_t nregloc;
-@@ -367,7 +369,8 @@ dwfl_core_file_attach (Dwfl *dwfl, Elf *core)
- &nhdr, &name_offset, &desc_offset)) > 0)
- {
- /* Do not check NAME for now, help broken Linux kernels. */
-- const char *name = note_data->d_buf + name_offset;
-+ const char *name = (nhdr.n_namesz == 0
-+ ? "" : note_data->d_buf + name_offset);
- const char *desc = note_data->d_buf + desc_offset;
- GElf_Word regs_offset;
- size_t nregloc;
-
-diff --git a/src/elfcmp.c b/src/elfcmp.c
-index 7673cf2..5046420 100644
---- a/src/elfcmp.c
-+++ b/src/elfcmp.c
-@@ -419,7 +419,8 @@ main (int argc, char *argv[])
- && (off1 = gelf_getnote (data1, off1, &note1,
- &name_offset, &desc_offset)) > 0)
- {
-- const char *name1 = data1->d_buf + name_offset;
-+ const char *name1 = (note1.n_namesz == 0
-+ ? "" : data1->d_buf + name_offset);
- const void *desc1 = data1->d_buf + desc_offset;
- if (off2 >= data2->d_size)
- {
-@@ -435,7 +436,8 @@ main (int argc, char *argv[])
- error (2, 0, gettext ("\
- cannot read note section [%zu] '%s' in '%s': %s"),
- elf_ndxscn (scn2), sname2, fname2, elf_errmsg (-1));
-- const char *name2 = data2->d_buf + name_offset;
-+ const char *name2 = (note2.n_namesz == 0
-+ ? "" : data2->d_buf + name_offset);
- const void *desc2 = data2->d_buf + desc_offset;
-
- if (note1.n_namesz != note2.n_namesz
-diff --git a/src/readelf.c b/src/readelf.c
-index 490b6d5..97a43b0 100644
---- a/src/readelf.c
-+++ b/src/readelf.c
-@@ -9365,7 +9365,7 @@ handle_notes_data (Ebl *ebl, const GElf_Ehdr *ehdr,
- && (offset = gelf_getnote (data, offset,
- &nhdr, &name_offset, &desc_offset)) > 0)
- {
-- const char *name = data->d_buf + name_offset;
-+ const char *name = nhdr.n_namesz == 0 ? "" : data->d_buf + name_offset;
- const char *desc = data->d_buf + desc_offset;
-
- char buf[100];
---
-1.8.3.1
diff --git a/main/elfutils/CVE-2018-18310.patch b/main/elfutils/CVE-2018-18310.patch
deleted file mode 100644
index e6078116f8..0000000000
--- a/main/elfutils/CVE-2018-18310.patch
+++ /dev/null
@@ -1,53 +0,0 @@
-From b6e1a48cca51aa246cba78e99f7e2dfa200b9d26 Mon Sep 17 00:00:00 2001
-From: Mark Wielaard <mark@klomp.org>
-Date: Sun, 14 Oct 2018 16:45:48 +0200
-Subject: [PATCH] libdwfl: Sanity check partial core file data reads.
-
-There were two issues when reading note data from a core file.
-We didn't check if the data we already had in a buffer was big
-enough. And if we did get the data, we should check if we got
-everything, or just a part of the data.
-
-https://sourceware.org/bugzilla/show_bug.cgi?id=23752
-
-Signed-off-by: Mark Wielaard <mark@klomp.org>
----
- libdwfl/dwfl_segment_report_module.c | 13 +++++++++++--
- 1 file changed, 11 insertions(+), 2 deletions(-)
-
-diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c
-index 36e5c823..87498846 100644
---- a/libdwfl/dwfl_segment_report_module.c
-+++ b/libdwfl/dwfl_segment_report_module.c
-@@ -1,5 +1,5 @@
- /* Sniff out modules from ELF headers visible in memory segments.
-- Copyright (C) 2008-2012, 2014, 2015 Red Hat, Inc.
-+ Copyright (C) 2008-2012, 2014, 2015, 2018 Red Hat, Inc.
- This file is part of elfutils.
-
- This file is free software; you can redistribute it and/or modify
-@@ -301,7 +301,10 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name,
- inline bool read_portion (void **data, size_t *data_size,
- GElf_Addr vaddr, size_t filesz)
- {
-- if (vaddr - start + filesz > buffer_available
-+ /* Check whether we will have to read the segment data, or if it
-+ can be returned from the existing buffer. */
-+ if (filesz > buffer_available
-+ || vaddr - start > buffer_available - filesz
- /* If we're in string mode, then don't consider the buffer we have
- sufficient unless it contains the terminator of the string. */
- || (filesz == 0 && memchr (vaddr - start + buffer, '\0',
-@@ -459,6 +462,12 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name,
- if (read_portion (&data, &data_size, vaddr, filesz))
- return;
-
-+ /* data_size will be zero if we got everything from the initial
-+ buffer, otherwise it will be the size of the new buffer that
-+ could be read. */
-+ if (data_size != 0)
-+ filesz = data_size;
-+
- assert (sizeof (Elf32_Nhdr) == sizeof (Elf64_Nhdr));
-
- void *notes;
diff --git a/main/elfutils/error.h b/main/elfutils/error.h
new file mode 100644
index 0000000000..ef06827a0b
--- /dev/null
+++ b/main/elfutils/error.h
@@ -0,0 +1,27 @@
+#ifndef _ERROR_H_
+#define _ERROR_H_
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+static unsigned int error_message_count = 0;
+
+static inline void error(int status, int errnum, const char* format, ...)
+{
+ va_list ap;
+ fprintf(stderr, "%s: ", program_invocation_name);
+ va_start(ap, format);
+ vfprintf(stderr, format, ap);
+ va_end(ap);
+ if (errnum)
+ fprintf(stderr, ": %s", strerror(errnum));
+ fprintf(stderr, "\n");
+ error_message_count++;
+ if (status)
+ exit(status);
+}
+
+#endif /* _ERROR_H_ */
diff --git a/main/elfutils/fix-aarch64_fregs.patch b/main/elfutils/fix-aarch64_fregs.patch
index bafa8012cf..4007416391 100644
--- a/main/elfutils/fix-aarch64_fregs.patch
+++ b/main/elfutils/fix-aarch64_fregs.patch
@@ -3,14 +3,6 @@ Casting to Dwarf_Word instead of & 0xFFFFFFF should do.
--- a/backends/aarch64_initreg.c 2015-11-27 14:36:29.000000000 +0100
+++ b/backends/aarch64_initreg.c 2016-08-09 03:47:25.428560159 +0200
-@@ -33,7 +33,6 @@
- #include "system.h"
- #include <assert.h>
- #ifdef __aarch64__
--# include <linux/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 @@
Dwarf_Word dwarf_fregs[32];
diff --git a/main/elfutils/musl-accessperms.patch b/main/elfutils/musl-accessperms.patch
deleted file mode 100644
index 0c7d2fa25d..0000000000
--- a/main/elfutils/musl-accessperms.patch
+++ /dev/null
@@ -1,13 +0,0 @@
---- a/src/strip.c 2015-10-12 12:22:58.000000000 +0200
-+++ b/src/strip.c 2015-11-20 07:44:13.626287111 +0100
-@@ -44,6 +44,10 @@
- #include <libebl.h>
- #include <system.h>
-
-+#if !defined(ACCESSPERMS)
-+#define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO)
-+#endif
-+
- typedef uint8_t GElf_Byte;
-
- /* Name and version of program. */
diff --git a/main/elfutils/musl-asm-ptrace-h.patch b/main/elfutils/musl-asm-ptrace-h.patch
new file mode 100644
index 0000000000..fc1468690f
--- /dev/null
+++ b/main/elfutils/musl-asm-ptrace-h.patch
@@ -0,0 +1,10 @@
+--- a/backends/ppc_initreg.c 2019-11-26 23:48:42.000000000 +0100
++++ b/backends/ppc_initreg.c 2019-12-08 16:57:58.334872602 +0100
+@@ -32,6 +32,7 @@
+
+ #include <stdlib.h>
+ #if defined(__powerpc__) && defined(__linux__)
++# include <asm/ptrace.h>
+ # include <sys/ptrace.h>
+ # include <sys/user.h>
+ #endif
diff --git a/main/elfutils/musl-canonicalize_file_name.patch b/main/elfutils/musl-canonicalize_file_name.patch
deleted file mode 100644
index 60e22bb5bb..0000000000
--- a/main/elfutils/musl-canonicalize_file_name.patch
+++ /dev/null
@@ -1,22 +0,0 @@
---- a/libdwfl/dwfl_build_id_find_elf.c 2015-10-12 12:22:58.000000000 +0200
-+++ b/libdwfl/dwfl_build_id_find_elf.c 2015-11-20 05:13:10.972994172 +0100
-@@ -94,7 +94,7 @@
- {
- if (*file_name != NULL)
- free (*file_name);
-- *file_name = canonicalize_file_name (name);
-+ *file_name = realpath (name, NULL);
- if (*file_name == NULL)
- {
- *file_name = name;
---- a/libdwfl/find-debuginfo.c 2015-10-12 12:22:58.000000000 +0200
-+++ b/libdwfl/find-debuginfo.c 2015-11-20 05:18:56.990967176 +0100
-@@ -372,7 +372,7 @@
- /* If FILE_NAME is a symlink, the debug file might be associated
- with the symlink target name instead. */
-
-- char *canon = canonicalize_file_name (file_name);
-+ char *canon = realpath (file_name, NULL);
- if (canon != NULL && strcmp (file_name, canon))
- fd = find_debuginfo_in_path (mod, canon,
- debuglink_file, debuglink_crc,
diff --git a/main/elfutils/musl-fts-obstack.patch b/main/elfutils/musl-fts-obstack.patch
new file mode 100644
index 0000000000..8d45854e66
--- /dev/null
+++ b/main/elfutils/musl-fts-obstack.patch
@@ -0,0 +1,87 @@
+--- a/configure.ac 2015-10-15 15:16:57.000000000 +0200
++++ b/configure.ac 2015-11-20 05:32:57.723901582 +0100
+@@ -305,6 +305,62 @@
+ fi
+ AC_SUBST([argp_LDADD])
+
++dnl Check if we have fts available from our libc
++AC_LINK_IFELSE(
++ [AC_LANG_PROGRAM(
++ [#if !defined(__x86_64__)
++ #undef _FILE_OFFSET_BITS
++ #define _FILE_OFFSET_BITS 32
++ #endif
++ #include <fts.h>],
++ [FTS* fts = 0; return fts_close(fts); return 0;]
++ )],
++ [libc_has_fts="true"],
++ [libc_has_fts="false"]
++)
++
++dnl If our libc doesn't provide fts, then test for libfts
++if test "$libc_has_fts" = "false" ; then
++ AC_MSG_WARN("libc does not have fts")
++ AC_CHECK_LIB([fts], [fts_close], [have_fts="true"], [have_fts="false"])
++
++ if test "$have_fts" = "false"; then
++ AC_MSG_ERROR("no libfts found")
++ else
++ fts_LDADD="-lfts"
++ fi
++else
++ fts_LDADD=""
++fi
++AC_SUBST([fts_LDADD])
++
++dnl Check if we have obstack available from our libc
++AC_LINK_IFELSE(
++ [AC_LANG_PROGRAM(
++ [#include <obstack.h>],
++ [_obstack_begin(0, 0, 0, NULL, NULL); return 0;]
++ )],
++ [libc_has_obstack="true"],
++ [libc_has_obstack="false"]
++)
++
++dnl If our libc doesn't provide obstack, then test for libobstack
++if test "$libc_has_obstack" = "false" ; then
++ AC_MSG_WARN("libc does not have obstack")
++ AC_CHECK_LIB([obstack], [_obstack_begin], [have_obstack="true"], [have_obstack="false"])
++
++ if test "$have_obstack" = "false"; then
++ AC_MSG_ERROR("no libobstack found")
++ else
++ obstack_LDADD="-lobstack"
++ fi
++else
++ obstack_LDADD=""
++fi
++AC_SUBST([obstack_LDADD])
++
++dnl The directories with content.
++
+ dnl The directories with content.
+
+ dnl Documentation.
+--- a/src/Makefile.am.orig
++++ b/src/Makefile.am
+@@ -46,7 +46,7 @@
+ else
+ libasm = ../libasm/libasm.so
+ libdw = ../libdw/libdw.so
+-libelf = ../libelf/libelf.so
++libelf = ../libelf/libelf.so $(fts_LDADD) $(obstack_LDADD)
+ endif
+ libebl = ../libebl/libebl.a
+ libeu = ../lib/libeu.a
+--- a/libdw/Makefile.am.orig
++++ b/libdw/Makefile.am
+@@ -109,7 +109,7 @@
+ ../libcpu/libcpu_pic.a libdw_pic.a ../libdwelf/libdwelf_pic.a \
+ ../libdwfl/libdwfl_pic.a
+ libdw_so_DEPS = ../lib/libeu.a ../libelf/libelf.so
+-libdw_so_LDLIBS = $(libdw_so_DEPS) -ldl -lz $(argp_LDADD) $(zip_LIBS) -pthread
++libdw_so_LDLIBS = $(libdw_so_DEPS) -ldl -lz $(argp_LDADD) $(fts_LDADD) $(obstack_LDADD) $(zip_LIBS) -pthread
+ libdw_so_SOURCES =
+ libdw.so$(EXEEXT): $(srcdir)/libdw.map $(libdw_so_LIBS) $(libdw_so_DEPS)
+ $(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $@ \
diff --git a/main/elfutils/musl-macros.patch b/main/elfutils/musl-macros.patch
index 5900bdd764..0d7ec4155e 100644
--- a/main/elfutils/musl-macros.patch
+++ b/main/elfutils/musl-macros.patch
@@ -66,3 +66,22 @@ index 69fe3d7..e5c99b8 100644
extern void *xmalloc (size_t) __attribute__ ((__malloc__));
extern void *xcalloc (size_t, size_t) __attribute__ ((__malloc__));
+diff --git a/src/strip.c b/src/strip.c
+index 48792a7..d2f0c60 100644
+--- a/src/strip.c
++++ b/src/strip.c
+@@ -46,6 +46,14 @@
+ #include <system.h>
+ #include <printversion.h>
+
++#if !defined(FNM_EXTMATCH)
++# define FNM_EXTMATCH 0
++#endif
++
++#if !defined(ACCESSPERMS)
++#define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO)
++#endif
++
+ typedef uint8_t GElf_Byte;
+
+ /* Name and version of program. */
diff --git a/main/elfutils/musl-qsort_r.patch b/main/elfutils/musl-qsort_r.patch
index e1455baf69..0843aec648 100644
--- a/main/elfutils/musl-qsort_r.patch
+++ b/main/elfutils/musl-qsort_r.patch
@@ -1,7 +1,9 @@
---- a/src/readelf.c 2015-10-12 12:22:58.000000000 +0200
-+++ b/src/readelf.c 2015-11-20 08:11:32.945159213 +0100
-@@ -4366,10 +4366,11 @@
- return base;
+diff --git a/src/readelf.c b/src/readelf.c
+index cbb519d..dea513b 100644
+--- a/src/readelf.c
++++ b/src/readelf.c
+@@ -4829,10 +4829,11 @@ listptr_base (struct listptr *p)
+ return cudie_base (&cu);
}
+static const char *listptr_name;
@@ -14,7 +16,7 @@
struct listptr *p1 = (void *) a;
struct listptr *p2 = (void *) b;
-@@ -4385,21 +4386,21 @@
+@@ -4848,21 +4849,21 @@ compare_listptr (const void *a, const void *b, void *arg)
p1->warned = p2->warned = true;
error (0, 0,
gettext ("%s %#" PRIx64 " used with different address sizes"),
@@ -37,9 +39,18 @@
- name, (uint64_t) p1->offset);
+ listptr_name, (uint64_t) p1->offset);
}
+ if (p1->attr != p2 ->attr)
+ {
+@@ -4870,7 +4871,7 @@ compare_listptr (const void *a, const void *b, void *arg)
+ error (0, 0,
+ gettext ("%s %#" PRIx64
+ " used with different attribute %s and %s"),
+- name, (uint64_t) p1->offset, dwarf_attr_name (p2->attr),
++ listptr_name, (uint64_t) p1->offset, dwarf_attr_name (p2->attr),
+ dwarf_attr_name (p2->attr));
+ }
}
-
-@@ -4464,9 +4465,11 @@
+@@ -4941,9 +4942,11 @@ notice_listptr (enum section_e section, struct listptr_table *table,
static void
sort_listptr (struct listptr_table *table, const char *name)
{
diff --git a/main/elfutils/musl-strndupa.patch b/main/elfutils/musl-strndupa.patch
new file mode 100644
index 0000000000..a5206885d1
--- /dev/null
+++ b/main/elfutils/musl-strndupa.patch
@@ -0,0 +1,18 @@
+--- a/src/unstrip.c.orig 2017-04-27 14:26:26.000000000 +0000
++++ b/src/unstrip.c 2017-05-05 15:51:33.515154220 +0000
+@@ -56,6 +56,15 @@
+ # define _(str) gettext (str)
+ #endif
+
++#ifndef strndupa
++#define strndupa(s, n) \
++ (__extension__ ({const char *__in = (s); \
++ size_t __len = strnlen (__in, (n)) + 1; \
++ char *__out = (char *) alloca (__len); \
++ __out[__len-1] = '\0'; \
++ (char *) memcpy (__out, __in, __len-1);}))
++#endif
++
+ /* Name and version of program. */
+ ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;
+
diff --git a/main/elfutils/no-werror.patch b/main/elfutils/no-werror.patch
deleted file mode 100644
index ddf963244a..0000000000
--- a/main/elfutils/no-werror.patch
+++ /dev/null
@@ -1,32 +0,0 @@
-diff --git a/config/eu.am b/config/eu.am
-index 8fe1e25..afeb095 100644
---- a/config/eu.am
-+++ b/config/eu.am
-@@ -71,7 +71,7 @@ AM_CFLAGS = -std=gnu99 -Wall -Wshadow -Wformat=2 \
- -Wold-style-definition -Wstrict-prototypes \
- $(LOGICAL_OP_WARNING) $(DUPLICATED_COND_WARNING) \
- $(NULL_DEREFERENCE_WARNING) $(IMPLICIT_FALLTHROUGH_WARNING) \
-- $(if $($(*F)_no_Werror),,-Werror) \
-+ $(if $($(*F)_no_Werror),,$(WERROR)) \
- $(if $($(*F)_no_Wunused),,-Wunused -Wextra) \
- $(if $($(*F)_no_Wstack_usage),,$(STACK_USAGE_WARNING)) \
- $($(*F)_CFLAGS)
-diff --git a/configure.ac b/configure.ac
-index 4549906..6a74a06 100644
---- a/configure.ac
-+++ b/configure.ac
-@@ -57,6 +57,14 @@ AC_CONFIG_FILES([elfutils.spec:config/elfutils.spec.in])
-
- AC_CANONICAL_HOST
-
-+AC_ARG_ENABLE(werror,
-+[AS_HELP_STRING([--disable-werror],
-+ [turn off -Werror @<:@default=enabled@:>@])])
-+if test "x$enable_werror" != "xno"; then
-+ WERROR="-Werror"
-+fi
-+AC_SUBST(WERROR)
-+
- AC_ARG_ENABLE(deterministic-archives,
- [AS_HELP_STRING([--enable-deterministic-archives],
- [ar and ranlib default to -D behavior])], [