Date: Mon, 7 Dec 2015 20:21:12 +0000 (UTC) From: Ed Maste <emaste@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r291958 - head/contrib/elftoolchain/elfcopy Message-ID: <201512072021.tB7KLC3f071899@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: emaste Date: Mon Dec 7 20:21:12 2015 New Revision: 291958 URL: https://svnweb.freebsd.org/changeset/base/291958 Log: elfcopy: exclude extension when converting from binary When converting from binary to ELF, elfcopy creates symbols _binary_<filename>_start_, _binary_<filename>_end, and _binary_<filename>_size. For compatibility with GNU objcopy (and to produce sensible symbol names) the extension must be stripped off. Reviewed by: imp Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D4238 Modified: head/contrib/elftoolchain/elfcopy/binary.c Modified: head/contrib/elftoolchain/elfcopy/binary.c ============================================================================== --- head/contrib/elftoolchain/elfcopy/binary.c Mon Dec 7 19:21:08 2015 (r291957) +++ head/contrib/elftoolchain/elfcopy/binary.c Mon Dec 7 20:21:12 2015 (r291958) @@ -37,6 +37,16 @@ ELFTC_VCSID("$Id: binary.c 3174 2015-03-27 17:13:41Z emaste $"); +static int +basename_length(const char *filename) +{ + char *p; + + if ((p = strchr(filename, '.')) != NULL) + return (p - filename); + return (strlen(filename)); +} + /* * Convert ELF object to `binary'. Sections with SHF_ALLOC flag set * are copied to the result binary. The relative offsets for each section @@ -211,7 +221,8 @@ create_elf_from_binary(struct elfcopy *e shtab->sz += gelf_fsize(ecp->eout, ELF_T_SHDR, 2, EV_CURRENT); #define _GEN_SYMNAME(S) do { \ - snprintf(name, sizeof(name), "%s%s%s", "_binary_", ifn, S); \ + snprintf(name, sizeof(name), "%s%.*s%s", "_binary_", \ + basename_length(ifn), ifn, S); \ } while (0) /*
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201512072021.tB7KLC3f071899>