Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3027102pxj; Sun, 6 Jun 2021 23:39:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw//f9Qf6LIPZrerwhDjQ6O6H2Dq67WTpyyoQn0+ADX/Mf87zc1G5jruPsAh4gIcv7BkHWO X-Received: by 2002:a17:906:ae85:: with SMTP id md5mr16358602ejb.301.1623047962365; Sun, 06 Jun 2021 23:39:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623047962; cv=none; d=google.com; s=arc-20160816; b=QT2cQhOB7c3DG7M45o+JHPg8cXGOi/Cv8hGzW7mmal0HH9k/7l3eGN37I/oXWbhxb/ KT+02pshoK7+JMCR2lwqujdkfAyfVECZWl5V7DxZoT8K9dpyM/rnAkr/3Uj/db7rZuWk i6Da8nL5S+YGqknluOM4+QS+prDn0oOtDzvwxpQSXzBcvENDgCOOWz63/tp7lkPl/WY1 anjWo6lsLq2Nbj5aNSKYx0P2gA+M424daQtmql9EY06vVJ76v3mQxv+fq/9rLS2vLfSr aV3cuQ5QrmKGvqw00qObuNXwmfQA6paPuoXZ53q+kVRu9xanP1Q3PGoyS4Y0K8T40oTi yUrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=DqoukaJCRKTkM6JiI62w32J67kUfQvlzLExmSAw+z6g=; b=QxcUiOhY3swrPEAcbbl0Z8Da8OrccPB8oS7yTwN+PDZLrWeNwTWDy6lHGzCrT1BPJj Ei4kWD3Kl5FFMoBAWPlgY2709mbHPsGURtKhmZqi4HUkk0YUrMRvWtu+RjPczgyvZgQ/ cpqoFO5cX1fih/XW2oiBVWEovsvxYOj32yDLi1deoNNDpkbdRRZZUlsc5fj6vFnKL0IF er/jD57pGMCSeFrAbrrFUJ4oqNdvm2rZGdxRgb4ciZhEESf1wwZ8vzskO3Q13RrtpAmq JvvzJRl1/61JJ5D0EePHim2Rzbqw70tmLNHEppHMKWO1Ya/bkjCqdYmUkuHGdeZ5yzeX IBGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FdoO8D5O; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f16si1523538edy.343.2021.06.06.23.39.00; Sun, 06 Jun 2021 23:39:22 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FdoO8D5O; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230193AbhFGGjc (ORCPT + 99 others); Mon, 7 Jun 2021 02:39:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:56366 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229993AbhFGGj3 (ORCPT ); Mon, 7 Jun 2021 02:39:29 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0DEBA6121E for ; Mon, 7 Jun 2021 06:37:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1623047859; bh=0YmlqGb0FyE2AjCwbtQ/9mSsCd5wlLanyBCpjo5ZUnY=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=FdoO8D5OBQkjg7pxfi/bbd40E3tMYAAwR7NCYNUkuSLZuC5YZvG13KsnU635mBP11 RP9T9KV0EYMwz65lCzzn800HQX+FQJqYWIrnybmyECoQms45kdCgJo0L2IXmu6wf3D +dTecYd16rQQOUexTi3vmJltQ+1JCen5hDg+d+Y5gt2IHSkQrvzMtyDgPZJSUbQYO3 Z6qUezNr6ieUDxTjYod/OpEG8D0C3fCJsQtrHXwADac3jmJ8eQkKUDMF+k9zhUj2hJ Uo6q4ecLCo+2vXyzi6JwAx4WAH5DUcnfEEXLlonxWUZPd9hh9oBgk3cQcZTJMTwabq WYDtaRppfEDtQ== Received: by mail-oi1-f178.google.com with SMTP id u11so17057999oiv.1 for ; Sun, 06 Jun 2021 23:37:39 -0700 (PDT) X-Gm-Message-State: AOAM530aIsKVcYGBRi7XindJUY6qGdbYt1ThSop1L7ZgUreoetFSe16o jhBKbUAh7K49gRyNY5cpZuGz1XdHtTS/A/wRBgg= X-Received: by 2002:aca:4343:: with SMTP id q64mr10379921oia.33.1623047858403; Sun, 06 Jun 2021 23:37:38 -0700 (PDT) MIME-Version: 1.0 References: <20210607023839.26387-1-mark-pk.tsai@mediatek.com> In-Reply-To: <20210607023839.26387-1-mark-pk.tsai@mediatek.com> From: Ard Biesheuvel Date: Mon, 7 Jun 2021 08:37:27 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] recordmcount: avoid using ABS symbol as reference To: Mark-PK Tsai Cc: Matthias Brugger , "Steven Rostedt (VMware)" , Sami Tolvanen , Matt Helsley , Linux Kernel Mailing List , Linux ARM , linux-mediatek@lists.infradead.org, yj.chiang@mediatek.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 7 Jun 2021 at 04:42, Mark-PK Tsai wrote: > > 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 > A RELA section's r_info field points to the section to which it applies. This is why in the example above section #65522 points to section #65521. This has nothing to do with the numerical value of SHN_ABS. > 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. > Could you give a better account of the error you are trying to address? Also, arm64 no longer defines a section_count symbol (since v5.11), so please make sure that the diagnostics of the issue you are addressing are accurate for mainline. > 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 > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel