This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Drop handrolled or #ifdef'ed libc replacements


mempcpy, memrchr, rawmemchr, and argp are provided by gnulib now. We
don't need to define them locally and we don't need to search for an
external libargp.

Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
---
 ChangeLog                      |  4 ++++
 configure.ac                   | 31 -------------------------------
 lib/ChangeLog                  |  5 +++++
 lib/system.h                   |  5 -----
 lib/xstrndup.c                 |  2 +-
 libasm/ChangeLog               |  4 ++++
 libasm/disasm_str.c            |  2 +-
 libdw/ChangeLog                |  4 ++++
 libdw/Makefile.am              |  2 +-
 libdwfl/ChangeLog              |  4 ++++
 libdwfl/linux-kernel-modules.c |  1 -
 libebl/ChangeLog               |  5 +++++
 libebl/eblmachineflagname.c    |  1 -
 libebl/eblopenbackend.c        |  1 -
 libelf/ChangeLog               |  5 +++++
 libelf/elf_getarsym.c          |  8 --------
 libelf/elf_strptr.c            | 11 -----------
 src/ChangeLog                  |  4 ++++
 src/Makefile.am                | 30 +++++++++++++++---------------
 tests/ChangeLog                |  5 +++++
 tests/Makefile.am              | 32 ++++++++++++++++----------------
 tests/elfstrmerge.c            |  1 -
 22 files changed, 74 insertions(+), 93 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a2a0f63..6fe525c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2017-04-27  Ulf Hermann  <ulf.hermann@qt.io>
+
+	* configure.ac: Drop checks for memrchr, rawmemchr, mempcpy, argp.
+
 2017-04-21  Ulf Hermann  <ulf.hermann@qt.io>
 
 	* .gitignore: Add generated gnulib headers.
diff --git a/configure.ac b/configure.ac
index a5aea7f..a48b13e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -290,13 +290,7 @@ zip_LIBS="$LIBS"
 LIBS="$save_LIBS"
 AC_SUBST([zip_LIBS])
 
