From owner-svn-src-head@freebsd.org Tue Dec 20 18:25:42 2016 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 B1BDFC89AD3; Tue, 20 Dec 2016 18:25:42 +0000 (UTC) (envelope-from markj@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 6728E1A06; Tue, 20 Dec 2016 18:25:42 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBKIPfHv099703; Tue, 20 Dec 2016 18:25:41 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBKIPfVD099702; Tue, 20 Dec 2016 18:25:41 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201612201825.uBKIPfVD099702@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Tue, 20 Dec 2016 18:25:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310332 - head/cddl/contrib/opensolaris/lib/libdtrace/common 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.23 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: Tue, 20 Dec 2016 18:25:42 -0000 Author: markj Date: Tue Dec 20 18:25:41 2016 New Revision: 310332 URL: https://svnweb.freebsd.org/changeset/base/310332 Log: Avoid modifying the object string table when patching USDT probes. dtrace converts pairs of consecutive underscores in a probe name to dashes. When dtrace -G processes relocations corresponding to USDT probe sites, it performs this conversion on the corresponding symbol names prior to looking up the resulting probe names in the USDT provider definition. However, in so doing it would actually modify the input object's string table, which breaks the string suffix merging done by recent binutils. Because we don't care about the symbol name once the probe site is recorded, just perform the probe lookup using a temporary copy. Reported by: hrs, swills MFC after: 3 weeks Modified: head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c Modified: head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c ============================================================================== --- head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c Tue Dec 20 18:09:59 2016 (r310331) +++ head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c Tue Dec 20 18:25:41 2016 (r310332) @@ -1223,6 +1223,7 @@ process_obj(dtrace_hdl_t *dtp, const cha static const char dt_enabled[] = "enabled"; static const char dt_symprefix[] = "$dtrace"; static const char dt_symfmt[] = "%s%ld.%s"; + char probename[DTRACE_NAMELEN]; int fd, i, ndx, eprobe, mod = 0; Elf *elf = NULL; GElf_Ehdr ehdr; @@ -1576,8 +1577,6 @@ process_obj(dtrace_hdl_t *dtp, const cha bcopy(s, pname, p - s); pname[p - s] = '\0'; - p = strhyphenate(p + 3); /* strlen("___") */ - if (dt_symtab_lookup(data_sym, isym, rela.r_offset, shdr_rel.sh_info, &fsym, (emachine1 == EM_PPC64), elf) != 0) @@ -1628,10 +1627,14 @@ process_obj(dtrace_hdl_t *dtp, const cha "no such provider %s", pname)); } - if ((prp = dt_probe_lookup(pvp, p)) == NULL) { + if (strlcpy(probename, p + 3, sizeof (probename)) >= + sizeof (probename)) return (dt_link_error(dtp, elf, fd, bufs, - "no such probe %s", p)); - } + "invalid probe name %s", probename)); + (void) strhyphenate(probename); + if ((prp = dt_probe_lookup(pvp, probename)) == NULL) + return (dt_link_error(dtp, elf, fd, bufs, + "no such probe %s", probename)); assert(fsym.st_value <= rela.r_offset);