This patch to libbacktrace provides dummy versions of lstat and readlink if they are not available on the system. Bootstrapped and ran libbacktrace tests on x86_64-pc-linux-gnu both normally and with a hand-edited config.h. Committed to mainline.
Ian 2017-09-22 Ian Lance Taylor <i...@golang.org> PR sanitizer/77631 * configure.ac: Check for lstat and readlink. * elf.c (lstat, readlink): Provide dummy versions if real versions are not available. * configure, config.h.in: Rebuild.
Index: configure.ac =================================================================== --- configure.ac (revision 253093) +++ configure.ac (working copy) @@ -373,6 +373,7 @@ if test "$have_fcntl" = "yes"; then fi AC_CHECK_DECLS(strnlen) +AC_CHECK_FUNCS(lstat readlink) # Check for getexecname function. if test -n "${with_target_subdir}"; then Index: elf.c =================================================================== --- elf.c (revision 253093) +++ elf.c (working copy) @@ -75,6 +75,35 @@ xstrnlen (const char *s, size_t maxlen) #endif +#ifndef HAVE_LSTAT + +/* Dummy version of lstat for systems that don't have it. */ + +static int +xlstat (const char *path ATTRIBUTE_UNUSED, struct stat *st ATTRIBUTE_UNUSED) +{ + return -1; +} + +#define lstat xlstat + +#endif + +#ifndef HAVE_READLINK + +/* Dummy version of readlink for systems that don't have it. */ + +static ssize_t +xreadlink (const char *path ATTRIBUTE_UNUSED, char *buf ATTRIBUTE_UNUSED, + size_t bufsz ATTRIBUTE_UNUSED) +{ + return -1; +} + +#define readlink xreadlink + +#endif + #ifndef HAVE_DL_ITERATE_PHDR /* Dummy version of dl_iterate_phdr for systems that don't have it. */