Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] Update elfutils to 0.182.
@ 2020-11-02  1:56 ericonr
  2020-11-02  1:58 ` [PR PATCH] [Updated] " ericonr
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: ericonr @ 2020-11-02  1:56 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 369 bytes --]

There is a new pull request by ericonr against master on the void-packages repository

https://github.com/ericonr/void-packages debuginfod
https://github.com/void-linux/void-packages/pull/26067

Update elfutils to 0.182.
Also create the debuginfod subpackage and use it in gdb.

A patch file from https://github.com/void-linux/void-packages/pull/26067.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-debuginfod-26067.patch --]
[-- Type: text/x-diff, Size: 30895 bytes --]

From e652bf4916435a4760c393b905b57346fa08648b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
Date: Sun, 25 Oct 2020 18:57:17 -0300
Subject: [PATCH 1/2] elfutils: update to 0.182, add debuginfod subpkgs, update
 patches.

---
 common/shlibs                                 |   1 +
 srcpkgs/debuginfod                            |   1 +
 srcpkgs/elfutils/patches/debuginfod.patch     |  13 +
 .../elfutils/patches/fix-aarch64_fregs.patch  |  22 +-
 .../elfutils/patches/fix-uninitialized.patch  |  11 -
 srcpkgs/elfutils/patches/fts-obstack.patch    | 107 ++++++
 srcpkgs/elfutils/patches/musl-cdefs.patch     |  30 --
 .../elfutils/patches/musl-fts-obstack.patch   |  87 -----
 srcpkgs/elfutils/patches/musl-macros.patch    | 339 +++++++++++++++---
 srcpkgs/elfutils/patches/musl-strndupa.patch  |  18 -
 srcpkgs/elfutils/template                     |  34 +-
 srcpkgs/libdebuginfod                         |   1 +
 12 files changed, 449 insertions(+), 215 deletions(-)
 create mode 120000 srcpkgs/debuginfod
 create mode 100644 srcpkgs/elfutils/patches/debuginfod.patch
 delete mode 100644 srcpkgs/elfutils/patches/fix-uninitialized.patch
 create mode 100644 srcpkgs/elfutils/patches/fts-obstack.patch
 delete mode 100644 srcpkgs/elfutils/patches/musl-cdefs.patch
 delete mode 100644 srcpkgs/elfutils/patches/musl-fts-obstack.patch
 delete mode 100644 srcpkgs/elfutils/patches/musl-strndupa.patch
 create mode 120000 srcpkgs/libdebuginfod

diff --git a/common/shlibs b/common/shlibs
index e0e75cea1b4..30cc8236b86 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -736,6 +736,7 @@ libmtp.so.9 libmtp-1.1.4_1
 libelf.so.1 libelf-0.155_1
 libdw.so.1 libelf-0.155_1
 libasm.so.1 libelf-0.155_1
+libdebuginfod.so.1 libdebuginfod-0.181_2
 libgtksourceview-3.0.so.1 gtksourceview-3.8.0_1
 libtalloc.so.2 talloc-2.0.1_1
 libmount.so.1 libmount-2.18_1
diff --git a/srcpkgs/debuginfod b/srcpkgs/debuginfod
new file mode 120000
index 00000000000..b76b36cfac4
--- /dev/null
+++ b/srcpkgs/debuginfod
@@ -0,0 +1 @@
+elfutils
\ No newline at end of file
diff --git a/srcpkgs/elfutils/patches/debuginfod.patch b/srcpkgs/elfutils/patches/debuginfod.patch
new file mode 100644
index 00000000000..d26d945d1ff
--- /dev/null
+++ b/srcpkgs/elfutils/patches/debuginfod.patch
@@ -0,0 +1,13 @@
+diff --git debuginfod/debuginfod.cxx debuginfod/debuginfod.cxx
+index 3085f388..d2a434ee 100644
+--- debuginfod/debuginfod.cxx
++++ debuginfod/debuginfod.cxx
+@@ -46,7 +46,7 @@ extern "C" {
+ #include <unistd.h>
+ #include <stdlib.h>
+ #include <error.h>
+-// #include <libintl.h> // not until it supports C++ << better
++#include <libintl.h>
+ #include <locale.h>
+ #include <pthread.h>
+ #include <signal.h>
diff --git a/srcpkgs/elfutils/patches/fix-aarch64_fregs.patch b/srcpkgs/elfutils/patches/fix-aarch64_fregs.patch
index e9641542144..070d2527656 100644
--- a/srcpkgs/elfutils/patches/fix-aarch64_fregs.patch
+++ b/srcpkgs/elfutils/patches/fix-aarch64_fregs.patch
@@ -1,14 +1,22 @@
-It looks like fregs.vregs[] is an array of double?
-Casting to Dwarf_Word instead of & 0xFFFFFFF should do.
-
---- backends/aarch64_initreg.c	2015-11-27 14:36:29.000000000 +0100
-+++ backends/aarch64_initreg.c	2016-08-09 03:47:25.428560159 +0200
-@@ -82,7 +83,7 @@
+diff --git backends/aarch64_initreg.c backends/aarch64_initreg.c
+index daf6f375..02ca1dc0 100644
+--- backends/aarch64_initreg.c
++++ backends/aarch64_initreg.c
+@@ -46,6 +46,8 @@
+ #define BACKEND aarch64_
+ #include "libebl_CPU.h"
+ 
++#include <string.h>
++
+ bool
+ aarch64_set_initial_registers_tid (pid_t tid __attribute__ ((unused)),
+ 			  ebl_tid_registers_t *setfunc __attribute__ ((unused)),
+@@ -82,7 +84,7 @@ aarch64_set_initial_registers_tid (pid_t tid __attribute__ ((unused)),
  
    Dwarf_Word dwarf_fregs[32];
    for (int r = 0; r < 32; r++)
 -    dwarf_fregs[r] = fregs.vregs[r] & 0xFFFFFFFF;
-+    dwarf_fregs[r] = (Dwarf_Word)fregs.vregs[r];
++    memcpy(dwarf_fregs + r, fregs.vregs + r, sizeof(dwarf_fregs[0]));
  
    if (! setfunc (64, 32, dwarf_fregs, arg))
      return false;
diff --git a/srcpkgs/elfutils/patches/fix-uninitialized.patch b/srcpkgs/elfutils/patches/fix-uninitialized.patch
deleted file mode 100644
index 6ab15e50e2b..00000000000
--- a/srcpkgs/elfutils/patches/fix-uninitialized.patch
+++ /dev/null
@@ -1,11 +0,0 @@
-
---- libcpu/i386_disasm.c	2015-08-21 14:22:37.000000000 +0200
-+++ libcpu/i386_disasm.c	2015-11-20 06:30:59.250629957 +0100
-@@ -710,6 +710,7 @@
- 
- 		case 'm':
- 		  /* Mnemonic.  */
-+		  str = mnebuf;
- 
- 		  if (unlikely (instrtab[cnt].mnemonic == MNE_INVALID))
- 		    {
diff --git a/srcpkgs/elfutils/patches/fts-obstack.patch b/srcpkgs/elfutils/patches/fts-obstack.patch
new file mode 100644
index 00000000000..44ef0aee70e
--- /dev/null
+++ b/srcpkgs/elfutils/patches/fts-obstack.patch
@@ -0,0 +1,107 @@
+diff --git ChangeLog ChangeLog
+index 128da6c6..565d021c 100644
+--- ChangeLog
++++ ChangeLog
+@@ -1,3 +1,7 @@
++2020-11-01  Érico N. Rolim  <erico.erc@gmail.com>
++
++	* configure.ac: Check for fts and obstack from outside libc.
++
+ 2020-10-28  Mark Wielaard  <mark@klomp.org>
+ 
+ 	* configure.ac: Set version to 0.182.
+diff --git configure.ac configure.ac
+index 515ac704..c1a6954d 100644
+--- configure.ac
++++ configure.ac
+@@ -542,6 +542,26 @@ else
+ fi
+ AC_SUBST([argp_LDADD])
+ 
++saved_LIBS="$LIBS"
++AC_SEARCH_LIBS([fts_close], [fts])
++LIBS="$saved_LIBS"
++case "$ac_cv_search_fts_close" in
++        no) AC_MSG_FAILURE([failed to find fts_close]) ;;
++        -l*) fts_LIBS="$ac_cv_search_fts_close" ;;
++        *) fts_LIBS= ;;
++esac
++AC_SUBST([fts_LIBS])
++
++saved_LIBS="$LIBS"
++AC_SEARCH_LIBS([_obstack_free], [obstack])
++LIBS="$saved_LIBS"
++case "$ac_cv_search__obstack_free" in
++        no) AC_MSG_FAILURE([failed to find obstack_free]) ;;
++        -l*) obstack_LIBS="$ac_cv_search__obstack_free" ;;
++        *) obstack_LIBS= ;;
++esac
++AC_SUBST([obstack_LIBS])
++
+ dnl The directories with content.
+ 
+ dnl Documentation.
+diff --git debuginfod/Makefile.am debuginfod/Makefile.am
+index 01985600..0af3b58c 100644
+--- debuginfod/Makefile.am
++++ debuginfod/Makefile.am
+@@ -71,10 +71,10 @@ bin_PROGRAMS += debuginfod-find
+ endif
+ 
+ debuginfod_SOURCES = debuginfod.cxx
+-debuginfod_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod) $(libmicrohttpd_LIBS) $(sqlite3_LIBS) $(libarchive_LIBS) -lpthread -ldl
++debuginfod_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod) $(argp_LDADD) $(fts_LIBS) $(libmicrohttpd_LIBS) $(sqlite3_LIBS) $(libarchive_LIBS) -lpthread -ldl
+ 
+ debuginfod_find_SOURCES = debuginfod-find.c
+-debuginfod_find_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod)
++debuginfod_find_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod) $(argp_LDADD) $(fts_LIBS)
+ 
+ if LIBDEBUGINFOD
+ noinst_LIBRARIES = libdebuginfod.a
+@@ -98,7 +98,7 @@ libdebuginfod_so_LIBS = libdebuginfod_pic.a
+ if DUMMY_LIBDEBUGINFOD
+ libdebuginfod_so_LDLIBS =
+ else
+-libdebuginfod_so_LDLIBS = $(libcurl_LIBS)
++libdebuginfod_so_LDLIBS = $(libcurl_LIBS) $(fts_LIBS)
+ endif
+ libdebuginfod.so$(EXEEXT): $(srcdir)/libdebuginfod.map $(libdebuginfod_so_LIBS)
+ 	$(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $@ \
+diff --git libdw/Makefile.am libdw/Makefile.am
+index 33b5838d..1dbb3d5e 100644
+--- libdw/Makefile.am
++++ libdw/Makefile.am
+@@ -109,7 +109,7 @@ libdw_so_LIBS = ../libebl/libebl_pic.a ../backends/libebl_backends_pic.a \
+ 		../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_LIBS) $(obstack_LIBS) $(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 src/Makefile.am src/Makefile.am
+index e462e7d7..88d0ac8f 100644
+--- src/Makefile.am
++++ src/Makefile.am
+@@ -69,7 +69,7 @@ ar_no_Wstack_usage = yes
+ unstrip_no_Wstack_usage = yes
+ 
+ readelf_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD)
+-nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) \
++nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) $(obstack_LIBS) \
+ 	   $(demanglelib)
+ size_LDADD = $(libelf) $(libeu) $(argp_LDADD)
+ strip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
+@@ -78,9 +78,9 @@ findtextrel_LDADD = $(libdw) $(libelf) $(libeu) $(argp_LDADD)
+ addr2line_LDADD = $(libdw) $(libelf) $(libeu) $(argp_LDADD) $(demanglelib)
+ elfcmp_LDADD = $(libebl) $(libdw) $(libelf) $(libeu) $(argp_LDADD)
+ objdump_LDADD  = $(libasm) $(libebl) $(libdw) $(libelf) $(libeu) $(argp_LDADD)
+-ranlib_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD)
++ranlib_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD) $(obstack_LIBS)
+ strings_LDADD = $(libelf) $(libeu) $(argp_LDADD)
+-ar_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD)
++ar_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD) $(obstack_LIBS)
+ unstrip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
+ stack_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) $(demanglelib)
+ elfcompress_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
diff --git a/srcpkgs/elfutils/patches/musl-cdefs.patch b/srcpkgs/elfutils/patches/musl-cdefs.patch
deleted file mode 100644
index 65ef9f4d23c..00000000000
--- a/srcpkgs/elfutils/patches/musl-cdefs.patch
+++ /dev/null
@@ -1,30 +0,0 @@
---- libelf/elf.h	2015-08-21 14:22:37.000000000 +0200
-+++ libelf/elf.h	2015-11-20 04:54:33.948081321 +0100
-@@ -21,6 +21,17 @@
- 
- #include <features.h>
- 
-+#if !defined(__BEGIN_DECLS)
-+/* C++ needs to know that types and declarations are C, not C++.  */
-+#ifdef  __cplusplus
-+# define __BEGIN_DECLS  extern "C" {
-+# define __END_DECLS    }
-+#else
-+# define __BEGIN_DECLS
-+# define __END_DECLS
-+#endif
-+#endif
-+
- __BEGIN_DECLS
- 
- /* Standard ELF types.  */
---- lib/fixedsizehash.h.orig
-+++ lib/fixedsizehash.h
-@@ -30,7 +30,6 @@
- #include <errno.h>
- #include <stdlib.h>
- #include <string.h>
--#include <sys/cdefs.h>
- 
- #include <system.h>
- 
diff --git a/srcpkgs/elfutils/patches/musl-fts-obstack.patch b/srcpkgs/elfutils/patches/musl-fts-obstack.patch
deleted file mode 100644
index 77e3c4ea040..00000000000
--- a/srcpkgs/elfutils/patches/musl-fts-obstack.patch
+++ /dev/null
@@ -1,87 +0,0 @@
---- configure.ac	2015-10-15 15:16:57.000000000 +0200
-+++ 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.
---- src/Makefile.am.orig
-+++ 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
---- libdw/Makefile.am.orig
-+++ 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/srcpkgs/elfutils/patches/musl-macros.patch b/srcpkgs/elfutils/patches/musl-macros.patch
index 8ce586b2930..ff5d06efac0 100644
--- a/srcpkgs/elfutils/patches/musl-macros.patch
+++ b/srcpkgs/elfutils/patches/musl-macros.patch
@@ -1,66 +1,293 @@
---- src/arlib.h	2015-08-21 14:22:37.000000000 +0200
-+++ src/arlib.h	2015-11-20 08:02:55.153199611 +0100
-@@ -29,6 +29,16 @@
- #include <stdint.h>
- #include <sys/types.h>
- 
-+#if !defined(ACCESSPERMS)
-+# define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
-+#endif
-+#if !defined(ALLPERMS)
-+# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
-+#endif
-+#if !defined(DEFFILEMODE)
-+# define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)/* 0666*/
-+#endif
-+
+diff --git debuginfod/debuginfod-client.c debuginfod/debuginfod-client.c
+index 0e5177bc..ce1d819b 100644
+--- debuginfod/debuginfod-client.c
++++ debuginfod/debuginfod-client.c
+@@ -212,13 +212,13 @@ debuginfod_init_cache (char *cache_path, char *interval_path, char *maxage_path)
+     return 0;
  
- /* State of -D/-U flags.  */
- extern bool arlib_deterministic_output;
---- src/elfcompress.c.orig	2016-04-02 12:51:26.903848894 +0200
-+++ src/elfcompress.c	2016-04-02 12:55:15.076996338 +0200
-@@ -35,6 +35,14 @@
- #include <gelf.h>
- #include "system.h"
+   /* Create the cache and config files as necessary.  */
+-  if (stat(cache_path, &st) != 0 && mkdir(cache_path, 0777) < 0)
++  if (stat(cache_path, &st) != 0 && mkdir(cache_path, ACCESSPERMS) < 0)
+     return -errno;
  
-+#if !defined(FNM_EXTMATCH)
-+# define FNM_EXTMATCH 0
-+#endif
-+
-+#if !defined(ALLPERMS)
-+# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
+   int fd = -1;
+ 
+   /* init cleaning interval config file.  */
+-  fd = open(interval_path, O_CREAT | O_RDWR, 0666);
++  fd = open(interval_path, O_CREAT | O_RDWR, DEFFILEMODE);
+   if (fd < 0)
+     return -errno;
+ 
+@@ -227,7 +227,7 @@ debuginfod_init_cache (char *cache_path, char *interval_path, char *maxage_path)
+ 
+   /* init max age config file.  */
+   if (stat(maxage_path, &st) != 0
+-      && (fd = open(maxage_path, O_CREAT | O_RDWR, 0666)) < 0)
++      && (fd = open(maxage_path, O_CREAT | O_RDWR, DEFFILEMODE)) < 0)
+     return -errno;
+ 
+   if (dprintf(fd, "%ld", cache_default_max_unused_age_s) < 0)
+diff --git lib/system.h lib/system.h
+index 292082bd..5d16ebc6 100644
+--- lib/system.h
++++ lib/system.h
+@@ -85,6 +85,18 @@
+      __res; })
+ #endif
+ 
++#ifndef ACCESSPERMS
++#define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
 +#endif
 +
- /* Name and version of program.  */
- static void print_version (FILE *stream, struct argp_state *state);
- ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;
---- src/strip.c.orig	2017-08-02 12:06:25.000000000 +0000
-+++ src/strip.c	2017-08-05 01:58:01.523493062 +0000
-@@ -47,6 +47,14 @@
- #include <system.h>
- #include <printversion.h>
- 
-+#if !defined(FNM_EXTMATCH)
-+# define FNM_EXTMATCH 0
++#ifndef ALLPERMS
++#define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
 +#endif
 +
-+#if !defined(ACCESSPERMS)
-+#define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO)
++#ifndef DEFFILEMODE
++#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)/* DEFFILEMODE*/
 +#endif
 +
- typedef uint8_t GElf_Byte;
+ static inline ssize_t __attribute__ ((unused))
+ pwrite_retry (int fd, const void *buf, size_t len, off_t off)
+ {
+diff --git src/unstrip.c src/unstrip.c
+index 0257d9cc..c99ee612 100644
+--- src/unstrip.c
++++ src/unstrip.c
+@@ -315,7 +315,7 @@ make_directories (const char *path)
+   if (dir == NULL)
+     error(EXIT_FAILURE, errno, _("memory exhausted"));
  
- /* Name and version of program.  */
---- tests/elfstrmerge.c.orig	2020-09-13 08:20:50.538492600 +0700
-+++ tests/elfstrmerge.c	2020-09-13 08:21:40.205734827 +0700
-@@ -33,6 +33,10 @@
- #include ELFUTILS_HEADER(dwelf)
- #include "elf-knowledge.h"
+-  while (mkdir (dir, 0777) < 0 && errno != EEXIST)
++  while (mkdir (dir, ACCESSPERMS) < 0 && errno != EEXIST)
+     {
+       if (errno == ENOENT)
+         make_directories (dir);
+@@ -2192,7 +2192,7 @@ DWARF data in '%s' not adjusted for prelinking bias; consider prelink -u"),
  
-+#if !defined(ALLPERMS)
-+# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
-+#endif
-+
- /* The original ELF file.  */
- static int fd = -1;
- static Elf *elf = NULL;
+       /* Copy the unstripped file and then modify it.  */
+       int outfd = open (output_file, O_RDWR | O_CREAT,
+-			  stripped_ehdr->e_type == ET_REL ? 0666 : 0777);
++			  stripped_ehdr->e_type == ET_REL ? DEFFILEMODE : ACCESSPERMS);
+       if (outfd < 0)
+ 	error (EXIT_FAILURE, errno, _("cannot open '%s'"), output_file);
+       Elf *outelf = elf_begin (outfd, ELF_C_WRITE, NULL);
+diff --git tests/alldts.c tests/alldts.c
+index 28b3063c..b88a3e61 100644
+--- tests/alldts.c
++++ tests/alldts.c
+@@ -68,7 +68,7 @@ main (void)
+   (void) __fsetlocking (stdout, FSETLOCKING_BYCALLER);
+ 
+   /* Open the file.  */
+-  int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
++  int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s': %m\n", fname);
+diff --git tests/arextract.c tests/arextract.c
+index 2c4dc758..936d7f55 100644
+--- tests/arextract.c
++++ tests/arextract.c
+@@ -95,7 +95,7 @@ Failed to get base address for the archive element: %s\n",
+ 	    }
+ 
+ 	  /* Open the output file.  */
+-	  outfd = open (argv[3], O_CREAT | O_TRUNC | O_RDWR, 0666);
++	  outfd = open (argv[3], O_CREAT | O_TRUNC | O_RDWR, DEFFILEMODE);
+ 	  if (outfd == -1)
+ 	    {
+ 	      printf ("cannot open output file: %m");
+diff --git tests/ecp.c tests/ecp.c
+index 1df40a32..44a7bda2 100644
+--- tests/ecp.c
++++ tests/ecp.c
+@@ -43,7 +43,7 @@ main (int argc, char *argv[])
+     error (EXIT_FAILURE, 0, "problems opening '%s' as ELF file: %s",
+ 	   argv[1], elf_errmsg (-1));
+ 
+-  int outfd = creat (argv[2], 0666);
++  int outfd = creat (argv[2], DEFFILEMODE);
+   if (outfd == -1)
+     error (EXIT_FAILURE, errno, "cannot open output file '%s'", argv[2]);
+ 
+diff --git tests/elfstrtab.c tests/elfstrtab.c
+index c27d6cfb..9866237c 100644
+--- tests/elfstrtab.c
++++ tests/elfstrtab.c
+@@ -134,7 +134,7 @@ check_elf (const char *fname, int class, int use_mmap)
+   printf ("\nfname: %s\n", fname);
+   stridx = 0;
+ 
+-  int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
++  int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s': %s\n", fname, strerror (errno));
+@@ -280,7 +280,7 @@ check_elf (const char *fname, int class, int use_mmap)
+   close (fd);
+ 
+   /* Read the ELF from disk now.  */
+-  fd = open (fname, O_RDWR, 0666);
++  fd = open (fname, O_RDWR, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s' read-only: %s\n", fname, strerror (errno));
+@@ -349,7 +349,7 @@ check_elf (const char *fname, int class, int use_mmap)
+   close (fd);
+ 
+   // And read it in one last time.
+-  fd = open (fname, O_RDONLY, 0666);
++  fd = open (fname, O_RDONLY, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s' read-only: %s\n", fname, strerror (errno));
+diff --git tests/emptyfile.c tests/emptyfile.c
+index 6d086246..18036ebe 100644
+--- tests/emptyfile.c
++++ tests/emptyfile.c
+@@ -67,7 +67,7 @@ check_elf (const char *fname, int class, int use_mmap)
+   printf ("\nfname: %s\n", fname);
+   stridx = 0; // Reset strtab strings index
+ 
+-  int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
++  int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s': %s\n", fname, strerror (errno));
+@@ -125,7 +125,7 @@ check_elf (const char *fname, int class, int use_mmap)
+   close (fd);
+ 
+   /* Reread the ELF from disk now.  */
+-  fd = open (fname, O_RDWR, 0666);
++  fd = open (fname, O_RDWR, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot (re)open `%s': %s\n", fname, strerror (errno));
+@@ -208,7 +208,7 @@ check_elf (const char *fname, int class, int use_mmap)
+   close (fd);
+ 
+   // And read it in one last time.
+-  fd = open (fname, O_RDONLY, 0666);
++  fd = open (fname, O_RDONLY, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s' read-only: %s\n", fname, strerror (errno));
+diff --git tests/fillfile.c tests/fillfile.c
+index 915e249d..96f2b0f9 100644
+--- tests/fillfile.c
++++ tests/fillfile.c
+@@ -201,7 +201,7 @@ check_elf (const char *fname, int class, int use_mmap)
+   printf ("\nfname: %s\n", fname);
+   stridx = 0; // Reset strtab strings index
+ 
+-  int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
++  int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s': %s\n", fname, strerror (errno));
+@@ -266,7 +266,7 @@ check_elf (const char *fname, int class, int use_mmap)
+ 
+   /* Reread the ELF from disk now.  */
+   printf ("Rereading %s\n", fname);
+-  fd = open (fname, O_RDWR, 0666);
++  fd = open (fname, O_RDWR, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot (re)open `%s': %s\n", fname, strerror (errno));
+@@ -347,7 +347,7 @@ check_elf (const char *fname, int class, int use_mmap)
+ 
+   // And read it in one last time.
+   printf ("Rereading %s again\n", fname);
+-  fd = open (fname, O_RDONLY, 0666);
++  fd = open (fname, O_RDONLY, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s' read-only: %s\n", fname, strerror (errno));
+diff --git tests/newdata.c tests/newdata.c
+index 9af99564..5a512109 100644
+--- tests/newdata.c
++++ tests/newdata.c
+@@ -243,7 +243,7 @@ check_elf (int class, int use_mmap)
+ 
+   printf ("\ncheck_elf: %s\n", fname);
+ 
+-  int fd = open (fname, O_RDWR|O_CREAT|O_TRUNC, 00666);
++  int fd = open (fname, O_RDWR|O_CREAT|O_TRUNC, 0DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot create `%s': %s\n", fname, strerror (errno));
+diff --git tests/update1.c tests/update1.c
+index f4c14753..e2370936 100644
+--- tests/update1.c
++++ tests/update1.c
+@@ -38,7 +38,7 @@ main (int argc, char *argv[] __attribute__ ((unused)))
+   Elf32_Ehdr *ehdr;
+   int i;
+ 
+-  fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
++  fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s': %s\n", fname, strerror (errno));
+diff --git tests/update2.c tests/update2.c
+index 5805163d..14a62cfa 100644
+--- tests/update2.c
++++ tests/update2.c
+@@ -39,7 +39,7 @@ main (int argc, char *argv[] __attribute__ ((unused)))
+   Elf32_Phdr *phdr;
+   int i;
+ 
+-  fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
++  fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s': %s\n", fname, strerror (errno));
+diff --git tests/update3.c tests/update3.c
+index 7a4224dd..f7c8c28b 100644
+--- tests/update3.c
++++ tests/update3.c
+@@ -46,7 +46,7 @@ main (int argc, char *argv[] __attribute__ ((unused)))
+   Dwelf_Strent *shstrtabse;
+   int i;
+ 
+-  fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
++  fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s': %s\n", fname, strerror (errno));
+diff --git tests/update4.c tests/update4.c
+index a9bd4bf9..45153d73 100644
+--- tests/update4.c
++++ tests/update4.c
+@@ -50,7 +50,7 @@ main (int argc, char *argv[] __attribute__ ((unused)))
+   Dwelf_Strent *shstrtabse;
+   int i;
+ 
+-  fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
++  fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s': %s\n", fname, strerror (errno));
+diff --git tests/vendorelf.c tests/vendorelf.c
+index bc13cce3..23f59af5 100644
+--- tests/vendorelf.c
++++ tests/vendorelf.c
+@@ -36,7 +36,7 @@ check_elf (const char *fname, int class, int use_mmap)
+ {
+   printf ("\nfname: %s\n", fname);
+ 
+-  int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
++  int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s': %s\n", fname, strerror (errno));
+@@ -124,7 +124,7 @@ check_elf (const char *fname, int class, int use_mmap)
+   close (fd);
+ 
+   /* Reread the ELF from disk now.  */
+-  fd = open (fname, O_RDONLY, 0666);
++  fd = open (fname, O_RDONLY, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s' read-only: %s\n", fname, strerror (errno));
diff --git a/srcpkgs/elfutils/patches/musl-strndupa.patch b/srcpkgs/elfutils/patches/musl-strndupa.patch
deleted file mode 100644
index f365fb019f2..00000000000
--- a/srcpkgs/elfutils/patches/musl-strndupa.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- src/unstrip.c.orig	2017-04-27 14:26:26.000000000 +0000
-+++ 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/srcpkgs/elfutils/template b/srcpkgs/elfutils/template
index 02e6e20c64b..f74d15691a3 100644
--- a/srcpkgs/elfutils/template
+++ b/srcpkgs/elfutils/template
@@ -1,22 +1,26 @@
 # Template file for 'elfutils'
 pkgname=elfutils
-version=0.181
+version=0.182
 revision=1
 build_style=gnu-configure
-configure_args="--program-prefix=eu- --disable-debuginfod --disable-libdebuginfod"
+configure_args="--program-prefix=eu-"
 hostmakedepends="automake libtool pkg-config"
-makedepends="bzip2-devel liblzma-devel zlib-devel"
+makedepends="bzip2-devel liblzma-devel zlib-devel
+ libcurl-devel libarchive-devel sqlite-devel libmicrohttpd-devel"
 short_desc="Utilities to handle ELF object files"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://sourceware.org/elfutils/"
 distfiles="https://sourceware.org/${pkgname}/ftp/${version}/${pkgname}-${version}.tar.bz2"
-checksum=29a6ad7421ec2acfee489bb4a699908281ead2cb63a20a027ce8804a165f0eb3
+checksum=ecc406914edf335f0b7fc084ebe6c460c4d6d5175bfdd6688c1c78d9146b8858
 
 CFLAGS="-Wno-error"
+CXXFLAGS="-Wl,-z,stack-size=2097152"
 
 if [ "$XBPS_TARGET_LIBC" = musl ]; then
-	makedepends+=" argp-standalone musl-fts-devel musl-obstack-devel"
+	makedepends+=" argp-standalone musl-fts-devel musl-obstack-devel musl-legacy-compat"
+	# XXX: breaks some expected functionality
+	CFLAGS+=" -DFNM_EXTMATCH=0"
 fi
 
 post_extract() {
@@ -30,6 +34,22 @@ pre_configure() {
 	autoreconf -if
 }
 
+libdebuginfod_package() {
+	short_desc+=" - debuginfod library"
+	pkg_install() {
+		vmove "usr/lib/libdebuginfod-*.so*"
+	}
+}
+
+debuginfod_package() {
+	short_desc+=" - debuginfod programs"
+	pkg_install() {
+		vmove "usr/bin/debuginfod*"
+		vmove "usr/share/man/man1/debuginfod-find.1"
+		vmove "usr/share/man/man8/debuginfod.8"
+	}
+}
+
 libelf_package() {
 	short_desc+=" - runtime library"
 	pkg_install() {
@@ -38,11 +58,13 @@ libelf_package() {
 }
 
 elfutils-devel_package() {
-	depends="libelf>=${version}_${revision} ${makedepends}"
+	depends="libelf>=${version}_${revision} libdebuginfod>=${version}_${revision}
+	 ${makedepends}"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig
 		vmove "usr/lib/*.a"
+		vmove usr/share/man/man3
 	}
 }
diff --git a/srcpkgs/libdebuginfod b/srcpkgs/libdebuginfod
new file mode 120000
index 00000000000..b76b36cfac4
--- /dev/null
+++ b/srcpkgs/libdebuginfod
@@ -0,0 +1 @@
+elfutils
\ No newline at end of file

From 2da2188ef4350e74e23434d28749346230b0748e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
Date: Sun, 25 Oct 2020 18:23:45 -0300
Subject: [PATCH 2/2] gdb: add debuginfod option, enable by default.

---
 srcpkgs/gdb/template | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/srcpkgs/gdb/template b/srcpkgs/gdb/template
index 0e2e399e798..d18b93af9c4 100644
--- a/srcpkgs/gdb/template
+++ b/srcpkgs/gdb/template
@@ -7,10 +7,12 @@ pycompile_dirs="/usr/share/gdb/python"
 configure_args="--disable-werror --disable-nls --with-system-readline
  --with-system-gdbinit=/etc/gdb/gdbinit --with-system-zlib $(vopt_enable gdbserver)
  $(vopt_if static 'CFLAGS=-static CXXFLAGS=-static LDFLAGS=-static')
- $(vopt_if python --with-python=/usr/bin/python3)"
-hostmakedepends="texinfo perl $(vopt_if python python3-devel)"
+ $(vopt_if python --with-python=/usr/bin/python3)
+ $(vopt_with debuginfod)"
+hostmakedepends="texinfo perl pkg-config $(vopt_if python python3-devel)"
 makedepends="ncurses-devel zlib-devel readline-devel expat-devel
- $(vopt_if python 'python3-devel gettext-libs')"
+ $(vopt_if python 'python3-devel gettext-libs')
+ $(vopt_if debuginfod elfutils-devel)"
 short_desc="GNU Debugger"
 maintainer="Anthony Iliopoulos <ailiop@altatus.com>"
 license="GPL-3.0-or-later"
@@ -28,10 +30,11 @@ fi
 CFLAGS+=" -fcommon"
 CXXFLAGS+=" -fcommon"
 # Package build options
-build_options="gdbserver static python"
+build_options="gdbserver static python debuginfod"
 desc_option_gdbserver="Enable support for building GDB server"
+desc_option_debuginfod="Enable support for libdebuginfod"
 # Enable gdbserver if !static.
-build_options_default="gdbserver python"
+build_options_default="gdbserver python debuginfod"
 # Both options cannot be enabled at the same time
 vopt_conflict gdbserver static
 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PR PATCH] [Updated] Update elfutils to 0.182.
  2020-11-02  1:56 [PR PATCH] Update elfutils to 0.182 ericonr
@ 2020-11-02  1:58 ` ericonr
  2020-11-02  2:01 ` ericonr
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: ericonr @ 2020-11-02  1:58 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 374 bytes --]

There is an updated pull request by ericonr against master on the void-packages repository

https://github.com/ericonr/void-packages debuginfod
https://github.com/void-linux/void-packages/pull/26067

Update elfutils to 0.182.
Also create the debuginfod subpackage and use it in gdb.

A patch file from https://github.com/void-linux/void-packages/pull/26067.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-debuginfod-26067.patch --]
[-- Type: text/x-diff, Size: 31085 bytes --]

From b714ba4b2b45143e8db59b22fb555c7938923776 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
Date: Sun, 25 Oct 2020 18:57:17 -0300
Subject: [PATCH 1/2] elfutils: update to 0.182, add debuginfod subpkgs, adopt.

Cleaned up patches, fixed the aarch64-fregs one (it was doing the wrong
thing), and moved closer to where upstream is moving regarding musl
compat.
---
 common/shlibs                                 |   1 +
 srcpkgs/debuginfod                            |   1 +
 srcpkgs/elfutils/patches/debuginfod.patch     |  13 +
 .../elfutils/patches/fix-aarch64_fregs.patch  |  22 +-
 .../elfutils/patches/fix-uninitialized.patch  |  11 -
 srcpkgs/elfutils/patches/fts-obstack.patch    | 107 ++++++
 srcpkgs/elfutils/patches/musl-cdefs.patch     |  30 --
 .../elfutils/patches/musl-fts-obstack.patch   |  87 -----
 srcpkgs/elfutils/patches/musl-macros.patch    | 339 +++++++++++++++---
 srcpkgs/elfutils/patches/musl-strndupa.patch  |  18 -
 srcpkgs/elfutils/template                     |  36 +-
 srcpkgs/libdebuginfod                         |   1 +
 12 files changed, 450 insertions(+), 216 deletions(-)
 create mode 120000 srcpkgs/debuginfod
 create mode 100644 srcpkgs/elfutils/patches/debuginfod.patch
 delete mode 100644 srcpkgs/elfutils/patches/fix-uninitialized.patch
 create mode 100644 srcpkgs/elfutils/patches/fts-obstack.patch
 delete mode 100644 srcpkgs/elfutils/patches/musl-cdefs.patch
 delete mode 100644 srcpkgs/elfutils/patches/musl-fts-obstack.patch
 delete mode 100644 srcpkgs/elfutils/patches/musl-strndupa.patch
 create mode 120000 srcpkgs/libdebuginfod

diff --git a/common/shlibs b/common/shlibs
index e0e75cea1b4..30cc8236b86 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -736,6 +736,7 @@ libmtp.so.9 libmtp-1.1.4_1
 libelf.so.1 libelf-0.155_1
 libdw.so.1 libelf-0.155_1
 libasm.so.1 libelf-0.155_1
+libdebuginfod.so.1 libdebuginfod-0.181_2
 libgtksourceview-3.0.so.1 gtksourceview-3.8.0_1
 libtalloc.so.2 talloc-2.0.1_1
 libmount.so.1 libmount-2.18_1
diff --git a/srcpkgs/debuginfod b/srcpkgs/debuginfod
new file mode 120000
index 00000000000..b76b36cfac4
--- /dev/null
+++ b/srcpkgs/debuginfod
@@ -0,0 +1 @@
+elfutils
\ No newline at end of file
diff --git a/srcpkgs/elfutils/patches/debuginfod.patch b/srcpkgs/elfutils/patches/debuginfod.patch
new file mode 100644
index 00000000000..d26d945d1ff
--- /dev/null
+++ b/srcpkgs/elfutils/patches/debuginfod.patch
@@ -0,0 +1,13 @@
+diff --git debuginfod/debuginfod.cxx debuginfod/debuginfod.cxx
+index 3085f388..d2a434ee 100644
+--- debuginfod/debuginfod.cxx
++++ debuginfod/debuginfod.cxx
+@@ -46,7 +46,7 @@ extern "C" {
+ #include <unistd.h>
+ #include <stdlib.h>
+ #include <error.h>
+-// #include <libintl.h> // not until it supports C++ << better
++#include <libintl.h>
+ #include <locale.h>
+ #include <pthread.h>
+ #include <signal.h>
diff --git a/srcpkgs/elfutils/patches/fix-aarch64_fregs.patch b/srcpkgs/elfutils/patches/fix-aarch64_fregs.patch
index e9641542144..070d2527656 100644
--- a/srcpkgs/elfutils/patches/fix-aarch64_fregs.patch
+++ b/srcpkgs/elfutils/patches/fix-aarch64_fregs.patch
@@ -1,14 +1,22 @@
-It looks like fregs.vregs[] is an array of double?
-Casting to Dwarf_Word instead of & 0xFFFFFFF should do.
-
---- backends/aarch64_initreg.c	2015-11-27 14:36:29.000000000 +0100
-+++ backends/aarch64_initreg.c	2016-08-09 03:47:25.428560159 +0200
-@@ -82,7 +83,7 @@
+diff --git backends/aarch64_initreg.c backends/aarch64_initreg.c
+index daf6f375..02ca1dc0 100644
+--- backends/aarch64_initreg.c
++++ backends/aarch64_initreg.c
+@@ -46,6 +46,8 @@
+ #define BACKEND aarch64_
+ #include "libebl_CPU.h"
+ 
++#include <string.h>
++
+ bool
+ aarch64_set_initial_registers_tid (pid_t tid __attribute__ ((unused)),
+ 			  ebl_tid_registers_t *setfunc __attribute__ ((unused)),
+@@ -82,7 +84,7 @@ aarch64_set_initial_registers_tid (pid_t tid __attribute__ ((unused)),
  
    Dwarf_Word dwarf_fregs[32];
    for (int r = 0; r < 32; r++)
 -    dwarf_fregs[r] = fregs.vregs[r] & 0xFFFFFFFF;
-+    dwarf_fregs[r] = (Dwarf_Word)fregs.vregs[r];
++    memcpy(dwarf_fregs + r, fregs.vregs + r, sizeof(dwarf_fregs[0]));
  
    if (! setfunc (64, 32, dwarf_fregs, arg))
      return false;
diff --git a/srcpkgs/elfutils/patches/fix-uninitialized.patch b/srcpkgs/elfutils/patches/fix-uninitialized.patch
deleted file mode 100644
index 6ab15e50e2b..00000000000
--- a/srcpkgs/elfutils/patches/fix-uninitialized.patch
+++ /dev/null
@@ -1,11 +0,0 @@
-
---- libcpu/i386_disasm.c	2015-08-21 14:22:37.000000000 +0200
-+++ libcpu/i386_disasm.c	2015-11-20 06:30:59.250629957 +0100
-@@ -710,6 +710,7 @@
- 
- 		case 'm':
- 		  /* Mnemonic.  */
-+		  str = mnebuf;
- 
- 		  if (unlikely (instrtab[cnt].mnemonic == MNE_INVALID))
- 		    {
diff --git a/srcpkgs/elfutils/patches/fts-obstack.patch b/srcpkgs/elfutils/patches/fts-obstack.patch
new file mode 100644
index 00000000000..44ef0aee70e
--- /dev/null
+++ b/srcpkgs/elfutils/patches/fts-obstack.patch
@@ -0,0 +1,107 @@
+diff --git ChangeLog ChangeLog
+index 128da6c6..565d021c 100644
+--- ChangeLog
++++ ChangeLog
+@@ -1,3 +1,7 @@
++2020-11-01  Érico N. Rolim  <erico.erc@gmail.com>
++
++	* configure.ac: Check for fts and obstack from outside libc.
++
+ 2020-10-28  Mark Wielaard  <mark@klomp.org>
+ 
+ 	* configure.ac: Set version to 0.182.
+diff --git configure.ac configure.ac
+index 515ac704..c1a6954d 100644
+--- configure.ac
++++ configure.ac
+@@ -542,6 +542,26 @@ else
+ fi
+ AC_SUBST([argp_LDADD])
+ 
++saved_LIBS="$LIBS"
++AC_SEARCH_LIBS([fts_close], [fts])
++LIBS="$saved_LIBS"
++case "$ac_cv_search_fts_close" in
++        no) AC_MSG_FAILURE([failed to find fts_close]) ;;
++        -l*) fts_LIBS="$ac_cv_search_fts_close" ;;
++        *) fts_LIBS= ;;
++esac
++AC_SUBST([fts_LIBS])
++
++saved_LIBS="$LIBS"
++AC_SEARCH_LIBS([_obstack_free], [obstack])
++LIBS="$saved_LIBS"
++case "$ac_cv_search__obstack_free" in
++        no) AC_MSG_FAILURE([failed to find obstack_free]) ;;
++        -l*) obstack_LIBS="$ac_cv_search__obstack_free" ;;
++        *) obstack_LIBS= ;;
++esac
++AC_SUBST([obstack_LIBS])
++
+ dnl The directories with content.
+ 
+ dnl Documentation.
+diff --git debuginfod/Makefile.am debuginfod/Makefile.am
+index 01985600..0af3b58c 100644
+--- debuginfod/Makefile.am
++++ debuginfod/Makefile.am
+@@ -71,10 +71,10 @@ bin_PROGRAMS += debuginfod-find
+ endif
+ 
+ debuginfod_SOURCES = debuginfod.cxx
+-debuginfod_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod) $(libmicrohttpd_LIBS) $(sqlite3_LIBS) $(libarchive_LIBS) -lpthread -ldl
++debuginfod_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod) $(argp_LDADD) $(fts_LIBS) $(libmicrohttpd_LIBS) $(sqlite3_LIBS) $(libarchive_LIBS) -lpthread -ldl
+ 
+ debuginfod_find_SOURCES = debuginfod-find.c
+-debuginfod_find_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod)
++debuginfod_find_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod) $(argp_LDADD) $(fts_LIBS)
+ 
+ if LIBDEBUGINFOD
+ noinst_LIBRARIES = libdebuginfod.a
+@@ -98,7 +98,7 @@ libdebuginfod_so_LIBS = libdebuginfod_pic.a
+ if DUMMY_LIBDEBUGINFOD
+ libdebuginfod_so_LDLIBS =
+ else
+-libdebuginfod_so_LDLIBS = $(libcurl_LIBS)
++libdebuginfod_so_LDLIBS = $(libcurl_LIBS) $(fts_LIBS)
+ endif
+ libdebuginfod.so$(EXEEXT): $(srcdir)/libdebuginfod.map $(libdebuginfod_so_LIBS)
+ 	$(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $@ \
+diff --git libdw/Makefile.am libdw/Makefile.am
+index 33b5838d..1dbb3d5e 100644
+--- libdw/Makefile.am
++++ libdw/Makefile.am
+@@ -109,7 +109,7 @@ libdw_so_LIBS = ../libebl/libebl_pic.a ../backends/libebl_backends_pic.a \
+ 		../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_LIBS) $(obstack_LIBS) $(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 src/Makefile.am src/Makefile.am
+index e462e7d7..88d0ac8f 100644
+--- src/Makefile.am
++++ src/Makefile.am
+@@ -69,7 +69,7 @@ ar_no_Wstack_usage = yes
+ unstrip_no_Wstack_usage = yes
+ 
+ readelf_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD)
+-nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) \
++nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) $(obstack_LIBS) \
+ 	   $(demanglelib)
+ size_LDADD = $(libelf) $(libeu) $(argp_LDADD)
+ strip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
+@@ -78,9 +78,9 @@ findtextrel_LDADD = $(libdw) $(libelf) $(libeu) $(argp_LDADD)
+ addr2line_LDADD = $(libdw) $(libelf) $(libeu) $(argp_LDADD) $(demanglelib)
+ elfcmp_LDADD = $(libebl) $(libdw) $(libelf) $(libeu) $(argp_LDADD)
+ objdump_LDADD  = $(libasm) $(libebl) $(libdw) $(libelf) $(libeu) $(argp_LDADD)
+-ranlib_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD)
++ranlib_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD) $(obstack_LIBS)
+ strings_LDADD = $(libelf) $(libeu) $(argp_LDADD)
+-ar_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD)
++ar_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD) $(obstack_LIBS)
+ unstrip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
+ stack_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) $(demanglelib)
+ elfcompress_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
diff --git a/srcpkgs/elfutils/patches/musl-cdefs.patch b/srcpkgs/elfutils/patches/musl-cdefs.patch
deleted file mode 100644
index 65ef9f4d23c..00000000000
--- a/srcpkgs/elfutils/patches/musl-cdefs.patch
+++ /dev/null
@@ -1,30 +0,0 @@
---- libelf/elf.h	2015-08-21 14:22:37.000000000 +0200
-+++ libelf/elf.h	2015-11-20 04:54:33.948081321 +0100
-@@ -21,6 +21,17 @@
- 
- #include <features.h>
- 
-+#if !defined(__BEGIN_DECLS)
-+/* C++ needs to know that types and declarations are C, not C++.  */
-+#ifdef  __cplusplus
-+# define __BEGIN_DECLS  extern "C" {
-+# define __END_DECLS    }
-+#else
-+# define __BEGIN_DECLS
-+# define __END_DECLS
-+#endif
-+#endif
-+
- __BEGIN_DECLS
- 
- /* Standard ELF types.  */
---- lib/fixedsizehash.h.orig
-+++ lib/fixedsizehash.h
-@@ -30,7 +30,6 @@
- #include <errno.h>
- #include <stdlib.h>
- #include <string.h>
--#include <sys/cdefs.h>
- 
- #include <system.h>
- 
diff --git a/srcpkgs/elfutils/patches/musl-fts-obstack.patch b/srcpkgs/elfutils/patches/musl-fts-obstack.patch
deleted file mode 100644
index 77e3c4ea040..00000000000
--- a/srcpkgs/elfutils/patches/musl-fts-obstack.patch
+++ /dev/null
@@ -1,87 +0,0 @@
---- configure.ac	2015-10-15 15:16:57.000000000 +0200
-+++ 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.
---- src/Makefile.am.orig
-+++ 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
---- libdw/Makefile.am.orig
-+++ 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/srcpkgs/elfutils/patches/musl-macros.patch b/srcpkgs/elfutils/patches/musl-macros.patch
index 8ce586b2930..ff5d06efac0 100644
--- a/srcpkgs/elfutils/patches/musl-macros.patch
+++ b/srcpkgs/elfutils/patches/musl-macros.patch
@@ -1,66 +1,293 @@
---- src/arlib.h	2015-08-21 14:22:37.000000000 +0200
-+++ src/arlib.h	2015-11-20 08:02:55.153199611 +0100
-@@ -29,6 +29,16 @@
- #include <stdint.h>
- #include <sys/types.h>
- 
-+#if !defined(ACCESSPERMS)
-+# define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
-+#endif
-+#if !defined(ALLPERMS)
-+# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
-+#endif
-+#if !defined(DEFFILEMODE)
-+# define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)/* 0666*/
-+#endif
-+
+diff --git debuginfod/debuginfod-client.c debuginfod/debuginfod-client.c
+index 0e5177bc..ce1d819b 100644
+--- debuginfod/debuginfod-client.c
++++ debuginfod/debuginfod-client.c
+@@ -212,13 +212,13 @@ debuginfod_init_cache (char *cache_path, char *interval_path, char *maxage_path)
+     return 0;
  