-AC_CHECK_DECLS([memrchr, rawmemchr],[],[],
-               [#define _GNU_SOURCE
-                #include <string.h>])
 AC_CHECK_DECLS([powerof2],[],[],[#include <sys/param.h>])
-AC_CHECK_DECLS([mempcpy],[],[],
-               [#define _GNU_SOURCE
-                #include <string.h>])
 
 AC_CHECK_LIB([stdc++], [__cxa_demangle], [dnl
 AC_DEFINE([USE_DEMANGLE], [1], [Defined if demangling is enabled])])
@@ -369,31 +363,6 @@ CFLAGS="$old_CFLAGS"])
 AM_CONDITIONAL(HAVE_IMPLICIT_FALLTHROUGH_WARNING,
 	       [test "x$ac_cv_implicit_fallthrough" != "xno"])
 
-dnl Check if we have argp available from our libc
-AC_LINK_IFELSE(
-	[AC_LANG_PROGRAM(
-		[#include <argp.h>],
-		[int argc=1; char *argv[]={"test"}; argp_parse(0,argc,&argv,0,0,0); return 0;]
-		)],
-	[libc_has_argp="true"],
-	[libc_has_argp="false"]
-)
-
-dnl If our libc doesn't provide argp, then test for libargp
-if test "$libc_has_argp" = "false" ; then
-	AC_MSG_WARN("libc does not have argp")
-	AC_CHECK_LIB([argp], [argp_parse], [have_argp="true"], [have_argp="false"])
-
-	if test "$have_argp" = "false"; then
-		AC_MSG_ERROR("no libargp found")
-	else
-		argp_LDADD="-largp"
-	fi
-else
-	argp_LDADD=""
-fi
-AC_SUBST([argp_LDADD])
-
 dnl Check if we have <linux/bpf.h> for EM_BPF disassembly.
 AC_CHECK_HEADERS(linux/bpf.h)
 AM_CONDITIONAL(HAVE_LINUX_BPF_H, [test "x$ac_cv_header_linux_bpf_h" = "xyes"])
diff --git a/lib/ChangeLog b/lib/ChangeLog
index 8cac7af..82c009e 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,3 +1,8 @@
+2017-04-27  Ulf Hermann  <ulf.hermann@qt.io>
+
+	* system.h: Drop mempcpy replacement.
+	* xstrndup.c: Don't include system.h.
+
 2017-04-20  Ulf Hermann  <ulf.hermann@qt.io>
 
 	* crc32.c: include config.h.
diff --git a/lib/system.h b/lib/system.h
index 9203335..ffa2bc7 100644
--- a/lib/system.h
+++ b/lib/system.h
@@ -63,11 +63,6 @@
 #define powerof2(x) (((x) & ((x) - 1)) == 0)
 #endif
 
-#if !HAVE_DECL_MEMPCPY
-#define mempcpy(dest, src, n) \
-    ((void *) ((char *) memcpy (dest, src, n) + (size_t) n))
-#endif
-
 /* A special gettext function we use if the strings are too short.  */
 #define sgettext(Str) \
   ({ const char *__res = strrchr (gettext (Str), '|');			      \
diff --git a/lib/xstrndup.c b/lib/xstrndup.c
index a257aa9..d43e3b9 100644
--- a/lib/xstrndup.c
+++ b/lib/xstrndup.c
@@ -33,7 +33,7 @@
 #include <stdint.h>
 #include <string.h>
 #include "libeu.h"
-#include "system.h"
+
 
 /* Return a newly allocated copy of STRING.  */
 char *
diff --git a/libasm/ChangeLog b/libasm/ChangeLog
index ef183a6..80aa7de 100644
--- a/libasm/ChangeLog
+++ b/libasm/ChangeLog
@@ -1,3 +1,7 @@
+2017-02-27  Ulf Hermann  <ulf.hermann@qt.io>
+
+	* disasm_str.c: Don't include system.h
+
 2017-02-21  Ulf Hermann  <ulf.hermann@qt.io>
 
 	* Makefile.am: Link libasm agaist libgnu.a if requested.
diff --git a/libasm/disasm_str.c b/libasm/disasm_str.c
index c14e6d5..5b0bb29 100644
--- a/libasm/disasm_str.c
+++ b/libasm/disasm_str.c
@@ -31,7 +31,7 @@
 #endif
 
 #include <string.h>
-#include <system.h>
+
 #include "libasmP.h"
 
 
diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 8052b5b..6e11181 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,3 +1,7 @@
+2017-02-27  Ulf Hermann  <ulf.hermann@qt.io>
+
+	* Makefile.am: Remove argp_LDADD.
+
 2017-02-21  Ulf Hermann  <ulf.hermann@qt.io>
 
 	* Makefile.am: Link libdw agaist libgnu.a if requested.
diff --git a/libdw/Makefile.am b/libdw/Makefile.am
index 2c3efca..8843062 100644
--- a/libdw/Makefile.am
+++ b/libdw/Makefile.am
@@ -118,7 +118,7 @@ libdw.so$(EXEEXT): $(srcdir)/libdw.map libdw_pic.a ../libdwelf/libdwelf_pic.a \
 		-Wl,--enable-new-dtags,-rpath,$(pkglibdir) \
 		-Wl,--version-script,$<,--no-undefined \
 		-Wl,--whole-archive $(filter-out $<,$^) -Wl,--no-whole-archive\
-		-ldl -lz $(argp_LDADD) $(zip_LIBS) $(libgnu)
+		-ldl -lz $(zip_LIBS) $(libgnu)
 	@$(textrel_check)
 	$(AM_V_at)ln -fs $@ $@.$(VERSION)
 
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index a1ed675..a7e6e30 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,7 @@
+2017-04-27  Ulf Hermann  <ulf.hermann@qt.io>
+
+	* linux-kernel-modules.c: Don't include system.h.
+
 2017-04-20  Ulf Hermann  <ulf.hermann@qt.io>
 
 	* derelocate.c (compare_secrefs): Compare by end address and then by
diff --git a/libdwfl/linux-kernel-modules.c b/libdwfl/linux-kernel-modules.c
index 6c6c603..5f132b4 100644
--- a/libdwfl/linux-kernel-modules.c
+++ b/libdwfl/linux-kernel-modules.c
@@ -37,7 +37,6 @@
 #endif
 
 #include <config.h>
-#include <system.h>
 
 #include "libdwflP.h"
 #include <inttypes.h>
diff --git a/libebl/ChangeLog b/libebl/ChangeLog
index 506915b..0605083 100644
--- a/libebl/ChangeLog
+++ b/libebl/ChangeLog
@@ -1,3 +1,8 @@
+2017-04-27  Ulf Hermann  <ulf.hermann@qt.io>
+
+	* eblmachineflagname.c: Don't include system.h.
+	* eblopenbackend.c: Likewise.
+
 2017-04-20  Ulf Hermann  <ulf.hermann@qt.io>
 
 	* libebl.h: Use __pure_attribute__.
diff --git a/libebl/eblmachineflagname.c b/libebl/eblmachineflagname.c
index 5f44077..6079a61 100644
--- a/libebl/eblmachineflagname.c
+++ b/libebl/eblmachineflagname.c
@@ -33,7 +33,6 @@
 
 #include <stdio.h>
 #include <string.h>
-#include <system.h>
 #include <libeblP.h>
 
 
diff --git a/libebl/eblopenbackend.c b/libebl/eblopenbackend.c
index f3a65cf..aa75b95 100644
--- a/libebl/eblopenbackend.c
+++ b/libebl/eblopenbackend.c
@@ -39,7 +39,6 @@
 #include <string.h>
 #include <stdio.h>
 
-#include <system.h>
 #include <libeblP.h>
 
 
diff --git a/libelf/ChangeLog b/libelf/ChangeLog
index d9ac7c6..9165634 100644
--- a/libelf/ChangeLog
+++ b/libelf/ChangeLog
@@ -1,3 +1,8 @@
+2017-04-27  Ulf Hermann  <ulf.hermann@qt.io>
+
+	* elf_getarsym.c: Don't replace rawmemchr.
+	* elf_strptr.c: Don't replace memrchr.
+
 2017-04-21  Ulf Hermann  <ulf.hermann@qt.io>
 
 	* Makefile.am: Link libelf agaist libgnu.a if requested.
diff --git a/libelf/elf_getarsym.c b/libelf/elf_getarsym.c
index d5f0ba4..65c67cc 100644
--- a/libelf/elf_getarsym.c
+++ b/libelf/elf_getarsym.c
@@ -297,15 +297,7 @@ elf_getarsym (Elf *elf, size_t *ptr)
 		arsym[cnt].as_off = (*u32)[cnt];
 
 	      arsym[cnt].as_hash = _dl_elf_hash (str_data);
-#if HAVE_DECL_RAWMEMCHR
 	      str_data = rawmemchr (str_data, '\0') + 1;
-#else
-	      char c;
-	      do {
-		c = *str_data;
-		str_data++;
-	      } while (c);
-#endif
 	    }
 
 	  /* At the end a special entry.  */
diff --git a/libelf/elf_strptr.c b/libelf/elf_strptr.c
index e72a3a3..cb4ed42 100644
--- a/libelf/elf_strptr.c
+++ b/libelf/elf_strptr.c
@@ -55,18 +55,7 @@ get_zdata (Elf_Scn *strscn)
 
 static bool validate_str (const char *str, size_t from, size_t to)
 {
-#if HAVE_DECL_MEMRCHR
   return memrchr (&str[from], '\0', to - from) != NULL;
-#else
-  do {
-    if (to <= from)
-      return false;
-
-    to--;
-  } while (str[to]);
-
-  return true;
-#endif
 }
 
 char *
diff --git a/src/ChangeLog b/src/ChangeLog
index 59a8059..c5805c9 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2017-04-27  Ulf Hermann  <ulf.hermann@qt.io>
+
+	* Makefile.am: Drop argp_LDADD.
+
 2017-04-21  Ulf Hermann  <ulf.hermann@qt.io>
 
 	* Makefile.am: Link tools agaist libgnu.a if requested.
diff --git a/src/Makefile.am b/src/Makefile.am
index d53dd5b..aca4b1c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -72,22 +72,22 @@ ranlib_no_Wstack_usage = yes
 ar_no_Wstack_usage = yes
 unstrip_no_Wstack_usage = yes
 
-readelf_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(libgnu) $(argp_LDADD) -ldl
-nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(libgnu) $(argp_LDADD) -ldl \
+readelf_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(libgnu) -ldl
+nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(libgnu) -ldl \
 	   $(demanglelib)
-size_LDADD = $(libelf) $(libeu) $(libgnu) $(argp_LDADD)
-strip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(libgnu) $(argp_LDADD) -ldl
-elflint_LDADD  = $(libebl) $(libelf) $(libeu) $(libgnu) $(argp_LDADD) -ldl
-findtextrel_LDADD = $(libdw) $(libelf) $(libeu) $(libgnu) $(argp_LDADD)
-addr2line_LDADD = $(libdw) $(libelf) $(libeu) $(libgnu) $(argp_LDADD) $(demanglelib)
-elfcmp_LDADD = $(libebl) $(libelf) $(libeu) $(libgnu) $(argp_LDADD) -ldl
-objdump_LDADD  = $(libasm) $(libebl) $(libelf) $(libeu) $(libgnu) $(argp_LDADD) -ldl
-ranlib_LDADD = libar.a $(libelf) $(libeu) $(libgnu) $(argp_LDADD)
-strings_LDADD = $(libelf) $(libeu) $(libgnu) $(argp_LDADD)
-ar_LDADD = libar.a $(libelf) $(libeu) $(libgnu) $(argp_LDADD)
-unstrip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(libgnu) $(argp_LDADD) -ldl
-stack_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(libgnu) $(argp_LDADD) -ldl $(demanglelib)
-elfcompress_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(libgnu) $(argp_LDADD)
+size_LDADD = $(libelf) $(libeu) $(libgnu)
+strip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(libgnu) -ldl
+elflint_LDADD  = $(libebl) $(libelf) $(libeu) $(libgnu) -ldl
+findtextrel_LDADD = $(libdw) $(libelf) $(libeu) $(libgnu)
+addr2line_LDADD = $(libdw) $(libelf) $(libeu) $(libgnu) $(demanglelib)
+elfcmp_LDADD = $(libebl) $(libelf) $(libeu) $(libgnu) -ldl
+objdump_LDADD  = $(libasm) $(libebl) $(libelf) $(libeu) $(libgnu) -ldl
+ranlib_LDADD = libar.a $(libelf) $(libeu) $(libgnu)
+strings_LDADD = $(libelf) $(libeu) $(libgnu)
+ar_LDADD = libar.a $(libelf) $(libeu) $(libgnu)
+unstrip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(libgnu) -ldl
+stack_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(libgnu) -ldl $(demanglelib)
+elfcompress_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(libgnu)
 
 installcheck-binPROGRAMS: $(bin_PROGRAMS)
 	bad=0; pid=$$$$; list="$(bin_PROGRAMS)"; for p in $$list; do \
diff --git a/tests/ChangeLog b/tests/ChangeLog
index fddf352..d2a14c2 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,8 @@
+2017-04-27  Ulf Hermann <ulf.hermann@qt.io>
+
+	* Makefile.am: Drop argp_LDADD.
+	* elfstrmerge.c: Don't include system.h.
+
 2017-04-21  Ulf Hermann <ulf.hermann@qt.io>
 
 	* Makefile.am: Link test programs agaist libgnu.a if requested.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 5376250..69d1fcd 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -426,12 +426,12 @@ get_lines_LDADD = $(libdw) $(libelf) $(libgnu)
 get_files_LDADD = $(libdw) $(libelf) $(libgnu)
 get_aranges_LDADD = $(libdw) $(libelf) $(libgnu)
 allfcts_LDADD = $(libdw) $(libelf) $(libgnu)
-line2addr_LDADD = $(libdw) $(libgnu) $(argp_LDADD)
-addrscopes_LDADD = $(libdw) $(libgnu) $(argp_LDADD)
-funcscopes_LDADD = $(libdw) $(libgnu) $(argp_LDADD)
-funcretval_LDADD = $(libdw) $(libgnu) $(argp_LDADD)
-allregs_LDADD = $(libdw) $(libgnu) $(argp_LDADD)
-find_prologues_LDADD = $(libdw) $(libgnu) $(argp_LDADD)
+line2addr_LDADD = $(libdw) $(libgnu)
+addrscopes_LDADD = $(libdw) $(libgnu)
+funcscopes_LDADD = $(libdw) $(libgnu)
+funcretval_LDADD = $(libdw) $(libgnu)
+allregs_LDADD = $(libdw) $(libgnu)
+find_prologues_LDADD = $(libdw) $(libgnu)
 #show_ciefde_LDADD = ../libdwarf/libdwarf.so $(libelf)
 asm_tst1_LDADD = $(libasm) $(libebl) $(libelf) $(libdw) $(libgnu) -ldl
 asm_tst2_LDADD = $(libasm) $(libebl) $(libelf) $(libdw) $(libgnu) -ldl
@@ -442,31 +442,31 @@ asm_tst6_LDADD = $(libasm) $(libebl) $(libelf) $(libdw) $(libgnu) -ldl
 asm_tst7_LDADD = $(libasm) $(libebl) $(libelf) $(libdw) $(libgnu) -ldl
 asm_tst8_LDADD = $(libasm) $(libebl) $(libelf) $(libdw) $(libgnu) -ldl
 asm_tst9_LDADD = $(libasm) $(libebl) $(libelf) $(libdw) $(libgnu) -ldl
-dwflmodtest_LDADD = $(libdw) $(libebl) $(libelf) $(libgnu) $(argp_LDADD) -ldl
+dwflmodtest_LDADD = $(libdw) $(libebl) $(libelf) $(libgnu) -ldl
 rdwrmmap_LDADD = $(libelf) $(libgnu)
 dwfl_bug_addr_overflow_LDADD = $(libdw) $(libebl) $(libelf) $(libgnu) -ldl
 arls_LDADD = $(libelf) $(libgnu)
 dwfl_bug_fd_leak_LDADD = $(libdw) $(libebl) $(libelf) $(libgnu) -ldl
 dwfl_bug_report_LDADD = $(libdw) $(libebl) $(libelf) $(libgnu) -ldl
 dwfl_bug_getmodules_LDADD = $(libdw) $(libebl) $(libelf) $(libgnu) -ldl
-dwfl_addr_sect_LDADD = $(libdw) $(libebl) $(libelf) $(libgnu) $(argp_LDADD) -ldl
+dwfl_addr_sect_LDADD = $(libdw) $(libebl) $(libelf) $(libgnu) -ldl
 dwarf_getmacros_LDADD = $(libdw) $(libgnu)
 dwarf_ranges_LDADD = $(libdw) $(libgnu)
 dwarf_getstring_LDADD = $(libdw) $(libgnu)
-addrcfi_LDADD = $(libdw) $(libebl) $(libelf) $(libgnu) $(argp_LDADD) -ldl
+addrcfi_LDADD = $(libdw) $(libebl) $(libelf) $(libgnu) -ldl
 test_flag_nobits_LDADD = $(libelf) $(libgnu)
 rerequest_tag_LDADD = $(libdw) $(libgnu)
 alldts_LDADD = $(libdw) $(libelf) $(libgnu)
 md5_sha1_test_LDADD = $(libeu) $(libgnu)
 typeiter_LDADD = $(libdw) $(libelf) $(libgnu)
 typeiter2_LDADD = $(libdw) $(libelf) $(libgnu)
-low_high_pc_LDADD = $(libdw) $(libelf) $(libgnu) $(argp_LDADD)
+low_high_pc_LDADD = $(libdw) $(libelf) $(libgnu)
 test_elf_cntl_gelf_getshdr_LDADD = $(libelf) $(libgnu)
-dwflsyms_LDADD = $(libdw) $(libelf) $(libgnu) $(argp_LDADD)
-dwfllines_LDADD = $(libdw) $(libelf) $(libgnu) $(argp_LDADD)
+dwflsyms_LDADD = $(libdw) $(libelf) $(libgnu)
+dwfllines_LDADD = $(libdw) $(libelf) $(libgnu)
 dwfl_report_elf_align_LDADD = $(libdw) $(libgnu)
-varlocs_LDADD = $(libdw) $(libelf) $(libgnu) $(argp_LDADD)
-backtrace_LDADD = $(libdw) $(libelf) $(libgnu) $(argp_LDADD)
+varlocs_LDADD = $(libdw) $(libelf) $(libgnu)
+backtrace_LDADD = $(libdw) $(libelf) $(libgnu)
 # backtrace-child-biarch also uses those *_CFLAGS and *_LDLAGS variables:
 backtrace_child_CFLAGS = -fPIE
 backtrace_child_LDFLAGS = -pie -pthread
@@ -481,8 +481,8 @@ deleted_LDADD = ./deleted-lib.so $(libgnu)
 deleted_lib_so_LDFLAGS = -shared -rdynamic
 deleted_lib_so_CFLAGS = -fPIC -fasynchronous-unwind-tables
 deleted_lib_so_LDADD = $(libgnu)
-aggregate_size_LDADD = $(libdw) $(libelf) $(libgnu) $(argp_LDADD)
-peel_type_LDADD = $(libdw) $(libelf) $(libgnu) $(argp_LDADD)
+aggregate_size_LDADD = $(libdw) $(libelf) $(libgnu)
+peel_type_LDADD = $(libdw) $(libelf) $(libgnu)
 vdsosyms_LDADD = $(libdw) $(libelf) $(libgnu)
 getsrc_die_LDADD = $(libdw) $(libelf) $(libgnu)
 strptr_LDADD = $(libelf) $(libgnu)
diff --git a/tests/elfstrmerge.c b/tests/elfstrmerge.c
index 8d5b53c..c2c3fb9 100644
--- a/tests/elfstrmerge.c
+++ b/tests/elfstrmerge.c
@@ -29,7 +29,6 @@
 #include <inttypes.h>
 #include <unistd.h>
 
-#include <system.h>
 #include <gelf.h>
 #include ELFUTILS_HEADER(dwelf)
 #include "elf-knowledge.h"
-- 
2.1.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]