From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2116) id 9848C38582BE; Fri, 8 Jul 2022 17:33:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9848C38582BE MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Ian Lance Taylor To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-1579] libbacktrace: check for sys/link.h X-Act-Checkin: gcc X-Git-Author: Ian Lance Taylor X-Git-Refname: refs/heads/master X-Git-Oldrev: b984b84cbe4bf026edef2ba37685f3958a1dc1cf X-Git-Newrev: 55bb77b50a5ec520f28978ac3fdac1983200e1f7 Message-Id: <20220708173302.9848C38582BE@sourceware.org> Date: Fri, 8 Jul 2022 17:33:02 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Jul 2022 17:33:02 -0000 https://gcc.gnu.org/g:55bb77b50a5ec520f28978ac3fdac1983200e1f7 commit r13-1579-g55bb77b50a5ec520f28978ac3fdac1983200e1f7 Author: Ian Lance Taylor Date: Fri Jul 8 10:28:24 2022 -0700 libbacktrace: check for sys/link.h QNX uses sys/link.h rather than link.h for dl_iterate_phdr Fixes https://github.com/ianlancetaylor/libbacktrace/issues/86 * configure.ac: Check for sys/link.h. Use either link.h or sys/link.h when checking for dl_iterate_phdr. * elf.c: Include sys/link.h if available. * configure, config.h.in: Regenerate. Diff: --- libbacktrace/config.h.in | 3 +++ libbacktrace/configure | 17 +++++++++++------ libbacktrace/configure.ac | 10 +++++++--- libbacktrace/elf.c | 7 ++++++- 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/libbacktrace/config.h.in b/libbacktrace/config.h.in index cdb416e6406..a21e2eaf525 100644 --- a/libbacktrace/config.h.in +++ b/libbacktrace/config.h.in @@ -85,6 +85,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_SYS_LDR_H +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_LINK_H + /* Define to 1 if you have the header file. */ #undef HAVE_SYS_MMAN_H diff --git a/libbacktrace/configure b/libbacktrace/configure index 537486d34f2..705b71bd8cd 100755 --- a/libbacktrace/configure +++ b/libbacktrace/configure @@ -13267,26 +13267,31 @@ fi # Check for dl_iterate_phdr. -for ac_header in link.h +for ac_header in link.h sys/link.h do : - ac_fn_c_check_header_mongrel "$LINENO" "link.h" "ac_cv_header_link_h" "$ac_includes_default" -if test "x$ac_cv_header_link_h" = xyes; then : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF -#define HAVE_LINK_H 1 +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done -if test "$ac_cv_header_link_h" = "no"; then +if test "$ac_cv_header_link_h" = "no" -a "$ac_cv_header_sys_link_h" = "no"; then have_dl_iterate_phdr=no else if test -n "${with_target_subdir}"; then + link_h=link.h + if test "$ac_cv_header_link_h" = "no"; then + link_h=sys/link.h + fi # When built as a GCC target library, we can't do a link test. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include +#include <$link_h> _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | diff --git a/libbacktrace/configure.ac b/libbacktrace/configure.ac index 857987a2859..1daaa2f62d2 100644 --- a/libbacktrace/configure.ac +++ b/libbacktrace/configure.ac @@ -335,13 +335,17 @@ fi AC_SUBST(BACKTRACE_USES_MALLOC) # Check for dl_iterate_phdr. -AC_CHECK_HEADERS(link.h) -if test "$ac_cv_header_link_h" = "no"; then +AC_CHECK_HEADERS(link.h sys/link.h) +if test "$ac_cv_header_link_h" = "no" -a "$ac_cv_header_sys_link_h" = "no"; then have_dl_iterate_phdr=no else if test -n "${with_target_subdir}"; then + link_h=link.h + if test "$ac_cv_header_link_h" = "no"; then + link_h=sys/link.h + fi # When built as a GCC target library, we can't do a link test. - AC_EGREP_HEADER([dl_iterate_phdr], [link.h], [have_dl_iterate_phdr=yes], + AC_EGREP_HEADER([dl_iterate_phdr], [$link_h], [have_dl_iterate_phdr=yes], [have_dl_iterate_phdr=no]) else AC_CHECK_FUNC([dl_iterate_phdr], [have_dl_iterate_phdr=yes], diff --git a/libbacktrace/elf.c b/libbacktrace/elf.c index 8b82dd45875..181d195fe35 100644 --- a/libbacktrace/elf.c +++ b/libbacktrace/elf.c @@ -40,7 +40,12 @@ POSSIBILITY OF SUCH DAMAGE. */ #include #ifdef HAVE_DL_ITERATE_PHDR -#include + #ifdef HAVE_LINK_H + #include + #endif + #ifdef HAVE_SYS_LINK_H + #include + #endif #endif #include "backtrace.h"