- /* State of -D/-U flags.  */
- extern bool arlib_deterministic_output;
---- src/elfcompress.c.orig	2016-04-02 12:51:26.903848894 +0200
-+++ src/elfcompress.c	2016-04-02 12:55:15.076996338 +0200
-@@ -35,6 +35,14 @@
- #include <gelf.h>
- #include "system.h"
+   /* Create the cache and config files as necessary.  */
+-  if (stat(cache_path, &st) != 0 && mkdir(cache_path, 0777) < 0)
++  if (stat(cache_path, &st) != 0 && mkdir(cache_path, ACCESSPERMS) < 0)
+     return -errno;
  
-+#if !defined(FNM_EXTMATCH)
-+# define FNM_EXTMATCH 0
-+#endif
-+
-+#if !defined(ALLPERMS)
-+# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
+   int fd = -1;
+ 
+   /* init cleaning interval config file.  */
+-  fd = open(interval_path, O_CREAT | O_RDWR, 0666);
++  fd = open(interval_path, O_CREAT | O_RDWR, DEFFILEMODE);
+   if (fd < 0)
+     return -errno;
+ 
+@@ -227,7 +227,7 @@ debuginfod_init_cache (char *cache_path, char *interval_path, char *maxage_path)
+ 
+   /* init max age config file.  */
+   if (stat(maxage_path, &st) != 0
+-      && (fd = open(maxage_path, O_CREAT | O_RDWR, 0666)) < 0)
++      && (fd = open(maxage_path, O_CREAT | O_RDWR, DEFFILEMODE)) < 0)
+     return -errno;
+ 
+   if (dprintf(fd, "%ld", cache_default_max_unused_age_s) < 0)
+diff --git lib/system.h lib/system.h
+index 292082bd..5d16ebc6 100644
+--- lib/system.h
++++ lib/system.h
+@@ -85,6 +85,18 @@
+      __res; })
+ #endif
+ 
++#ifndef ACCESSPERMS
++#define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
 +#endif
 +
- /* Name and version of program.  */
- static void print_version (FILE *stream, struct argp_state *state);
- ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;
---- src/strip.c.orig	2017-08-02 12:06:25.000000000 +0000
-+++ src/strip.c	2017-08-05 01:58:01.523493062 +0000
-@@ -47,6 +47,14 @@
- #include <system.h>
- #include <printversion.h>
- 
-+#if !defined(FNM_EXTMATCH)
-+# define FNM_EXTMATCH 0
++#ifndef ALLPERMS
++#define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
 +#endif
 +
-+#if !defined(ACCESSPERMS)
-+#define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO)
++#ifndef DEFFILEMODE
++#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)/* DEFFILEMODE*/
 +#endif
 +
- typedef uint8_t GElf_Byte;
+ static inline ssize_t __attribute__ ((unused))
+ pwrite_retry (int fd, const void *buf, size_t len, off_t off)
+ {
+diff --git src/unstrip.c src/unstrip.c
+index 0257d9cc..c99ee612 100644
+--- src/unstrip.c
++++ src/unstrip.c
+@@ -315,7 +315,7 @@ make_directories (const char *path)
+   if (dir == NULL)
+     error(EXIT_FAILURE, errno, _("memory exhausted"));
  
- /* Name and version of program.  */
---- tests/elfstrmerge.c.orig	2020-09-13 08:20:50.538492600 +0700
-+++ tests/elfstrmerge.c	2020-09-13 08:21:40.205734827 +0700
-@@ -33,6 +33,10 @@
- #include ELFUTILS_HEADER(dwelf)
- #include "elf-knowledge.h"
+-  while (mkdir (dir, 0777) < 0 && errno != EEXIST)
++  while (mkdir (dir, ACCESSPERMS) < 0 && errno != EEXIST)
+     {
+       if (errno == ENOENT)
+         make_directories (dir);
+@@ -2192,7 +2192,7 @@ DWARF data in '%s' not adjusted for prelinking bias; consider prelink -u"),
  
-+#if !defined(ALLPERMS)
-+# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
-+#endif
-+
- /* The original ELF file.  */
- static int fd = -1;
- static Elf *elf = NULL;
+       /* Copy the unstripped file and then modify it.  */
+       int outfd = open (output_file, O_RDWR | O_CREAT,
+-			  stripped_ehdr->e_type == ET_REL ? 0666 : 0777);
++			  stripped_ehdr->e_type == ET_REL ? DEFFILEMODE : ACCESSPERMS);
+       if (outfd < 0)
+ 	error (EXIT_FAILURE, errno, _("cannot open '%s'"), output_file);
+       Elf *outelf = elf_begin (outfd, ELF_C_WRITE, NULL);
+diff --git tests/alldts.c tests/alldts.c
+index 28b3063c..b88a3e61 100644
+--- tests/alldts.c
++++ tests/alldts.c
+@@ -68,7 +68,7 @@ main (void)
+   (void) __fsetlocking (stdout, FSETLOCKING_BYCALLER);
+ 
+   /* Open the file.  */
+-  int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
++  int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s': %m\n", fname);
+diff --git tests/arextract.c tests/arextract.c
+index 2c4dc758..936d7f55 100644
+--- tests/arextract.c
++++ tests/arextract.c
+@@ -95,7 +95,7 @@ Failed to get base address for the archive element: %s\n",
+ 	    }
+ 
+ 	  /* Open the output file.  */
+-	  outfd = open (argv[3], O_CREAT | O_TRUNC | O_RDWR, 0666);
++	  outfd = open (argv[3], O_CREAT | O_TRUNC | O_RDWR, DEFFILEMODE);
+ 	  if (outfd == -1)
+ 	    {
+ 	      printf ("cannot open output file: %m");
+diff --git tests/ecp.c tests/ecp.c
+index 1df40a32..44a7bda2 100644
+--- tests/ecp.c
++++ tests/ecp.c
+@@ -43,7 +43,7 @@ main (int argc, char *argv[])
+     error (EXIT_FAILURE, 0, "problems opening '%s' as ELF file: %s",
+ 	   argv[1], elf_errmsg (-1));
+ 
+-  int outfd = creat (argv[2], 0666);
++  int outfd = creat (argv[2], DEFFILEMODE);
+   if (outfd == -1)
+     error (EXIT_FAILURE, errno, "cannot open output file '%s'", argv[2]);
+ 
+diff --git tests/elfstrtab.c tests/elfstrtab.c
+index c27d6cfb..9866237c 100644
+--- tests/elfstrtab.c
++++ tests/elfstrtab.c
+@@ -134,7 +134,7 @@ check_elf (const char *fname, int class, int use_mmap)
+   printf ("\nfname: %s\n", fname);
+   stridx = 0;
+ 
+-  int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
++  int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s': %s\n", fname, strerror (errno));
+@@ -280,7 +280,7 @@ check_elf (const char *fname, int class, int use_mmap)
+   close (fd);
+ 
+   /* Read the ELF from disk now.  */
+-  fd = open (fname, O_RDWR, 0666);
++  fd = open (fname, O_RDWR, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s' read-only: %s\n", fname, strerror (errno));
+@@ -349,7 +349,7 @@ check_elf (const char *fname, int class, int use_mmap)
+   close (fd);
+ 
+   // And read it in one last time.
+-  fd = open (fname, O_RDONLY, 0666);
++  fd = open (fname, O_RDONLY, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s' read-only: %s\n", fname, strerror (errno));
+diff --git tests/emptyfile.c tests/emptyfile.c
+index 6d086246..18036ebe 100644
+--- tests/emptyfile.c
++++ tests/emptyfile.c
+@@ -67,7 +67,7 @@ check_elf (const char *fname, int class, int use_mmap)
+   printf ("\nfname: %s\n", fname);
+   stridx = 0; // Reset strtab strings index
+ 
+-  int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
++  int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s': %s\n", fname, strerror (errno));
+@@ -125,7 +125,7 @@ check_elf (const char *fname, int class, int use_mmap)
+   close (fd);
+ 
+   /* Reread the ELF from disk now.  */
+-  fd = open (fname, O_RDWR, 0666);
++  fd = open (fname, O_RDWR, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot (re)open `%s': %s\n", fname, strerror (errno));
+@@ -208,7 +208,7 @@ check_elf (const char *fname, int class, int use_mmap)
+   close (fd);
+ 
+   // And read it in one last time.
+-  fd = open (fname, O_RDONLY, 0666);
++  fd = open (fname, O_RDONLY, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s' read-only: %s\n", fname, strerror (errno));
+diff --git tests/fillfile.c tests/fillfile.c
+index 915e249d..96f2b0f9 100644
+--- tests/fillfile.c
++++ tests/fillfile.c
+@@ -201,7 +201,7 @@ check_elf (const char *fname, int class, int use_mmap)
+   printf ("\nfname: %s\n", fname);
+   stridx = 0; // Reset strtab strings index
+ 
+-  int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
++  int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s': %s\n", fname, strerror (errno));
+@@ -266,7 +266,7 @@ check_elf (const char *fname, int class, int use_mmap)
+ 
+   /* Reread the ELF from disk now.  */
+   printf ("Rereading %s\n", fname);
+-  fd = open (fname, O_RDWR, 0666);
++  fd = open (fname, O_RDWR, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot (re)open `%s': %s\n", fname, strerror (errno));
+@@ -347,7 +347,7 @@ check_elf (const char *fname, int class, int use_mmap)
+ 
+   // And read it in one last time.
+   printf ("Rereading %s again\n", fname);
+-  fd = open (fname, O_RDONLY, 0666);
++  fd = open (fname, O_RDONLY, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s' read-only: %s\n", fname, strerror (errno));
+diff --git tests/newdata.c tests/newdata.c
+index 9af99564..5a512109 100644
+--- tests/newdata.c
++++ tests/newdata.c
+@@ -243,7 +243,7 @@ check_elf (int class, int use_mmap)
+ 
+   printf ("\ncheck_elf: %s\n", fname);
+ 
+-  int fd = open (fname, O_RDWR|O_CREAT|O_TRUNC, 00666);
++  int fd = open (fname, O_RDWR|O_CREAT|O_TRUNC, 0DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot create `%s': %s\n", fname, strerror (errno));
+diff --git tests/update1.c tests/update1.c
+index f4c14753..e2370936 100644
+--- tests/update1.c
++++ tests/update1.c
+@@ -38,7 +38,7 @@ main (int argc, char *argv[] __attribute__ ((unused)))
+   Elf32_Ehdr *ehdr;
+   int i;
+ 
+-  fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
++  fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s': %s\n", fname, strerror (errno));
+diff --git tests/update2.c tests/update2.c
+index 5805163d..14a62cfa 100644
+--- tests/update2.c
++++ tests/update2.c
+@@ -39,7 +39,7 @@ main (int argc, char *argv[] __attribute__ ((unused)))
+   Elf32_Phdr *phdr;
+   int i;
+ 
+-  fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
++  fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s': %s\n", fname, strerror (errno));
+diff --git tests/update3.c tests/update3.c
+index 7a4224dd..f7c8c28b 100644
+--- tests/update3.c
++++ tests/update3.c
+@@ -46,7 +46,7 @@ main (int argc, char *argv[] __attribute__ ((unused)))
+   Dwelf_Strent *shstrtabse;
+   int i;
+ 
+-  fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
++  fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s': %s\n", fname, strerror (errno));
+diff --git tests/update4.c tests/update4.c
+index a9bd4bf9..45153d73 100644
+--- tests/update4.c
++++ tests/update4.c
+@@ -50,7 +50,7 @@ main (int argc, char *argv[] __attribute__ ((unused)))
+   Dwelf_Strent *shstrtabse;
+   int i;
+ 
+-  fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
++  fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s': %s\n", fname, strerror (errno));
+diff --git tests/vendorelf.c tests/vendorelf.c
+index bc13cce3..23f59af5 100644
+--- tests/vendorelf.c
++++ tests/vendorelf.c
+@@ -36,7 +36,7 @@ check_elf (const char *fname, int class, int use_mmap)
+ {
+   printf ("\nfname: %s\n", fname);
+ 
+-  int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
++  int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s': %s\n", fname, strerror (errno));
+@@ -124,7 +124,7 @@ check_elf (const char *fname, int class, int use_mmap)
+   close (fd);
+ 
+   /* Reread the ELF from disk now.  */
+-  fd = open (fname, O_RDONLY, 0666);
++  fd = open (fname, O_RDONLY, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s' read-only: %s\n", fname, strerror (errno));
diff --git a/srcpkgs/elfutils/patches/musl-strndupa.patch b/srcpkgs/elfutils/patches/musl-strndupa.patch
deleted file mode 100644
index f365fb019f2..00000000000
--- a/srcpkgs/elfutils/patches/musl-strndupa.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- src/unstrip.c.orig	2017-04-27 14:26:26.000000000 +0000
-+++ 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/srcpkgs/elfutils/template b/srcpkgs/elfutils/template
index 02e6e20c64b..c41c9ee4aaa 100644
--- a/srcpkgs/elfutils/template
+++ b/srcpkgs/elfutils/template
@@ -1,22 +1,26 @@
 # Template file for 'elfutils'
 pkgname=elfutils
-version=0.181
+version=0.182
 revision=1
 build_style=gnu-configure
-configure_args="--program-prefix=eu- --disable-debuginfod --disable-libdebuginfod"
+configure_args="--program-prefix=eu-"
 hostmakedepends="automake libtool pkg-config"
-makedepends="bzip2-devel liblzma-devel zlib-devel"
+makedepends="bzip2-devel liblzma-devel zlib-devel
+ libcurl-devel libarchive-devel sqlite-devel libmicrohttpd-devel"
 short_desc="Utilities to handle ELF object files"
-maintainer="Orphaned <orphan@voidlinux.org>"
+maintainer="Érico Nogueira <ericonr@disroot.org>"
 license="GPL-3.0-or-later"
 homepage="https://sourceware.org/elfutils/"
 distfiles="https://sourceware.org/${pkgname}/ftp/${version}/${pkgname}-${version}.tar.bz2"
-checksum=29a6ad7421ec2acfee489bb4a699908281ead2cb63a20a027ce8804a165f0eb3
+checksum=ecc406914edf335f0b7fc084ebe6c460c4d6d5175bfdd6688c1c78d9146b8858
 
 CFLAGS="-Wno-error"
+CXXFLAGS="-Wl,-z,stack-size=2097152"
 
 if [ "$XBPS_TARGET_LIBC" = musl ]; then
-	makedepends+=" argp-standalone musl-fts-devel musl-obstack-devel"
+	makedepends+=" argp-standalone musl-fts-devel musl-obstack-devel musl-legacy-compat"
+	# XXX: breaks some expected functionality
+	CFLAGS+=" -DFNM_EXTMATCH=0"
 fi
 
 post_extract() {
@@ -30,6 +34,22 @@ pre_configure() {
 	autoreconf -if
 }
 
+libdebuginfod_package() {
+	short_desc+=" - debuginfod library"
+	pkg_install() {
+		vmove "usr/lib/libdebuginfod-*.so*"
+	}
+}
+
+debuginfod_package() {
+	short_desc+=" - debuginfod programs"
+	pkg_install() {
+		vmove "usr/bin/debuginfod*"
+		vmove "usr/share/man/man1/debuginfod-find.1"
+		vmove "usr/share/man/man8/debuginfod.8"
+	}
+}
+
 libelf_package() {
 	short_desc+=" - runtime library"
 	pkg_install() {
@@ -38,11 +58,13 @@ libelf_package() {
 }
 
 elfutils-devel_package() {
-	depends="libelf>=${version}_${revision} ${makedepends}"
+	depends="libelf>=${version}_${revision} libdebuginfod>=${version}_${revision}
+	 ${makedepends}"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig
 		vmove "usr/lib/*.a"
+		vmove usr/share/man/man3
 	}
 }
diff --git a/srcpkgs/libdebuginfod b/srcpkgs/libdebuginfod
new file mode 120000
index 00000000000..b76b36cfac4
--- /dev/null
+++ b/srcpkgs/libdebuginfod
@@ -0,0 +1 @@
+elfutils
\ No newline at end of file

From 73c78dd5f4220f248d04318be1b4b553dd396a4a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
Date: Sun, 25 Oct 2020 18:23:45 -0300
Subject: [PATCH 2/2] gdb: add debuginfod option, enable by default.

---
 srcpkgs/gdb/template | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/srcpkgs/gdb/template b/srcpkgs/gdb/template
index 0e2e399e798..d18b93af9c4 100644
--- a/srcpkgs/gdb/template
+++ b/srcpkgs/gdb/template
@@ -7,10 +7,12 @@ pycompile_dirs="/usr/share/gdb/python"
 configure_args="--disable-werror --disable-nls --with-system-readline
  --with-system-gdbinit=/etc/gdb/gdbinit --with-system-zlib $(vopt_enable gdbserver)
  $(vopt_if static 'CFLAGS=-static CXXFLAGS=-static LDFLAGS=-static')
- $(vopt_if python --with-python=/usr/bin/python3)"
-hostmakedepends="texinfo perl $(vopt_if python python3-devel)"
+ $(vopt_if python --with-python=/usr/bin/python3)
+ $(vopt_with debuginfod)"
+hostmakedepends="texinfo perl pkg-config $(vopt_if python python3-devel)"
 makedepends="ncurses-devel zlib-devel readline-devel expat-devel
- $(vopt_if python 'python3-devel gettext-libs')"
+ $(vopt_if python 'python3-devel gettext-libs')
+ $(vopt_if debuginfod elfutils-devel)"
 short_desc="GNU Debugger"
 maintainer="Anthony Iliopoulos <ailiop@altatus.com>"
 license="GPL-3.0-or-later"
@@ -28,10 +30,11 @@ fi
 CFLAGS+=" -fcommon"
 CXXFLAGS+=" -fcommon"
 # Package build options
-build_options="gdbserver static python"
+build_options="gdbserver static python debuginfod"
 desc_option_gdbserver="Enable support for building GDB server"
+desc_option_debuginfod="Enable support for libdebuginfod"
 # Enable gdbserver if !static.
-build_options_default="gdbserver python"
+build_options_default="gdbserver python debuginfod"
 # Both options cannot be enabled at the same time
 vopt_conflict gdbserver static
 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PR PATCH] [Updated] Update elfutils to 0.182.
  2020-11-02  1:56 [PR PATCH] Update elfutils to 0.182 ericonr
  2020-11-02  1:58 ` [PR PATCH] [Updated] " ericonr
@ 2020-11-02  2:01 ` ericonr
  2020-11-02  2:02 ` ericonr
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: ericonr @ 2020-11-02  2:01 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 462 bytes --]

There is an updated pull request by ericonr against master on the void-packages repository

https://github.com/ericonr/void-packages debuginfod
https://github.com/void-linux/void-packages/pull/26067

Update elfutils to 0.182.
Also create the debuginfod subpackage and use it in gdb.

This PR can wait on some musl patches that I'd like to backport for the fregs patch.

A patch file from https://github.com/void-linux/void-packages/pull/26067.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-debuginfod-26067.patch --]
[-- Type: text/x-diff, Size: 31193 bytes --]

From b714ba4b2b45143e8db59b22fb555c7938923776 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
Date: Sun, 25 Oct 2020 18:57:17 -0300
Subject: [PATCH 1/2] elfutils: update to 0.182, add debuginfod subpkgs, adopt.

Cleaned up patches, fixed the aarch64-fregs one (it was doing the wrong
thing), and moved closer to where upstream is moving regarding musl
compat.
---
 common/shlibs                                 |   1 +
 srcpkgs/debuginfod                            |   1 +
 srcpkgs/elfutils/patches/debuginfod.patch     |  13 +
 .../elfutils/patches/fix-aarch64_fregs.patch  |  22 +-
 .../elfutils/patches/fix-uninitialized.patch  |  11 -
 srcpkgs/elfutils/patches/fts-obstack.patch    | 107 ++++++
 srcpkgs/elfutils/patches/musl-cdefs.patch     |  30 --
 .../elfutils/patches/musl-fts-obstack.patch   |  87 -----
 srcpkgs/elfutils/patches/musl-macros.patch    | 339 +++++++++++++++---
 srcpkgs/elfutils/patches/musl-strndupa.patch  |  18 -
 srcpkgs/elfutils/template                     |  36 +-
 srcpkgs/libdebuginfod                         |   1 +
 12 files changed, 450 insertions(+), 216 deletions(-)
 create mode 120000 srcpkgs/debuginfod
 create mode 100644 srcpkgs/elfutils/patches/debuginfod.patch
 delete mode 100644 srcpkgs/elfutils/patches/fix-uninitialized.patch
 create mode 100644 srcpkgs/elfutils/patches/fts-obstack.patch
 delete mode 100644 srcpkgs/elfutils/patches/musl-cdefs.patch
 delete mode 100644 srcpkgs/elfutils/patches/musl-fts-obstack.patch
 delete mode 100644 srcpkgs/elfutils/patches/musl-strndupa.patch
 create mode 120000 srcpkgs/libdebuginfod

diff --git a/common/shlibs b/common/shlibs
index e0e75cea1b4..30cc8236b86 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -736,6 +736,7 @@ libmtp.so.9 libmtp-1.1.4_1
 libelf.so.1 libelf-0.155_1
 libdw.so.1 libelf-0.155_1
 libasm.so.1 libelf-0.155_1
+libdebuginfod.so.1 libdebuginfod-0.181_2
 libgtksourceview-3.0.so.1 gtksourceview-3.8.0_1
 libtalloc.so.2 talloc-2.0.1_1
 libmount.so.1 libmount-2.18_1
diff --git a/srcpkgs/debuginfod b/srcpkgs/debuginfod
new file mode 120000
index 00000000000..b76b36cfac4
--- /dev/null
+++ b/srcpkgs/debuginfod
@@ -0,0 +1 @@
+elfutils
\ No newline at end of file
diff --git a/srcpkgs/elfutils/patches/debuginfod.patch b/srcpkgs/elfutils/patches/debuginfod.patch
new file mode 100644
index 00000000000..d26d945d1ff
--- /dev/null
+++ b/srcpkgs/elfutils/patches/debuginfod.patch
@@ -0,0 +1,13 @@
+diff --git debuginfod/debuginfod.cxx debuginfod/debuginfod.cxx
+index 3085f388..d2a434ee 100644
+--- debuginfod/debuginfod.cxx
++++ debuginfod/debuginfod.cxx
+@@ -46,7 +46,7 @@ extern "C" {
+ #include <unistd.h>
+ #include <stdlib.h>
+ #include <error.h>
+-// #include <libintl.h> // not until it supports C++ << better
++#include <libintl.h>
+ #include <locale.h>
+ #include <pthread.h>
+ #include <signal.h>
diff --git a/srcpkgs/elfutils/patches/fix-aarch64_fregs.patch b/srcpkgs/elfutils/patches/fix-aarch64_fregs.patch
index e9641542144..070d2527656 100644
--- a/srcpkgs/elfutils/patches/fix-aarch64_fregs.patch
+++ b/srcpkgs/elfutils/patches/fix-aarch64_fregs.patch
@@ -1,14 +1,22 @@
-It looks like fregs.vregs[] is an array of double?
-Casting to Dwarf_Word instead of & 0xFFFFFFF should do.
-
---- backends/aarch64_initreg.c	2015-11-27 14:36:29.000000000 +0100
-+++ backends/aarch64_initreg.c	2016-08-09 03:47:25.428560159 +0200
-@@ -82,7 +83,7 @@
+diff --git backends/aarch64_initreg.c backends/aarch64_initreg.c
+index daf6f375..02ca1dc0 100644
+--- backends/aarch64_initreg.c
++++ backends/aarch64_initreg.c
+@@ -46,6 +46,8 @@
+ #define BACKEND aarch64_
+ #include "libebl_CPU.h"
+ 
++#include <string.h>
++
+ bool
+ aarch64_set_initial_registers_tid (pid_t tid __attribute__ ((unused)),
+ 			  ebl_tid_registers_t *setfunc __attribute__ ((unused)),
+@@ -82,7 +84,7 @@ aarch64_set_initial_registers_tid (pid_t tid __attribute__ ((unused)),
  
    Dwarf_Word dwarf_fregs[32];
    for (int r = 0; r < 32; r++)
 -    dwarf_fregs[r] = fregs.vregs[r] & 0xFFFFFFFF;
-+    dwarf_fregs[r] = (Dwarf_Word)fregs.vregs[r];
++    memcpy(dwarf_fregs + r, fregs.vregs + r, sizeof(dwarf_fregs[0]));
  
    if (! setfunc (64, 32, dwarf_fregs, arg))
      return false;
diff --git a/srcpkgs/elfutils/patches/fix-uninitialized.patch b/srcpkgs/elfutils/patches/fix-uninitialized.patch
deleted file mode 100644
index 6ab15e50e2b..00000000000
--- a/srcpkgs/elfutils/patches/fix-uninitialized.patch
+++ /dev/null
@@ -1,11 +0,0 @@
-
---- libcpu/i386_disasm.c	2015-08-21 14:22:37.000000000 +0200
-+++ libcpu/i386_disasm.c	2015-11-20 06:30:59.250629957 +0100
-@@ -710,6 +710,7 @@
- 
- 		case 'm':
- 		  /* Mnemonic.  */
-+		  str = mnebuf;
- 
- 		  if (unlikely (instrtab[cnt].mnemonic == MNE_INVALID))
- 		    {
diff --git a/srcpkgs/elfutils/patches/fts-obstack.patch b/srcpkgs/elfutils/patches/fts-obstack.patch
new file mode 100644
index 00000000000..44ef0aee70e
--- /dev/null
+++ b/srcpkgs/elfutils/patches/fts-obstack.patch
@@ -0,0 +1,107 @@
+diff --git ChangeLog ChangeLog
+index 128da6c6..565d021c 100644
+--- ChangeLog
++++ ChangeLog
+@@ -1,3 +1,7 @@
++2020-11-01  Érico N. Rolim  <erico.erc@gmail.com>
++
++	* configure.ac: Check for fts and obstack from outside libc.
++
+ 2020-10-28  Mark Wielaard  <mark@klomp.org>
+ 
+ 	* configure.ac: Set version to 0.182.
+diff --git configure.ac configure.ac
+index 515ac704..c1a6954d 100644
+--- configure.ac
++++ configure.ac
+@@ -542,6 +542,26 @@ else
+ fi
+ AC_SUBST([argp_LDADD])
+ 
++saved_LIBS="$LIBS"
++AC_SEARCH_LIBS([fts_close], [fts])
++LIBS="$saved_LIBS"
++case "$ac_cv_search_fts_close" in
++        no) AC_MSG_FAILURE([failed to find fts_close]) ;;
++        -l*) fts_LIBS="$ac_cv_search_fts_close" ;;
++        *) fts_LIBS= ;;
++esac
++AC_SUBST([fts_LIBS])
++
++saved_LIBS="$LIBS"
++AC_SEARCH_LIBS([_obstack_free], [obstack])
++LIBS="$saved_LIBS"
++case "$ac_cv_search__obstack_free" in
++        no) AC_MSG_FAILURE([failed to find obstack_free]) ;;
++        -l*) obstack_LIBS="$ac_cv_search__obstack_free" ;;
++        *) obstack_LIBS= ;;
++esac
++AC_SUBST([obstack_LIBS])
++
+ dnl The directories with content.
+ 
+ dnl Documentation.
+diff --git debuginfod/Makefile.am debuginfod/Makefile.am
+index 01985600..0af3b58c 100644
+--- debuginfod/Makefile.am
++++ debuginfod/Makefile.am
+@@ -71,10 +71,10 @@ bin_PROGRAMS += debuginfod-find
+ endif
+ 
+ debuginfod_SOURCES = debuginfod.cxx
+-debuginfod_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod) $(libmicrohttpd_LIBS) $(sqlite3_LIBS) $(libarchive_LIBS) -lpthread -ldl
++debuginfod_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod) $(argp_LDADD) $(fts_LIBS) $(libmicrohttpd_LIBS) $(sqlite3_LIBS) $(libarchive_LIBS) -lpthread -ldl
+ 
+ debuginfod_find_SOURCES = debuginfod-find.c
+-debuginfod_find_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod)
++debuginfod_find_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod) $(argp_LDADD) $(fts_LIBS)
+ 
+ if LIBDEBUGINFOD
+ noinst_LIBRARIES = libdebuginfod.a
+@@ -98,7 +98,7 @@ libdebuginfod_so_LIBS = libdebuginfod_pic.a
+ if DUMMY_LIBDEBUGINFOD
+ libdebuginfod_so_LDLIBS =
+ else
+-libdebuginfod_so_LDLIBS = $(libcurl_LIBS)
++libdebuginfod_so_LDLIBS = $(libcurl_LIBS) $(fts_LIBS)
+ endif
+ libdebuginfod.so$(EXEEXT): $(srcdir)/libdebuginfod.map $(libdebuginfod_so_LIBS)
+ 	$(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $@ \
+diff --git libdw/Makefile.am libdw/Makefile.am
+index 33b5838d..1dbb3d5e 100644
+--- libdw/Makefile.am
++++ libdw/Makefile.am
+@@ -109,7 +109,7 @@ libdw_so_LIBS = ../libebl/libebl_pic.a ../backends/libebl_backends_pic.a \
+ 		../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_LIBS) $(obstack_LIBS) $(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 src/Makefile.am src/Makefile.am
+index e462e7d7..88d0ac8f 100644
+--- src/Makefile.am
++++ src/Makefile.am
+@@ -69,7 +69,7 @@ ar_no_Wstack_usage = yes
+ unstrip_no_Wstack_usage = yes
+ 
+ readelf_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD)
+-nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) \
++nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) $(obstack_LIBS) \
+ 	   $(demanglelib)
+ size_LDADD = $(libelf) $(libeu) $(argp_LDADD)
+ strip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
+@@ -78,9 +78,9 @@ findtextrel_LDADD = $(libdw) $(libelf) $(libeu) $(argp_LDADD)
+ addr2line_LDADD = $(libdw) $(libelf) $(libeu) $(argp_LDADD) $(demanglelib)
+ elfcmp_LDADD = $(libebl) $(libdw) $(libelf) $(libeu) $(argp_LDADD)
+ objdump_LDADD  = $(libasm) $(libebl) $(libdw) $(libelf) $(libeu) $(argp_LDADD)
+-ranlib_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD)
++ranlib_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD) $(obstack_LIBS)
+ strings_LDADD = $(libelf) $(libeu) $(argp_LDADD)
+-ar_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD)
++ar_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD) $(obstack_LIBS)
+ unstrip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
+ stack_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) $(demanglelib)
+ elfcompress_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
diff --git a/srcpkgs/elfutils/patches/musl-cdefs.patch b/srcpkgs/elfutils/patches/musl-cdefs.patch
deleted file mode 100644
index 65ef9f4d23c..00000000000
--- a/srcpkgs/elfutils/patches/musl-cdefs.patch
+++ /dev/null
@@ -1,30 +0,0 @@
---- libelf/elf.h	2015-08-21 14:22:37.000000000 +0200
-+++ libelf/elf.h	2015-11-20 04:54:33.948081321 +0100
-@@ -21,6 +21,17 @@
- 
- #include <features.h>
- 
-+#if !defined(__BEGIN_DECLS)
-+/* C++ needs to know that types and declarations are C, not C++.  */
-+#ifdef  __cplusplus
-+# define __BEGIN_DECLS  extern "C" {
-+# define __END_DECLS    }
-+#else
-+# define __BEGIN_DECLS
-+# define __END_DECLS
-+#endif
-+#endif
-+
- __BEGIN_DECLS
- 
- /* Standard ELF types.  */
---- lib/fixedsizehash.h.orig
-+++ lib/fixedsizehash.h
-@@ -30,7 +30,6 @@
- #include <errno.h>
- #include <stdlib.h>
- #include <string.h>
--#include <sys/cdefs.h>
- 
- #include <system.h>
- 
diff --git a/srcpkgs/elfutils/patches/musl-fts-obstack.patch b/srcpkgs/elfutils/patches/musl-fts-obstack.patch
deleted file mode 100644
index 77e3c4ea040..00000000000
--- a/srcpkgs/elfutils/patches/musl-fts-obstack.patch
+++ /dev/null
@@ -1,87 +0,0 @@
---- configure.ac	2015-10-15 15:16:57.000000000 +0200
-+++ 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.
---- src/Makefile.am.orig
-+++ 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
---- libdw/Makefile.am.orig
-+++ 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/srcpkgs/elfutils/patches/musl-macros.patch b/srcpkgs/elfutils/patches/musl-macros.patch
index 8ce586b2930..ff5d06efac0 100644
--- a/srcpkgs/elfutils/patches/musl-macros.patch
+++ b/srcpkgs/elfutils/patches/musl-macros.patch
@@ -1,66 +1,293 @@
---- src/arlib.h	2015-08-21 14:22:37.000000000 +0200
-+++ src/arlib.h	2015-11-20 08:02:55.153199611 +0100
-@@ -29,6 +29,16 @@
- #include <stdint.h>
- #include <sys/types.h>
- 
-+#if !defined(ACCESSPERMS)
-+# define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
-+#endif
-+#if !defined(ALLPERMS)
-+# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
-+#endif
-+#if !defined(DEFFILEMODE)
-+# define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)/* 0666*/
-+#endif
-+
+diff --git debuginfod/debuginfod-client.c debuginfod/debuginfod-client.c
+index 0e5177bc..ce1d819b 100644
+--- debuginfod/debuginfod-client.c
++++ debuginfod/debuginfod-client.c
+@@ -212,13 +212,13 @@ debuginfod_init_cache (char *cache_path, char *interval_path, char *maxage_path)
+     return 0;
  
