From 1ab3c2befeedf5bd891cfbe17cfef79c06e5079a Mon Sep 17 00:00:00 2001 From: "Anthony G. Basile" Date: Mon, 4 May 2015 02:25:39 +0300 Subject: [PATCH] Link against standalone argp library argp is not part of POSIX standards and not provided by uClibc or some other standard C libraries. However, it is possible to link against a breakout argp library. One is provided at http://www.lysator.liu.se/~nisse/misc/ This patch tests if libc provides argp otherwise it adds the linker flag -largp where needed in the build system. Signed-off-by: Anthony G. Basile Signed-off-by: Max Filippov --- ChangeLog | 5 +++++ configure.ac | 25 +++++++++++++++++++++++++ libdw/ChangeLog | 5 +++++ libdw/Makefile.am | 2 +- src/ChangeLog | 7 +++++++ src/Makefile.am | 30 +++++++++++++++--------------- tests/ChangeLog | 8 ++++++++ tests/Makefile.am | 30 +++++++++++++++--------------- 8 files changed, 81 insertions(+), 31 deletions(-) diff --git a/ChangeLog b/ChangeLog index f727bf2..d3e46fc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-05-04 Anthony G. Basile + + * configure.ac (argp_LDADD): Check if libc has argp and set + argp_LDADD accordingly. + 2015-05-03 Max Filippov * configure.ac (DEMANGLE): Fix enable_demangler setting. diff --git a/configure.ac b/configure.ac index 7ba4d11..68b7f5b 100644 --- a/configure.ac +++ b/configure.ac @@ -253,6 +253,31 @@ AS_IF([test "x$enable_symbol_versioning" = "xno"], [AC_MSG_WARN([Disabling symbol versioning breaks ABI compatibility.]) enable_symbol_versioning=no],[enable_symbol_versioning=yes]) +dnl Check if we have argp available from our libc +AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [#include ], + [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 The directories with content. dnl Documentation. diff --git a/libdw/ChangeLog b/libdw/ChangeLog index 739e0f6..fd3e4ad 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,3 +1,8 @@ +2015-05-04 Anthony G. Basile + + * Makefile.am (libdw_so_SOURCES): Append $(argp_LDADD) to link + command. + 2015-04-22 Mark Wielaard * memory-access.h (__libdw_max_len_leb128): Take type_len as argument. diff --git a/libdw/Makefile.am b/libdw/Makefile.am index 272289c..2299b2f 100644 --- a/libdw/Makefile.am +++ b/libdw/Makefile.am @@ -112,7 +112,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 $(zip_LIBS) + -ldl $(argp_LDADD) $(zip_LIBS) @$(textrel_check) ln -fs $@ $@.$(VERSION) diff --git a/src/ChangeLog b/src/ChangeLog index a4ac4e4..0aa85ee 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2015-05-04 Anthony G. Basile + + * Makefile.am (readelf_LDADD, nm_LDADD, size_LDADD, strip_LDADD) + (ld_LDADD, elflint_LDADD, findtextrel_LDADD, addr2line_LDADD) + (elfcmp_LDADD, objdump_LDADD, ranlib_LDADD, strings_LDADD) + (ar_LDADD, unstrip_LDADD, stack_LDADD): Append $(argp_LDADD). + 2015-03-22 Mark Wielaard * readelf.c (print_debug_frame_section): Cast start to Dwarf_Off diff --git a/src/Makefile.am b/src/Makefile.am index 7a25374..ab5364f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -89,27 +89,27 @@ endif # XXX While the file is not finished, don't warn about this ldgeneric_no_Wunused = yes -readelf_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) -ldl -nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) -ldl \ +readelf_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) -ldl +nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) -ldl \ $(demanglelib) -size_LDADD = $(libelf) $(libeu) -strip_LDADD = $(libebl) $(libelf) $(libeu) -ldl -ld_LDADD = $(libebl) $(libelf) $(libeu) -ldl +size_LDADD = $(libelf) $(libeu) $(argp_LDADD) +strip_LDADD = $(libebl) $(libelf) $(libeu) $(argp_LDADD) -ldl +ld_LDADD = $(libebl) $(libelf) $(libeu) $(argp_LDADD) -ldl if NATIVE_LD # -ldl is always needed for libebl. ld_LDADD += libld_elf.a endif ld_LDFLAGS = -rdynamic -elflint_LDADD = $(libebl) $(libelf) $(libeu) -ldl -findtextrel_LDADD = $(libdw) $(libelf) -addr2line_LDADD = $(libdw) $(libelf) -elfcmp_LDADD = $(libebl) $(libelf) -ldl -objdump_LDADD = $(libasm) $(libebl) $(libelf) $(libeu) -ldl -ranlib_LDADD = libar.a $(libelf) $(libeu) -strings_LDADD = $(libelf) $(libeu) -ar_LDADD = libar.a $(libelf) $(libeu) -unstrip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) -ldl -stack_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) -ldl $(demanglelib) +elflint_LDADD = $(libebl) $(libelf) $(libeu) $(argp_LDADD) -ldl +findtextrel_LDADD = $(libdw) $(libelf) $(argp_LDADD) +addr2line_LDADD = $(libdw) $(libelf) $(argp_LDADD) +elfcmp_LDADD = $(libebl) $(libelf) $(argp_LDADD) -ldl +objdump_LDADD = $(libasm) $(libebl) $(libelf) $(libeu) $(argp_LDADD) -ldl +ranlib_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD) +strings_LDADD = $(libelf) $(libeu) $(argp_LDADD) +ar_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD) +unstrip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) -ldl +stack_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) -ldl $(demanglelib) ldlex.o: ldscript.c ldlex_no_Werror = yes diff --git a/tests/ChangeLog b/tests/ChangeLog index 0556b1f..11e96a7 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,11 @@ +2015-05-04 Anthony G. Basile + + * Makefile.am (line2addr_LDADD, addrscopes_LDADD, funcscopes_LDADD) + (funcretval_LDADD, allregs_LDADD, find_prologues_LDADD) + (dwflmodtest_LDADD, dwfl_addr_sect_LDADD, addrcfi_LDADD) + (low_high_pc_LDADD, dwflsyms_LDADD, dwfllines_LDADD, varlocs_LDADD) + (backtrace_LDADD, aggregate_size_LDADD): Append $(argp_LDADD). + 2015-05-01 Mark Wielaard * run-stack-d-test.sh: Use --raw and mangled output. diff --git a/tests/Makefile.am b/tests/Makefile.am index f94bd67..fdbf5bf 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -380,12 +380,12 @@ get_lines_LDADD = $(libdw) $(libelf) get_files_LDADD = $(libdw) $(libelf) get_aranges_LDADD = $(libdw) $(libelf) allfcts_LDADD = $(libdw) $(libelf) -line2addr_LDADD = $(libdw) -addrscopes_LDADD = $(libdw) -funcscopes_LDADD = $(libdw) -funcretval_LDADD = $(libdw) -allregs_LDADD = $(libdw) -find_prologues_LDADD = $(libdw) +line2addr_LDADD = $(libdw) $(argp_LDADD) +addrscopes_LDADD = $(libdw) $(argp_LDADD) +funcscopes_LDADD = $(libdw) $(argp_LDADD) +funcretval_LDADD = $(libdw) $(argp_LDADD) +allregs_LDADD = $(libdw) $(argp_LDADD) +find_prologues_LDADD = $(libdw) $(argp_LDADD) #show_ciefde_LDADD = ../libdwarf/libdwarf.so $(libelf) asm_tst1_LDADD = $(libasm) $(libebl) $(libelf) -ldl asm_tst2_LDADD = $(libasm) $(libebl) $(libelf) -ldl @@ -396,31 +396,31 @@ asm_tst6_LDADD = $(libasm) $(libebl) $(libelf) -ldl asm_tst7_LDADD = $(libasm) $(libebl) $(libelf) -ldl asm_tst8_LDADD = $(libasm) $(libebl) $(libelf) -ldl asm_tst9_LDADD = $(libasm) $(libebl) $(libelf) -ldl -dwflmodtest_LDADD = $(libdw) $(libebl) $(libelf) -ldl +dwflmodtest_LDADD = $(libdw) $(libebl) $(libelf) $(argp_LDADD) -ldl rdwrmmap_LDADD = $(libelf) dwfl_bug_addr_overflow_LDADD = $(libdw) $(libebl) $(libelf) -ldl arls_LDADD = $(libelf) dwfl_bug_fd_leak_LDADD = $(libdw) $(libebl) $(libelf) -ldl dwfl_bug_report_LDADD = $(libdw) $(libebl) $(libelf) -ldl dwfl_bug_getmodules_LDADD = $(libdw) $(libebl) $(libelf) -ldl -dwfl_addr_sect_LDADD = $(libdw) $(libebl) $(libelf) -ldl +dwfl_addr_sect_LDADD = $(libdw) $(libebl) $(libelf) $(argp_LDADD) -ldl dwarf_getmacros_LDADD = $(libdw) dwarf_ranges_LDADD = $(libdw) dwarf_getstring_LDADD = $(libdw) -addrcfi_LDADD = $(libdw) $(libebl) $(libelf) -ldl +addrcfi_LDADD = $(libdw) $(libebl) $(libelf) $(argp_LDADD) -ldl test_flag_nobits_LDADD = $(libelf) rerequest_tag_LDADD = $(libdw) alldts_LDADD = $(libebl) $(libelf) md5_sha1_test_LDADD = $(libeu) typeiter_LDADD = $(libdw) $(libelf) typeiter2_LDADD = $(libdw) $(libelf) -low_high_pc_LDADD = $(libdw) $(libelf) +low_high_pc_LDADD = $(libdw) $(libelf) $(argp_LDADD) test_elf_cntl_gelf_getshdr_LDADD = $(libelf) -dwflsyms_LDADD = $(libdw) $(libelf) -dwfllines_LDADD = $(libdw) $(libelf) +dwflsyms_LDADD = $(libdw) $(libelf) $(argp_LDADD) +dwfllines_LDADD = $(libdw) $(libelf) $(argp_LDADD) dwfl_report_elf_align_LDADD = $(libdw) -varlocs_LDADD = $(libdw) $(libelf) -backtrace_LDADD = $(libdw) $(libelf) +varlocs_LDADD = $(libdw) $(libelf) $(argp_LDADD) +backtrace_LDADD = $(libdw) $(libelf) $(argp_LDADD) # backtrace-child-biarch also uses those *_CFLAGS and *_LDLAGS variables: backtrace_child_CFLAGS = -fPIE backtrace_child_LDFLAGS = -pie -pthread @@ -434,7 +434,7 @@ buildid_LDADD = $(libdw) $(libelf) deleted_LDADD = ./deleted-lib.so deleted_lib_so_LDFLAGS = -shared -rdynamic deleted_lib_so_CFLAGS = -fPIC -fasynchronous-unwind-tables -aggregate_size_LDADD = $(libdw) $(libelf) +aggregate_size_LDADD = $(libdw) $(libelf) $(argp_LDADD) vdsosyms_LDADD = $(libdw) $(libelf) getsrc_die_LDADD = $(libdw) $(libelf) strptr_LDADD = $(libelf) -- 2.7.4