Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2925030pxj; Sun, 6 Jun 2021 19:41:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxl8VtSyI4fffCGAe7BEY8J22aQal6BeVUDfxDyXc9uyXLqgYSaP21vevCJeeUgSv5Gcg01 X-Received: by 2002:a17:907:779a:: with SMTP id ky26mr15644726ejc.293.1623033676119; Sun, 06 Jun 2021 19:41:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623033676; cv=none; d=google.com; s=arc-20160816; b=qqeF4dAEBO+PFbzICxGTRKD45XXIdP4DTtYtTtD1uZInk37lNGIcmOCkCsMwmeEWbf aGe5QBWLtKlHUbmNHQv+veBSnnNhSIs4is8wxw9PNd8ElsmFh/5IogxShyeonkuiK22H ZgeR76tI0cxvH+7S8eJcLHWsxPar7TCPvHnLCd52XwHOrqVnHOZknAQi/GgSM3AieC6H yOBF5Sr+qr5ZBd8jdYDlPqCW91An7gum+rcmpd+CHvMq/wg/oTi+SfO6TRVfFurImmHi AwcIS67pFv4rh6e602Uh/xfZnrZu90vVsaY99bOPX2HlMwGW1lm9IMg3vutTb4MXzM2O /EPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=gLdMJPZOas5wOXplH/56VRWbXis7WlXGnlW/gdZVU44=; b=hSvCkv/af0KNNtYs8AFPLHFzFwUTP0id7lx8asDMvKvFpk4G5OIkOh6CSZCRzUP+db 80bpi1V4vxx/vidY0LVk9RDp7QkcynMio2x/j+3dMz+9u81BHMmD1KTCbjjlr+y0KdKH F8mM/pE/O7vvbzgAlKj4iHQ9oAFut3yT3+WAuVGdsxZhQVlmg7hdYJh1sC3GuGyj6X2i gt6WJj+nIecO9vOEXJGCLEoaYz/TD8QIZ0nUP/N62Oh5ZTxCIdTaqllYgx8uN29nCQYa TRZbWzLtROKObs45FqQBuiwy0NhJWQKCUjMEZYGjpow3/HgMBpOEwO7Yi+6D/0CSzAPl wlzQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b16si11353340ede.389.2021.06.06.19.40.54; Sun, 06 Jun 2021 19:41:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230247AbhFGCk7 (ORCPT + 99 others); Sun, 6 Jun 2021 22:40:59 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:41067 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S230145AbhFGCk6 (ORCPT ); Sun, 6 Jun 2021 22:40:58 -0400 X-UUID: 8faeb201501c425bb379ce289d69de36-20210607 X-UUID: 8faeb201501c425bb379ce289d69de36-20210607 Received: from mtkmbs10n2.mediatek.inc [(172.21.101.183)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1632690706; Mon, 07 Jun 2021 10:38:56 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs08n1.mediatek.inc (172.21.101.55) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 7 Jun 2021 10:38:48 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Mon, 7 Jun 2021 10:38:48 +0800 From: Mark-PK Tsai To: Matthias Brugger CC: , Mark-PK Tsai , "Sami Tolvanen" , Matt Helsley , , , , Subject: [PATCH] recordmcount: avoid using ABS symbol as reference Date: Mon, 7 Jun 2021 10:38:39 +0800 Message-ID: <20210607023839.26387-1-mark-pk.tsai@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Avoid using ABS symbol, which won't be relocate, as reference. On arm64 platform, if there's shndx equals SHN_ABS(0xfff1). Section Headers: [Nr] Name Type Address Off Size ES Flg Lk Inf Al [65521] .text.n_tty_receive_buf PROGBITS 0000000000000000 3cdab520 000054 00 AX 0 0 4 [65522] .rela.text.n_tty_receive_buf RELA 0000000000000000 3cdab578 000030 18 I 152076 65521 8 find_secsym_ndx, which use r_info in rela section to find the reference symbol, may take ABS symbol as base. Symbol table '.symtab' contains 453285 entries: Num: Value Size Type Bind Vis Ndx Name 6: 0000000000000002 0 NOTYPE LOCAL DEFAULT ABS section_count Which cause an invalid address in __mcount_loc. Signed-off-by: Mark-PK Tsai --- scripts/recordmcount.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/recordmcount.h b/scripts/recordmcount.h index f9b19524da11..9b69167fb7ff 100644 --- a/scripts/recordmcount.h +++ b/scripts/recordmcount.h @@ -526,6 +526,10 @@ static int find_secsym_ndx(unsigned const txtndx, for (symp = sym0, t = nsym; t; --t, ++symp) { unsigned int const st_bind = ELF_ST_BIND(symp->st_info); + /* avoid absolute symbols */ + if (symp->st_shndx == SHN_ABS) + continue; + if (txtndx == get_symindex(symp, symtab, symtab_shndx) /* avoid STB_WEAK */ && (STB_LOCAL == st_bind || STB_GLOBAL == st_bind)) { -- 2.18.0