- /* State of -D/-U flags.  */
- extern bool arlib_deterministic_output;
---- src/elfcompress.c.orig	2016-04-02 12:51:26.903848894 +0200
-+++ src/elfcompress.c	2016-04-02 12:55:15.076996338 +0200
-@@ -35,6 +35,14 @@
- #include <gelf.h>
- #include "system.h"
+   /* Create the cache and config files as necessary.  */
+-  if (stat(cache_path, &st) != 0 && mkdir(cache_path, 0777) < 0)
++  if (stat(cache_path, &st) != 0 && mkdir(cache_path, ACCESSPERMS) < 0)
+     return -errno;
  
-+#if !defined(FNM_EXTMATCH)
-+# define FNM_EXTMATCH 0
-+#endif
-+
-+#if !defined(ALLPERMS)
-+# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
+   int fd = -1;
+ 
+   /* init cleaning interval config file.  */
+-  fd = open(interval_path, O_CREAT | O_RDWR, 0666);
++  fd = open(interval_path, O_CREAT | O_RDWR, DEFFILEMODE);
+   if (fd < 0)
+     return -errno;
+ 
+@@ -227,7 +227,7 @@ debuginfod_init_cache (char *cache_path, char *interval_path, char *maxage_path)
+ 
+   /* init max age config file.  */
+   if (stat(maxage_path, &st) != 0
+-      && (fd = open(maxage_path, O_CREAT | O_RDWR, 0666)) < 0)
++      && (fd = open(maxage_path, O_CREAT | O_RDWR, DEFFILEMODE)) < 0)
+     return -errno;
+ 
+   if (dprintf(fd, "%ld", cache_default_max_unused_age_s) < 0)
+diff --git lib/system.h lib/system.h
+index 292082bd..5d16ebc6 100644
+--- lib/system.h
++++ lib/system.h
+@@ -85,6 +85,18 @@
+      __res; })
+ #endif
+ 
++#ifndef ACCESSPERMS
++#define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
 +#endif
 +
- /* Name and version of program.  */
- static void print_version (FILE *stream, struct argp_state *state);
- ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;
---- src/strip.c.orig	2017-08-02 12:06:25.000000000 +0000
-+++ src/strip.c	2017-08-05 01:58:01.523493062 +0000
-@@ -47,6 +47,14 @@
- #include <system.h>
- #include <printversion.h>
- 
-+#if !defined(FNM_EXTMATCH)
-+# define FNM_EXTMATCH 0
++#ifndef ALLPERMS
++#define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
 +#endif
 +
-+#if !defined(ACCESSPERMS)
-+#define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO)
++#ifndef DEFFILEMODE
++#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)/* DEFFILEMODE*/
 +#endif
 +
