From owner-svn-src-head@freebsd.org Mon Dec 7 20:21:13 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E971F9B9129; Mon, 7 Dec 2015 20:21:13 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B6F8A1437; Mon, 7 Dec 2015 20:21:13 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id tB7KLCfs071900; Mon, 7 Dec 2015 20:21:12 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id tB7KLC3f071899; Mon, 7 Dec 2015 20:21:12 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201512072021.tB7KLC3f071899@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Mon, 7 Dec 2015 20:21:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r291958 - head/contrib/elftoolchain/elfcopy X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Dec 2015 20:21:14 -0000 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__start_, _binary__end, and _binary__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) /*