From nobody Wed May 11 20:46:56 2022 X-Original-To: dev-commits-src-branches@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 0C4341AE2CDC; Wed, 11 May 2022 20:46:57 +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 4Kz6Qm6vxYz4sZK; Wed, 11 May 2022 20:46:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1652302017; 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=A8GQpTx7lGbN867anXJmqQ7WXgyrtLfFfJbAHe5TWgQ=; b=sjz2LJIvWI/6M4njykiWydT28qSB3TCJv5Ux+dVqIdfAaRhir4Aad3L4kq9rHmyUV0CjTW HIhYWBFiJwTkgL0G7961Mt22paxgCq3ZOpSY4B+j3kro2mYVyo2uOedJqCBgi7V8wcww2f Vyzp5lZE7u9MzCEdkuyqi+eKJqG8cnCXECBsUdK/lvWUTI9Fw8zwRXPEndcnShGDCeF+x8 9qdfbG3DVPFq5avbrAuScrEX0o0PF2QyQpuiWZ0jztdyTtWd/KM15hvGyXkxmhQgALCydD 0zLRI40HE+KSAH/4cffJPPNkwlyJfnYyRLlDtblPp659PLsxRYjtXQmHs4Kanw== 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 CD0BC20CB3; Wed, 11 May 2022 20:46:56 +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 24BKkuUJ098467; Wed, 11 May 2022 20:46:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 24BKkuLt098466; Wed, 11 May 2022 20:46:56 GMT (envelope-from git) Date: Wed, 11 May 2022 20:46:56 GMT Message-Id: <202205112046.24BKkuLt098466@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: c1ccbc7f518e - stable/13 - libpmcstat: Fix a few ARM-specific issues with function symbols. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/stable/13 X-Git-Reftype: branch X-Git-Commit: c1ccbc7f518e4e3c54ea4acd2d217c0ce5f6a13c Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1652302017; 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=A8GQpTx7lGbN867anXJmqQ7WXgyrtLfFfJbAHe5TWgQ=; b=xznYQeNoSik4qYQ+QfVovbRPLF00AvrwZfY8znvZGiuj9a15m3BK4jNpf0Wa78nCcn0ioa 1GOfQAFZPD2nmBwd0QtiihuOukXUKXw8fovFzNXMrHzk01YjlaH3nzzGeRiBzGLOeKmJhN RtXx/YO3xvLmad0zEMMNrItmWI0wfL/ptxuTT7kOtthQFR8fmjjk2jXpiuQxtQcpb0SmjM tuBfiSjrxIRAk0n6F13RzumQlYfyzX9DAR2BQ2srcBV1dpXVVnh7VnOQ1yNm1E0j5BqExy wT6oOKJZKHKvrZHGgSY3j4L0KeViGFc4JKEnME+UJS+dFgt2dU3A3rc62drS6g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1652302017; a=rsa-sha256; cv=none; b=AcTvLWuQCCKwDlf7DZ37XzPEQ++elUqzEQBlzGRUQqxJYj1m+c6U8STGePa3MoOglnR1IT SpmDCIBu5edHB6biW7LW4/qoNxoVuR5XB8uwAjg64fVRdGynQ9djXhHJTh48gxJtQPRApm fn6JcClmiRHTFUK/8LKzyEsrTR0PSUgIoqSlHkqT7eHWfraV11Bn2vXYPlHAScTGDArNnt A7JfPXyEysSzVMKUUJrMzkIBrB7oQVmN27UzItvI0/2ZrrmFi0HJNQ4C/eROW/AFLmSU5B KEftxchpX+oLaEMT7QuEauqSBPPuEtoclW3fjXyw0EDnEXHFselmNfnq0StnqA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=c1ccbc7f518e4e3c54ea4acd2d217c0ce5f6a13c commit c1ccbc7f518e4e3c54ea4acd2d217c0ce5f6a13c Author: John Baldwin AuthorDate: 2022-03-10 23:39:53 +0000 Commit: John Baldwin CommitDate: 2022-05-11 18:57:17 +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 (cherry picked from commit a6db407f15ab7d0dbfd83a48173343654106510e) --- 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 9ee7097e95ec..7e021666aa58 100644 --- a/lib/libpmcstat/libpmcstat_image.c +++ b/lib/libpmcstat/libpmcstat_image.c @@ -118,13 +118,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);