- typedef uint8_t GElf_Byte;
+ static inline ssize_t __attribute__ ((unused))
+ pwrite_retry (int fd, const void *buf, size_t len, off_t off)
+ {
+diff --git src/unstrip.c src/unstrip.c
+index 0257d9cc..c99ee612 100644
+--- src/unstrip.c
++++ src/unstrip.c
+@@ -315,7 +315,7 @@ make_directories (const char *path)
+   if (dir == NULL)
+     error(EXIT_FAILURE, errno, _("memory exhausted"));
  
- /* Name and version of program.  */
---- tests/elfstrmerge.c.orig	2020-09-13 08:20:50.538492600 +0700
-+++ tests/elfstrmerge.c	2020-09-13 08:21:40.205734827 +0700
-@@ -33,6 +33,10 @@
- #include ELFUTILS_HEADER(dwelf)
- #include "elf-knowledge.h"
+-  while (mkdir (dir, 0777) < 0 && errno != EEXIST)
++  while (mkdir (dir, ACCESSPERMS) < 0 && errno != EEXIST)
+     {
+       if (errno == ENOENT)
+         make_directories (dir);
+@@ -2192,7 +2192,7 @@ DWARF data in '%s' not adjusted for prelinking bias; consider prelink -u"),
  
-+#if !defined(ALLPERMS)
-+# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
-+#endif
-+
- /* The original ELF file.  */
- static int fd = -1;
- static Elf *elf = NULL;
+       /* Copy the unstripped file and then modify it.  */
+       int outfd = open (output_file, O_RDWR | O_CREAT,
+-			  stripped_ehdr->e_type == ET_REL ? 0666 : 0777);
++			  stripped_ehdr->e_type == ET_REL ? DEFFILEMODE : ACCESSPERMS);
+       if (outfd < 0)
+ 	error (EXIT_FAILURE, errno, _("cannot open '%s'"), output_file);
+       Elf *outelf = elf_begin (outfd, ELF_C_WRITE, NULL);
+diff --git tests/alldts.c tests/alldts.c
+index 28b3063c..b88a3e61 100644
+--- tests/alldts.c
++++ tests/alldts.c
+@@ -68,7 +68,7 @@ main (void)
+   (void) __fsetlocking (stdout, FSETLOCKING_BYCALLER);
+ 
+   /* Open the file.  */
+-  int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
++  int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s': %m\n", fname);
+diff --git tests/arextract.c tests/arextract.c
+index 2c4dc758..936d7f55 100644
+--- tests/arextract.c
++++ tests/arextract.c
+@@ -95,7 +95,7 @@ Failed to get base address for the archive element: %s\n",
+ 	    }
+ 
+ 	  /* Open the output file.  */
+-	  outfd = open (argv[3], O_CREAT | O_TRUNC | O_RDWR, 0666);
++	  outfd = open (argv[3], O_CREAT | O_TRUNC | O_RDWR, DEFFILEMODE);
+ 	  if (outfd == -1)
+ 	    {
+ 	      printf ("cannot open output file: %m");
+diff --git tests/ecp.c tests/ecp.c
+index 1df40a32..44a7bda2 100644
+--- tests/ecp.c
++++ tests/ecp.c
+@@ -43,7 +43,7 @@ main (int argc, char *argv[])
+     error (EXIT_FAILURE, 0, "problems opening '%s' as ELF file: %s",
+ 	   argv[1], elf_errmsg (-1));
+ 
+-  int outfd = creat (argv[2], 0666);
++  int outfd = creat (argv[2], DEFFILEMODE);
+   if (outfd == -1)
+     error (EXIT_FAILURE, errno, "cannot open output file '%s'", argv[2]);
+ 
+diff --git tests/elfstrtab.c tests/elfstrtab.c
+index c27d6cfb..9866237c 100644
+--- tests/elfstrtab.c
++++ tests/elfstrtab.c
+@@ -134,7 +134,7 @@ check_elf (const char *fname, int class, int use_mmap)
+   printf ("\nfname: %s\n", fname);
+   stridx = 0;
+ 
+-  int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
++  int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s': %s\n", fname, strerror (errno));
+@@ -280,7 +280,7 @@ check_elf (const char *fname, int class, int use_mmap)
+   close (fd);
+ 
+   /* Read the ELF from disk now.  */
+-  fd = open (fname, O_RDWR, 0666);
++  fd = open (fname, O_RDWR, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s' read-only: %s\n", fname, strerror (errno));
+@@ -349,7 +349,7 @@ check_elf (const char *fname, int class, int use_mmap)
+   close (fd);
+ 
+   // And read it in one last time.
+-  fd = open (fname, O_RDONLY, 0666);
++  fd = open (fname, O_RDONLY, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s' read-only: %s\n", fname, strerror (errno));
+diff --git tests/emptyfile.c tests/emptyfile.c
+index 6d086246..18036ebe 100644
+--- tests/emptyfile.c
++++ tests/emptyfile.c
+@@ -67,7 +67,7 @@ check_elf (const char *fname, int class, int use_mmap)
+   printf ("\nfname: %s\n", fname);
+   stridx = 0; // Reset strtab strings index
+ 
+-  int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
++  int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s': %s\n", fname, strerror (errno));
+@@ -125,7 +125,7 @@ check_elf (const char *fname, int class, int use_mmap)
+   close (fd);
+ 
+   /* Reread the ELF from disk now.  */
+-  fd = open (fname, O_RDWR, 0666);
++  fd = open (fname, O_RDWR, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot (re)open `%s': %s\n", fname, strerror (errno));
+@@ -208,7 +208,7 @@ check_elf (const char *fname, int class, int use_mmap)
+   close (fd);
+ 
+   // And read it in one last time.
+-  fd = open (fname, O_RDONLY, 0666);
++  fd = open (fname, O_RDONLY, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s' read-only: %s\n", fname, strerror (errno));
+diff --git tests/fillfile.c tests/fillfile.c
+index 915e249d..96f2b0f9 100644
+--- tests/fillfile.c
++++ tests/fillfile.c
+@@ -201,7 +201,7 @@ check_elf (const char *fname, int class, int use_mmap)
+   printf ("\nfname: %s\n", fname);
+   stridx = 0; // Reset strtab strings index
+ 
+-  int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
++  int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s': %s\n", fname, strerror (errno));
+@@ -266,7 +266,7 @@ check_elf (const char *fname, int class, int use_mmap)
+ 
+   /* Reread the ELF from disk now.  */
+   printf ("Rereading %s\n", fname);
+-  fd = open (fname, O_RDWR, 0666);
++  fd = open (fname, O_RDWR, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot (re)open `%s': %s\n", fname, strerror (errno));
+@@ -347,7 +347,7 @@ check_elf (const char *fname, int class, int use_mmap)
+ 
+   // And read it in one last time.
+   printf ("Rereading %s again\n", fname);
+-  fd = open (fname, O_RDONLY, 0666);
++  fd = open (fname, O_RDONLY, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s' read-only: %s\n", fname, strerror (errno));
+diff --git tests/newdata.c tests/newdata.c
+index 9af99564..5a512109 100644
+--- tests/newdata.c
++++ tests/newdata.c
+@@ -243,7 +243,7 @@ check_elf (int class, int use_mmap)
+ 
+   printf ("\ncheck_elf: %s\n", fname);
+ 
+-  int fd = open (fname, O_RDWR|O_CREAT|O_TRUNC, 00666);
++  int fd = open (fname, O_RDWR|O_CREAT|O_TRUNC, 0DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot create `%s': %s\n", fname, strerror (errno));
+diff --git tests/update1.c tests/update1.c
+index f4c14753..e2370936 100644
+--- tests/update1.c
++++ tests/update1.c
+@@ -38,7 +38,7 @@ main (int argc, char *argv[] __attribute__ ((unused)))
+   Elf32_Ehdr *ehdr;
+   int i;
+ 
+-  fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
++  fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s': %s\n", fname, strerror (errno));
+diff --git tests/update2.c tests/update2.c
+index 5805163d..14a62cfa 100644
+--- tests/update2.c
++++ tests/update2.c
+@@ -39,7 +39,7 @@ main (int argc, char *argv[] __attribute__ ((unused)))
+   Elf32_Phdr *phdr;
+   int i;
+ 
+-  fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
++  fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s': %s\n", fname, strerror (errno));
+diff --git tests/update3.c tests/update3.c
+index 7a4224dd..f7c8c28b 100644
+--- tests/update3.c
++++ tests/update3.c
+@@ -46,7 +46,7 @@ main (int argc, char *argv[] __attribute__ ((unused)))
+   Dwelf_Strent *shstrtabse;
+   int i;
+ 
+-  fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
++  fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s': %s\n", fname, strerror (errno));
+diff --git tests/update4.c tests/update4.c
+index a9bd4bf9..45153d73 100644
+--- tests/update4.c
++++ tests/update4.c
+@@ -50,7 +50,7 @@ main (int argc, char *argv[] __attribute__ ((unused)))
+   Dwelf_Strent *shstrtabse;
+   int i;
+ 
+-  fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
++  fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s': %s\n", fname, strerror (errno));
+diff --git tests/vendorelf.c tests/vendorelf.c
+index bc13cce3..23f59af5 100644
+--- tests/vendorelf.c
++++ tests/vendorelf.c
+@@ -36,7 +36,7 @@ check_elf (const char *fname, int class, int use_mmap)
+ {
+   printf ("\nfname: %s\n", fname);
+ 
+-  int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
++  int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s': %s\n", fname, strerror (errno));
+@@ -124,7 +124,7 @@ check_elf (const char *fname, int class, int use_mmap)
+   close (fd);
+ 
+   /* Reread the ELF from disk now.  */
+-  fd = open (fname, O_RDONLY, 0666);
++  fd = open (fname, O_RDONLY, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s' read-only: %s\n", fname, strerror (errno));
diff --git a/srcpkgs/elfutils/patches/musl-strndupa.patch b/srcpkgs/elfutils/patches/musl-strndupa.patch
deleted file mode 100644
index f365fb019f2..00000000000
--- a/srcpkgs/elfutils/patches/musl-strndupa.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- src/unstrip.c.orig	2017-04-27 14:26:26.000000000 +0000
-+++ 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/srcpkgs/elfutils/template b/srcpkgs/elfutils/template
index 02e6e20c64b..c41c9ee4aaa 100644
--- a/srcpkgs/elfutils/template
+++ b/srcpkgs/elfutils/template
@@ -1,22 +1,26 @@
 # Template file for 'elfutils'
 pkgname=elfutils
-version=0.181
+version=0.182
 revision=1
 build_style=gnu-configure
-configure_args="--program-prefix=eu- --disable-debuginfod --disable-libdebuginfod"
+configure_args="--program-prefix=eu-"
 hostmakedepends="automake libtool pkg-config"
-makedepends="bzip2-devel liblzma-devel zlib-devel"
+makedepends="bzip2-devel liblzma-devel zlib-devel
+ libcurl-devel libarchive-devel sqlite-devel libmicrohttpd-devel"
 short_desc="Utilities to handle ELF object files"
-maintainer="Orphaned <orphan@voidlinux.org>"
+maintainer="Érico Nogueira <ericonr@disroot.org>"
 license="GPL-3.0-or-later"
 homepage="https://sourceware.org/elfutils/"
 distfiles="https://sourceware.org/${pkgname}/ftp/${version}/${pkgname}-${version}.tar.bz2"
-checksum=29a6ad7421ec2acfee489bb4a699908281ead2cb63a20a027ce8804a165f0eb3
+checksum=ecc406914edf335f0b7fc084ebe6c460c4d6d5175bfdd6688c1c78d9146b8858
 
 CFLAGS="-Wno-error"
+CXXFLAGS="-Wl,-z,stack-size=2097152"
 
 if [ "$XBPS_TARGET_LIBC" = musl ]; then
-	makedepends+=" argp-standalone musl-fts-devel musl-obstack-devel"
+	makedepends+=" argp-standalone musl-fts-devel musl-obstack-devel musl-legacy-compat"
+	# XXX: breaks some expected functionality
+	CFLAGS+=" -DFNM_EXTMATCH=0"
 fi
 
 post_extract() {
@@ -30,6 +34,22 @@ pre_configure() {
 	autoreconf -if
 }
 
+libdebuginfod_package() {
+	short_desc+=" - debuginfod library"
+	pkg_install() {
+		vmove "usr/lib/libdebuginfod-*.so*"
+	}
+}
+
+debuginfod_package() {
+	short_desc+=" - debuginfod programs"
+	pkg_install() {
+		vmove "usr/bin/debuginfod*"
+		vmove "usr/share/man/man1/debuginfod-find.1"
+		vmove "usr/share/man/man8/debuginfod.8"
+	}
+}
+
 libelf_package() {
 	short_desc+=" - runtime library"
 	pkg_install() {
@@ -38,11 +58,13 @@ libelf_package() {
 }
 
 elfutils-devel_package() {
-	depends="libelf>=${version}_${revision} ${makedepends}"
+	depends="libelf>=${version}_${revision} libdebuginfod>=${version}_${revision}
+	 ${makedepends}"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig
 		vmove "usr/lib/*.a"
+		vmove usr/share/man/man3
 	}
 }
diff --git a/srcpkgs/libdebuginfod b/srcpkgs/libdebuginfod
new file mode 120000
index 00000000000..b76b36cfac4
--- /dev/null
+++ b/srcpkgs/libdebuginfod
@@ -0,0 +1 @@
+elfutils
\ No newline at end of file

From b1e6176323f9c0903df87bc51c317a338be1e562 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
Date: Sun, 25 Oct 2020 18:23:45 -0300
Subject: [PATCH 2/2] gdb: add debuginfod option, enable by default.

---
 srcpkgs/gdb/template | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/srcpkgs/gdb/template b/srcpkgs/gdb/template
index 0e2e399e798..e2a39e7d103 100644
--- a/srcpkgs/gdb/template
+++ b/srcpkgs/gdb/template
@@ -1,16 +1,18 @@
 # Template file for 'gdb'
 pkgname=gdb
 version=10.1
-revision=1
+revision=2
 build_style=gnu-configure
 pycompile_dirs="/usr/share/gdb/python"
 configure_args="--disable-werror --disable-nls --with-system-readline
  --with-system-gdbinit=/etc/gdb/gdbinit --with-system-zlib $(vopt_enable gdbserver)
  $(vopt_if static 'CFLAGS=-static CXXFLAGS=-static LDFLAGS=-static')
- $(vopt_if python --with-python=/usr/bin/python3)"
-hostmakedepends="texinfo perl $(vopt_if python python3-devel)"
+ $(vopt_if python --with-python=/usr/bin/python3)
+ $(vopt_with debuginfod)"
+hostmakedepends="texinfo perl pkg-config $(vopt_if python python3-devel)"
 makedepends="ncurses-devel zlib-devel readline-devel expat-devel
- $(vopt_if python 'python3-devel gettext-libs')"
+ $(vopt_if python 'python3-devel gettext-libs')
+ $(vopt_if debuginfod elfutils-devel)"
 short_desc="GNU Debugger"
 maintainer="Anthony Iliopoulos <ailiop@altatus.com>"
 license="GPL-3.0-or-later"
@@ -28,10 +30,11 @@ fi
 CFLAGS+=" -fcommon"
 CXXFLAGS+=" -fcommon"
 # Package build options
-build_options="gdbserver static python"
+build_options="gdbserver static python debuginfod"
 desc_option_gdbserver="Enable support for building GDB server"
+desc_option_debuginfod="Enable support for libdebuginfod"
 # Enable gdbserver if !static.
-build_options_default="gdbserver python"
+build_options_default="gdbserver python debuginfod"
 # Both options cannot be enabled at the same time
 vopt_conflict gdbserver static
 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PR PATCH] [Updated] Update elfutils to 0.182.
  2020-11-02  1:56 [PR PATCH] Update elfutils to 0.182 ericonr
  2020-11-02  1:58 ` [PR PATCH] [Updated] " ericonr
  2020-11-02  2:01 ` ericonr
@ 2020-11-02  2:02 ` ericonr
  2020-11-02  2:03 ` ericonr
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: ericonr @ 2020-11-02  2:02 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 462 bytes --]

There is an updated pull request by ericonr against master on the void-packages repository

https://github.com/ericonr/void-packages debuginfod
https://github.com/void-linux/void-packages/pull/26067

Update elfutils to 0.182.
Also create the debuginfod subpackage and use it in gdb.

This PR can wait on some musl patches that I'd like to backport for the fregs patch.

A patch file from https://github.com/void-linux/void-packages/pull/26067.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-debuginfod-26067.patch --]
[-- Type: text/x-diff, Size: 31193 bytes --]

From 33c52c8f466957c1a9d99e44f16dc870b6663d45 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
Date: Sun, 25 Oct 2020 18:57:17 -0300
Subject: [PATCH 1/2] elfutils: update to 0.182, add debuginfod subpkgs, adopt.

Cleaned up patches, fixed the aarch64-fregs one (it was doing the wrong
thing), and moved closer to where upstream is moving regarding musl
compat.
---
 common/shlibs                                 |   1 +
 srcpkgs/debuginfod                            |   1 +
 srcpkgs/elfutils/patches/debuginfod.patch     |  13 +
 .../elfutils/patches/fix-aarch64_fregs.patch  |  22 +-
 .../elfutils/patches/fix-uninitialized.patch  |  11 -
 srcpkgs/elfutils/patches/fts-obstack.patch    | 107 ++++++
 srcpkgs/elfutils/patches/musl-cdefs.patch     |  30 --
 .../elfutils/patches/musl-fts-obstack.patch   |  87 -----
 srcpkgs/elfutils/patches/musl-macros.patch    | 339 +++++++++++++++---
 srcpkgs/elfutils/patches/musl-strndupa.patch  |  18 -
 srcpkgs/elfutils/template                     |  36 +-
 srcpkgs/libdebuginfod                         |   1 +
 12 files changed, 450 insertions(+), 216 deletions(-)
 create mode 120000 srcpkgs/debuginfod
 create mode 100644 srcpkgs/elfutils/patches/debuginfod.patch
 delete mode 100644 srcpkgs/elfutils/patches/fix-uninitialized.patch
 create mode 100644 srcpkgs/elfutils/patches/fts-obstack.patch
 delete mode 100644 srcpkgs/elfutils/patches/musl-cdefs.patch
 delete mode 100644 srcpkgs/elfutils/patches/musl-fts-obstack.patch
 delete mode 100644 srcpkgs/elfutils/patches/musl-strndupa.patch
 create mode 120000 srcpkgs/libdebuginfod

diff --git a/common/shlibs b/common/shlibs
index e0e75cea1b4..54253148fd0 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -736,6 +736,7 @@ libmtp.so.9 libmtp-1.1.4_1
 libelf.so.1 libelf-0.155_1
 libdw.so.1 libelf-0.155_1
 libasm.so.1 libelf-0.155_1
+libdebuginfod.so.1 libdebuginfod-0.182_1
 libgtksourceview-3.0.so.1 gtksourceview-3.8.0_1
 libtalloc.so.2 talloc-2.0.1_1
 libmount.so.1 libmount-2.18_1
diff --git a/srcpkgs/debuginfod b/srcpkgs/debuginfod
new file mode 120000
index 00000000000..b76b36cfac4
--- /dev/null
+++ b/srcpkgs/debuginfod
@@ -0,0 +1 @@
+elfutils
\ No newline at end of file
diff --git a/srcpkgs/elfutils/patches/debuginfod.patch b/srcpkgs/elfutils/patches/debuginfod.patch
new file mode 100644
index 00000000000..d26d945d1ff
--- /dev/null
+++ b/srcpkgs/elfutils/patches/debuginfod.patch
@@ -0,0 +1,13 @@
+diff --git debuginfod/debuginfod.cxx debuginfod/debuginfod.cxx
+index 3085f388..d2a434ee 100644
+--- debuginfod/debuginfod.cxx
++++ debuginfod/debuginfod.cxx
+@@ -46,7 +46,7 @@ extern "C" {
+ #include <unistd.h>
+ #include <stdlib.h>
+ #include <error.h>
+-// #include <libintl.h> // not until it supports C++ << better
++#include <libintl.h>
+ #include <locale.h>
+ #include <pthread.h>
+ #include <signal.h>
diff --git a/srcpkgs/elfutils/patches/fix-aarch64_fregs.patch b/srcpkgs/elfutils/patches/fix-aarch64_fregs.patch
index e9641542144..070d2527656 100644
--- a/srcpkgs/elfutils/patches/fix-aarch64_fregs.patch
+++ b/srcpkgs/elfutils/patches/fix-aarch64_fregs.patch
@@ -1,14 +1,22 @@
-It looks like fregs.vregs[] is an array of double?
-Casting to Dwarf_Word instead of & 0xFFFFFFF should do.
-
---- backends/aarch64_initreg.c	2015-11-27 14:36:29.000000000 +0100
-+++ backends/aarch64_initreg.c	2016-08-09 03:47:25.428560159 +0200
-@@ -82,7 +83,7 @@
+diff --git backends/aarch64_initreg.c backends/aarch64_initreg.c
+index daf6f375..02ca1dc0 100644
+--- backends/aarch64_initreg.c
++++ backends/aarch64_initreg.c
+@@ -46,6 +46,8 @@
+ #define BACKEND aarch64_
+ #include "libebl_CPU.h"
+ 
++#include <string.h>
++
+ bool
+ aarch64_set_initial_registers_tid (pid_t tid __attribute__ ((unused)),
+ 			  ebl_tid_registers_t *setfunc __attribute__ ((unused)),
+@@ -82,7 +84,7 @@ aarch64_set_initial_registers_tid (pid_t tid __attribute__ ((unused)),
  
    Dwarf_Word dwarf_fregs[32];
    for (int r = 0; r < 32; r++)
 -    dwarf_fregs[r] = fregs.vregs[r] & 0xFFFFFFFF;
-+    dwarf_fregs[r] = (Dwarf_Word)fregs.vregs[r];
++    memcpy(dwarf_fregs + r, fregs.vregs + r, sizeof(dwarf_fregs[0]));
  
    if (! setfunc (64, 32, dwarf_fregs, arg))
      return false;
diff --git a/srcpkgs/elfutils/patches/fix-uninitialized.patch b/srcpkgs/elfutils/patches/fix-uninitialized.patch
deleted file mode 100644
index 6ab15e50e2b..00000000000
--- a/srcpkgs/elfutils/patches/fix-uninitialized.patch
+++ /dev/null
@@ -1,11 +0,0 @@
-
---- libcpu/i386_disasm.c	2015-08-21 14:22:37.000000000 +0200
-+++ libcpu/i386_disasm.c	2015-11-20 06:30:59.250629957 +0100
-@@ -710,6 +710,7 @@
- 
- 		case 'm':
- 		  /* Mnemonic.  */
-+		  str = mnebuf;
- 
- 		  if (unlikely (instrtab[cnt].mnemonic == MNE_INVALID))
- 		    {
diff --git a/srcpkgs/elfutils/patches/fts-obstack.patch b/srcpkgs/elfutils/patches/fts-obstack.patch
new file mode 100644
index 00000000000..44ef0aee70e
--- /dev/null
+++ b/srcpkgs/elfutils/patches/fts-obstack.patch
@@ -0,0 +1,107 @@
+diff --git ChangeLog ChangeLog
+index 128da6c6..565d021c 100644
+--- ChangeLog
++++ ChangeLog
+@@ -1,3 +1,7 @@
++2020-11-01  Érico N. Rolim  <erico.erc@gmail.com>
++
++	* configure.ac: Check for fts and obstack from outside libc.
++
+ 2020-10-28  Mark Wielaard  <mark@klomp.org>
+ 
+ 	* configure.ac: Set version to 0.182.
+diff --git configure.ac configure.ac
+index 515ac704..c1a6954d 100644
+--- configure.ac
++++ configure.ac
+@@ -542,6 +542,26 @@ else
+ fi
+ AC_SUBST([argp_LDADD])
+ 
++saved_LIBS="$LIBS"
++AC_SEARCH_LIBS([fts_close], [fts])
++LIBS="$saved_LIBS"
++case "$ac_cv_search_fts_close" in
++        no) AC_MSG_FAILURE([failed to find fts_close]) ;;
++        -l*) fts_LIBS="$ac_cv_search_fts_close" ;;
++        *) fts_LIBS= ;;
++esac
++AC_SUBST([fts_LIBS])
++
++saved_LIBS="$LIBS"
++AC_SEARCH_LIBS([_obstack_free], [obstack])
++LIBS="$saved_LIBS"
++case "$ac_cv_search__obstack_free" in
++        no) AC_MSG_FAILURE([failed to find obstack_free]) ;;
++        -l*) obstack_LIBS="$ac_cv_search__obstack_free" ;;
++        *) obstack_LIBS= ;;
++esac
++AC_SUBST([obstack_LIBS])
++
+ dnl The directories with content.
+ 
+ dnl Documentation.
+diff --git debuginfod/Makefile.am debuginfod/Makefile.am
+index 01985600..0af3b58c 100644
+--- debuginfod/Makefile.am
++++ debuginfod/Makefile.am
+@@ -71,10 +71,10 @@ bin_PROGRAMS += debuginfod-find
+ endif
+ 
+ debuginfod_SOURCES = debuginfod.cxx
+-debuginfod_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod) $(libmicrohttpd_LIBS) $(sqlite3_LIBS) $(libarchive_LIBS) -lpthread -ldl
++debuginfod_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod) $(argp_LDADD) $(fts_LIBS) $(libmicrohttpd_LIBS) $(sqlite3_LIBS) $(libarchive_LIBS) -lpthread -ldl
+ 
+ debuginfod_find_SOURCES = debuginfod-find.c
+-debuginfod_find_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod)
++debuginfod_find_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod) $(argp_LDADD) $(fts_LIBS)
+ 
+ if LIBDEBUGINFOD
+ noinst_LIBRARIES = libdebuginfod.a
+@@ -98,7 +98,7 @@ libdebuginfod_so_LIBS = libdebuginfod_pic.a
+ if DUMMY_LIBDEBUGINFOD
+ libdebuginfod_so_LDLIBS =
+ else
+-libdebuginfod_so_LDLIBS = $(libcurl_LIBS)
++libdebuginfod_so_LDLIBS = $(libcurl_LIBS) $(fts_LIBS)
+ endif
+ libdebuginfod.so$(EXEEXT): $(srcdir)/libdebuginfod.map $(libdebuginfod_so_LIBS)
+ 	$(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $@ \
+diff --git libdw/Makefile.am libdw/Makefile.am
+index 33b5838d..1dbb3d5e 100644
+--- libdw/Makefile.am
++++ libdw/Makefile.am
+@@ -109,7 +109,7 @@ libdw_so_LIBS = ../libebl/libebl_pic.a ../backends/libebl_backends_pic.a \
+ 		../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_LIBS) $(obstack_LIBS) $(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 src/Makefile.am src/Makefile.am
+index e462e7d7..88d0ac8f 100644
+--- src/Makefile.am
++++ src/Makefile.am
+@@ -69,7 +69,7 @@ ar_no_Wstack_usage = yes
+ unstrip_no_Wstack_usage = yes
+ 
+ readelf_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD)
+-nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) \
++nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) $(obstack_LIBS) \
+ 	   $(demanglelib)
+ size_LDADD = $(libelf) $(libeu) $(argp_LDADD)
+ strip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
+@@ -78,9 +78,9 @@ findtextrel_LDADD = $(libdw) $(libelf) $(libeu) $(argp_LDADD)
+ addr2line_LDADD = $(libdw) $(libelf) $(libeu) $(argp_LDADD) $(demanglelib)
+ elfcmp_LDADD = $(libebl) $(libdw) $(libelf) $(libeu) $(argp_LDADD)
+ objdump_LDADD  = $(libasm) $(libebl) $(libdw) $(libelf) $(libeu) $(argp_LDADD)
+-ranlib_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD)
++ranlib_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD) $(obstack_LIBS)
+ strings_LDADD = $(libelf) $(libeu) $(argp_LDADD)
+-ar_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD)
++ar_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD) $(obstack_LIBS)
+ unstrip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
+ stack_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) $(demanglelib)
+ elfcompress_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
diff --git a/srcpkgs/elfutils/patches/musl-cdefs.patch b/srcpkgs/elfutils/patches/musl-cdefs.patch
deleted file mode 100644
index 65ef9f4d23c..00000000000
--- a/srcpkgs/elfutils/patches/musl-cdefs.patch
+++ /dev/null
@@ -1,30 +0,0 @@
---- libelf/elf.h	2015-08-21 14:22:37.000000000 +0200
-+++ libelf/elf.h	2015-11-20 04:54:33.948081321 +0100
-@@ -21,6 +21,17 @@
- 
- #include <features.h>
- 
-+#if !defined(__BEGIN_DECLS)
-+/* C++ needs to know that types and declarations are C, not C++.  */
-+#ifdef  __cplusplus
-+# define __BEGIN_DECLS  extern "C" {
-+# define __END_DECLS    }
-+#else
-+# define __BEGIN_DECLS
-+# define __END_DECLS
-+#endif
-+#endif
-+
- __BEGIN_DECLS
- 
- /* Standard ELF types.  */
---- lib/fixedsizehash.h.orig
-+++ lib/fixedsizehash.h
-@@ -30,7 +30,6 @@
- #include <errno.h>
- #include <stdlib.h>
- #include <string.h>
--#include <sys/cdefs.h>
- 
- #include <system.h>
- 
diff --git a/srcpkgs/elfutils/patches/musl-fts-obstack.patch b/srcpkgs/elfutils/patches/musl-fts-obstack.patch
deleted file mode 100644
index 77e3c4ea040..00000000000
--- a/srcpkgs/elfutils/patches/musl-fts-obstack.patch
+++ /dev/null
@@ -1,87 +0,0 @@
---- configure.ac	2015-10-15 15:16:57.000000000 +0200
-+++ 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.
---- src/Makefile.am.orig
-+++ 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
---- libdw/Makefile.am.orig
-+++ 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/srcpkgs/elfutils/patches/musl-macros.patch b/srcpkgs/elfutils/patches/musl-macros.patch
index 8ce586b2930..ff5d06efac0 100644
--- a/srcpkgs/elfutils/patches/musl-macros.patch
+++ b/srcpkgs/elfutils/patches/musl-macros.patch
@@ -1,66 +1,293 @@
---- src/arlib.h	2015-08-21 14:22:37.000000000 +0200
-+++ src/arlib.h	2015-11-20 08:02:55.153199611 +0100
-@@ -29,6 +29,16 @@
- #include <stdint.h>
- #include <sys/types.h>
- 
-+#if !defined(ACCESSPERMS)
-+# define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
-+#endif
-+#if !defined(ALLPERMS)
-+# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
-+#endif
-+#if !defined(DEFFILEMODE)
-+# define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)/* 0666*/
-+#endif
-+
+diff --git debuginfod/debuginfod-client.c debuginfod/debuginfod-client.c
+index 0e5177bc..ce1d819b 100644
+--- debuginfod/debuginfod-client.c
++++ debuginfod/debuginfod-client.c
+@@ -212,13 +212,13 @@ debuginfod_init_cache (char *cache_path, char *interval_path, char *maxage_path)
+     return 0;
  
- /* State of -D/-U flags.  */
- extern bool arlib_deterministic_output;
---- src/elfcompress.c.orig	2016-04-02 12:51:26.903848894 +0200
-+++ src/elfcompress.c	2016-04-02 12:55:15.076996338 +0200
-@@ -35,6 +35,14 @@
- #include <gelf.h>
- #include "system.h"
+   /* Create the cache and config files as necessary.  */
+-  if (stat(cache_path, &st) != 0 && mkdir(cache_path, 0777) < 0)
++  if (stat(cache_path, &st) != 0 && mkdir(cache_path, ACCESSPERMS) < 0)
+     return -errno;
  
-+#if !defined(FNM_EXTMATCH)
-+# define FNM_EXTMATCH 0
-+#endif
-+
-+#if !defined(ALLPERMS)
-+# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
+   int fd = -1;
+ 
+   /* init cleaning interval config file.  */
+-  fd = open(interval_path, O_CREAT | O_RDWR, 0666);
++  fd = open(interval_path, O_CREAT | O_RDWR, DEFFILEMODE);
+   if (fd < 0)
+     return -errno;
+ 
+@@ -227,7 +227,7 @@ debuginfod_init_cache (char *cache_path, char *interval_path, char *maxage_path)
+ 
+   /* init max age config file.  */
+   if (stat(maxage_path, &st) != 0
+-      && (fd = open(maxage_path, O_CREAT | O_RDWR, 0666)) < 0)
++      && (fd = open(maxage_path, O_CREAT | O_RDWR, DEFFILEMODE)) < 0)
+     return -errno;
+ 
+   if (dprintf(fd, "%ld", cache_default_max_unused_age_s) < 0)
+diff --git lib/system.h lib/system.h
+index 292082bd..5d16ebc6 100644
+--- lib/system.h
++++ lib/system.h
+@@ -85,6 +85,18 @@
+      __res; })
+ #endif
+ 
++#ifndef ACCESSPERMS
++#define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
 +#endif
 +
- /* Name and version of program.  */
- static void print_version (FILE *stream, struct argp_state *state);
- ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;
---- src/strip.c.orig	2017-08-02 12:06:25.000000000 +0000
-+++ src/strip.c	2017-08-05 01:58:01.523493062 +0000
-@@ -47,6 +47,14 @@
- #include <system.h>
- #include <printversion.h>
- 
-+#if !defined(FNM_EXTMATCH)
-+# define FNM_EXTMATCH 0
++#ifndef ALLPERMS
++#define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
 +#endif
 +
-+#if !defined(ACCESSPERMS)
-+#define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO)
++#ifndef DEFFILEMODE
++#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)/* DEFFILEMODE*/
 +#endif
 +
- typedef uint8_t GElf_Byte;
+ static inline ssize_t __attribute__ ((unused))
+ pwrite_retry (int fd, const void *buf, size_t len, off_t off)
+ {
+diff --git src/unstrip.c src/unstrip.c
+index 0257d9cc..c99ee612 100644
+--- src/unstrip.c
++++ src/unstrip.c
+@@ -315,7 +315,7 @@ make_directories (const char *path)
+   if (dir == NULL)
+     error(EXIT_FAILURE, errno, _("memory exhausted"));
  
- /* Name and version of program.  */
---- tests/elfstrmerge.c.orig	2020-09-13 08:20:50.538492600 +0700
-+++ tests/elfstrmerge.c	2020-09-13 08:21:40.205734827 +0700
-@@ -33,6 +33,10 @@
- #include ELFUTILS_HEADER(dwelf)
- #include "elf-knowledge.h"
+-  while (mkdir (dir, 0777) < 0 && errno != EEXIST)
++  while (mkdir (dir, ACCESSPERMS) < 0 && errno != EEXIST)
+     {
+       if (errno == ENOENT)
+         make_directories (dir);
+@@ -2192,7 +2192,7 @@ DWARF data in '%s' not adjusted for prelinking bias; consider prelink -u"),
  
-+#if !defined(ALLPERMS)
-+# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
-+#endif
-+
- /* The original ELF file.  */
- static int fd = -1;
- static Elf *elf = NULL;
+       /* Copy the unstripped file and then modify it.  */
+       int outfd = open (output_file, O_RDWR | O_CREAT,
+-			  stripped_ehdr->e_type == ET_REL ? 0666 : 0777);
++			  stripped_ehdr->e_type == ET_REL ? DEFFILEMODE : ACCESSPERMS);
+       if (outfd < 0)
+ 	error (EXIT_FAILURE, errno, _("cannot open '%s'"), output_file);
+       Elf *outelf = elf_begin (outfd, ELF_C_WRITE, NULL);
+diff --git tests/alldts.c tests/alldts.c
+index 28b3063c..b88a3e61 100644
+--- tests/alldts.c
++++ tests/alldts.c
+@@ -68,7 +68,7 @@ main (void)
+   (void) __fsetlocking (stdout, FSETLOCKING_BYCALLER);
+ 
+   /* Open the file.  */
+-  int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
++  int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s': %m\n", fname);
+diff --git tests/arextract.c tests/arextract.c
+index 2c4dc758..936d7f55 100644
+--- tests/arextract.c
++++ tests/arextract.c
+@@ -95,7 +95,7 @@ Failed to get base address for the archive element: %s\n",
+ 	    }
+ 
+ 	  /* Open the output file.  */
+-	  outfd = open (argv[3], O_CREAT | O_TRUNC | O_RDWR, 0666);
++	  outfd = open (argv[3], O_CREAT | O_TRUNC | O_RDWR, DEFFILEMODE);
+ 	  if (outfd == -1)
+ 	    {
+ 	      printf ("cannot open output file: %m");
+diff --git tests/ecp.c tests/ecp.c
+index 1df40a32..44a7bda2 100644
+--- tests/ecp.c
++++ tests/ecp.c
+@@ -43,7 +43,7 @@ main (int argc, char *argv[])
+     error (EXIT_FAILURE, 0, "problems opening '%s' as ELF file: %s",
+ 	   argv[1], elf_errmsg (-1));
+ 
+-  int outfd = creat (argv[2], 0666);
++  int outfd = creat (argv[2], DEFFILEMODE);
+   if (outfd == -1)
+     error (EXIT_FAILURE, errno, "cannot open output file '%s'", argv[2]);
+ 
+diff --git tests/elfstrtab.c tests/elfstrtab.c
+index c27d6cfb..9866237c 100644
+--- tests/elfstrtab.c
++++ tests/elfstrtab.c
+@@ -134,7 +134,7 @@ check_elf (const char *fname, int class, int use_mmap)
+   printf ("\nfname: %s\n", fname);
+   stridx = 0;
+ 
+-  int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
++  int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s': %s\n", fname, strerror (errno));
+@@ -280,7 +280,7 @@ check_elf (const char *fname, int class, int use_mmap)
+   close (fd);
+ 
+   /* Read the ELF from disk now.  */
+-  fd = open (fname, O_RDWR, 0666);
++  fd = open (fname, O_RDWR, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s' read-only: %s\n", fname, strerror (errno));
+@@ -349,7 +349,7 @@ check_elf (const char *fname, int class, int use_mmap)
+   close (fd);
+ 
+   // And read it in one last time.
+-  fd = open (fname, O_RDONLY, 0666);
++  fd = open (fname, O_RDONLY, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s' read-only: %s\n", fname, strerror (errno));
+diff --git tests/emptyfile.c tests/emptyfile.c
+index 6d086246..18036ebe 100644
+--- tests/emptyfile.c
++++ tests/emptyfile.c
+@@ -67,7 +67,7 @@ check_elf (const char *fname, int class, int use_mmap)
+   printf ("\nfname: %s\n", fname);
+   stridx = 0; // Reset strtab strings index
+ 
+-  int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
++  int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s': %s\n", fname, strerror (errno));
+@@ -125,7 +125,7 @@ check_elf (const char *fname, int class, int use_mmap)
+   close (fd);
+ 
+   /* Reread the ELF from disk now.  */
+-  fd = open (fname, O_RDWR, 0666);
++  fd = open (fname, O_RDWR, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot (re)open `%s': %s\n", fname, strerror (errno));
+@@ -208,7 +208,7 @@ check_elf (const char *fname, int class, int use_mmap)
+   close (fd);
+ 
+   // And read it in one last time.
+-  fd = open (fname, O_RDONLY, 0666);
++  fd = open (fname, O_RDONLY, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s' read-only: %s\n", fname, strerror (errno));
+diff --git tests/fillfile.c tests/fillfile.c
+index 915e249d..96f2b0f9 100644
+--- tests/fillfile.c
++++ tests/fillfile.c
+@@ -201,7 +201,7 @@ check_elf (const char *fname, int class, int use_mmap)
+   printf ("\nfname: %s\n", fname);
+   stridx = 0; // Reset strtab strings index
+ 
+-  int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
++  int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s': %s\n", fname, strerror (errno));
+@@ -266,7 +266,7 @@ check_elf (const char *fname, int class, int use_mmap)
+ 
+   /* Reread the ELF from disk now.  */
+   printf ("Rereading %s\n", fname);
+-  fd = open (fname, O_RDWR, 0666);
++  fd = open (fname, O_RDWR, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot (re)open `%s': %s\n", fname, strerror (errno));
+@@ -347,7 +347,7 @@ check_elf (const char *fname, int class, int use_mmap)
+ 
+   // And read it in one last time.
+   printf ("Rereading %s again\n", fname);
+-  fd = open (fname, O_RDONLY, 0666);
++  fd = open (fname, O_RDONLY, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s' read-only: %s\n", fname, strerror (errno));
+diff --git tests/newdata.c tests/newdata.c
+index 9af99564..5a512109 100644
+--- tests/newdata.c
++++ tests/newdata.c
+@@ -243,7 +243,7 @@ check_elf (int class, int use_mmap)
+ 
+   printf ("\ncheck_elf: %s\n", fname);
+ 
+-  int fd = open (fname, O_RDWR|O_CREAT|O_TRUNC, 00666);
++  int fd = open (fname, O_RDWR|O_CREAT|O_TRUNC, 0DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot create `%s': %s\n", fname, strerror (errno));
+diff --git tests/update1.c tests/update1.c
+index f4c14753..e2370936 100644
+--- tests/update1.c
++++ tests/update1.c
+@@ -38,7 +38,7 @@ main (int argc, char *argv[] __attribute__ ((unused)))
+   Elf32_Ehdr *ehdr;
+   int i;
+ 
+-  fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
++  fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s': %s\n", fname, strerror (errno));
+diff --git tests/update2.c tests/update2.c
+index 5805163d..14a62cfa 100644
+--- tests/update2.c
++++ tests/update2.c
+@@ -39,7 +39,7 @@ main (int argc, char *argv[] __attribute__ ((unused)))
+   Elf32_Phdr *phdr;
+   int i;
+ 
+-  fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
++  fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s': %s\n", fname, strerror (errno));
+diff --git tests/update3.c tests/update3.c
+index 7a4224dd..f7c8c28b 100644
+--- tests/update3.c
++++ tests/update3.c
+@@ -46,7 +46,7 @@ main (int argc, char *argv[] __attribute__ ((unused)))
+   Dwelf_Strent *shstrtabse;
+   int i;
+ 
+-  fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
++  fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s': %s\n", fname, strerror (errno));
+diff --git tests/update4.c tests/update4.c
+index a9bd4bf9..45153d73 100644
+--- tests/update4.c
++++ tests/update4.c
+@@ -50,7 +50,7 @@ main (int argc, char *argv[] __attribute__ ((unused)))
+   Dwelf_Strent *shstrtabse;
+   int i;
+ 
+-  fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
++  fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s': %s\n", fname, strerror (errno));
+diff --git tests/vendorelf.c tests/vendorelf.c
+index bc13cce3..23f59af5 100644
+--- tests/vendorelf.c
++++ tests/vendorelf.c
+@@ -36,7 +36,7 @@ check_elf (const char *fname, int class, int use_mmap)
+ {
+   printf ("\nfname: %s\n", fname);
+ 
+-  int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
++  int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s': %s\n", fname, strerror (errno));
+@@ -124,7 +124,7 @@ check_elf (const char *fname, int class, int use_mmap)
+   close (fd);
+ 
+   /* Reread the ELF from disk now.  */
+-  fd = open (fname, O_RDONLY, 0666);
++  fd = open (fname, O_RDONLY, DEFFILEMODE);
+   if (fd == -1)
+     {
+       printf ("cannot open `%s' read-only: %s\n", fname, strerror (errno));
diff --git a/srcpkgs/elfutils/patches/musl-strndupa.patch b/srcpkgs/elfutils/patches/musl-strndupa.patch
deleted file mode 100644
index f365fb019f2..00000000000
--- a/srcpkgs/elfutils/patches/musl-strndupa.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- src/unstrip.c.orig	2017-04-27 14:26:26.000000000 +0000
-+++ 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/srcpkgs/elfutils/template b/srcpkgs/elfutils/template
index 02e6e20c64b..c41c9ee4aaa 100644
--- a/srcpkgs/elfutils/template
+++ b/srcpkgs/elfutils/template
@@ -1,22 +1,26 @@
 # Template file for 'elfutils'
 pkgname=elfutils
-version=0.181
+version=0.182
 revision=1
 build_style=gnu-configure
-configure_args="--program-prefix=eu- --disable-debuginfod --disable-libdebuginfod"
+configure_args="--program-prefix=eu-"
 hostmakedepends="automake libtool pkg-config"
-makedepends="bzip2-devel liblzma-devel zlib-devel"
+makedepends="bzip2-devel liblzma-devel zlib-devel
+ libcurl-devel libarchive-devel sqlite-devel libmicrohttpd-devel"
 short_desc="Utilities to handle ELF object files"
-maintainer="Orphaned <orphan@voidlinux.org>"
+maintainer="Érico Nogueira <ericonr@disroot.org>"
 license="GPL-3.0-or-later"
 homepage="https://sourceware.org/elfutils/"
 distfiles="https://sourceware.org/${pkgname}/ftp/${version}/${pkgname}-${version}.tar.bz2"
-checksum=29a6ad7421ec2acfee489bb4a699908281ead2cb63a20a027ce8804a165f0eb3
+checksum=ecc406914edf335f0b7fc084ebe6c460c4d6d5175bfdd6688c1c78d9146b8858
 
 CFLAGS="-Wno-error"
+CXXFLAGS="-Wl,-z,stack-size=2097152"
 
 if [ "$XBPS_TARGET_LIBC" = musl ]; then
-	makedepends+=" argp-standalone musl-fts-devel musl-obstack-devel"
+	makedepends+=" argp-standalone musl-fts-devel musl-obstack-devel musl-legacy-compat"
+	# XXX: breaks some expected functionality
+	CFLAGS+=" -DFNM_EXTMATCH=0"
 fi
 
 post_extract() {
@@ -30,6 +34,22 @@ pre_configure() {
 	autoreconf -if
 }
 
+libdebuginfod_package() {
+	short_desc+=" - debuginfod library"
+	pkg_install() {
+		vmove "usr/lib/libdebuginfod-*.so*"
+	}
+}
+
+debuginfod_package() {
+	short_desc+=" - debuginfod programs"
+	pkg_install() {
+		vmove "usr/bin/debuginfod*"
+		vmove "usr/share/man/man1/debuginfod-find.1"
+		vmove "usr/share/man/man8/debuginfod.8"
+	}
+}
+
 libelf_package() {
 	short_desc+=" - runtime library"
 	pkg_install() {
@@ -38,11 +58,13 @@ libelf_package() {
 }
 
 elfutils-devel_package() {
-	depends="libelf>=${version}_${revision} ${makedepends}"
+	depends="libelf>=${version}_${revision} libdebuginfod>=${version}_${revision}
+	 ${makedepends}"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig
 		vmove "usr/lib/*.a"
+		vmove usr/share/man/man3
 	}
 }
diff --git a/srcpkgs/libdebuginfod b/srcpkgs/libdebuginfod
new file mode 120000
index 00000000000..b76b36cfac4
--- /dev/null
+++ b/srcpkgs/libdebuginfod
@@ -0,0 +1 @@
+elfutils
\ No newline at end of file

From 174c9a793872cb0a87fdb7cd2999874d01c84507 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
Date: Sun, 25 Oct 2020 18:23:45 -0300
Subject: [PATCH 2/2] gdb: add debuginfod option, enable by default.

---
 srcpkgs/gdb/template | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/srcpkgs/gdb/template b/srcpkgs/gdb/template
index 0e2e399e798..e2a39e7d103 100644
--- a/srcpkgs/gdb/template
+++ b/srcpkgs/gdb/template
@@ -1,16 +1,18 @@
 # Template file for 'gdb'
 pkgname=gdb
 version=10.1
-revision=1
+revision=2
 build_style=gnu-configure
 pycompile_dirs="/usr/share/gdb/python"
 configure_args="--disable-werror --disable-nls --with-system-readline
  --with-system-gdbinit=/etc/gdb/gdbinit --with-system-zlib $(vopt_enable gdbserver)
  $(vopt_if static 'CFLAGS=-static CXXFLAGS=-static LDFLAGS=-static')
- $(vopt_if python --with-python=/usr/bin/python3)"
-hostmakedepends="texinfo perl $(vopt_if python python3-devel)"
+ $(vopt_if python --with-python=/usr/bin/python3)
+ $(vopt_with debuginfod)"
+hostmakedepends="texinfo perl pkg-config $(vopt_if python python3-devel)"
 makedepends="ncurses-devel zlib-devel readline-devel expat-devel
- $(vopt_if python 'python3-devel gettext-libs')"
+ $(vopt_if python 'python3-devel gettext-libs')
+ $(vopt_if debuginfod elfutils-devel)"
 short_desc="GNU Debugger"
 maintainer="Anthony Iliopoulos <ailiop@altatus.com>"
 license="GPL-3.0-or-later"
@@ -28,10 +30,11 @@ fi
 CFLAGS+=" -fcommon"
 CXXFLAGS+=" -fcommon"
 # Package build options
-build_options="gdbserver static python"
+build_options="gdbserver static python debuginfod"
 desc_option_gdbserver="Enable support for building GDB server"
+desc_option_debuginfod="Enable support for libdebuginfod"
 # Enable gdbserver if !static.
-build_options_default="gdbserver python"
+build_options_default="gdbserver python debuginfod"
 # Both options cannot be enabled at the same time
 vopt_conflict gdbserver static
 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PR PATCH] [Updated] Update elfutils to 0.182.
  2020-11-02  1:56 [PR PATCH] Update elfutils to 0.182 ericonr
                   ` (2 preceding siblings ...)
  2020-11-02  2:02 ` ericonr
@ 2020-11-02  2:03 ` ericonr
  2020-11-02 18:21 ` ericonr
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: ericonr @ 2020-11-02  2:03 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 462 bytes --]

There is an updated pull request by ericonr against master on the void-packages repository

https://github.com/ericonr/void-packages debuginfod
https://github.com/void-linux/void-packages/pull/26067

Update elfutils to 0.182.
Also create the debuginfod subpackage and use it in gdb.

This PR can wait on some musl patches that I'd like to backport for the fregs patch.

A patch file from https://github.com/void-linux/void-packages/pull/26067.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-debuginfod-26067.patch --]
[-- Type: text/x-diff, Size: 23386 bytes --]

From 3cabb1311663d0660e3109c26107edcdb60e05e8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
Date: Sun, 25 Oct 2020 18:57:17 -0300
Subject: [PATCH 1/2] elfutils: update to 0.182, add debuginfod subpkgs, adopt.

Cleaned up patches, fixed the aarch64-fregs one (it was doing the wrong
thing), and moved closer to where upstream is moving regarding musl
compat.
---
 common/shlibs                                 |   1 +
 srcpkgs/debuginfod                            |   1 +
 srcpkgs/elfutils/patches/debuginfod.patch     |  13 ++
 .../elfutils/patches/fix-aarch64_fregs.patch  |  22 ++--
 .../elfutils/patches/fix-uninitialized.patch  |  11 --
 srcpkgs/elfutils/patches/fts-obstack.patch    | 107 ++++++++++++++++
 srcpkgs/elfutils/patches/musl-cdefs.patch     |  30 -----
 .../elfutils/patches/musl-fts-obstack.patch   |  87 -------------
 srcpkgs/elfutils/patches/musl-macros.patch    | 118 ++++++++++--------
 srcpkgs/elfutils/patches/musl-strndupa.patch  |  18 ---
 srcpkgs/elfutils/template                     |  36 ++++--
 srcpkgs/libdebuginfod                         |   1 +
 12 files changed, 230 insertions(+), 215 deletions(-)
 create mode 120000 srcpkgs/debuginfod
 create mode 100644 srcpkgs/elfutils/patches/debuginfod.patch
 delete mode 100644 srcpkgs/elfutils/patches/fix-uninitialized.patch
 create mode 100644 srcpkgs/elfutils/patches/fts-obstack.patch
 delete mode 100644 srcpkgs/elfutils/patches/musl-cdefs.patch
 delete mode 100644 srcpkgs/elfutils/patches/musl-fts-obstack.patch
 delete mode 100644 srcpkgs/elfutils/patches/musl-strndupa.patch
 create mode 120000 srcpkgs/libdebuginfod

diff --git a/common/shlibs b/common/shlibs
index e0e75cea1b4..54253148fd0 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -736,6 +736,7 @@ libmtp.so.9 libmtp-1.1.4_1
 libelf.so.1 libelf-0.155_1
 libdw.so.1 libelf-0.155_1
 libasm.so.1 libelf-0.155_1
+libdebuginfod.so.1 libdebuginfod-0.182_1
 libgtksourceview-3.0.so.1 gtksourceview-3.8.0_1
 libtalloc.so.2 talloc-2.0.1_1
 libmount.so.1 libmount-2.18_1
diff --git a/srcpkgs/debuginfod b/srcpkgs/debuginfod
new file mode 120000
index 00000000000..b76b36cfac4
--- /dev/null
+++ b/srcpkgs/debuginfod
@@ -0,0 +1 @@
+elfutils
\ No newline at end of file
diff --git a/srcpkgs/elfutils/patches/debuginfod.patch b/srcpkgs/elfutils/patches/debuginfod.patch
new file mode 100644
index 00000000000..d26d945d1ff
--- /dev/null
+++ b/srcpkgs/elfutils/patches/debuginfod.patch
@@ -0,0 +1,13 @@
+diff --git debuginfod/debuginfod.cxx debuginfod/debuginfod.cxx
+index 3085f388..d2a434ee 100644
+--- debuginfod/debuginfod.cxx
++++ debuginfod/debuginfod.cxx
+@@ -46,7 +46,7 @@ extern "C" {
+ #include <unistd.h>
+ #include <stdlib.h>
+ #include <error.h>
+-// #include <libintl.h> // not until it supports C++ << better
++#include <libintl.h>
+ #include <locale.h>
+ #include <pthread.h>
+ #include <signal.h>
diff --git a/srcpkgs/elfutils/patches/fix-aarch64_fregs.patch b/srcpkgs/elfutils/patches/fix-aarch64_fregs.patch
index e9641542144..070d2527656 100644
--- a/srcpkgs/elfutils/patches/fix-aarch64_fregs.patch
+++ b/srcpkgs/elfutils/patches/fix-aarch64_fregs.patch
@@ -1,14 +1,22 @@
-It looks like fregs.vregs[] is an array of double?
-Casting to Dwarf_Word instead of & 0xFFFFFFF should do.
-
---- backends/aarch64_initreg.c	2015-11-27 14:36:29.000000000 +0100
-+++ backends/aarch64_initreg.c	2016-08-09 03:47:25.428560159 +0200
-@@ -82,7 +83,7 @@
+diff --git backends/aarch64_initreg.c backends/aarch64_initreg.c
+index daf6f375..02ca1dc0 100644
+--- backends/aarch64_initreg.c
++++ backends/aarch64_initreg.c
+@@ -46,6 +46,8 @@
+ #define BACKEND aarch64_
+ #include "libebl_CPU.h"
+ 
++#include <string.h>
++
+ bool
+ aarch64_set_initial_registers_tid (pid_t tid __attribute__ ((unused)),
+ 			  ebl_tid_registers_t *setfunc __attribute__ ((unused)),
+@@ -82,7 +84,7 @@ aarch64_set_initial_registers_tid (pid_t tid __attribute__ ((unused)),
  
    Dwarf_Word dwarf_fregs[32];
    for (int r = 0; r < 32; r++)
 -    dwarf_fregs[r] = fregs.vregs[r] & 0xFFFFFFFF;
-+    dwarf_fregs[r] = (Dwarf_Word)fregs.vregs[r];
++    memcpy(dwarf_fregs + r, fregs.vregs + r, sizeof(dwarf_fregs[0]));
  
    if (! setfunc (64, 32, dwarf_fregs, arg))
      return false;
diff --git a/srcpkgs/elfutils/patches/fix-uninitialized.patch b/srcpkgs/elfutils/patches/fix-uninitialized.patch
deleted file mode 100644
index 6ab15e50e2b..00000000000
--- a/srcpkgs/elfutils/patches/fix-uninitialized.patch
+++ /dev/null
@@ -1,11 +0,0 @@
-
---- libcpu/i386_disasm.c	2015-08-21 14:22:37.000000000 +0200
-+++ libcpu/i386_disasm.c	2015-11-20 06:30:59.250629957 +0100
-@@ -710,6 +710,7 @@
- 
- 		case 'm':
- 		  /* Mnemonic.  */
-+		  str = mnebuf;
- 
- 		  if (unlikely (instrtab[cnt].mnemonic == MNE_INVALID))
- 		    {
diff --git a/srcpkgs/elfutils/patches/fts-obstack.patch b/srcpkgs/elfutils/patches/fts-obstack.patch
new file mode 100644
index 00000000000..44ef0aee70e
--- /dev/null
+++ b/srcpkgs/elfutils/patches/fts-obstack.patch
@@ -0,0 +1,107 @@
+diff --git ChangeLog ChangeLog
+index 128da6c6..565d021c 100644
+--- ChangeLog
++++ ChangeLog
+@@ -1,3 +1,7 @@
++2020-11-01  Érico N. Rolim  <erico.erc@gmail.com>
++
++	* configure.ac: Check for fts and obstack from outside libc.
++
+ 2020-10-28  Mark Wielaard  <mark@klomp.org>
+ 
+ 	* configure.ac: Set version to 0.182.
+diff --git configure.ac configure.ac
+index 515ac704..c1a6954d 100644
+--- configure.ac
++++ configure.ac
+@@ -542,6 +542,26 @@ else
+ fi
+ AC_SUBST([argp_LDADD])
+ 
++saved_LIBS="$LIBS"
++AC_SEARCH_LIBS([fts_close], [fts])
++LIBS="$saved_LIBS"
++case "$ac_cv_search_fts_close" in
++        no) AC_MSG_FAILURE([failed to find fts_close]) ;;
++        -l*) fts_LIBS="$ac_cv_search_fts_close" ;;
++        *) fts_LIBS= ;;
++esac
++AC_SUBST([fts_LIBS])
++
++saved_LIBS="$LIBS"
++AC_SEARCH_LIBS([_obstack_free], [obstack])
++LIBS="$saved_LIBS"
++case "$ac_cv_search__obstack_free" in
++        no) AC_MSG_FAILURE([failed to find obstack_free]) ;;
++        -l*) obstack_LIBS="$ac_cv_search__obstack_free" ;;
++        *) obstack_LIBS= ;;
++esac
++AC_SUBST([obstack_LIBS])
++
+ dnl The directories with content.
+ 
+ dnl Documentation.
+diff --git debuginfod/Makefile.am debuginfod/Makefile.am
+index 01985600..0af3b58c 100644
+--- debuginfod/Makefile.am
++++ debuginfod/Makefile.am
+@@ -71,10 +71,10 @@ bin_PROGRAMS += debuginfod-find
+ endif
+ 
+ debuginfod_SOURCES = debuginfod.cxx
+-debuginfod_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod) $(libmicrohttpd_LIBS) $(sqlite3_LIBS) $(libarchive_LIBS) -lpthread -ldl
++debuginfod_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod) $(argp_LDADD) $(fts_LIBS) $(libmicrohttpd_LIBS) $(sqlite3_LIBS) $(libarchive_LIBS) -lpthread -ldl
+ 
+ debuginfod_find_SOURCES = debuginfod-find.c
+-debuginfod_find_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod)
++debuginfod_find_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod) $(argp_LDADD) $(fts_LIBS)
+ 
+ if LIBDEBUGINFOD
+ noinst_LIBRARIES = libdebuginfod.a
+@@ -98,7 +98,7 @@ libdebuginfod_so_LIBS = libdebuginfod_pic.a
+ if DUMMY_LIBDEBUGINFOD
+ libdebuginfod_so_LDLIBS =
+ else
+-libdebuginfod_so_LDLIBS = $(libcurl_LIBS)
++libdebuginfod_so_LDLIBS = $(libcurl_LIBS) $(fts_LIBS)
+ endif
+ libdebuginfod.so$(EXEEXT): $(srcdir)/libdebuginfod.map $(libdebuginfod_so_LIBS)
+ 	$(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $@ \
+diff --git libdw/Makefile.am libdw/Makefile.am
+index 33b5838d..1dbb3d5e 100644
+--- libdw/Makefile.am
++++ libdw/Makefile.am
+@@ -109,7 +109,7 @@ libdw_so_LIBS = ../libebl/libebl_pic.a ../backends/libebl_backends_pic.a \
+ 		../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_LIBS) $(obstack_LIBS) $(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 src/Makefile.am src/Makefile.am
+index e462e7d7..88d0ac8f 100644
+--- src/Makefile.am
++++ src/Makefile.am
+@@ -69,7 +69,7 @@ ar_no_Wstack_usage = yes
+ unstrip_no_Wstack_usage = yes
+ 
+ readelf_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD)
+-nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) \
++nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) $(obstack_LIBS) \
+ 	   $(demanglelib)
+ size_LDADD = $(libelf) $(libeu) $(argp_LDADD)
+ strip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
+@@ -78,9 +78,9 @@ findtextrel_LDADD = $(libdw) $(libelf) $(libeu) $(argp_LDADD)
+ addr2line_LDADD = $(libdw) $(libelf) $(libeu) $(argp_LDADD) $(demanglelib)
+ elfcmp_LDADD = $(libebl) $(libdw) $(libelf) $(libeu) $(argp_LDADD)
+ objdump_LDADD  = $(libasm) $(libebl) $(libdw) $(libelf) $(libeu) $(argp_LDADD)
+-ranlib_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD)
++ranlib_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD) $(obstack_LIBS)
+ strings_LDADD = $(libelf) $(libeu) $(argp_LDADD)
+-ar_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD)
++ar_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD) $(obstack_LIBS)
+ unstrip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
+ stack_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) $(demanglelib)
+ elfcompress_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
diff --git a/srcpkgs/elfutils/patches/musl-cdefs.patch b/srcpkgs/elfutils/patches/musl-cdefs.patch
deleted file mode 100644
index 65ef9f4d23c..00000000000
--- a/srcpkgs/elfutils/patches/musl-cdefs.patch
+++ /dev/null
@@ -1,30 +0,0 @@
---- libelf/elf.h	2015-08-21 14:22:37.000000000 +0200
-+++ libelf/elf.h	2015-11-20 04:54:33.948081321 +0100
-@@ -21,6 +21,17 @@
- 
- #include <features.h>
- 
-+#if !defined(__BEGIN_DECLS)
-+/* C++ needs to know that types and declarations are C, not C++.  */
-+#ifdef  __cplusplus
-+# define __BEGIN_DECLS  extern "C" {
-+# define __END_DECLS    }
-+#else
-+# define __BEGIN_DECLS
-+# define __END_DECLS
-+#endif
-+#endif
-+
- __BEGIN_DECLS
- 
- /* Standard ELF types.  */
---- lib/fixedsizehash.h.orig
-+++ lib/fixedsizehash.h
-@@ -30,7 +30,6 @@
- #include <errno.h>
- #include <stdlib.h>
- #include <string.h>
--#include <sys/cdefs.h>
- 
- #include <system.h>
- 
diff --git a/srcpkgs/elfutils/patches/musl-fts-obstack.patch b/srcpkgs/elfutils/patches/musl-fts-obstack.patch
deleted file mode 100644
index 77e3c4ea040..00000000000
--- a/srcpkgs/elfutils/patches/musl-fts-obstack.patch
+++ /dev/null
@@ -1,87 +0,0 @@
---- configure.ac	2015-10-15 15:16:57.000000000 +0200
-+++ 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.
---- src/Makefile.am.orig
-+++ 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
---- libdw/Makefile.am.orig
-+++ 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/srcpkgs/elfutils/patches/musl-macros.patch b/srcpkgs/elfutils/patches/musl-macros.patch
index 8ce586b2930..97a8c2bf352 100644
--- a/srcpkgs/elfutils/patches/musl-macros.patch
+++ b/srcpkgs/elfutils/patches/musl-macros.patch
@@ -1,66 +1,74 @@
---- src/arlib.h	2015-08-21 14:22:37.000000000 +0200
-+++ src/arlib.h	2015-11-20 08:02:55.153199611 +0100
-@@ -29,6 +29,16 @@
- #include <stdint.h>
- #include <sys/types.h>
+diff --git debuginfod/debuginfod-client.c debuginfod/debuginfod-client.c
+index 0e5177bc..ce1d819b 100644
+--- debuginfod/debuginfod-client.c
++++ debuginfod/debuginfod-client.c
+@@ -212,13 +212,13 @@ debuginfod_init_cache (char *cache_path, char *interval_path, char *maxage_path)
+     return 0;
  
