From nobody Thu Mar 10 23:41:33 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 21C4E19F8CC1; Thu, 10 Mar 2022 23:41:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KF5Ds73Xtz3jRD; Thu, 10 Mar 2022 23:41:33 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646955694; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ZpR8pIGfVpl7W/O9Z4EA2HMCg6IlvmnP2GXm3M5besk=; b=uT2SmG6qGp1Yhy+1MYdApIzlSpxEtvqo6Nb1yWBIUycfo+lz7nJX1nxQ1ZaLrcxr/W8ml0 MAJKu+9KTHoA3+yClJfqyafkdlIlaIRR1CLa4u9fPdyT0MWViRXScoJNq9p1K1vFLTzuu4 O6D2cxy95+LZK4g6Q5RYPFokprVHJct9A1cKyPN93hYb2YYK4sQBLzRG0SSbQRBgRzmeo5 +L88GizdLZSkRUYrSW3WFFIUhgApJjNtAP0CfBaYr21tFA7GkFpW40TFL571grFd1jY3HA ENv/eyO/5PMxQgjmve5lFiN0XIjBKHBbkX+9Cz7H+Ga28I43X1neN4MbPIsBGA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C0EBB666A; Thu, 10 Mar 2022 23:41:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 22ANfX0c025041; Thu, 10 Mar 2022 23:41:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 22ANfXvn025040; Thu, 10 Mar 2022 23:41:33 GMT (envelope-from git) Date: Thu, 10 Mar 2022 23:41:33 GMT Message-Id: <202203102341.22ANfXvn025040@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: a6db407f15ab - main - libpmcstat: Fix a few ARM-specific issues with function symbols. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a6db407f15ab7d0dbfd83a48173343654106510e Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646955694; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ZpR8pIGfVpl7W/O9Z4EA2HMCg6IlvmnP2GXm3M5besk=; b=njUWsGbYaD3PiQddy0xmr//zziDo0jTRbtq2ltTFojnvix0XUtTVMUwR+0+GczZzD8PSQh CkEZL/60b9/Xtsu/3CYS6f/yMwFXJ5KmacUZFVhuz715w8cUYHRF2N6Rj1B3T5Svzo8Eoo o8y9X2oy8yy0dh8UGh8a6TSh0dOLWAFemNZf8Ucap/ndcLntNZW54muudoaiLc9fJb0CUW 096u4B4Pf2AsnFtSy5VKfQFBXLSpPiSE5BBXFsfPLJKuK6xINttPalV3QBrjnI29g32BHw MvTiH7fAhADtTIEQsrIm7/4hQ0NQSs4kk6YagDpR5L569w+CFD5oXcvMYGYnJg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1646955694; a=rsa-sha256; cv=none; b=oBRK4w1WM9BICfz95Qc2GFYExYZFzGkPbi2WBE9iF0f9YnaL49D9VwA0M5gKZPmyitb1T2 jEkSCe/UszY4xjoE2TR0UKOuI4inqyGWfvNY18cYSJTbKLRIctoJkIlBxoPJVr+gv7lUdg +UzoxUpucuZcTBK/ce9nBi3uCn9ROU0FrT5Q3qvEkxY9jDzWjBQXbxZ3wFOgwFhGP8gTXL 5L8pO5TdjjrSCBsoDNEZbTuJ+zaft4AB7brLdQHT5yAcVdAw+xHnV66OtpehnzDxyOLruV LjvIEpo8RxV6wXlyK0t1OKTblFyr24p/yMSCZM28mZqXPMKdH1JAsAcZAV75Mw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=a6db407f15ab7d0dbfd83a48173343654106510e commit a6db407f15ab7d0dbfd83a48173343654106510e Author: John Baldwin AuthorDate: 2022-03-10 23:39:53 +0000 Commit: John Baldwin CommitDate: 2022-03-10 23:39:53 +0000 libpmcstat: Fix a few ARM-specific issues with function symbols. - Refine the checks for ARM mapping symbols and apply them on arm64 as well as 32-bit arm. In particular, mapping symbols can have additional characters and are not strictly limited to just "$a" but can append additional characters (e.g. "$a.1"). Add "$x" to the list of mapping symbol prefixes. - Clear the LSB of function symbol addresses. Thumb function addresses set the LSB to enable Thumb mode. However, the actual function starts at the aligned address with LSB clear. Not clearing the LSB can cause pmcannotate to pass misaligned addresses to objdump when extracting disassembly. Reviewed by: andrew Obtained from: CheriBSD Sponsored by: University of Cambridge, Google, Inc. Differential Revision: https://reviews.freebsd.org/D34416 --- lib/libpmcstat/libpmcstat_image.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/libpmcstat/libpmcstat_image.c b/lib/libpmcstat/libpmcstat_image.c index 97109f203806..c63f00e03253 100644 --- a/lib/libpmcstat/libpmcstat_image.c +++ b/lib/libpmcstat/libpmcstat_image.c @@ -119,13 +119,23 @@ pmcstat_image_add_symbols(struct pmcstat_image *image, Elf *e, if ((fnname = elf_strptr(e, sh->sh_link, sym.st_name)) == NULL) continue; -#ifdef __arm__ - /* Remove spurious ARM function name. */ + +#if defined(__aarch64__) || defined(__arm__) + /* Ignore ARM mapping symbols. */ if (fnname[0] == '$' && (fnname[1] == 'a' || fnname[1] == 't' || - fnname[1] == 'd') && - fnname[2] == '\0') + fnname[1] == 'd' || fnname[1] == 'x')) continue; + + /* + * Clear LSB from starting addresses for functions + * which execute in Thumb mode. We should perhaps + * only do this for functions in a $t mapping symbol + * range, but parsing mapping symbols would be a lot + * of work and function addresses shouldn't have the + * LSB set otherwise. + */ + sym.st_value &= ~1; #endif symptr->ps_name = pmcstat_string_intern(fnname);