Skip to content

Commit 8602fda

Browse files
libbacktrace: check for sys/link.h
QNX uses sys/link.h rather than link.h for dl_iterate_phdr Fixes msysgit#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.
1 parent 7409767 commit 8602fda

File tree

4 files changed

+27
-10
lines changed

4 files changed

+27
-10
lines changed

config.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@
8585
/* Define to 1 if you have the <sys/ldr.h> header file. */
8686
#undef HAVE_SYS_LDR_H
8787

88+
/* Define to 1 if you have the <sys/link.h> header file. */
89+
#undef HAVE_SYS_LINK_H
90+
8891
/* Define to 1 if you have the <sys/mman.h> header file. */
8992
#undef HAVE_SYS_MMAN_H
9093

configure

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12316,26 +12316,31 @@ fi
1231612316
1231712317
1231812318
# Check for dl_iterate_phdr.
12319-
for ac_header in link.h
12319+
for ac_header in link.h sys/link.h
1232012320
do :
12321-
ac_fn_c_check_header_mongrel "$LINENO" "link.h" "ac_cv_header_link_h" "$ac_includes_default"
12322-
if test "x$ac_cv_header_link_h" = xyes; then :
12321+
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
12322+
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
12323+
if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
1232312324
cat >>confdefs.h <<_ACEOF
12324-
#define HAVE_LINK_H 1
12325+
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
1232512326
_ACEOF
1232612327
1232712328
fi
1232812329
1232912330
done
1233012331
12331-
if test "$ac_cv_header_link_h" = "no"; then
12332+
if test "$ac_cv_header_link_h" = "no" -a "$ac_cv_header_sys_link_h" = "no"; then
1233212333
have_dl_iterate_phdr=no
1233312334
else
1233412335
if test -n "${with_target_subdir}"; then
12336+
link_h=link.h
12337+
if test "$ac_cv_header_link_h" = "no"; then
12338+
link_h=sys/link.h
12339+
fi
1233512340
# When built as a GCC target library, we can't do a link test.
1233612341
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1233712342
/* end confdefs.h. */
12338-
#include <link.h>
12343+
#include <$link_h>
1233912344
1234012345
_ACEOF
1234112346
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |

configure.ac

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,13 +325,17 @@ fi
325325
AC_SUBST(BACKTRACE_USES_MALLOC)
326326

327327
# Check for dl_iterate_phdr.
328-
AC_CHECK_HEADERS(link.h)
329-
if test "$ac_cv_header_link_h" = "no"; then
328+
AC_CHECK_HEADERS(link.h sys/link.h)
329+
if test "$ac_cv_header_link_h" = "no" -a "$ac_cv_header_sys_link_h" = "no"; then
330330
have_dl_iterate_phdr=no
331331
else
332332
if test -n "${with_target_subdir}"; then
333+
link_h=link.h
334+
if test "$ac_cv_header_link_h" = "no"; then
335+
link_h=sys/link.h
336+
fi
333337
# When built as a GCC target library, we can't do a link test.
334-
AC_EGREP_HEADER([dl_iterate_phdr], [link.h], [have_dl_iterate_phdr=yes],
338+
AC_EGREP_HEADER([dl_iterate_phdr], [$link_h], [have_dl_iterate_phdr=yes],
335339
[have_dl_iterate_phdr=no])
336340
case "${host}" in
337341
*-*-solaris2.10*)

elf.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,12 @@ POSSIBILITY OF SUCH DAMAGE. */
4040
#include <unistd.h>
4141

4242
#ifdef HAVE_DL_ITERATE_PHDR
43-
#include <link.h>
43+
#ifdef HAVE_LINK_H
44+
#include <link.h>
45+
#endif
46+
#ifdef HAVE_SYS_LINK_H
47+
#include <sys/link.h>
48+
#endif
4449
#endif
4550

4651
#include "backtrace.h"

0 commit comments

Comments
 (0)