-+#if !defined(ACCESSPERMS)
-+# define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
-+#endif
-+#if !defined(ALLPERMS)
-+# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
-+#endif
-+#if !defined(DEFFILEMODE)
-+# define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)/* 0666*/
-+#endif
-+
+   /* Create the cache and config files as necessary.  */
+-  if (stat(cache_path, &st) != 0 && mkdir(cache_path, 0777) < 0)
++  if (stat(cache_path, &st) != 0 && mkdir(cache_path, ACCESSPERMS) < 0)
+     return -errno;
  
- /* State of -D/-U flags.  */
- extern bool arlib_deterministic_output;
---- src/elfcompress.c.orig	2016-04-02 12:51:26.903848894 +0200
-+++ src/elfcompress.c	2016-04-02 12:55:15.076996338 +0200
-@@ -35,6 +35,14 @@
- #include <gelf.h>
- #include "system.h"
+   int fd = -1;
  
-+#if !defined(FNM_EXTMATCH)
-+# define FNM_EXTMATCH 0
-+#endif
-+
-+#if !defined(ALLPERMS)
-+# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
+   /* init cleaning interval config file.  */
+-  fd = open(interval_path, O_CREAT | O_RDWR, 0666);
++  fd = open(interval_path, O_CREAT | O_RDWR, DEFFILEMODE);
+   if (fd < 0)
+     return -errno;
+ 
+@@ -227,7 +227,7 @@ debuginfod_init_cache (char *cache_path, char *interval_path, char *maxage_path)
+ 
+   /* init max age config file.  */
+   if (stat(maxage_path, &st) != 0
+-      && (fd = open(maxage_path, O_CREAT | O_RDWR, 0666)) < 0)
++      && (fd = open(maxage_path, O_CREAT | O_RDWR, DEFFILEMODE)) < 0)
+     return -errno;
+ 
+   if (dprintf(fd, "%ld", cache_default_max_unused_age_s) < 0)
+diff --git lib/system.h lib/system.h
+index 292082bd..5d16ebc6 100644
+--- lib/system.h
++++ lib/system.h
+@@ -85,6 +85,18 @@
+      __res; })
+ #endif
+ 
++#ifndef ACCESSPERMS
++#define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
 +#endif
 +
- /* Name and version of program.  */
- static void print_version (FILE *stream, struct argp_state *state);
- ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;
---- src/strip.c.orig	2017-08-02 12:06:25.000000000 +0000
-+++ src/strip.c	2017-08-05 01:58:01.523493062 +0000
-@@ -47,6 +47,14 @@
- #include <system.h>
- #include <printversion.h>
- 
-+#if !defined(FNM_EXTMATCH)
-+# define FNM_EXTMATCH 0
++#ifndef ALLPERMS
++#define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
 +#endif
 +
-+#if !defined(ACCESSPERMS)
-+#define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO)
++#ifndef DEFFILEMODE
++#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)/* DEFFILEMODE*/
 +#endif
 +
- typedef uint8_t GElf_Byte;
+ static inline ssize_t __attribute__ ((unused))
+ pwrite_retry (int fd, const void *buf, size_t len, off_t off)
+ {
+diff --git src/unstrip.c src/unstrip.c
+index 0257d9cc..c99ee612 100644
+--- src/unstrip.c
++++ src/unstrip.c
+@@ -315,7 +315,7 @@ make_directories (const char *path)
+   if (dir == NULL)
+     error(EXIT_FAILURE, errno, _("memory exhausted"));
  
- /* Name and version of program.  */
---- tests/elfstrmerge.c.orig	2020-09-13 08:20:50.538492600 +0700
-+++ tests/elfstrmerge.c	2020-09-13 08:21:40.205734827 +0700
-@@ -33,6 +33,10 @@
- #include ELFUTILS_HEADER(dwelf)
- #include "elf-knowledge.h"
+-  while (mkdir (dir, 0777) < 0 && errno != EEXIST)
++  while (mkdir (dir, ACCESSPERMS) < 0 && errno != EEXIST)
+     {
+       if (errno == ENOENT)
+         make_directories (dir);
+@@ -2192,7 +2192,7 @@ DWARF data in '%s' not adjusted for prelinking bias; consider prelink -u"),
  
-+#if !defined(ALLPERMS)
-+# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
-+#endif
-+
- /* The original ELF file.  */
- static int fd = -1;
- static Elf *elf = NULL;
+       /* Copy the unstripped file and then modify it.  */
+       int outfd = open (output_file, O_RDWR | O_CREAT,
+-			  stripped_ehdr->e_type == ET_REL ? 0666 : 0777);
++			  stripped_ehdr->e_type == ET_REL ? DEFFILEMODE : ACCESSPERMS);
+       if (outfd < 0)
+ 	error (EXIT_FAILURE, errno, _("cannot open '%s'"), output_file);
+       Elf *outelf = elf_begin (outfd, ELF_C_WRITE, NULL);
diff --git a/srcpkgs/elfutils/patches/musl-strndupa.patch b/srcpkgs/elfutils/patches/musl-strndupa.patch
deleted file mode 100644
index f365fb019f2..00000000000
--- a/srcpkgs/elfutils/patches/musl-strndupa.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- src/unstrip.c.orig	2017-04-27 14:26:26.000000000 +0000
-+++ 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/srcpkgs/elfutils/template b/srcpkgs/elfutils/template
index 02e6e20c64b..c41c9ee4aaa 100644
--- a/srcpkgs/elfutils/template
+++ b/srcpkgs/elfutils/template
@@ -1,22 +1,26 @@
 # Template file for 'elfutils'
 pkgname=elfutils
-version=0.181
+version=0.182
 revision=1
 build_style=gnu-configure
-configure_args="--program-prefix=eu- --disable-debuginfod --disable-libdebuginfod"
+configure_args="--program-prefix=eu-"
 hostmakedepends="automake libtool pkg-config"
-makedepends="bzip2-devel liblzma-devel zlib-devel"
+makedepends="bzip2-devel liblzma-devel zlib-devel
+ libcurl-devel libarchive-devel sqlite-devel libmicrohttpd-devel"
 short_desc="Utilities to handle ELF object files"
-maintainer="Orphaned <orphan@voidlinux.org>"
+maintainer="Érico Nogueira <ericonr@disroot.org>"
 license="GPL-3.0-or-later"
 homepage="https://sourceware.org/elfutils/"
 distfiles="https://sourceware.org/${pkgname}/ftp/${version}/${pkgname}-${version}.tar.bz2"
-checksum=29a6ad7421ec2acfee489bb4a699908281ead2cb63a20a027ce8804a165f0eb3
+checksum=ecc406914edf335f0b7fc084ebe6c460c4d6d5175bfdd6688c1c78d9146b8858
 
 CFLAGS="-Wno-error"
+CXXFLAGS="-Wl,-z,stack-size=2097152"
 
 if [ "$XBPS_TARGET_LIBC" = musl ]; then
-	makedepends+=" argp-standalone musl-fts-devel musl-obstack-devel"
+	makedepends+=" argp-standalone musl-fts-devel musl-obstack-devel musl-legacy-compat"
+	# XXX: breaks some expected functionality
+	CFLAGS+=" -DFNM_EXTMATCH=0"
 fi
 
 post_extract() {
@@ -30,6 +34,22 @@ pre_configure() {
 	autoreconf -if
 }
 
+libdebuginfod_package() {
+	short_desc+=" - debuginfod library"
+	pkg_install() {
+		vmove "usr/lib/libdebuginfod-*.so*"
+	}
+}
+
+debuginfod_package() {
+	short_desc+=" - debuginfod programs"
+	pkg_install() {
+		vmove "usr/bin/debuginfod*"
+		vmove "usr/share/man/man1/debuginfod-find.1"
+		vmove "usr/share/man/man8/debuginfod.8"
+	}
+}
+
 libelf_package() {
 	short_desc+=" - runtime library"
 	pkg_install() {
@@ -38,11 +58,13 @@ libelf_package() {
 }
 
 elfutils-devel_package() {
-	depends="libelf>=${version}_${revision} ${makedepends}"
+	depends="libelf>=${version}_${revision} libdebuginfod>=${version}_${revision}
+	 ${makedepends}"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig
 		vmove "usr/lib/*.a"
+		vmove usr/share/man/man3
 	}
 }
diff --git a/srcpkgs/libdebuginfod b/srcpkgs/libdebuginfod
new file mode 120000
index 00000000000..b76b36cfac4
--- /dev/null
+++ b/srcpkgs/libdebuginfod
@@ -0,0 +1 @@
+elfutils
\ No newline at end of file

From 154f60755cd02793fd6287a14d029afee29fe5fb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
Date: Sun, 25 Oct 2020 18:23:45 -0300
Subject: [PATCH 2/2] gdb: add debuginfod option, enable by default.

---
 srcpkgs/gdb/template | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/srcpkgs/gdb/template b/srcpkgs/gdb/template
index 0e2e399e798..e2a39e7d103 100644
--- a/srcpkgs/gdb/template
+++ b/srcpkgs/gdb/template
@@ -1,16 +1,18 @@
 # Template file for 'gdb'
 pkgname=gdb
 version=10.1
-revision=1
+revision=2
 build_style=gnu-configure
 pycompile_dirs="/usr/share/gdb/python"
 configure_args="--disable-werror --disable-nls --with-system-readline
  --with-system-gdbinit=/etc/gdb/gdbinit --with-system-zlib $(vopt_enable gdbserver)
  $(vopt_if static 'CFLAGS=-static CXXFLAGS=-static LDFLAGS=-static')
- $(vopt_if python --with-python=/usr/bin/python3)"
-hostmakedepends="texinfo perl $(vopt_if python python3-devel)"
+ $(vopt_if python --with-python=/usr/bin/python3)
+ $(vopt_with debuginfod)"
+hostmakedepends="texinfo perl pkg-config $(vopt_if python python3-devel)"
 makedepends="ncurses-devel zlib-devel readline-devel expat-devel
- $(vopt_if python 'python3-devel gettext-libs')"
+ $(vopt_if python 'python3-devel gettext-libs')
+ $(vopt_if debuginfod elfutils-devel)"
 short_desc="GNU Debugger"
 maintainer="Anthony Iliopoulos <ailiop@altatus.com>"
 license="GPL-3.0-or-later"
@@ -28,10 +30,11 @@ fi
 CFLAGS+=" -fcommon"
 CXXFLAGS+=" -fcommon"
 # Package build options
-build_options="gdbserver static python"
+build_options="gdbserver static python debuginfod"
 desc_option_gdbserver="Enable support for building GDB server"
+desc_option_debuginfod="Enable support for libdebuginfod"
 # Enable gdbserver if !static.
-build_options_default="gdbserver python"
+build_options_default="gdbserver python debuginfod"
 # Both options cannot be enabled at the same time
 vopt_conflict gdbserver static
 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PR PATCH] [Updated] Update elfutils to 0.182.
  2020-11-02  1:56 [PR PATCH] Update elfutils to 0.182 ericonr
                   ` (3 preceding siblings ...)
  2020-11-02  2:03 ` ericonr
@ 2020-11-02 18:21 ` ericonr
  2020-11-06 14:39 ` ericonr
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: ericonr @ 2020-11-02 18:21 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 462 bytes --]

There is an updated pull request by ericonr against master on the void-packages repository

https://github.com/ericonr/void-packages debuginfod
https://github.com/void-linux/void-packages/pull/26067

Update elfutils to 0.182.
Also create the debuginfod subpackage and use it in gdb.

This PR can wait on some musl patches that I'd like to backport for the fregs patch.

A patch file from https://github.com/void-linux/void-packages/pull/26067.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-debuginfod-26067.patch --]
[-- Type: text/x-diff, Size: 23409 bytes --]

From 2d51e19de6a267d3960e4a619e18465a34b34a99 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
Date: Sun, 25 Oct 2020 18:57:17 -0300
Subject: [PATCH 1/2] elfutils: update to 0.182, add debuginfod subpkgs, adopt.

Cleaned up patches, fixed the aarch64-fregs one (it was doing the wrong
thing), and moved closer to where upstream is moving regarding musl
compat.
---
 common/shlibs                                 |   1 +
 srcpkgs/debuginfod                            |   1 +
 srcpkgs/elfutils/patches/debuginfod.patch     |  13 ++
 .../elfutils/patches/fix-aarch64_fregs.patch  |  22 ++--
 .../elfutils/patches/fix-uninitialized.patch  |  11 --
 srcpkgs/elfutils/patches/fts-obstack.patch    | 107 ++++++++++++++++
 srcpkgs/elfutils/patches/musl-cdefs.patch     |  30 -----
 .../elfutils/patches/musl-fts-obstack.patch   |  87 -------------
 srcpkgs/elfutils/patches/musl-macros.patch    | 118 ++++++++++--------
 srcpkgs/elfutils/patches/musl-strndupa.patch  |  18 ---
 srcpkgs/elfutils/template                     |  37 ++++--
 srcpkgs/libdebuginfod                         |   1 +
 12 files changed, 231 insertions(+), 215 deletions(-)
 create mode 120000 srcpkgs/debuginfod
 create mode 100644 srcpkgs/elfutils/patches/debuginfod.patch
 delete mode 100644 srcpkgs/elfutils/patches/fix-uninitialized.patch
 create mode 100644 srcpkgs/elfutils/patches/fts-obstack.patch
 delete mode 100644 srcpkgs/elfutils/patches/musl-cdefs.patch
 delete mode 100644 srcpkgs/elfutils/patches/musl-fts-obstack.patch
 delete mode 100644 srcpkgs/elfutils/patches/musl-strndupa.patch
 create mode 120000 srcpkgs/libdebuginfod

diff --git a/common/shlibs b/common/shlibs
index e0e75cea1b4..54253148fd0 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -736,6 +736,7 @@ libmtp.so.9 libmtp-1.1.4_1
 libelf.so.1 libelf-0.155_1
 libdw.so.1 libelf-0.155_1
 libasm.so.1 libelf-0.155_1
+libdebuginfod.so.1 libdebuginfod-0.182_1
 libgtksourceview-3.0.so.1 gtksourceview-3.8.0_1
 libtalloc.so.2 talloc-2.0.1_1
 libmount.so.1 libmount-2.18_1
diff --git a/srcpkgs/debuginfod b/srcpkgs/debuginfod
new file mode 120000
index 00000000000..b76b36cfac4
--- /dev/null
+++ b/srcpkgs/debuginfod
@@ -0,0 +1 @@
+elfutils
\ No newline at end of file
diff --git a/srcpkgs/elfutils/patches/debuginfod.patch b/srcpkgs/elfutils/patches/debuginfod.patch
new file mode 100644
index 00000000000..d26d945d1ff
--- /dev/null
+++ b/srcpkgs/elfutils/patches/debuginfod.patch
@@ -0,0 +1,13 @@
+diff --git debuginfod/debuginfod.cxx debuginfod/debuginfod.cxx
+index 3085f388..d2a434ee 100644
+--- debuginfod/debuginfod.cxx
++++ debuginfod/debuginfod.cxx
+@@ -46,7 +46,7 @@ extern "C" {
+ #include <unistd.h>
+ #include <stdlib.h>
+ #include <error.h>
+-// #include <libintl.h> // not until it supports C++ << better
++#include <libintl.h>
+ #include <locale.h>
+ #include <pthread.h>
+ #include <signal.h>
diff --git a/srcpkgs/elfutils/patches/fix-aarch64_fregs.patch b/srcpkgs/elfutils/patches/fix-aarch64_fregs.patch
index e9641542144..070d2527656 100644
--- a/srcpkgs/elfutils/patches/fix-aarch64_fregs.patch
+++ b/srcpkgs/elfutils/patches/fix-aarch64_fregs.patch
@@ -1,14 +1,22 @@
-It looks like fregs.vregs[] is an array of double?
-Casting to Dwarf_Word instead of & 0xFFFFFFF should do.
-
---- backends/aarch64_initreg.c	2015-11-27 14:36:29.000000000 +0100
-+++ backends/aarch64_initreg.c	2016-08-09 03:47:25.428560159 +0200
-@@ -82,7 +83,7 @@
+diff --git backends/aarch64_initreg.c backends/aarch64_initreg.c
+index daf6f375..02ca1dc0 100644
+--- backends/aarch64_initreg.c
++++ backends/aarch64_initreg.c
+@@ -46,6 +46,8 @@
+ #define BACKEND aarch64_
+ #include "libebl_CPU.h"
+ 
++#include <string.h>
++
+ bool
+ aarch64_set_initial_registers_tid (pid_t tid __attribute__ ((unused)),
+ 			  ebl_tid_registers_t *setfunc __attribute__ ((unused)),
+@@ -82,7 +84,7 @@ aarch64_set_initial_registers_tid (pid_t tid __attribute__ ((unused)),
  
    Dwarf_Word dwarf_fregs[32];
    for (int r = 0; r < 32; r++)
 -    dwarf_fregs[r] = fregs.vregs[r] & 0xFFFFFFFF;
-+    dwarf_fregs[r] = (Dwarf_Word)fregs.vregs[r];
++    memcpy(dwarf_fregs + r, fregs.vregs + r, sizeof(dwarf_fregs[0]));
  
    if (! setfunc (64, 32, dwarf_fregs, arg))
      return false;
diff --git a/srcpkgs/elfutils/patches/fix-uninitialized.patch b/srcpkgs/elfutils/patches/fix-uninitialized.patch
deleted file mode 100644
index 6ab15e50e2b..00000000000
--- a/srcpkgs/elfutils/patches/fix-uninitialized.patch
+++ /dev/null
@@ -1,11 +0,0 @@
-
---- libcpu/i386_disasm.c	2015-08-21 14:22:37.000000000 +0200
-+++ libcpu/i386_disasm.c	2015-11-20 06:30:59.250629957 +0100
-@@ -710,6 +710,7 @@
- 
- 		case 'm':
- 		  /* Mnemonic.  */
-+		  str = mnebuf;
- 
- 		  if (unlikely (instrtab[cnt].mnemonic == MNE_INVALID))
- 		    {
diff --git a/srcpkgs/elfutils/patches/fts-obstack.patch b/srcpkgs/elfutils/patches/fts-obstack.patch
new file mode 100644
index 00000000000..44ef0aee70e
--- /dev/null
+++ b/srcpkgs/elfutils/patches/fts-obstack.patch
@@ -0,0 +1,107 @@
+diff --git ChangeLog ChangeLog
+index 128da6c6..565d021c 100644
+--- ChangeLog
++++ ChangeLog
+@@ -1,3 +1,7 @@
++2020-11-01  Érico N. Rolim  <erico.erc@gmail.com>
++
++	* configure.ac: Check for fts and obstack from outside libc.
++
+ 2020-10-28  Mark Wielaard  <mark@klomp.org>
+ 
+ 	* configure.ac: Set version to 0.182.
+diff --git configure.ac configure.ac
+index 515ac704..c1a6954d 100644
+--- configure.ac
++++ configure.ac
+@@ -542,6 +542,26 @@ else
+ fi
+ AC_SUBST([argp_LDADD])
+ 
++saved_LIBS="$LIBS"
++AC_SEARCH_LIBS([fts_close], [fts])
++LIBS="$saved_LIBS"
++case "$ac_cv_search_fts_close" in
++        no) AC_MSG_FAILURE([failed to find fts_close]) ;;
++        -l*) fts_LIBS="$ac_cv_search_fts_close" ;;
++        *) fts_LIBS= ;;
++esac
++AC_SUBST([fts_LIBS])
++
++saved_LIBS="$LIBS"
++AC_SEARCH_LIBS([_obstack_free], [obstack])
++LIBS="$saved_LIBS"
++case "$ac_cv_search__obstack_free" in
++        no) AC_MSG_FAILURE([failed to find obstack_free]) ;;
++        -l*) obstack_LIBS="$ac_cv_search__obstack_free" ;;
++        *) obstack_LIBS= ;;
++esac
++AC_SUBST([obstack_LIBS])
++
+ dnl The directories with content.
+ 
+ dnl Documentation.
+diff --git debuginfod/Makefile.am debuginfod/Makefile.am
+index 01985600..0af3b58c 100644
+--- debuginfod/Makefile.am
++++ debuginfod/Makefile.am
+@@ -71,10 +71,10 @@ bin_PROGRAMS += debuginfod-find
+ endif
+ 
+ debuginfod_SOURCES = debuginfod.cxx
+-debuginfod_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod) $(libmicrohttpd_LIBS) $(sqlite3_LIBS) $(libarchive_LIBS) -lpthread -ldl
++debuginfod_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod) $(argp_LDADD) $(fts_LIBS) $(libmicrohttpd_LIBS) $(sqlite3_LIBS) $(libarchive_LIBS) -lpthread -ldl
+ 
+ debuginfod_find_SOURCES = debuginfod-find.c
+-debuginfod_find_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod)
++debuginfod_find_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod) $(argp_LDADD) $(fts_LIBS)
+ 
+ if LIBDEBUGINFOD
+ noinst_LIBRARIES = libdebuginfod.a
+@@ -98,7 +98,7 @@ libdebuginfod_so_LIBS = libdebuginfod_pic.a
+ if DUMMY_LIBDEBUGINFOD
+ libdebuginfod_so_LDLIBS =
+ else
+-libdebuginfod_so_LDLIBS = $(libcurl_LIBS)
++libdebuginfod_so_LDLIBS = $(libcurl_LIBS) $(fts_LIBS)
+ endif
+ libdebuginfod.so$(EXEEXT): $(srcdir)/libdebuginfod.map $(libdebuginfod_so_LIBS)
+ 	$(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $@ \
+diff --git libdw/Makefile.am libdw/Makefile.am
+index 33b5838d..1dbb3d5e 100644
+--- libdw/Makefile.am
++++ libdw/Makefile.am
+@@ -109,7 +109,7 @@ libdw_so_LIBS = ../libebl/libebl_pic.a ../backends/libebl_backends_pic.a \
+ 		../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_LIBS) $(obstack_LIBS) $(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 src/Makefile.am src/Makefile.am
+index e462e7d7..88d0ac8f 100644
+--- src/Makefile.am
++++ src/Makefile.am
+@@ -69,7 +69,7 @@ ar_no_Wstack_usage = yes
+ unstrip_no_Wstack_usage = yes
+ 
+ readelf_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD)
+-nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) \
++nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) $(obstack_LIBS) \
+ 	   $(demanglelib)
+ size_LDADD = $(libelf) $(libeu) $(argp_LDADD)
+ strip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
+@@ -78,9 +78,9 @@ findtextrel_LDADD = $(libdw) $(libelf) $(libeu) $(argp_LDADD)
+ addr2line_LDADD = $(libdw) $(libelf) $(libeu) $(argp_LDADD) $(demanglelib)
+ elfcmp_LDADD = $(libebl) $(libdw) $(libelf) $(libeu) $(argp_LDADD)
+ objdump_LDADD  = $(libasm) $(libebl) $(libdw) $(libelf) $(libeu) $(argp_LDADD)
+-ranlib_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD)
++ranlib_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD) $(obstack_LIBS)
+ strings_LDADD = $(libelf) $(libeu) $(argp_LDADD)
+-ar_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD)
++ar_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD) $(obstack_LIBS)
+ unstrip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
+ stack_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) $(demanglelib)
+ elfcompress_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
diff --git a/srcpkgs/elfutils/patches/musl-cdefs.patch b/srcpkgs/elfutils/patches/musl-cdefs.patch
deleted file mode 100644
index 65ef9f4d23c..00000000000
--- a/srcpkgs/elfutils/patches/musl-cdefs.patch
+++ /dev/null
@@ -1,30 +0,0 @@
---- libelf/elf.h	2015-08-21 14:22:37.000000000 +0200
-+++ libelf/elf.h	2015-11-20 04:54:33.948081321 +0100
-@@ -21,6 +21,17 @@
- 
- #include <features.h>
- 
-+#if !defined(__BEGIN_DECLS)
-+/* C++ needs to know that types and declarations are C, not C++.  */
-+#ifdef  __cplusplus
-+# define __BEGIN_DECLS  extern "C" {
-+# define __END_DECLS    }
-+#else
-+# define __BEGIN_DECLS
-+# define __END_DECLS
-+#endif
-+#endif
-+
- __BEGIN_DECLS
- 
- /* Standard ELF types.  */
---- lib/fixedsizehash.h.orig
-+++ lib/fixedsizehash.h
-@@ -30,7 +30,6 @@
- #include <errno.h>
- #include <stdlib.h>
- #include <string.h>
--#include <sys/cdefs.h>
- 
- #include <system.h>
- 
diff --git a/srcpkgs/elfutils/patches/musl-fts-obstack.patch b/srcpkgs/elfutils/patches/musl-fts-obstack.patch
deleted file mode 100644
index 77e3c4ea040..00000000000
--- a/srcpkgs/elfutils/patches/musl-fts-obstack.patch
+++ /dev/null
@@ -1,87 +0,0 @@
---- configure.ac	2015-10-15 15:16:57.000000000 +0200
-+++ 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.
---- src/Makefile.am.orig
-+++ 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
---- libdw/Makefile.am.orig
-+++ 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/srcpkgs/elfutils/patches/musl-macros.patch b/srcpkgs/elfutils/patches/musl-macros.patch
index 8ce586b2930..97a8c2bf352 100644
--- a/srcpkgs/elfutils/patches/musl-macros.patch
+++ b/srcpkgs/elfutils/patches/musl-macros.patch
@@ -1,66 +1,74 @@
---- src/arlib.h	2015-08-21 14:22:37.000000000 +0200
-+++ src/arlib.h	2015-11-20 08:02:55.153199611 +0100
-@@ -29,6 +29,16 @@
- #include <stdint.h>
- #include <sys/types.h>
+diff --git debuginfod/debuginfod-client.c debuginfod/debuginfod-client.c
+index 0e5177bc..ce1d819b 100644
+--- debuginfod/debuginfod-client.c
++++ debuginfod/debuginfod-client.c
+@@ -212,13 +212,13 @@ debuginfod_init_cache (char *cache_path, char *interval_path, char *maxage_path)
+     return 0;
  
