diff options
author | emaste <emaste@FreeBSD.org> | 2015-12-11 20:13:36 +0000 |
---|---|---|
committer | emaste <emaste@FreeBSD.org> | 2015-12-11 20:13:36 +0000 |
commit | 08c7091d4a30fde09fdda23d2016d8d11624cb15 (patch) | |
tree | fa4048de2a3b89d666f609663721fe14dee0627a /elfcopy/binary.c | |
parent | f776db09f98d97717b9d579ba1d88ed8c5e3a040 (diff) | |
download | FreeBSD-src-08c7091d4a30fde09fdda23d2016d8d11624cb15.zip FreeBSD-src-08c7091d4a30fde09fdda23d2016d8d11624cb15.tar.gz |
Import ELF Tool Chain snapshot revision r3272
From http://svn.code.sf.net/p/elftoolchain/code/
Diffstat (limited to 'elfcopy/binary.c')
-rw-r--r-- | elfcopy/binary.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/elfcopy/binary.c b/elfcopy/binary.c index 23e46e7..7c834a9 100644 --- a/elfcopy/binary.c +++ b/elfcopy/binary.c @@ -35,7 +35,7 @@ #include "elfcopy.h" -ELFTC_VCSID("$Id: binary.c 3174 2015-03-27 17:13:41Z emaste $"); +ELFTC_VCSID("$Id: binary.c 3270 2015-12-11 18:48:56Z emaste $"); /* * Convert ELF object to `binary'. Sections with SHF_ALLOC flag set @@ -140,6 +140,7 @@ create_elf_from_binary(struct elfcopy *ecp, int ifd, const char *ifn) GElf_Shdr sh; void *content; uint64_t off, data_start, data_end, data_size; + char *sym_basename, *p; /* Reset internal section list. */ if (!TAILQ_EMPTY(&ecp->v_sec)) @@ -210,8 +211,13 @@ create_elf_from_binary(struct elfcopy *ecp, int ifd, const char *ifn) /* Count in .symtab and .strtab section headers. */ shtab->sz += gelf_fsize(ecp->eout, ELF_T_SHDR, 2, EV_CURRENT); + if ((sym_basename = strdup(ifn)) == NULL) + err(1, "strdup"); + p = sym_basename; + while ((p = strchr(p, '.')) != NULL) + *p++ = '_'; #define _GEN_SYMNAME(S) do { \ - snprintf(name, sizeof(name), "%s%s%s", "_binary_", ifn, S); \ + snprintf(name, sizeof(name), "%s%s%s", "_binary_", sym_basename, S); \ } while (0) /* @@ -233,6 +239,7 @@ create_elf_from_binary(struct elfcopy *ecp, int ifd, const char *ifn) finalize_external_symtab(ecp); create_symtab_data(ecp); #undef _GEN_SYMNAME + free(sym_basename); /* * Write the underlying ehdr. Note that it should be called |