From 0ecbc86fe5bd2501ccbd620e92ef0e4b47466519 Mon Sep 17 00:00:00 2001 From: emaste Date: Wed, 20 Apr 2016 19:13:00 +0000 Subject: [PATCH] elfcopy: map all !alnum characters to '_' in binary input symbol names This matches bfd and gold. Obtained from: ELF Tool Chain r3445 Sponsored by: The FreeBSD Foundation --- contrib/elftoolchain/elfcopy/binary.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/contrib/elftoolchain/elfcopy/binary.c b/contrib/elftoolchain/elfcopy/binary.c index 7c834a9aaa3..476e6c7b346 100644 --- a/contrib/elftoolchain/elfcopy/binary.c +++ b/contrib/elftoolchain/elfcopy/binary.c @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -213,9 +214,9 @@ create_elf_from_binary(struct elfcopy *ecp, int ifd, const char *ifn) if ((sym_basename = strdup(ifn)) == NULL) err(1, "strdup"); - p = sym_basename; - while ((p = strchr(p, '.')) != NULL) - *p++ = '_'; + for (p = sym_basename; *p != '\0'; p++) + if (!isalnum(*p)) + *p = '_'; #define _GEN_SYMNAME(S) do { \ snprintf(name, sizeof(name), "%s%s%s", "_binary_", sym_basename, S); \ } while (0) -- 2.11.4.GIT