-+#if !defined(ACCESSPERMS)
-+# define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
-+#endif
-+#if !defined(ALLPERMS)
-+# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
-+#endif
-+#if !defined(DEFFILEMODE)
-+# define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)/* 0666*/
-+#endif
-+
+   /* Create the cache and config files as necessary.  */
+-  if (stat(cache_path, &st) != 0 && mkdir(cache_path, 0777) < 0)
++  if (stat(cache_path, &st) != 0 && mkdir(cache_path, ACCESSPERMS) < 0)
+     return -errno;
  
- /* State of -D/-U flags.  */
- extern bool arlib_deterministic_output;
---- src/elfcompress.c.orig	2016-04-02 12:51:26.903848894 +0200
-+++ src/elfcompress.c	2016-04-02 12:55:15.076996338 +0200
-@@ -35,6 +35,14 @@
- #include <gelf.h>
- #include "system.h"
+   int fd = -1;
  
-+#if !defined(FNM_EXTMATCH)
-+# define FNM_EXTMATCH 0
-+#endif
-+
-+#if !defined(ALLPERMS)
-+# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
+   /* init cleaning interval config file.  */
+-  fd = open(interval_path, O_CREAT | O_RDWR, 0666);
++  fd = open(interval_path, O_CREAT | O_RDWR, DEFFILEMODE);
+   if (fd < 0)
+     return -errno;
+ 
+@@ -227,7 +227,7 @@ debuginfod_init_cache (char *cache_path, char *interval_path, char *maxage_path)
+ 
+   /* init max age config file.  */
+   if (stat(maxage_path, &st) != 0
+-      && (fd = open(maxage_path, O_CREAT | O_RDWR, 0666)) < 0)
++      && (fd = open(maxage_path, O_CREAT | O_RDWR, DEFFILEMODE)) < 0)
+     return -errno;
+ 
+   if (dprintf(fd, "%ld", cache_default_max_unused_age_s) < 0)
+diff --git lib/system.h lib/system.h
+index 292082bd..5d16ebc6 100644
+--- lib/system.h
++++ lib/system.h
+@@ -85,6 +85,18 @@
+      __res; })
+ #endif
+ 
++#ifndef ACCESSPERMS
++#define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
 +#endif
 +
- /* Name and version of program.  */
- static void print_version (FILE *stream, struct argp_state *state);
- ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;
---- src/strip.c.orig	2017-08-02 12:06:25.000000000 +0000
-+++ src/strip.c	2017-08-05 01:58:01.523493062 +0000
-@@ -47,6 +47,14 @@
- #include <system.h>
- #include <printversion.h>
- 
-+#if !defined(FNM_EXTMATCH)
-+# define FNM_EXTMATCH 0
++#ifndef ALLPERMS
++#define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
 +#endif
 +
-+#if !defined(ACCESSPERMS)
-+#define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO)
++#ifndef DEFFILEMODE
++#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)/* DEFFILEMODE*/
 +#endif
 +
- typedef uint8_t GElf_Byte;
+ static inline ssize_t __attribute__ ((unused))
+ pwrite_retry (int fd, const void *buf, size_t len, off_t off)
+ {
+diff --git src/unstrip.c src/unstrip.c
+index 0257d9cc..c99ee612 100644
+--- src/unstrip.c
++++ src/unstrip.c
+@@ -315,7 +315,7 @@ make_directories (const char *path)
+   if (dir == NULL)
+     error(EXIT_FAILURE, errno, _("memory exhausted"));
  
- /* Name and version of program.  */
---- tests/elfstrmerge.c.orig	2020-09-13 08:20:50.538492600 +0700
-+++ tests/elfstrmerge.c	2020-09-13 08:21:40.205734827 +0700
-@@ -33,6 +33,10 @@
- #include ELFUTILS_HEADER(dwelf)
- #include "elf-knowledge.h"
+-  while (mkdir (dir, 0777) < 0 && errno != EEXIST)
++  while (mkdir (dir, ACCESSPERMS) < 0 && errno != EEXIST)
+     {
+       if (errno == ENOENT)
+         make_directories (dir);
+@@ -2192,7 +2192,7 @@ DWARF data in '%s' not adjusted for prelinking bias; consider prelink -u"),
  
-+#if !defined(ALLPERMS)
-+# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
-+#endif
-+
- /* The original ELF file.  */
- static int fd = -1;
- static Elf *elf = NULL;
+       /* Copy the unstripped file and then modify it.  */
+       int outfd = open (output_file, O_RDWR | O_CREAT,
+-			  stripped_ehdr->e_type == ET_REL ? 0666 : 0777);
++			  stripped_ehdr->e_type == ET_REL ? DEFFILEMODE : ACCESSPERMS);
+       if (outfd < 0)
+ 	error (EXIT_FAILURE, errno, _("cannot open '%s'"), output_file);
+       Elf *outelf = elf_begin (outfd, ELF_C_WRITE, NULL);
diff --git a/srcpkgs/elfutils/patches/musl-strndupa.patch b/srcpkgs/elfutils/patches/musl-strndupa.patch
deleted file mode 100644
index f365fb019f2..00000000000
--- a/srcpkgs/elfutils/patches/musl-strndupa.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- src/unstrip.c.orig	2017-04-27 14:26:26.000000000 +0000
-+++ 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/srcpkgs/elfutils/template b/srcpkgs/elfutils/template
index 02e6e20c64b..99159a2be41 100644
--- a/srcpkgs/elfutils/template
+++ b/srcpkgs/elfutils/template
@@ -1,22 +1,26 @@
 # Template file for 'elfutils'
 pkgname=elfutils
-version=0.181
+version=0.182
 revision=1
 build_style=gnu-configure
-configure_args="--program-prefix=eu- --disable-debuginfod --disable-libdebuginfod"
+configure_args="--program-prefix=eu-"
 hostmakedepends="automake libtool pkg-config"
-makedepends="bzip2-devel liblzma-devel zlib-devel"
+makedepends="bzip2-devel liblzma-devel zlib-devel
+ libcurl-devel libarchive-devel sqlite-devel libmicrohttpd-devel"
 short_desc="Utilities to handle ELF object files"
-maintainer="Orphaned <orphan@voidlinux.org>"
+maintainer="Érico Nogueira <ericonr@disroot.org>"
 license="GPL-3.0-or-later"
 homepage="https://sourceware.org/elfutils/"
 distfiles="https://sourceware.org/${pkgname}/ftp/${version}/${pkgname}-${version}.tar.bz2"
-checksum=29a6ad7421ec2acfee489bb4a699908281ead2cb63a20a027ce8804a165f0eb3
+checksum=ecc406914edf335f0b7fc084ebe6c460c4d6d5175bfdd6688c1c78d9146b8858
 
 CFLAGS="-Wno-error"
+CXXFLAGS="-Wl,-z,stack-size=2097152"
 
 if [ "$XBPS_TARGET_LIBC" = musl ]; then
-	makedepends+=" argp-standalone musl-fts-devel musl-obstack-devel"
+	makedepends+=" argp-standalone musl-fts-devel musl-obstack-devel musl-legacy-compat"
+	# XXX: breaks some expected functionality
+	CFLAGS+=" -DFNM_EXTMATCH=0"
 fi
 
 post_extract() {
@@ -30,6 +34,23 @@ pre_configure() {
 	autoreconf -if
 }
 
+libdebuginfod_package() {
+	short_desc+=" - debuginfod library"
+	pkg_install() {
+		vmove "usr/lib/libdebuginfod-*.so*"
+		vmove etc/profile.d
+	}
+}
+
+debuginfod_package() {
+	short_desc+=" - debuginfod programs"
+	pkg_install() {
+		vmove "usr/bin/debuginfod*"
+		vmove "usr/share/man/man1/debuginfod-find.1"
+		vmove "usr/share/man/man8/debuginfod.8"
+	}
+}
+
 libelf_package() {
 	short_desc+=" - runtime library"
 	pkg_install() {
@@ -38,11 +59,13 @@ libelf_package() {
 }
 
 elfutils-devel_package() {
-	depends="libelf>=${version}_${revision} ${makedepends}"
+	depends="libelf>=${version}_${revision} libdebuginfod>=${version}_${revision}
+	 ${makedepends}"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig
 		vmove "usr/lib/*.a"
+		vmove usr/share/man/man3
 	}
 }
diff --git a/srcpkgs/libdebuginfod b/srcpkgs/libdebuginfod
new file mode 120000
index 00000000000..b76b36cfac4
--- /dev/null
+++ b/srcpkgs/libdebuginfod
@@ -0,0 +1 @@
+elfutils
\ No newline at end of file

From 99cf10b42f69c27f9e8e080d278900bf6b45ba66 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
Date: Sun, 25 Oct 2020 18:23:45 -0300
Subject: [PATCH 2/2] gdb: add debuginfod option, enable by default.

---
 srcpkgs/gdb/template | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/srcpkgs/gdb/template b/srcpkgs/gdb/template
index 0e2e399e798..e2a39e7d103 100644
--- a/srcpkgs/gdb/template
+++ b/srcpkgs/gdb/template
@@ -1,16 +1,18 @@
 # Template file for 'gdb'
 pkgname=gdb
 version=10.1
-revision=1
+revision=2
 build_style=gnu-configure
 pycompile_dirs="/usr/share/gdb/python"
 configure_args="--disable-werror --disable-nls --with-system-readline
  --with-system-gdbinit=/etc/gdb/gdbinit --with-system-zlib $(vopt_enable gdbserver)
  $(vopt_if static 'CFLAGS=-static CXXFLAGS=-static LDFLAGS=-static')
- $(vopt_if python --with-python=/usr/bin/python3)"
-hostmakedepends="texinfo perl $(vopt_if python python3-devel)"
+ $(vopt_if python --with-python=/usr/bin/python3)
+ $(vopt_with debuginfod)"
+hostmakedepends="texinfo perl pkg-config $(vopt_if python python3-devel)"
 makedepends="ncurses-devel zlib-devel readline-devel expat-devel
- $(vopt_if python 'python3-devel gettext-libs')"
+ $(vopt_if python 'python3-devel gettext-libs')
+ $(vopt_if debuginfod elfutils-devel)"
 short_desc="GNU Debugger"
 maintainer="Anthony Iliopoulos <ailiop@altatus.com>"
 license="GPL-3.0-or-later"
@@ -28,10 +30,11 @@ fi
 CFLAGS+=" -fcommon"
 CXXFLAGS+=" -fcommon"
 # Package build options
-build_options="gdbserver static python"
+build_options="gdbserver static python debuginfod"
 desc_option_gdbserver="Enable support for building GDB server"
+desc_option_debuginfod="Enable support for libdebuginfod"
 # Enable gdbserver if !static.
-build_options_default="gdbserver python"
+build_options_default="gdbserver python debuginfod"
 # Both options cannot be enabled at the same time
 vopt_conflict gdbserver static
 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PR PATCH] [Updated] Update elfutils to 0.182.
  2020-11-02  1:56 [PR PATCH] Update elfutils to 0.182 ericonr
                   ` (4 preceding siblings ...)
  2020-11-02 18:21 ` ericonr
@ 2020-11-06 14:39 ` ericonr
  2020-11-17 13:56 ` ericonr
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: ericonr @ 2020-11-06 14:39 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 462 bytes --]

There is an updated pull request by ericonr against master on the void-packages repository

https://github.com/ericonr/void-packages debuginfod
https://github.com/void-linux/void-packages/pull/26067

Update elfutils to 0.182.
Also create the debuginfod subpackage and use it in gdb.

This PR can wait on some musl patches that I'd like to backport for the fregs patch.

A patch file from https://github.com/void-linux/void-packages/pull/26067.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-debuginfod-26067.patch --]
[-- Type: text/x-diff, Size: 25849 bytes --]

From 47f58f42470e0fa6e0d603cabffd6d3c8753847c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
Date: Fri, 6 Nov 2020 11:35:39 -0300
Subject: [PATCH 1/4] musl: add patch for aarch64 fregs and vregs.

Necessary for building elfutils for aarch64 without patches.
---
 srcpkgs/musl/patches/aarch64-fregs.patch | 37 ++++++++++++++++++++++++
 srcpkgs/musl/template                    |  2 +-
 2 files changed, 38 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/musl/patches/aarch64-fregs.patch

diff --git a/srcpkgs/musl/patches/aarch64-fregs.patch b/srcpkgs/musl/patches/aarch64-fregs.patch
new file mode 100644
index 00000000000..9c89de44732
--- /dev/null
+++ b/srcpkgs/musl/patches/aarch64-fregs.patch
@@ -0,0 +1,37 @@
+Use types compatible with glibc/kernel headers.
+
+diff --git a/arch/aarch64/bits/signal.h b/arch/aarch64/bits/signal.h
+index b71261f5..5098c734 100644
+--- arch/aarch64/bits/signal.h
++++ arch/aarch64/bits/signal.h
+@@ -11,7 +11,7 @@ typedef unsigned long greg_t;
+ typedef unsigned long gregset_t[34];
+ 
+ typedef struct {
+-	long double vregs[32];
++	__uint128_t vregs[32];
+ 	unsigned int fpsr;
+ 	unsigned int fpcr;
+ } fpregset_t;
+@@ -34,7 +34,7 @@ struct fpsimd_context {
+ 	struct _aarch64_ctx head;
+ 	unsigned int fpsr;
+ 	unsigned int fpcr;
+-	long double vregs[32];
++	__uint128_t vregs[32];
+ };
+ struct esr_context {
+ 	struct _aarch64_ctx head;
+diff --git a/arch/aarch64/bits/user.h b/arch/aarch64/bits/user.h
+index d12cdf7f..8a1002aa 100644
+--- arch/aarch64/bits/user.h
++++ arch/aarch64/bits/user.h
+@@ -6,7 +6,7 @@ struct user_regs_struct {
+ };
+ 
+ struct user_fpsimd_struct {
+-	long double vregs[32];
++	__uint128_t vregs[32];
+ 	unsigned int fpsr;
+ 	unsigned int fpcr;
+ };
diff --git a/srcpkgs/musl/template b/srcpkgs/musl/template
index 22e79588acd..6a0ac60b03c 100644
--- a/srcpkgs/musl/template
+++ b/srcpkgs/musl/template
@@ -2,7 +2,7 @@
 pkgname=musl
 reverts="1.2.0_1"
 version=1.1.24
-revision=3
+revision=4
 archs="*-musl"
 bootstrap=yes
 build_style=gnu-configure

From 71981a52c8617f09c5d5e25772491deb8b1a7cb1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
Date: Fri, 6 Nov 2020 11:36:42 -0300
Subject: [PATCH 2/4] cross-aarch64-linux-musl: revbump to apply musl patch.

Patch can be seen in the commit before this one.
---
 srcpkgs/cross-aarch64-linux-musl/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cross-aarch64-linux-musl/template b/srcpkgs/cross-aarch64-linux-musl/template
index 8dba1d564ec..0ec44fad6f6 100644
--- a/srcpkgs/cross-aarch64-linux-musl/template
+++ b/srcpkgs/cross-aarch64-linux-musl/template
@@ -12,7 +12,7 @@ _sysroot="/usr/${_triplet}"
 
 pkgname=cross-${_triplet}
 version=0.33
-revision=3
+revision=4
 short_desc="Cross toolchain for ARM64 LE target (musl)"
 maintainer="Orphaned <orphan@voidlinux.org>"
 homepage="https://www.voidlinux.org/"

From 49e64b38f65ae876fb69d367912409dca00ecfad Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
Date: Sun, 25 Oct 2020 18:57:17 -0300
Subject: [PATCH 3/4] elfutils: update to 0.182, add debuginfod subpkgs, adopt.

Cleaned up patches, remove the aarch64-fregs one (it was fixed with a
musl patch, instead), and moved closer to where upstream is moving
regarding musl compat.
---
 common/shlibs                                 |   1 +
 srcpkgs/debuginfod                            |   1 +
 srcpkgs/elfutils/patches/debuginfod.patch     |  13 ++
 .../elfutils/patches/fix-aarch64_fregs.patch  |  14 ---
 .../elfutils/patches/fix-uninitialized.patch  |  11 --
 srcpkgs/elfutils/patches/fts-obstack.patch    | 107 ++++++++++++++++
 srcpkgs/elfutils/patches/musl-cdefs.patch     |  30 -----
 .../elfutils/patches/musl-fts-obstack.patch   |  87 -------------
 srcpkgs/elfutils/patches/musl-macros.patch    | 118 ++++++++++--------
 srcpkgs/elfutils/patches/musl-strndupa.patch  |  18 ---
 srcpkgs/elfutils/template                     |  37 ++++--
 srcpkgs/libdebuginfod                         |   1 +
 12 files changed, 216 insertions(+), 222 deletions(-)
 create mode 120000 srcpkgs/debuginfod
 create mode 100644 srcpkgs/elfutils/patches/debuginfod.patch
 delete mode 100644 srcpkgs/elfutils/patches/fix-aarch64_fregs.patch
 delete mode 100644 srcpkgs/elfutils/patches/fix-uninitialized.patch
 create mode 100644 srcpkgs/elfutils/patches/fts-obstack.patch
 delete mode 100644 srcpkgs/elfutils/patches/musl-cdefs.patch
 delete mode 100644 srcpkgs/elfutils/patches/musl-fts-obstack.patch
 delete mode 100644 srcpkgs/elfutils/patches/musl-strndupa.patch
 create mode 120000 srcpkgs/libdebuginfod

diff --git a/common/shlibs b/common/shlibs
index ceb355ffac6..d33b9c2d6aa 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -736,6 +736,7 @@ libmtp.so.9 libmtp-1.1.4_1
 libelf.so.1 libelf-0.155_1
 libdw.so.1 libelf-0.155_1
 libasm.so.1 libelf-0.155_1
+libdebuginfod.so.1 libdebuginfod-0.182_1
 libgtksourceview-3.0.so.1 gtksourceview-3.8.0_1
 libtalloc.so.2 talloc-2.0.1_1
 libmount.so.1 libmount-2.18_1
diff --git a/srcpkgs/debuginfod b/srcpkgs/debuginfod
new file mode 120000
index 00000000000..b76b36cfac4
--- /dev/null
+++ b/srcpkgs/debuginfod
@@ -0,0 +1 @@
+elfutils
\ No newline at end of file
diff --git a/srcpkgs/elfutils/patches/debuginfod.patch b/srcpkgs/elfutils/patches/debuginfod.patch
new file mode 100644
index 00000000000..d26d945d1ff
--- /dev/null
+++ b/srcpkgs/elfutils/patches/debuginfod.patch
@@ -0,0 +1,13 @@
+diff --git debuginfod/debuginfod.cxx debuginfod/debuginfod.cxx
+index 3085f388..d2a434ee 100644
+--- debuginfod/debuginfod.cxx
++++ debuginfod/debuginfod.cxx
+@@ -46,7 +46,7 @@ extern "C" {
+ #include <unistd.h>
+ #include <stdlib.h>
+ #include <error.h>
+-// #include <libintl.h> // not until it supports C++ << better
++#include <libintl.h>
+ #include <locale.h>
+ #include <pthread.h>
+ #include <signal.h>
diff --git a/srcpkgs/elfutils/patches/fix-aarch64_fregs.patch b/srcpkgs/elfutils/patches/fix-aarch64_fregs.patch
deleted file mode 100644
index e9641542144..00000000000
--- a/srcpkgs/elfutils/patches/fix-aarch64_fregs.patch
+++ /dev/null
@@ -1,14 +0,0 @@
-It looks like fregs.vregs[] is an array of double?
-Casting to Dwarf_Word instead of & 0xFFFFFFF should do.
-
---- backends/aarch64_initreg.c	2015-11-27 14:36:29.000000000 +0100
-+++ backends/aarch64_initreg.c	2016-08-09 03:47:25.428560159 +0200
-@@ -82,7 +83,7 @@
- 
-   Dwarf_Word dwarf_fregs[32];
-   for (int r = 0; r < 32; r++)
--    dwarf_fregs[r] = fregs.vregs[r] & 0xFFFFFFFF;
-+    dwarf_fregs[r] = (Dwarf_Word)fregs.vregs[r];
- 
-   if (! setfunc (64, 32, dwarf_fregs, arg))
-     return false;
diff --git a/srcpkgs/elfutils/patches/fix-uninitialized.patch b/srcpkgs/elfutils/patches/fix-uninitialized.patch
deleted file mode 100644
index 6ab15e50e2b..00000000000
--- a/srcpkgs/elfutils/patches/fix-uninitialized.patch
+++ /dev/null
@@ -1,11 +0,0 @@
-
---- libcpu/i386_disasm.c	2015-08-21 14:22:37.000000000 +0200
-+++ libcpu/i386_disasm.c	2015-11-20 06:30:59.250629957 +0100
-@@ -710,6 +710,7 @@
- 
- 		case 'm':
- 		  /* Mnemonic.  */
-+		  str = mnebuf;
- 
- 		  if (unlikely (instrtab[cnt].mnemonic == MNE_INVALID))
- 		    {
diff --git a/srcpkgs/elfutils/patches/fts-obstack.patch b/srcpkgs/elfutils/patches/fts-obstack.patch
new file mode 100644
index 00000000000..44ef0aee70e
--- /dev/null
+++ b/srcpkgs/elfutils/patches/fts-obstack.patch
@@ -0,0 +1,107 @@
+diff --git ChangeLog ChangeLog
+index 128da6c6..565d021c 100644
+--- ChangeLog
++++ ChangeLog
+@@ -1,3 +1,7 @@
++2020-11-01  Érico N. Rolim  <erico.erc@gmail.com>
++
++	* configure.ac: Check for fts and obstack from outside libc.
++
+ 2020-10-28  Mark Wielaard  <mark@klomp.org>
+ 
+ 	* configure.ac: Set version to 0.182.
+diff --git configure.ac configure.ac
+index 515ac704..c1a6954d 100644
+--- configure.ac
++++ configure.ac
+@@ -542,6 +542,26 @@ else
+ fi
+ AC_SUBST([argp_LDADD])
+ 
++saved_LIBS="$LIBS"
++AC_SEARCH_LIBS([fts_close], [fts])
++LIBS="$saved_LIBS"
++case "$ac_cv_search_fts_close" in
++        no) AC_MSG_FAILURE([failed to find fts_close]) ;;
++        -l*) fts_LIBS="$ac_cv_search_fts_close" ;;
++        *) fts_LIBS= ;;
++esac
++AC_SUBST([fts_LIBS])
++
++saved_LIBS="$LIBS"
++AC_SEARCH_LIBS([_obstack_free], [obstack])
++LIBS="$saved_LIBS"
++case "$ac_cv_search__obstack_free" in
++        no) AC_MSG_FAILURE([failed to find obstack_free]) ;;
++        -l*) obstack_LIBS="$ac_cv_search__obstack_free" ;;
++        *) obstack_LIBS= ;;
++esac
++AC_SUBST([obstack_LIBS])
++
+ dnl The directories with content.
+ 
+ dnl Documentation.
+diff --git debuginfod/Makefile.am debuginfod/Makefile.am
+index 01985600..0af3b58c 100644
+--- debuginfod/Makefile.am
++++ debuginfod/Makefile.am
+@@ -71,10 +71,10 @@ bin_PROGRAMS += debuginfod-find
+ endif
+ 
+ debuginfod_SOURCES = debuginfod.cxx
+-debuginfod_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod) $(libmicrohttpd_LIBS) $(sqlite3_LIBS) $(libarchive_LIBS) -lpthread -ldl
++debuginfod_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod) $(argp_LDADD) $(fts_LIBS) $(libmicrohttpd_LIBS) $(sqlite3_LIBS) $(libarchive_LIBS) -lpthread -ldl
+ 
+ debuginfod_find_SOURCES = debuginfod-find.c
+-debuginfod_find_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod)
++debuginfod_find_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod) $(argp_LDADD) $(fts_LIBS)
+ 
+ if LIBDEBUGINFOD
+ noinst_LIBRARIES = libdebuginfod.a
+@@ -98,7 +98,7 @@ libdebuginfod_so_LIBS = libdebuginfod_pic.a
+ if DUMMY_LIBDEBUGINFOD
+ libdebuginfod_so_LDLIBS =
+ else
+-libdebuginfod_so_LDLIBS = $(libcurl_LIBS)
++libdebuginfod_so_LDLIBS = $(libcurl_LIBS) $(fts_LIBS)
+ endif
+ libdebuginfod.so$(EXEEXT): $(srcdir)/libdebuginfod.map $(libdebuginfod_so_LIBS)
+ 	$(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $@ \
+diff --git libdw/Makefile.am libdw/Makefile.am
+index 33b5838d..1dbb3d5e 100644
+--- libdw/Makefile.am
++++ libdw/Makefile.am
+@@ -109,7 +109,7 @@ libdw_so_LIBS = ../libebl/libebl_pic.a ../backends/libebl_backends_pic.a \
+ 		../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_LIBS) $(obstack_LIBS) $(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 src/Makefile.am src/Makefile.am
+index e462e7d7..88d0ac8f 100644
+--- src/Makefile.am
++++ src/Makefile.am
+@@ -69,7 +69,7 @@ ar_no_Wstack_usage = yes
+ unstrip_no_Wstack_usage = yes
+ 
+ readelf_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD)
+-nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) \
++nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) $(obstack_LIBS) \
+ 	   $(demanglelib)
+ size_LDADD = $(libelf) $(libeu) $(argp_LDADD)
+ strip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
+@@ -78,9 +78,9 @@ findtextrel_LDADD = $(libdw) $(libelf) $(libeu) $(argp_LDADD)
+ addr2line_LDADD = $(libdw) $(libelf) $(libeu) $(argp_LDADD) $(demanglelib)
+ elfcmp_LDADD = $(libebl) $(libdw) $(libelf) $(libeu) $(argp_LDADD)
+ objdump_LDADD  = $(libasm) $(libebl) $(libdw) $(libelf) $(libeu) $(argp_LDADD)
+-ranlib_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD)
++ranlib_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD) $(obstack_LIBS)
+ strings_LDADD = $(libelf) $(libeu) $(argp_LDADD)
+-ar_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD)
++ar_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD) $(obstack_LIBS)
+ unstrip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
+ stack_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) $(demanglelib)
+ elfcompress_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
diff --git a/srcpkgs/elfutils/patches/musl-cdefs.patch b/srcpkgs/elfutils/patches/musl-cdefs.patch
deleted file mode 100644
index 65ef9f4d23c..00000000000
--- a/srcpkgs/elfutils/patches/musl-cdefs.patch
+++ /dev/null
@@ -1,30 +0,0 @@
---- libelf/elf.h	2015-08-21 14:22:37.000000000 +0200
-+++ libelf/elf.h	2015-11-20 04:54:33.948081321 +0100
-@@ -21,6 +21,17 @@
- 
- #include <features.h>
- 
-+#if !defined(__BEGIN_DECLS)
-+/* C++ needs to know that types and declarations are C, not C++.  */
-+#ifdef  __cplusplus
-+# define __BEGIN_DECLS  extern "C" {
-+# define __END_DECLS    }
-+#else
-+# define __BEGIN_DECLS
-+# define __END_DECLS
-+#endif
-+#endif
-+
- __BEGIN_DECLS
- 
- /* Standard ELF types.  */
---- lib/fixedsizehash.h.orig
-+++ lib/fixedsizehash.h
-@@ -30,7 +30,6 @@
- #include <errno.h>
- #include <stdlib.h>
- #include <string.h>
--#include <sys/cdefs.h>
- 
- #include <system.h>
- 
diff --git a/srcpkgs/elfutils/patches/musl-fts-obstack.patch b/srcpkgs/elfutils/patches/musl-fts-obstack.patch
deleted file mode 100644
index 77e3c4ea040..00000000000
--- a/srcpkgs/elfutils/patches/musl-fts-obstack.patch
+++ /dev/null
@@ -1,87 +0,0 @@
---- configure.ac	2015-10-15 15:16:57.000000000 +0200
-+++ 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.
---- src/Makefile.am.orig
-+++ 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
---- libdw/Makefile.am.orig
-+++ 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/srcpkgs/elfutils/patches/musl-macros.patch b/srcpkgs/elfutils/patches/musl-macros.patch
index 8ce586b2930..97a8c2bf352 100644
--- a/srcpkgs/elfutils/patches/musl-macros.patch
+++ b/srcpkgs/elfutils/patches/musl-macros.patch
@@ -1,66 +1,74 @@
---- src/arlib.h	2015-08-21 14:22:37.000000000 +0200
-+++ src/arlib.h	2015-11-20 08:02:55.153199611 +0100
-@@ -29,6 +29,16 @@
- #include <stdint.h>
- #include <sys/types.h>
+diff --git debuginfod/debuginfod-client.c debuginfod/debuginfod-client.c
+index 0e5177bc..ce1d819b 100644
+--- debuginfod/debuginfod-client.c
++++ debuginfod/debuginfod-client.c
+@@ -212,13 +212,13 @@ debuginfod_init_cache (char *cache_path, char *interval_path, char *maxage_path)
+     return 0;
  
