Adds configure-time check to test the function signature of elf_hash function, which may be provided by the libelf or elfutils packages. In the former, the 'name' argument must be an unsigned char pointer. In the later, the same argument must be a signed char pointer. The check sets the ELF_HASH_TAKES_SIGNED_CHAR symbol in config.h, and this is used at the existing call site to pass the proper type.
Signed-off-by: Zachary T Welch <[email protected]> --- configure.ac | 11 +++++++++++ ltrace-elf.c | 4 ++++ 2 files changed, 15 insertions(+), 0 deletions(-) diff --git a/configure.ac b/configure.ac index 1b70c46..ab813ec 100644 --- a/configure.ac +++ b/configure.ac @@ -123,6 +123,17 @@ int main () { AC_MSG_RESULT([yes])],[ AC_MSG_RESULT([no])]) +saved_CFLAGS="${CFLAGS}" +CFLAGS="${CFLAGS} -Wall -Werror" +AC_MSG_CHECKING([whether elf_hash takes a signed char string]) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <libelf.h>]], [[ + (void) elf_hash("name"); + ]])], + [AC_DEFINE([ELF_HASH_TAKES_SIGNED_CHAR], [1], + [elf_hash() takes signed char]) + AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no])]) +CFLAGS="${saved_CFLAGS}" CPPFLAGS=" \ ${CPPFLAGS} \ diff --git a/ltrace-elf.c b/ltrace-elf.c index 29a8b9d..e3ef5c3 100644 --- a/ltrace-elf.c +++ b/ltrace-elf.c @@ -529,7 +529,11 @@ in_load_libraries(const char *name, struct ltelf *lte, size_t count, GElf_Sym *s if (!count) return 1; +#ifdef ELF_HASH_TAKES_SIGNED_CHAR + hash = elf_hash(name); +#else hash = elf_hash((const unsigned char *)name); +#endif gnu_hash = private_elf_gnu_hash(name); for (i = 0; i < count; ++i) { -- 1.7.2.2 _______________________________________________ Ltrace-devel mailing list [email protected] http://lists.alioth.debian.org/mailman/listinfo/ltrace-devel
