[openwrt/openwrt] tools/elfutils: remove dirname

LEDE Commits lede-commits at lists.infradead.org
Tue Apr 30 04:38:03 PDT 2024


robimarko pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/00ff73ec6e815d9e82ef9164d23d445a2346579e

commit 00ff73ec6e815d9e82ef9164d23d445a2346579e
Author: Robert Marko <robimarko at gmail.com>
AuthorDate: Tue Apr 30 11:08:46 2024 +0200

    tools/elfutils: remove dirname
    
    In the 0.191 update dirname was used instead of <libgen.h> to fix the
    poisoned basename error:
    /usr/include/libgen.h:35:9: error: attempt to use poisoned "basename"
           35 | #define basename        __xpg_basename
    
    However, doing this has lead to libelf.a pulling in xmalloc, xstrdup and
    friends and statically linking them thus leading to a symbol name conflict
    with FRR host build and anything else that links against libelf and uses
    xmalloc and friends.
    
    Well, it turns out that upstream has added a helper[1] for basename so it
    can compile with musl 1.2.5 which dropped the basename declaration, but it
    also means that we must NOT include <libgen.h> and that poisoned error is
    intentional and added to prevent duplicate basename definitions.
    This also means that for macOS we dont need to do any additional header
    inclusions as the new helper takes care of basename.
    
    So, to fix the symbol conflict we can simply drop the <dirname.h> inclusion
    and build from elfutils.
    
    Tested on Fedora 40 as well as macOS 14.4.1.
    
    [1] https://sourceware.org/git/?p=elfutils.git;a=commit;h=a2194f6b305bf0d0b9dd49dccd0a5c21994c8eea
    
    Fixes: #24030
    Fixes: b6f025b42429 ("tools/elfutils: update to 1.91")
    
    Link: https://github.com/openwrt/openwrt/pull/15337
    Signed-off-by: Robert Marko <robimarko at gmail.com>
---
 tools/elfutils/Makefile                      |  3 +--
 tools/elfutils/patches/100-portability.patch | 10 +++++-----
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/tools/elfutils/Makefile b/tools/elfutils/Makefile
index 140250801c..466fc31271 100644
--- a/tools/elfutils/Makefile
+++ b/tools/elfutils/Makefile
@@ -4,7 +4,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=elfutils
 PKG_VERSION:=0.191
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
 PKG_SOURCE_URL:=https://sourceware.org/$(PKG_NAME)/ftp/$(PKG_VERSION)
@@ -41,7 +41,6 @@ PKG_GNULIB_ARGS = \
 
 PKG_GNULIB_MODS = \
 	argp \
-	dirname \
 	fts \
 	obstack \
 	progname \
diff --git a/tools/elfutils/patches/100-portability.patch b/tools/elfutils/patches/100-portability.patch
index 1a61455f48..6f7564731b 100644
--- a/tools/elfutils/patches/100-portability.patch
+++ b/tools/elfutils/patches/100-portability.patch
@@ -346,12 +346,11 @@
 +}
 --- a/libdwfl/libdwflP.h
 +++ b/libdwfl/libdwflP.h
-@@ -31,6 +31,8 @@
+@@ -31,6 +31,7 @@
  
  #include <libdwfl.h>
  #include <libebl.h>
 +#include <libeu.h>
-+#include <dirname.h>
  #include <assert.h>
  #include <dirent.h>
  #include <errno.h>
@@ -366,17 +365,18 @@
 +#endif
 --- a/libdw/libdwP.h
 +++ b/libdw/libdwP.h
-@@ -32,8 +32,10 @@
+@@ -32,10 +32,10 @@
  #include <stdbool.h>
  #include <pthread.h>
  
 +#include <libeu.h>
  #include <libdw.h>
  #include <dwarf.h>
-+#include <dirname.h>
- 
  
+-
  /* Known location expressions already decoded.  */
+ struct loc_s
+ {
 --- a/libdw/Makefile.am
 +++ b/libdw/Makefile.am
 @@ -34,14 +34,12 @@ endif




More information about the lede-commits mailing list