-+#if !defined(ACCESSPERMS)
-+# define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
-+#endif
-+#if !defined(ALLPERMS)
-+# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
-+#endif
-+#if !defined(DEFFILEMODE)
-+# define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)/* 0666*/
-+#endif
-+
+   /* Create the cache and config files as necessary.  */
+-  if (stat(cache_path, &st) != 0 && mkdir(cache_path, 0777) < 0)
++  if (stat(cache_path, &st) != 0 && mkdir(cache_path, ACCESSPERMS) < 0)
+     return -errno;
  
- /* State of -D/-U flags.  */
- extern bool arlib_deterministic_output;
---- src/elfcompress.c.orig	2016-04-02 12:51:26.903848894 +0200
-+++ src/elfcompress.c	2016-04-02 12:55:15.076996338 +0200
-@@ -35,6 +35,14 @@
- #include <gelf.h>
- #include "system.h"
+   int fd = -1;
  
-+#if !defined(FNM_EXTMATCH)
-+# define FNM_EXTMATCH 0
-+#endif
-+
-+#if !defined(ALLPERMS)
-+# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
+   /* init cleaning interval config file.  */
+-  fd = open(interval_path, O_CREAT | O_RDWR, 0666);
++  fd = open(interval_path, O_CREAT | O_RDWR, DEFFILEMODE);
+   if (fd < 0)
+     return -errno;
+ 
+@@ -227,7 +227,7 @@ debuginfod_init_cache (char *cache_path, char *interval_path, char *maxage_path)
+ 
+   /* init max age config file.  */
+   if (stat(maxage_path, &st) != 0
+-      && (fd = open(maxage_path, O_CREAT | O_RDWR, 0666)) < 0)
++      && (fd = open(maxage_path, O_CREAT | O_RDWR, DEFFILEMODE)) < 0)
+     return -errno;
+ 
+   if (dprintf(fd, "%ld", cache_default_max_unused_age_s) < 0)
+diff --git lib/system.h lib/system.h
+index 292082bd..5d16ebc6 100644
+--- lib/system.h
++++ lib/system.h
+@@ -85,6 +85,18 @@
+      __res; })
+ #endif
+ 
++#ifndef ACCESSPERMS
++#define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
 +#endif
 +
- /* Name and version of program.  */
- static void print_version (FILE *stream, struct argp_state *state);
- ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;
---- src/strip.c.orig	2017-08-02 12:06:25.000000000 +0000
-+++ src/strip.c	2017-08-05 01:58:01.523493062 +0000
-@@ -47,6 +47,14 @@
- #include <system.h>
- #include <printversion.h>
- 
-+#if !defined(FNM_EXTMATCH)
-+# define FNM_EXTMATCH 0
++#ifndef ALLPERMS
++#define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
 +#endif
 +
-+#if !defined(ACCESSPERMS)
-+#define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO)
++#ifndef DEFFILEMODE
++#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)/* DEFFILEMODE*/
 +#endif
 +
- typedef uint8_t GElf_Byte;
+ static inline ssize_t __attribute__ ((unused))
+ pwrite_retry (int fd, const void *buf, size_t len, off_t off)
+ {
+diff --git src/unstrip.c src/unstrip.c
+index 0257d9cc..c99ee612 100644
+--- src/unstrip.c
++++ src/unstrip.c
+@@ -315,7 +315,7 @@ make_directories (const char *path)
+   if (dir == NULL)
+     error(EXIT_FAILURE, errno, _("memory exhausted"));
  
- /* Name and version of program.  */
---- tests/elfstrmerge.c.orig	2020-09-13 08:20:50.538492600 +0700
-+++ tests/elfstrmerge.c	2020-09-13 08:21:40.205734827 +0700
-@@ -33,6 +33,10 @@
- #include ELFUTILS_HEADER(dwelf)
- #include "elf-knowledge.h"
+-  while (mkdir (dir, 0777) < 0 && errno != EEXIST)
++  while (mkdir (dir, ACCESSPERMS) < 0 && errno != EEXIST)
+     {
+       if (errno == ENOENT)
+         make_directories (dir);
+@@ -2192,7 +2192,7 @@ DWARF data in '%s' not adjusted for prelinking bias; consider prelink -u"),
  
-+#if !defined(ALLPERMS)
-+# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
-+#endif
-+
- /* The original ELF file.  */
- static int fd = -1;
- static Elf *elf = NULL;
+       /* Copy the unstripped file and then modify it.  */
+       int outfd = open (output_file, O_RDWR | O_CREAT,
+-			  stripped_ehdr->e_type == ET_REL ? 0666 : 0777);
++			  stripped_ehdr->e_type == ET_REL ? DEFFILEMODE : ACCESSPERMS);
+       if (outfd < 0)
+ 	error (EXIT_FAILURE, errno, _("cannot open '%s'"), output_file);
+       Elf *outelf = elf_begin (outfd, ELF_C_WRITE, NULL);
diff --git a/srcpkgs/elfutils/patches/musl-strndupa.patch b/srcpkgs/elfutils/patches/musl-strndupa.patch
deleted file mode 100644
index f365fb019f2..00000000000
--- a/srcpkgs/elfutils/patches/musl-strndupa.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- src/unstrip.c.orig	2017-04-27 14:26:26.000000000 +0000
-+++ 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/srcpkgs/elfutils/template b/srcpkgs/elfutils/template
index 02e6e20c64b..99159a2be41 100644
--- a/srcpkgs/elfutils/template
+++ b/srcpkgs/elfutils/template
@@ -1,22 +1,26 @@
 # Template file for 'elfutils'
 pkgname=elfutils
-version=0.181
+version=0.182
 revision=1
 build_style=gnu-configure
-configure_args="--program-prefix=eu- --disable-debuginfod --disable-libdebuginfod"
+configure_args="--program-prefix=eu-"
 hostmakedepends="automake libtool pkg-config"
-makedepends="bzip2-devel liblzma-devel zlib-devel"
+makedepends="bzip2-devel liblzma-devel zlib-devel
+ libcurl-devel libarchive-devel sqlite-devel libmicrohttpd-devel"
 short_desc="Utilities to handle ELF object files"
-maintainer="Orphaned <orphan@voidlinux.org>"
+maintainer="Érico Nogueira <ericonr@disroot.org>"
 license="GPL-3.0-or-later"
 homepage="https://sourceware.org/elfutils/"
 distfiles="https://sourceware.org/${pkgname}/ftp/${version}/${pkgname}-${version}.tar.bz2"
-checksum=29a6ad7421ec2acfee489bb4a699908281ead2cb63a20a027ce8804a165f0eb3
+checksum=ecc406914edf335f0b7fc084ebe6c460c4d6d5175bfdd6688c1c78d9146b8858
 
 CFLAGS="-Wno-error"
+CXXFLAGS="-Wl,-z,stack-size=2097152"
 
 if [ "$XBPS_TARGET_LIBC" = musl ]; then
-	makedepends+=" argp-standalone musl-fts-devel musl-obstack-devel"
+	makedepends+=" argp-standalone musl-fts-devel musl-obstack-devel musl-legacy-compat"
+	# XXX: breaks some expected functionality
+	CFLAGS+=" -DFNM_EXTMATCH=0"
 fi
 
 post_extract() {
@@ -30,6 +34,23 @@ pre_configure() {
 	autoreconf -if
 }
 
+libdebuginfod_package() {
+	short_desc+=" - debuginfod library"
+	pkg_install() {
+		vmove "usr/lib/libdebuginfod-*.so*"
+		vmove etc/profile.d
+	}
+}
+
+debuginfod_package() {
+	short_desc+=" - debuginfod programs"
+	pkg_install() {
+		vmove "usr/bin/debuginfod*"
+		vmove "usr/share/man/man1/debuginfod-find.1"
+		vmove "usr/share/man/man8/debuginfod.8"
+	}
+}
+
 libelf_package() {
 	short_desc+=" - runtime library"
 	pkg_install() {
@@ -38,11 +59,13 @@ libelf_package() {
 }
 
 elfutils-devel_package() {
-	depends="libelf>=${version}_${revision} ${makedepends}"
+	depends="libelf>=${version}_${revision} libdebuginfod>=${version}_${revision}
+	 ${makedepends}"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig
 		vmove "usr/lib/*.a"
+		vmove usr/share/man/man3
 	}
 }
diff --git a/srcpkgs/libdebuginfod b/srcpkgs/libdebuginfod
new file mode 120000
index 00000000000..b76b36cfac4
--- /dev/null
+++ b/srcpkgs/libdebuginfod
@@ -0,0 +1 @@
+elfutils
\ No newline at end of file

From 3d184997a53801acaf720f22954a36659125c479 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
Date: Sun, 25 Oct 2020 18:23:45 -0300
Subject: [PATCH 4/4] gdb: add debuginfod option, enable by default.

---
 srcpkgs/gdb/template | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/srcpkgs/gdb/template b/srcpkgs/gdb/template
index 0e2e399e798..e2a39e7d103 100644
--- a/srcpkgs/gdb/template
+++ b/srcpkgs/gdb/template
@@ -1,16 +1,18 @@
 # Template file for 'gdb'
 pkgname=gdb
 version=10.1
-revision=1
+revision=2
 build_style=gnu-configure
 pycompile_dirs="/usr/share/gdb/python"
 configure_args="--disable-werror --disable-nls --with-system-readline
  --with-system-gdbinit=/etc/gdb/gdbinit --with-system-zlib $(vopt_enable gdbserver)
  $(vopt_if static 'CFLAGS=-static CXXFLAGS=-static LDFLAGS=-static')
- $(vopt_if python --with-python=/usr/bin/python3)"
-hostmakedepends="texinfo perl $(vopt_if python python3-devel)"
+ $(vopt_if python --with-python=/usr/bin/python3)
+ $(vopt_with debuginfod)"
+hostmakedepends="texinfo perl pkg-config $(vopt_if python python3-devel)"
 makedepends="ncurses-devel zlib-devel readline-devel expat-devel
- $(vopt_if python 'python3-devel gettext-libs')"
+ $(vopt_if python 'python3-devel gettext-libs')
+ $(vopt_if debuginfod elfutils-devel)"
 short_desc="GNU Debugger"
 maintainer="Anthony Iliopoulos <ailiop@altatus.com>"
 license="GPL-3.0-or-later"
@@ -28,10 +30,11 @@ fi
 CFLAGS+=" -fcommon"
 CXXFLAGS+=" -fcommon"
 # Package build options
-build_options="gdbserver static python"
+build_options="gdbserver static python debuginfod"
 desc_option_gdbserver="Enable support for building GDB server"
+desc_option_debuginfod="Enable support for libdebuginfod"
 # Enable gdbserver if !static.
-build_options_default="gdbserver python"
+build_options_default="gdbserver python debuginfod"
 # Both options cannot be enabled at the same time
 vopt_conflict gdbserver static
 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PR PATCH] [Updated] Update elfutils to 0.182.
  2020-11-02  1:56 [PR PATCH] Update elfutils to 0.182 ericonr
                   ` (5 preceding siblings ...)
  2020-11-06 14:39 ` ericonr
@ 2020-11-17 13:56 ` ericonr
  2020-11-18  2:32 ` ericonr
  2020-11-18  3:00 ` [PR PATCH] [Merged]: " ericonr
  8 siblings, 0 replies; 10+ messages in thread
From: ericonr @ 2020-11-17 13:56 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 462 bytes --]

There is an updated pull request by ericonr against master on the void-packages repository

https://github.com/ericonr/void-packages debuginfod
https://github.com/void-linux/void-packages/pull/26067

Update elfutils to 0.182.
Also create the debuginfod subpackage and use it in gdb.

This PR can wait on some musl patches that I'd like to backport for the fregs patch.

A patch file from https://github.com/void-linux/void-packages/pull/26067.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-debuginfod-26067.patch --]
[-- Type: text/x-diff, Size: 25849 bytes --]

From 0e9ea48235bded0bc52f068dbc2a2c2625fe5351 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
Date: Fri, 6 Nov 2020 11:35:39 -0300
Subject: [PATCH 1/4] musl: add patch for aarch64 fregs and vregs.

Necessary for building elfutils for aarch64 without patches.
---
 srcpkgs/musl/patches/aarch64-fregs.patch | 37 ++++++++++++++++++++++++
 srcpkgs/musl/template                    |  2 +-
 2 files changed, 38 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/musl/patches/aarch64-fregs.patch

diff --git a/srcpkgs/musl/patches/aarch64-fregs.patch b/srcpkgs/musl/patches/aarch64-fregs.patch
new file mode 100644
index 00000000000..9c89de44732
--- /dev/null
+++ b/srcpkgs/musl/patches/aarch64-fregs.patch
@@ -0,0 +1,37 @@
+Use types compatible with glibc/kernel headers.
+
+diff --git a/arch/aarch64/bits/signal.h b/arch/aarch64/bits/signal.h
+index b71261f5..5098c734 100644
+--- arch/aarch64/bits/signal.h
++++ arch/aarch64/bits/signal.h
+@@ -11,7 +11,7 @@ typedef unsigned long greg_t;
+ typedef unsigned long gregset_t[34];
+ 
+ typedef struct {
+-	long double vregs[32];
++	__uint128_t vregs[32];
+ 	unsigned int fpsr;
+ 	unsigned int fpcr;
+ } fpregset_t;
+@@ -34,7 +34,7 @@ struct fpsimd_context {
+ 	struct _aarch64_ctx head;
+ 	unsigned int fpsr;
+ 	unsigned int fpcr;
+-	long double vregs[32];
++	__uint128_t vregs[32];
+ };
+ struct esr_context {
+ 	struct _aarch64_ctx head;
+diff --git a/arch/aarch64/bits/user.h b/arch/aarch64/bits/user.h
+index d12cdf7f..8a1002aa 100644
+--- arch/aarch64/bits/user.h
++++ arch/aarch64/bits/user.h
+@@ -6,7 +6,7 @@ struct user_regs_struct {
+ };
+ 
+ struct user_fpsimd_struct {
+-	long double vregs[32];
++	__uint128_t vregs[32];
+ 	unsigned int fpsr;
+ 	unsigned int fpcr;
+ };
diff --git a/srcpkgs/musl/template b/srcpkgs/musl/template
index 22e79588acd..6a0ac60b03c 100644
--- a/srcpkgs/musl/template
+++ b/srcpkgs/musl/template
@@ -2,7 +2,7 @@
 pkgname=musl
 reverts="1.2.0_1"
 version=1.1.24
-revision=3
+revision=4
 archs="*-musl"
 bootstrap=yes
 build_style=gnu-configure

From 5475bb1f320e8fbd32b2f19d1204ae735703eff4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
Date: Fri, 6 Nov 2020 11:36:42 -0300
Subject: [PATCH 2/4] cross-aarch64-linux-musl: revbump to apply musl patch.

Patch can be seen in the commit before this one.
---
 srcpkgs/cross-aarch64-linux-musl/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cross-aarch64-linux-musl/template b/srcpkgs/cross-aarch64-linux-musl/template
index 5ce33afe375..48d3c201d06 100644
--- a/srcpkgs/cross-aarch64-linux-musl/template
+++ b/srcpkgs/cross-aarch64-linux-musl/template
@@ -12,7 +12,7 @@ _sysroot="/usr/${_triplet}"
 
 pkgname=cross-${_triplet}
 version=0.33
-revision=3
+revision=4
 short_desc="Cross toolchain for ARM64 LE target (musl)"
 maintainer="Orphaned <orphan@voidlinux.org>"
 homepage="https://www.voidlinux.org/"

From 68d8d298dda10af889ef54d09fa6ca42dfbb104e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
Date: Sun, 25 Oct 2020 18:57:17 -0300
Subject: [PATCH 3/4] elfutils: update to 0.182, add debuginfod subpkgs, adopt.

Cleaned up patches, remove the aarch64-fregs one (it was fixed with a
musl patch, instead), and moved closer to where upstream is moving
regarding musl compat.
---
 common/shlibs                                 |   1 +
 srcpkgs/debuginfod                            |   1 +
 srcpkgs/elfutils/patches/debuginfod.patch     |  13 ++
 .../elfutils/patches/fix-aarch64_fregs.patch  |  14 ---
 .../elfutils/patches/fix-uninitialized.patch  |  11 --
 srcpkgs/elfutils/patches/fts-obstack.patch    | 107 ++++++++++++++++
 srcpkgs/elfutils/patches/musl-cdefs.patch     |  30 -----
 .../elfutils/patches/musl-fts-obstack.patch   |  87 -------------
 srcpkgs/elfutils/patches/musl-macros.patch    | 118 ++++++++++--------
 srcpkgs/elfutils/patches/musl-strndupa.patch  |  18 ---
 srcpkgs/elfutils/template                     |  37 ++++--
 srcpkgs/libdebuginfod                         |   1 +
 12 files changed, 216 insertions(+), 222 deletions(-)
 create mode 120000 srcpkgs/debuginfod
 create mode 100644 srcpkgs/elfutils/patches/debuginfod.patch
 delete mode 100644 srcpkgs/elfutils/patches/fix-aarch64_fregs.patch
 delete mode 100644 srcpkgs/elfutils/patches/fix-uninitialized.patch
 create mode 100644 srcpkgs/elfutils/patches/fts-obstack.patch
 delete mode 100644 srcpkgs/elfutils/patches/musl-cdefs.patch
 delete mode 100644 srcpkgs/elfutils/patches/musl-fts-obstack.patch
 delete mode 100644 srcpkgs/elfutils/patches/musl-strndupa.patch
 create mode 120000 srcpkgs/libdebuginfod

diff --git a/common/shlibs b/common/shlibs
index a32a8f994e0..5c5b861eeb2 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -737,6 +737,7 @@ libmtp.so.9 libmtp-1.1.4_1
 libelf.so.1 libelf-0.155_1
 libdw.so.1 libelf-0.155_1
 libasm.so.1 libelf-0.155_1
+libdebuginfod.so.1 libdebuginfod-0.182_1
 libgtksourceview-3.0.so.1 gtksourceview-3.8.0_1
 libtalloc.so.2 talloc-2.0.1_1
 libmount.so.1 libmount-2.18_1
diff --git a/srcpkgs/debuginfod b/srcpkgs/debuginfod
new file mode 120000
index 00000000000..b76b36cfac4
--- /dev/null
+++ b/srcpkgs/debuginfod
@@ -0,0 +1 @@
+elfutils
\ No newline at end of file
diff --git a/srcpkgs/elfutils/patches/debuginfod.patch b/srcpkgs/elfutils/patches/debuginfod.patch
new file mode 100644
index 00000000000..d26d945d1ff
--- /dev/null
+++ b/srcpkgs/elfutils/patches/debuginfod.patch
@@ -0,0 +1,13 @@
+diff --git debuginfod/debuginfod.cxx debuginfod/debuginfod.cxx
+index 3085f388..d2a434ee 100644
+--- debuginfod/debuginfod.cxx
++++ debuginfod/debuginfod.cxx
+@@ -46,7 +46,7 @@ extern "C" {
+ #include <unistd.h>
+ #include <stdlib.h>
+ #include <error.h>
+-// #include <libintl.h> // not until it supports C++ << better
++#include <libintl.h>
+ #include <locale.h>
+ #include <pthread.h>
+ #include <signal.h>
diff --git a/srcpkgs/elfutils/patches/fix-aarch64_fregs.patch b/srcpkgs/elfutils/patches/fix-aarch64_fregs.patch
deleted file mode 100644
index e9641542144..00000000000
--- a/srcpkgs/elfutils/patches/fix-aarch64_fregs.patch
+++ /dev/null
@@ -1,14 +0,0 @@
-It looks like fregs.vregs[] is an array of double?
-Casting to Dwarf_Word instead of & 0xFFFFFFF should do.
-
---- backends/aarch64_initreg.c	2015-11-27 14:36:29.000000000 +0100
-+++ backends/aarch64_initreg.c	2016-08-09 03:47:25.428560159 +0200
-@@ -82,7 +83,7 @@
- 
-   Dwarf_Word dwarf_fregs[32];
-   for (int r = 0; r < 32; r++)
--    dwarf_fregs[r] = fregs.vregs[r] & 0xFFFFFFFF;
-+    dwarf_fregs[r] = (Dwarf_Word)fregs.vregs[r];
- 
-   if (! setfunc (64, 32, dwarf_fregs, arg))
-     return false;
diff --git a/srcpkgs/elfutils/patches/fix-uninitialized.patch b/srcpkgs/elfutils/patches/fix-uninitialized.patch
deleted file mode 100644
index 6ab15e50e2b..00000000000
--- a/srcpkgs/elfutils/patches/fix-uninitialized.patch
+++ /dev/null
@@ -1,11 +0,0 @@
-
---- libcpu/i386_disasm.c	2015-08-21 14:22:37.000000000 +0200
-+++ libcpu/i386_disasm.c	2015-11-20 06:30:59.250629957 +0100
-@@ -710,6 +710,7 @@
- 
- 		case 'm':
- 		  /* Mnemonic.  */
-+		  str = mnebuf;
- 
- 		  if (unlikely (instrtab[cnt].mnemonic == MNE_INVALID))
- 		    {
diff --git a/srcpkgs/elfutils/patches/fts-obstack.patch b/srcpkgs/elfutils/patches/fts-obstack.patch
new file mode 100644
index 00000000000..44ef0aee70e
--- /dev/null
+++ b/srcpkgs/elfutils/patches/fts-obstack.patch
@@ -0,0 +1,107 @@
+diff --git ChangeLog ChangeLog
+index 128da6c6..565d021c 100644
+--- ChangeLog
++++ ChangeLog
+@@ -1,3 +1,7 @@
++2020-11-01  Érico N. Rolim  <erico.erc@gmail.com>
++
++	* configure.ac: Check for fts and obstack from outside libc.
++
+ 2020-10-28  Mark Wielaard  <mark@klomp.org>
+ 
+ 	* configure.ac: Set version to 0.182.
+diff --git configure.ac configure.ac
+index 515ac704..c1a6954d 100644
+--- configure.ac
++++ configure.ac
+@@ -542,6 +542,26 @@ else
+ fi
+ AC_SUBST([argp_LDADD])
+ 
++saved_LIBS="$LIBS"
++AC_SEARCH_LIBS([fts_close], [fts])
++LIBS="$saved_LIBS"
++case "$ac_cv_search_fts_close" in
++        no) AC_MSG_FAILURE([failed to find fts_close]) ;;
++        -l*) fts_LIBS="$ac_cv_search_fts_close" ;;
++        *) fts_LIBS= ;;
++esac
++AC_SUBST([fts_LIBS])
++
++saved_LIBS="$LIBS"
++AC_SEARCH_LIBS([_obstack_free], [obstack])
++LIBS="$saved_LIBS"
++case "$ac_cv_search__obstack_free" in
++        no) AC_MSG_FAILURE([failed to find obstack_free]) ;;
++        -l*) obstack_LIBS="$ac_cv_search__obstack_free" ;;
++        *) obstack_LIBS= ;;
++esac
++AC_SUBST([obstack_LIBS])
++
+ dnl The directories with content.
+ 
+ dnl Documentation.
+diff --git debuginfod/Makefile.am debuginfod/Makefile.am
+index 01985600..0af3b58c 100644
+--- debuginfod/Makefile.am
++++ debuginfod/Makefile.am
+@@ -71,10 +71,10 @@ bin_PROGRAMS += debuginfod-find
+ endif
+ 
+ debuginfod_SOURCES = debuginfod.cxx
+-debuginfod_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod) $(libmicrohttpd_LIBS) $(sqlite3_LIBS) $(libarchive_LIBS) -lpthread -ldl
++debuginfod_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod) $(argp_LDADD) $(fts_LIBS) $(libmicrohttpd_LIBS) $(sqlite3_LIBS) $(libarchive_LIBS) -lpthread -ldl
+ 
+ debuginfod_find_SOURCES = debuginfod-find.c
+-debuginfod_find_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod)
++debuginfod_find_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod) $(argp_LDADD) $(fts_LIBS)
+ 
+ if LIBDEBUGINFOD
+ noinst_LIBRARIES = libdebuginfod.a
+@@ -98,7 +98,7 @@ libdebuginfod_so_LIBS = libdebuginfod_pic.a
+ if DUMMY_LIBDEBUGINFOD
+ libdebuginfod_so_LDLIBS =
+ else
+-libdebuginfod_so_LDLIBS = $(libcurl_LIBS)
++libdebuginfod_so_LDLIBS = $(libcurl_LIBS) $(fts_LIBS)
+ endif
+ libdebuginfod.so$(EXEEXT): $(srcdir)/libdebuginfod.map $(libdebuginfod_so_LIBS)
+ 	$(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $@ \
+diff --git libdw/Makefile.am libdw/Makefile.am
+index 33b5838d..1dbb3d5e 100644
+--- libdw/Makefile.am
++++ libdw/Makefile.am
+@@ -109,7 +109,7 @@ libdw_so_LIBS = ../libebl/libebl_pic.a ../backends/libebl_backends_pic.a \
+ 		../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_LIBS) $(obstack_LIBS) $(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 src/Makefile.am src/Makefile.am
+index e462e7d7..88d0ac8f 100644
+--- src/Makefile.am
++++ src/Makefile.am
+@@ -69,7 +69,7 @@ ar_no_Wstack_usage = yes
+ unstrip_no_Wstack_usage = yes
+ 
+ readelf_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD)
+-nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) \
++nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) $(obstack_LIBS) \
+ 	   $(demanglelib)
+ size_LDADD = $(libelf) $(libeu) $(argp_LDADD)
+ strip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
+@@ -78,9 +78,9 @@ findtextrel_LDADD = $(libdw) $(libelf) $(libeu) $(argp_LDADD)
+ addr2line_LDADD = $(libdw) $(libelf) $(libeu) $(argp_LDADD) $(demanglelib)
+ elfcmp_LDADD = $(libebl) $(libdw) $(libelf) $(libeu) $(argp_LDADD)
+ objdump_LDADD  = $(libasm) $(libebl) $(libdw) $(libelf) $(libeu) $(argp_LDADD)
+-ranlib_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD)
++ranlib_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD) $(obstack_LIBS)
+ strings_LDADD = $(libelf) $(libeu) $(argp_LDADD)
+-ar_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD)
++ar_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD) $(obstack_LIBS)
+ unstrip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
+ stack_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) $(demanglelib)
+ elfcompress_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
diff --git a/srcpkgs/elfutils/patches/musl-cdefs.patch b/srcpkgs/elfutils/patches/musl-cdefs.patch
deleted file mode 100644
index 65ef9f4d23c..00000000000
--- a/srcpkgs/elfutils/patches/musl-cdefs.patch
+++ /dev/null
@@ -1,30 +0,0 @@
---- libelf/elf.h	2015-08-21 14:22:37.000000000 +0200
-+++ libelf/elf.h	2015-11-20 04:54:33.948081321 +0100
-@@ -21,6 +21,17 @@
- 
- #include <features.h>
- 
-+#if !defined(__BEGIN_DECLS)
-+/* C++ needs to know that types and declarations are C, not C++.  */
-+#ifdef  __cplusplus
-+# define __BEGIN_DECLS  extern "C" {
-+# define __END_DECLS    }
-+#else
-+# define __BEGIN_DECLS
-+# define __END_DECLS
-+#endif
-+#endif
-+
- __BEGIN_DECLS
- 
- /* Standard ELF types.  */
---- lib/fixedsizehash.h.orig
-+++ lib/fixedsizehash.h
-@@ -30,7 +30,6 @@
- #include <errno.h>
- #include <stdlib.h>
- #include <string.h>
--#include <sys/cdefs.h>
- 
- #include <system.h>
- 
diff --git a/srcpkgs/elfutils/patches/musl-fts-obstack.patch b/srcpkgs/elfutils/patches/musl-fts-obstack.patch
deleted file mode 100644
index 77e3c4ea040..00000000000
--- a/srcpkgs/elfutils/patches/musl-fts-obstack.patch
+++ /dev/null
@@ -1,87 +0,0 @@
---- configure.ac	2015-10-15 15:16:57.000000000 +0200
-+++ 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.
---- src/Makefile.am.orig
-+++ 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
---- libdw/Makefile.am.orig
-+++ 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/srcpkgs/elfutils/patches/musl-macros.patch b/srcpkgs/elfutils/patches/musl-macros.patch
index 8ce586b2930..97a8c2bf352 100644
--- a/srcpkgs/elfutils/patches/musl-macros.patch
+++ b/srcpkgs/elfutils/patches/musl-macros.patch
@@ -1,66 +1,74 @@
---- src/arlib.h	2015-08-21 14:22:37.000000000 +0200
-+++ src/arlib.h	2015-11-20 08:02:55.153199611 +0100
-@@ -29,6 +29,16 @@
- #include <stdint.h>
- #include <sys/types.h>
+diff --git debuginfod/debuginfod-client.c debuginfod/debuginfod-client.c
+index 0e5177bc..ce1d819b 100644
+--- debuginfod/debuginfod-client.c
++++ debuginfod/debuginfod-client.c
+@@ -212,13 +212,13 @@ debuginfod_init_cache (char *cache_path, char *interval_path, char *maxage_path)
+     return 0;
  
-+#if !defined(ACCESSPERMS)
-+# define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
-+#endif
-+#if !defined(ALLPERMS)
-+# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
-+#endif
-+#if !defined(DEFFILEMODE)
-+# define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)/* 0666*/
-+#endif
-+
+   /* Create the cache and config files as necessary.  */
+-  if (stat(cache_path, &st) != 0 && mkdir(cache_path, 0777) < 0)
++  if (stat(cache_path, &st) != 0 && mkdir(cache_path, ACCESSPERMS) < 0)
+     return -errno;
  
- /* State of -D/-U flags.  */
- extern bool arlib_deterministic_output;
---- src/elfcompress.c.orig	2016-04-02 12:51:26.903848894 +0200
-+++ src/elfcompress.c	2016-04-02 12:55:15.076996338 +0200
-@@ -35,6 +35,14 @@
- #include <gelf.h>
- #include "system.h"
+   int fd = -1;
  
-+#if !defined(FNM_EXTMATCH)
-+# define FNM_EXTMATCH 0
-+#endif
-+
-+#if !defined(ALLPERMS)
-+# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
+   /* init cleaning interval config file.  */
+-  fd = open(interval_path, O_CREAT | O_RDWR, 0666);
++  fd = open(interval_path, O_CREAT | O_RDWR, DEFFILEMODE);
+   if (fd < 0)
+     return -errno;
+ 
+@@ -227,7 +227,7 @@ debuginfod_init_cache (char *cache_path, char *interval_path, char *maxage_path)
+ 
+   /* init max age config file.  */
+   if (stat(maxage_path, &st) != 0
+-      && (fd = open(maxage_path, O_CREAT | O_RDWR, 0666)) < 0)
++      && (fd = open(maxage_path, O_CREAT | O_RDWR, DEFFILEMODE)) < 0)
+     return -errno;
+ 
+   if (dprintf(fd, "%ld", cache_default_max_unused_age_s) < 0)
+diff --git lib/system.h lib/system.h
+index 292082bd..5d16ebc6 100644
+--- lib/system.h
++++ lib/system.h
+@@ -85,6 +85,18 @@
+      __res; })
+ #endif
+ 
++#ifndef ACCESSPERMS
++#define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
 +#endif
 +
- /* Name and version of program.  */
- static void print_version (FILE *stream, struct argp_state *state);
- ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;
---- src/strip.c.orig	2017-08-02 12:06:25.000000000 +0000
-+++ src/strip.c	2017-08-05 01:58:01.523493062 +0000
-@@ -47,6 +47,14 @@
- #include <system.h>
- #include <printversion.h>
- 
-+#if !defined(FNM_EXTMATCH)
-+# define FNM_EXTMATCH 0
++#ifndef ALLPERMS
++#define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
 +#endif
 +
-+#if !defined(ACCESSPERMS)
-+#define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO)
++#ifndef DEFFILEMODE
++#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)/* DEFFILEMODE*/
 +#endif
 +
- typedef uint8_t GElf_Byte;
+ static inline ssize_t __attribute__ ((unused))
+ pwrite_retry (int fd, const void *buf, size_t len, off_t off)
+ {
+diff --git src/unstrip.c src/unstrip.c
+index 0257d9cc..c99ee612 100644
+--- src/unstrip.c
++++ src/unstrip.c
+@@ -315,7 +315,7 @@ make_directories (const char *path)
+   if (dir == NULL)
+     error(EXIT_FAILURE, errno, _("memory exhausted"));
  
- /* Name and version of program.  */
---- tests/elfstrmerge.c.orig	2020-09-13 08:20:50.538492600 +0700
-+++ tests/elfstrmerge.c	2020-09-13 08:21:40.205734827 +0700
-@@ -33,6 +33,10 @@
- #include ELFUTILS_HEADER(dwelf)
- #include "elf-knowledge.h"
+-  while (mkdir (dir, 0777) < 0 && errno != EEXIST)
++  while (mkdir (dir, ACCESSPERMS) < 0 && errno != EEXIST)
+     {
+       if (errno == ENOENT)
+         make_directories (dir);
+@@ -2192,7 +2192,7 @@ DWARF data in '%s' not adjusted for prelinking bias; consider prelink -u"),
  
-+#if !defined(ALLPERMS)
-+# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
-+#endif
-+
- /* The original ELF file.  */
- static int fd = -1;
- static Elf *elf = NULL;
+       /* Copy the unstripped file and then modify it.  */
+       int outfd = open (output_file, O_RDWR | O_CREAT,
+-			  stripped_ehdr->e_type == ET_REL ? 0666 : 0777);
++			  stripped_ehdr->e_type == ET_REL ? DEFFILEMODE : ACCESSPERMS);
+       if (outfd < 0)
+ 	error (EXIT_FAILURE, errno, _("cannot open '%s'"), output_file);
+       Elf *outelf = elf_begin (outfd, ELF_C_WRITE, NULL);
diff --git a/srcpkgs/elfutils/patches/musl-strndupa.patch b/srcpkgs/elfutils/patches/musl-strndupa.patch
deleted file mode 100644
index f365fb019f2..00000000000
--- a/srcpkgs/elfutils/patches/musl-strndupa.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- src/unstrip.c.orig	2017-04-27 14:26:26.000000000 +0000
-+++ 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/srcpkgs/elfutils/template b/srcpkgs/elfutils/template
index 02e6e20c64b..99159a2be41 100644
--- a/srcpkgs/elfutils/template
+++ b/srcpkgs/elfutils/template
@@ -1,22 +1,26 @@
 # Template file for 'elfutils'
 pkgname=elfutils
-version=0.181
+version=0.182
 revision=1
 build_style=gnu-configure
-configure_args="--program-prefix=eu- --disable-debuginfod --disable-libdebuginfod"
+configure_args="--program-prefix=eu-"
 hostmakedepends="automake libtool pkg-config"
-makedepends="bzip2-devel liblzma-devel zlib-devel"
+makedepends="bzip2-devel liblzma-devel zlib-devel
+ libcurl-devel libarchive-devel sqlite-devel libmicrohttpd-devel"
 short_desc="Utilities to handle ELF object files"
-maintainer="Orphaned <orphan@voidlinux.org>"
+maintainer="Érico Nogueira <ericonr@disroot.org>"
 license="GPL-3.0-or-later"
 homepage="https://sourceware.org/elfutils/"
 distfiles="https://sourceware.org/${pkgname}/ftp/${version}/${pkgname}-${version}.tar.bz2"
-checksum=29a6ad7421ec2acfee489bb4a699908281ead2cb63a20a027ce8804a165f0eb3
+checksum=ecc406914edf335f0b7fc084ebe6c460c4d6d5175bfdd6688c1c78d9146b8858
 
 CFLAGS="-Wno-error"
+CXXFLAGS="-Wl,-z,stack-size=2097152"
 
 if [ "$XBPS_TARGET_LIBC" = musl ]; then
-	makedepends+=" argp-standalone musl-fts-devel musl-obstack-devel"
+	makedepends+=" argp-standalone musl-fts-devel musl-obstack-devel musl-legacy-compat"
+	# XXX: breaks some expected functionality
+	CFLAGS+=" -DFNM_EXTMATCH=0"
 fi
 
 post_extract() {
@@ -30,6 +34,23 @@ pre_configure() {
 	autoreconf -if
 }
 
+libdebuginfod_package() {
+	short_desc+=" - debuginfod library"
+	pkg_install() {
+		vmove "usr/lib/libdebuginfod-*.so*"
+		vmove etc/profile.d
+	}
+}
+
+debuginfod_package() {
+	short_desc+=" - debuginfod programs"
+	pkg_install() {
+		vmove "usr/bin/debuginfod*"
+		vmove "usr/share/man/man1/debuginfod-find.1"
+		vmove "usr/share/man/man8/debuginfod.8"
+	}
+}
+
 libelf_package() {
 	short_desc+=" - runtime library"
 	pkg_install() {
@@ -38,11 +59,13 @@ libelf_package() {
 }
 
 elfutils-devel_package() {
-	depends="libelf>=${version}_${revision} ${makedepends}"
+	depends="libelf>=${version}_${revision} libdebuginfod>=${version}_${revision}
+	 ${makedepends}"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig
 		vmove "usr/lib/*.a"
+		vmove usr/share/man/man3
 	}
 }
diff --git a/srcpkgs/libdebuginfod b/srcpkgs/libdebuginfod
new file mode 120000
index 00000000000..b76b36cfac4
--- /dev/null
+++ b/srcpkgs/libdebuginfod
@@ -0,0 +1 @@
+elfutils
\ No newline at end of file

From f40e2bcbe7a6998f01ad66ec080cd02c6830b00f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
Date: Sun, 25 Oct 2020 18:23:45 -0300
Subject: [PATCH 4/4] gdb: add debuginfod option, enable by default.

---
 srcpkgs/gdb/template | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/srcpkgs/gdb/template b/srcpkgs/gdb/template
index 0e2e399e798..e2a39e7d103 100644
--- a/srcpkgs/gdb/template
+++ b/srcpkgs/gdb/template
@@ -1,16 +1,18 @@
 # Template file for 'gdb'
 pkgname=gdb
 version=10.1
-revision=1
+revision=2
 build_style=gnu-configure
 pycompile_dirs="/usr/share/gdb/python"
 configure_args="--disable-werror --disable-nls --with-system-readline
  --with-system-gdbinit=/etc/gdb/gdbinit --with-system-zlib $(vopt_enable gdbserver)
  $(vopt_if static 'CFLAGS=-static CXXFLAGS=-static LDFLAGS=-static')
- $(vopt_if python --with-python=/usr/bin/python3)"
-hostmakedepends="texinfo perl $(vopt_if python python3-devel)"
+ $(vopt_if python --with-python=/usr/bin/python3)
+ $(vopt_with debuginfod)"
+hostmakedepends="texinfo perl pkg-config $(vopt_if python python3-devel)"
 makedepends="ncurses-devel zlib-devel readline-devel expat-devel
- $(vopt_if python 'python3-devel gettext-libs')"
+ $(vopt_if python 'python3-devel gettext-libs')
+ $(vopt_if debuginfod elfutils-devel)"
 short_desc="GNU Debugger"
 maintainer="Anthony Iliopoulos <ailiop@altatus.com>"
 license="GPL-3.0-or-later"
@@ -28,10 +30,11 @@ fi
 CFLAGS+=" -fcommon"
 CXXFLAGS+=" -fcommon"
 # Package build options
-build_options="gdbserver static python"
+build_options="gdbserver static python debuginfod"
 desc_option_gdbserver="Enable support for building GDB server"
+desc_option_debuginfod="Enable support for libdebuginfod"
 # Enable gdbserver if !static.
-build_options_default="gdbserver python"
+build_options_default="gdbserver python debuginfod"
 # Both options cannot be enabled at the same time
 vopt_conflict gdbserver static
 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PR PATCH] [Updated] Update elfutils to 0.182.
  2020-11-02  1:56 [PR PATCH] Update elfutils to 0.182 ericonr
                   ` (6 preceding siblings ...)
  2020-11-17 13:56 ` ericonr
@ 2020-11-18  2:32 ` ericonr
  2020-11-18  3:00 ` [PR PATCH] [Merged]: " ericonr
  8 siblings, 0 replies; 10+ messages in thread
From: ericonr @ 2020-11-18  2:32 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 462 bytes --]

There is an updated pull request by ericonr against master on the void-packages repository

https://github.com/ericonr/void-packages debuginfod
https://github.com/void-linux/void-packages/pull/26067

Update elfutils to 0.182.
Also create the debuginfod subpackage and use it in gdb.

This PR can wait on some musl patches that I'd like to backport for the fregs patch.

A patch file from https://github.com/void-linux/void-packages/pull/26067.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-debuginfod-26067.patch --]
[-- Type: text/x-diff, Size: 22898 bytes --]

From a80989ff37358fac0e230842d762d91771f2b140 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
Date: Sun, 25 Oct 2020 18:57:17 -0300
Subject: [PATCH 1/2] elfutils: update to 0.182, add debuginfod subpkgs, adopt.

Cleaned up patches, remove the aarch64-fregs one (it was fixed with a
musl patch, instead), and moved closer to where upstream is moving
regarding musl compat.
---
 common/shlibs                                 |   1 +
 srcpkgs/debuginfod                            |   1 +
 srcpkgs/elfutils/patches/debuginfod.patch     |  13 ++
 .../elfutils/patches/fix-aarch64_fregs.patch  |  14 ---
 .../elfutils/patches/fix-uninitialized.patch  |  11 --
 srcpkgs/elfutils/patches/fts-obstack.patch    | 107 ++++++++++++++++
 srcpkgs/elfutils/patches/musl-cdefs.patch     |  30 -----
 .../elfutils/patches/musl-fts-obstack.patch   |  87 -------------
 srcpkgs/elfutils/patches/musl-macros.patch    | 118 ++++++++++--------
 srcpkgs/elfutils/patches/musl-strndupa.patch  |  18 ---
 srcpkgs/elfutils/template                     |  37 ++++--
 srcpkgs/libdebuginfod                         |   1 +
 12 files changed, 216 insertions(+), 222 deletions(-)
 create mode 120000 srcpkgs/debuginfod
 create mode 100644 srcpkgs/elfutils/patches/debuginfod.patch
 delete mode 100644 srcpkgs/elfutils/patches/fix-aarch64_fregs.patch
 delete mode 100644 srcpkgs/elfutils/patches/fix-uninitialized.patch
 create mode 100644 srcpkgs/elfutils/patches/fts-obstack.patch
 delete mode 100644 srcpkgs/elfutils/patches/musl-cdefs.patch
 delete mode 100644 srcpkgs/elfutils/patches/musl-fts-obstack.patch
 delete mode 100644 srcpkgs/elfutils/patches/musl-strndupa.patch
 create mode 120000 srcpkgs/libdebuginfod

diff --git a/common/shlibs b/common/shlibs
index 8e73de74f7a..9a576f18d0f 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -737,6 +737,7 @@ libmtp.so.9 libmtp-1.1.4_1
 libelf.so.1 libelf-0.155_1
 libdw.so.1 libelf-0.155_1
 libasm.so.1 libelf-0.155_1
+libdebuginfod.so.1 libdebuginfod-0.182_1
 libgtksourceview-3.0.so.1 gtksourceview-3.8.0_1
 libtalloc.so.2 talloc-2.0.1_1
 libmount.so.1 libmount-2.18_1
diff --git a/srcpkgs/debuginfod b/srcpkgs/debuginfod
new file mode 120000
index 00000000000..b76b36cfac4
--- /dev/null
+++ b/srcpkgs/debuginfod
@@ -0,0 +1 @@
+elfutils
\ No newline at end of file
diff --git a/srcpkgs/elfutils/patches/debuginfod.patch b/srcpkgs/elfutils/patches/debuginfod.patch
new file mode 100644
index 00000000000..d26d945d1ff
--- /dev/null
+++ b/srcpkgs/elfutils/patches/debuginfod.patch
@@ -0,0 +1,13 @@
+diff --git debuginfod/debuginfod.cxx debuginfod/debuginfod.cxx
+index 3085f388..d2a434ee 100644
+--- debuginfod/debuginfod.cxx
++++ debuginfod/debuginfod.cxx
+@@ -46,7 +46,7 @@ extern "C" {
+ #include <unistd.h>
+ #include <stdlib.h>
+ #include <error.h>
+-// #include <libintl.h> // not until it supports C++ << better
++#include <libintl.h>
+ #include <locale.h>
+ #include <pthread.h>
+ #include <signal.h>
diff --git a/srcpkgs/elfutils/patches/fix-aarch64_fregs.patch b/srcpkgs/elfutils/patches/fix-aarch64_fregs.patch
deleted file mode 100644
index e9641542144..00000000000
--- a/srcpkgs/elfutils/patches/fix-aarch64_fregs.patch
+++ /dev/null
@@ -1,14 +0,0 @@
-It looks like fregs.vregs[] is an array of double?
-Casting to Dwarf_Word instead of & 0xFFFFFFF should do.
-
---- backends/aarch64_initreg.c	2015-11-27 14:36:29.000000000 +0100
-+++ backends/aarch64_initreg.c	2016-08-09 03:47:25.428560159 +0200
-@@ -82,7 +83,7 @@
- 
-   Dwarf_Word dwarf_fregs[32];
-   for (int r = 0; r < 32; r++)
--    dwarf_fregs[r] = fregs.vregs[r] & 0xFFFFFFFF;
-+    dwarf_fregs[r] = (Dwarf_Word)fregs.vregs[r];
- 
-   if (! setfunc (64, 32, dwarf_fregs, arg))
-     return false;
diff --git a/srcpkgs/elfutils/patches/fix-uninitialized.patch b/srcpkgs/elfutils/patches/fix-uninitialized.patch
deleted file mode 100644
index 6ab15e50e2b..00000000000
--- a/srcpkgs/elfutils/patches/fix-uninitialized.patch
+++ /dev/null
@@ -1,11 +0,0 @@
-
---- libcpu/i386_disasm.c	2015-08-21 14:22:37.000000000 +0200
-+++ libcpu/i386_disasm.c	2015-11-20 06:30:59.250629957 +0100
-@@ -710,6 +710,7 @@
- 
- 		case 'm':
- 		  /* Mnemonic.  */
-+		  str = mnebuf;
- 
- 		  if (unlikely (instrtab[cnt].mnemonic == MNE_INVALID))
- 		    {
diff --git a/srcpkgs/elfutils/patches/fts-obstack.patch b/srcpkgs/elfutils/patches/fts-obstack.patch
new file mode 100644
index 00000000000..44ef0aee70e
--- /dev/null
+++ b/srcpkgs/elfutils/patches/fts-obstack.patch
@@ -0,0 +1,107 @@
+diff --git ChangeLog ChangeLog
+index 128da6c6..565d021c 100644
+--- ChangeLog
++++ ChangeLog
+@@ -1,3 +1,7 @@
++2020-11-01  Érico N. Rolim  <erico.erc@gmail.com>
++
++	* configure.ac: Check for fts and obstack from outside libc.
++
+ 2020-10-28  Mark Wielaard  <mark@klomp.org>
+ 
+ 	* configure.ac: Set version to 0.182.
+diff --git configure.ac configure.ac
+index 515ac704..c1a6954d 100644
+--- configure.ac
++++ configure.ac
+@@ -542,6 +542,26 @@ else
+ fi
+ AC_SUBST([argp_LDADD])
+ 
++saved_LIBS="$LIBS"
++AC_SEARCH_LIBS([fts_close], [fts])
++LIBS="$saved_LIBS"
++case "$ac_cv_search_fts_close" in
++        no) AC_MSG_FAILURE([failed to find fts_close]) ;;
++        -l*) fts_LIBS="$ac_cv_search_fts_close" ;;
++        *) fts_LIBS= ;;
++esac
++AC_SUBST([fts_LIBS])
++
++saved_LIBS="$LIBS"
++AC_SEARCH_LIBS([_obstack_free], [obstack])
++LIBS="$saved_LIBS"
++case "$ac_cv_search__obstack_free" in
++        no) AC_MSG_FAILURE([failed to find obstack_free]) ;;
++        -l*) obstack_LIBS="$ac_cv_search__obstack_free" ;;
++        *) obstack_LIBS= ;;
++esac
++AC_SUBST([obstack_LIBS])
++
+ dnl The directories with content.
+ 
+ dnl Documentation.
+diff --git debuginfod/Makefile.am debuginfod/Makefile.am
+index 01985600..0af3b58c 100644
+--- debuginfod/Makefile.am
++++ debuginfod/Makefile.am
+@@ -71,10 +71,10 @@ bin_PROGRAMS += debuginfod-find
+ endif
+ 
+ debuginfod_SOURCES = debuginfod.cxx
+-debuginfod_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod) $(libmicrohttpd_LIBS) $(sqlite3_LIBS) $(libarchive_LIBS) -lpthread -ldl
++debuginfod_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod) $(argp_LDADD) $(fts_LIBS) $(libmicrohttpd_LIBS) $(sqlite3_LIBS) $(libarchive_LIBS) -lpthread -ldl
+ 
+ debuginfod_find_SOURCES = debuginfod-find.c
+-debuginfod_find_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod)
++debuginfod_find_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod) $(argp_LDADD) $(fts_LIBS)
+ 
+ if LIBDEBUGINFOD
+ noinst_LIBRARIES = libdebuginfod.a
+@@ -98,7 +98,7 @@ libdebuginfod_so_LIBS = libdebuginfod_pic.a
+ if DUMMY_LIBDEBUGINFOD
+ libdebuginfod_so_LDLIBS =
+ else
+-libdebuginfod_so_LDLIBS = $(libcurl_LIBS)
++libdebuginfod_so_LDLIBS = $(libcurl_LIBS) $(fts_LIBS)
+ endif
+ libdebuginfod.so$(EXEEXT): $(srcdir)/libdebuginfod.map $(libdebuginfod_so_LIBS)
+ 	$(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $@ \
+diff --git libdw/Makefile.am libdw/Makefile.am
+index 33b5838d..1dbb3d5e 100644
+--- libdw/Makefile.am
++++ libdw/Makefile.am
+@@ -109,7 +109,7 @@ libdw_so_LIBS = ../libebl/libebl_pic.a ../backends/libebl_backends_pic.a \
+ 		../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_LIBS) $(obstack_LIBS) $(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 src/Makefile.am src/Makefile.am
+index e462e7d7..88d0ac8f 100644
+--- src/Makefile.am
++++ src/Makefile.am
+@@ -69,7 +69,7 @@ ar_no_Wstack_usage = yes
+ unstrip_no_Wstack_usage = yes
+ 
+ readelf_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD)
+-nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) \
++nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) $(obstack_LIBS) \
+ 	   $(demanglelib)
+ size_LDADD = $(libelf) $(libeu) $(argp_LDADD)
+ strip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
+@@ -78,9 +78,9 @@ findtextrel_LDADD = $(libdw) $(libelf) $(libeu) $(argp_LDADD)
+ addr2line_LDADD = $(libdw) $(libelf) $(libeu) $(argp_LDADD) $(demanglelib)
+ elfcmp_LDADD = $(libebl) $(libdw) $(libelf) $(libeu) $(argp_LDADD)
+ objdump_LDADD  = $(libasm) $(libebl) $(libdw) $(libelf) $(libeu) $(argp_LDADD)
+-ranlib_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD)
++ranlib_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD) $(obstack_LIBS)
+ strings_LDADD = $(libelf) $(libeu) $(argp_LDADD)
+-ar_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD)
++ar_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD) $(obstack_LIBS)
+ unstrip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
+ stack_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) $(demanglelib)
+ elfcompress_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
diff --git a/srcpkgs/elfutils/patches/musl-cdefs.patch b/srcpkgs/elfutils/patches/musl-cdefs.patch
deleted file mode 100644
index 65ef9f4d23c..00000000000
--- a/srcpkgs/elfutils/patches/musl-cdefs.patch
+++ /dev/null
@@ -1,30 +0,0 @@
---- libelf/elf.h	2015-08-21 14:22:37.000000000 +0200
-+++ libelf/elf.h	2015-11-20 04:54:33.948081321 +0100
-@@ -21,6 +21,17 @@
- 
- #include <features.h>
- 
-+#if !defined(__BEGIN_DECLS)
-+/* C++ needs to know that types and declarations are C, not C++.  */
-+#ifdef  __cplusplus
-+# define __BEGIN_DECLS  extern "C" {
-+# define __END_DECLS    }
-+#else
-+# define __BEGIN_DECLS
-+# define __END_DECLS
-+#endif
-+#endif
-+
- __BEGIN_DECLS
- 
- /* Standard ELF types.  */
---- lib/fixedsizehash.h.orig
-+++ lib/fixedsizehash.h
-@@ -30,7 +30,6 @@
- #include <errno.h>
- #include <stdlib.h>
- #include <string.h>
--#include <sys/cdefs.h>
- 
- #include <system.h>
- 
diff --git a/srcpkgs/elfutils/patches/musl-fts-obstack.patch b/srcpkgs/elfutils/patches/musl-fts-obstack.patch
deleted file mode 100644
index 77e3c4ea040..00000000000
--- a/srcpkgs/elfutils/patches/musl-fts-obstack.patch
+++ /dev/null
@@ -1,87 +0,0 @@
---- configure.ac	2015-10-15 15:16:57.000000000 +0200
-+++ 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.
---- src/Makefile.am.orig
-+++ 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
---- libdw/Makefile.am.orig
-+++ 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/srcpkgs/elfutils/patches/musl-macros.patch b/srcpkgs/elfutils/patches/musl-macros.patch
index 8ce586b2930..97a8c2bf352 100644
--- a/srcpkgs/elfutils/patches/musl-macros.patch
+++ b/srcpkgs/elfutils/patches/musl-macros.patch
@@ -1,66 +1,74 @@
---- src/arlib.h	2015-08-21 14:22:37.000000000 +0200
-+++ src/arlib.h	2015-11-20 08:02:55.153199611 +0100
-@@ -29,6 +29,16 @@
- #include <stdint.h>
- #include <sys/types.h>
+diff --git debuginfod/debuginfod-client.c debuginfod/debuginfod-client.c
+index 0e5177bc..ce1d819b 100644
+--- debuginfod/debuginfod-client.c
++++ debuginfod/debuginfod-client.c
+@@ -212,13 +212,13 @@ debuginfod_init_cache (char *cache_path, char *interval_path, char *maxage_path)
+     return 0;
  
-+#if !defined(ACCESSPERMS)
-+# define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
-+#endif
-+#if !defined(ALLPERMS)
-+# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
-+#endif
-+#if !defined(DEFFILEMODE)
-+# define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)/* 0666*/
-+#endif
-+
+   /* Create the cache and config files as necessary.  */
+-  if (stat(cache_path, &st) != 0 && mkdir(cache_path, 0777) < 0)
++  if (stat(cache_path, &st) != 0 && mkdir(cache_path, ACCESSPERMS) < 0)
+     return -errno;
  
- /* State of -D/-U flags.  */
- extern bool arlib_deterministic_output;
---- src/elfcompress.c.orig	2016-04-02 12:51:26.903848894 +0200
-+++ src/elfcompress.c	2016-04-02 12:55:15.076996338 +0200
-@@ -35,6 +35,14 @@
- #include <gelf.h>
- #include "system.h"
+   int fd = -1;
  
-+#if !defined(FNM_EXTMATCH)
-+# define FNM_EXTMATCH 0
-+#endif
-+
-+#if !defined(ALLPERMS)
-+# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
+   /* init cleaning interval config file.  */
+-  fd = open(interval_path, O_CREAT | O_RDWR, 0666);
++  fd = open(interval_path, O_CREAT | O_RDWR, DEFFILEMODE);
+   if (fd < 0)
+     return -errno;
+ 
+@@ -227,7 +227,7 @@ debuginfod_init_cache (char *cache_path, char *interval_path, char *maxage_path)
+ 
+   /* init max age config file.  */
+   if (stat(maxage_path, &st) != 0
+-      && (fd = open(maxage_path, O_CREAT | O_RDWR, 0666)) < 0)
++      && (fd = open(maxage_path, O_CREAT | O_RDWR, DEFFILEMODE)) < 0)
+     return -errno;
+ 
+   if (dprintf(fd, "%ld", cache_default_max_unused_age_s) < 0)
+diff --git lib/system.h lib/system.h
+index 292082bd..5d16ebc6 100644
+--- lib/system.h
++++ lib/system.h
+@@ -85,6 +85,18 @@
+      __res; })
+ #endif
+ 
++#ifndef ACCESSPERMS
++#define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
 +#endif
 +
- /* Name and version of program.  */
- static void print_version (FILE *stream, struct argp_state *state);
- ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;
---- src/strip.c.orig	2017-08-02 12:06:25.000000000 +0000
-+++ src/strip.c	2017-08-05 01:58:01.523493062 +0000
-@@ -47,6 +47,14 @@
- #include <system.h>
- #include <printversion.h>
- 
-+#if !defined(FNM_EXTMATCH)
-+# define FNM_EXTMATCH 0
++#ifndef ALLPERMS
++#define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
 +#endif
 +
-+#if !defined(ACCESSPERMS)
-+#define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO)
++#ifndef DEFFILEMODE
++#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)/* DEFFILEMODE*/
 +#endif
 +
- typedef uint8_t GElf_Byte;
+ static inline ssize_t __attribute__ ((unused))
+ pwrite_retry (int fd, const void *buf, size_t len, off_t off)
+ {
+diff --git src/unstrip.c src/unstrip.c
+index 0257d9cc..c99ee612 100644
+--- src/unstrip.c
++++ src/unstrip.c
+@@ -315,7 +315,7 @@ make_directories (const char *path)
+   if (dir == NULL)
+     error(EXIT_FAILURE, errno, _("memory exhausted"));
  
- /* Name and version of program.  */
---- tests/elfstrmerge.c.orig	2020-09-13 08:20:50.538492600 +0700
-+++ tests/elfstrmerge.c	2020-09-13 08:21:40.205734827 +0700
-@@ -33,6 +33,10 @@
- #include ELFUTILS_HEADER(dwelf)
- #include "elf-knowledge.h"
+-  while (mkdir (dir, 0777) < 0 && errno != EEXIST)
++  while (mkdir (dir, ACCESSPERMS) < 0 && errno != EEXIST)
+     {
+       if (errno == ENOENT)
+         make_directories (dir);
+@@ -2192,7 +2192,7 @@ DWARF data in '%s' not adjusted for prelinking bias; consider prelink -u"),
  
-+#if !defined(ALLPERMS)
-+# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
-+#endif
-+
- /* The original ELF file.  */
- static int fd = -1;
- static Elf *elf = NULL;
+       /* Copy the unstripped file and then modify it.  */
+       int outfd = open (output_file, O_RDWR | O_CREAT,
+-			  stripped_ehdr->e_type == ET_REL ? 0666 : 0777);
++			  stripped_ehdr->e_type == ET_REL ? DEFFILEMODE : ACCESSPERMS);
+       if (outfd < 0)
+ 	error (EXIT_FAILURE, errno, _("cannot open '%s'"), output_file);
+       Elf *outelf = elf_begin (outfd, ELF_C_WRITE, NULL);
diff --git a/srcpkgs/elfutils/patches/musl-strndupa.patch b/srcpkgs/elfutils/patches/musl-strndupa.patch
deleted file mode 100644
index f365fb019f2..00000000000
--- a/srcpkgs/elfutils/patches/musl-strndupa.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- src/unstrip.c.orig	2017-04-27 14:26:26.000000000 +0000
-+++ 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/srcpkgs/elfutils/template b/srcpkgs/elfutils/template
index 02e6e20c64b..99159a2be41 100644
--- a/srcpkgs/elfutils/template
+++ b/srcpkgs/elfutils/template
@@ -1,22 +1,26 @@
 # Template file for 'elfutils'
 pkgname=elfutils
-version=0.181
+version=0.182
 revision=1
 build_style=gnu-configure
-configure_args="--program-prefix=eu- --disable-debuginfod --disable-libdebuginfod"
+configure_args="--program-prefix=eu-"
 hostmakedepends="automake libtool pkg-config"
-makedepends="bzip2-devel liblzma-devel zlib-devel"
+makedepends="bzip2-devel liblzma-devel zlib-devel
+ libcurl-devel libarchive-devel sqlite-devel libmicrohttpd-devel"
 short_desc="Utilities to handle ELF object files"
-maintainer="Orphaned <orphan@voidlinux.org>"
+maintainer="Érico Nogueira <ericonr@disroot.org>"
 license="GPL-3.0-or-later"
 homepage="https://sourceware.org/elfutils/"
 distfiles="https://sourceware.org/${pkgname}/ftp/${version}/${pkgname}-${version}.tar.bz2"
-checksum=29a6ad7421ec2acfee489bb4a699908281ead2cb63a20a027ce8804a165f0eb3
+checksum=ecc406914edf335f0b7fc084ebe6c460c4d6d5175bfdd6688c1c78d9146b8858
 
 CFLAGS="-Wno-error"
+CXXFLAGS="-Wl,-z,stack-size=2097152"
 
 if [ "$XBPS_TARGET_LIBC" = musl ]; then
-	makedepends+=" argp-standalone musl-fts-devel musl-obstack-devel"
+	makedepends+=" argp-standalone musl-fts-devel musl-obstack-devel musl-legacy-compat"
+	# XXX: breaks some expected functionality
+	CFLAGS+=" -DFNM_EXTMATCH=0"
 fi
 
 post_extract() {
@@ -30,6 +34,23 @@ pre_configure() {
 	autoreconf -if
 }
 
+libdebuginfod_package() {
+	short_desc+=" - debuginfod library"
+	pkg_install() {
+		vmove "usr/lib/libdebuginfod-*.so*"
+		vmove etc/profile.d
+	}
+}
+
+debuginfod_package() {
+	short_desc+=" - debuginfod programs"
+	pkg_install() {
+		vmove "usr/bin/debuginfod*"
+		vmove "usr/share/man/man1/debuginfod-find.1"
+		vmove "usr/share/man/man8/debuginfod.8"
+	}
+}
+
 libelf_package() {
 	short_desc+=" - runtime library"
 	pkg_install() {
@@ -38,11 +59,13 @@ libelf_package() {
 }
 
 elfutils-devel_package() {
-	depends="libelf>=${version}_${revision} ${makedepends}"
+	depends="libelf>=${version}_${revision} libdebuginfod>=${version}_${revision}
+	 ${makedepends}"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig
 		vmove "usr/lib/*.a"
+		vmove usr/share/man/man3
 	}
 }
diff --git a/srcpkgs/libdebuginfod b/srcpkgs/libdebuginfod
new file mode 120000
index 00000000000..b76b36cfac4
--- /dev/null
+++ b/srcpkgs/libdebuginfod
@@ -0,0 +1 @@
+elfutils
\ No newline at end of file

From 8da28eb7f80faf5afb6255fee324f8754bb56c12 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
Date: Sun, 25 Oct 2020 18:23:45 -0300
Subject: [PATCH 2/2] gdb: add debuginfod option, enable by default.

---
 srcpkgs/gdb/template | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/srcpkgs/gdb/template b/srcpkgs/gdb/template
index 0e2e399e798..e2a39e7d103 100644
--- a/srcpkgs/gdb/template
+++ b/srcpkgs/gdb/template
@@ -1,16 +1,18 @@
 # Template file for 'gdb'
 pkgname=gdb
 version=10.1
-revision=1
+revision=2
 build_style=gnu-configure
 pycompile_dirs="/usr/share/gdb/python"
 configure_args="--disable-werror --disable-nls --with-system-readline
  --with-system-gdbinit=/etc/gdb/gdbinit --with-system-zlib $(vopt_enable gdbserver)
  $(vopt_if static 'CFLAGS=-static CXXFLAGS=-static LDFLAGS=-static')
- $(vopt_if python --with-python=/usr/bin/python3)"
-hostmakedepends="texinfo perl $(vopt_if python python3-devel)"
+ $(vopt_if python --with-python=/usr/bin/python3)
+ $(vopt_with debuginfod)"
+hostmakedepends="texinfo perl pkg-config $(vopt_if python python3-devel)"
 makedepends="ncurses-devel zlib-devel readline-devel expat-devel
- $(vopt_if python 'python3-devel gettext-libs')"
+ $(vopt_if python 'python3-devel gettext-libs')
+ $(vopt_if debuginfod elfutils-devel)"
 short_desc="GNU Debugger"
 maintainer="Anthony Iliopoulos <ailiop@altatus.com>"
 license="GPL-3.0-or-later"
@@ -28,10 +30,11 @@ fi
 CFLAGS+=" -fcommon"
 CXXFLAGS+=" -fcommon"
 # Package build options
-build_options="gdbserver static python"
+build_options="gdbserver static python debuginfod"
 desc_option_gdbserver="Enable support for building GDB server"
+desc_option_debuginfod="Enable support for libdebuginfod"
 # Enable gdbserver if !static.
-build_options_default="gdbserver python"
+build_options_default="gdbserver python debuginfod"
 # Both options cannot be enabled at the same time
 vopt_conflict gdbserver static
 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PR PATCH] [Merged]: Update elfutils to 0.182.
  2020-11-02  1:56 [PR PATCH] Update elfutils to 0.182 ericonr
                   ` (7 preceding siblings ...)
  2020-11-18  2:32 ` ericonr
@ 2020-11-18  3:00 ` ericonr
  8 siblings, 0 replies; 10+ messages in thread
From: ericonr @ 2020-11-18  3:00 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 303 bytes --]

There's a merged pull request on the void-packages repository

Update elfutils to 0.182.
https://github.com/void-linux/void-packages/pull/26067

Description:
Also create the debuginfod subpackage and use it in gdb.

This PR can wait on some musl patches that I'd like to backport for the fregs patch.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-11-18  3:00 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-02  1:56 [PR PATCH] Update elfutils to 0.182 ericonr
2020-11-02  1:58 ` [PR PATCH] [Updated] " ericonr
2020-11-02  2:01 ` ericonr
2020-11-02  2:02 ` ericonr
2020-11-02  2:03 ` ericonr
2020-11-02 18:21 ` ericonr
2020-11-06 14:39 ` ericonr
2020-11-17 13:56 ` ericonr
2020-11-18  2:32 ` ericonr
2020-11-18  3:00 ` [PR PATCH] [Merged]: " ericonr

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).