From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C44F0C47094 for ; Mon, 7 Jun 2021 11:46:37 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8A9B0611BD for ; Mon, 7 Jun 2021 11:46:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8A9B0611BD Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0UupUvgx/BsMszmwTPAFYhqXZbQAJ1R9XKcgZ8xlpRU=; b=WJyDrsAFuXGhVk ZVxgrs2Ua/3RuzqUGKKv62zYStgmnR91y4Pys331upupSNWaaResflynrW19m3Q2OiTDCoM34jSMS Gdwd6A5aMGbmpUY9Sem3+7C9Vv48Zl1AOjTd3hKpSF8MyQLH3lwVV5tGyKMU0w0l33nnHKUoyCCbc +wnqbc0iGoFUSHAYQ1zy1SUxXq4Qdq18cNJ6HCNj0ZowTv3kqJev74VuCUrtVSfHE2XVDvA3iA8Fv R0izlPqlvY1ksvhkXKGo5Wwj5tDJs5LR2Vow0xtguZk46Yg4j9klcdzryQaRG2DDCSO3aDlsSVlWB J2/byy+ETVUCpNoYs0SQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqDgI-003Qss-4R; Mon, 07 Jun 2021 11:44:34 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqDgC-003QsG-2A; Mon, 07 Jun 2021 11:44:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=gYCYJldAbA8a06vrFGZoYfiU547SeEAFQmvggPR/Cg8=; b=AZAhLHO36Df0PZ1FreU05zRE6I 35ZDAPhr4sctYJzIC4j/cXB9wNqpvxrdrU8M3F4Ym515IQRyq86YMCVWbh8HbqoEk1OmcssdyfQz3 oJko1p/ZhnJi6d4me2Um3nLZ9rZwHMy4s2FfTpqJhE6Mjk3MOsMJPfXmRhLceJAbM6ahrIhzPwM1p KkeKvW8X4HH3QPBawquRsprt8hqzaPQ5IfbB0YUZADmn401Ug2ewnnCyc3c3+LAf6UydEA7QusaQG gJNNDRYI7SmQbQ2IikJ+2RfJFGAftaGvPUcGgkBe1J8hiSZ2+wzkIupSlA4bh/bMZRlsCnpgpni5O wWbdiByg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqDg0-004NVZ-TA; Mon, 07 Jun 2021 11:44:23 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 1349D300223; Mon, 7 Jun 2021 13:44:22 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 013882CF3852A; Mon, 7 Jun 2021 13:44:21 +0200 (CEST) Date: Mon, 7 Jun 2021 13:44:21 +0200 From: Peter Zijlstra To: Ard Biesheuvel Cc: Mark-PK Tsai , Linux Kbuild mailing list , linux-toolchains@vger.kernel.org, Linux ARM , Linux Kernel Mailing List , linux-mediatek@lists.infradead.org, Matthias Brugger , Matt Helsley , "Steven Rostedt (VMware)" , Sami Tolvanen , yj.chiang@mediatek.com Subject: Re: [PATCH] recordmcount: avoid using ABS symbol as reference Message-ID: References: <20210607074258.32322-1-mark-pk.tsai@mediatek.com> <20210607080626.32612-1-mark-pk.tsai@mediatek.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Jun 07, 2021 at 11:50:40AM +0200, Ard Biesheuvel wrote: > On Mon, 7 Jun 2021 at 10:06, Mark-PK Tsai wrote: > > > > > > On Mon, 7 Jun 2021 at 08:59, Mark-PK Tsai wrote: > > > > > > > > > > > > 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. > > > > > > > > > > If the r_info of RELA section is 65521(0xfff1), > > > > > > Oh sorry, I mean sh_info here. > > > > > > > > find_secsym_ndx() will use it to find the base symbol. > > > > > > > > > > > > > But what does that have to do with the sh_info field of the RELA > > > > section's Elf_Shdr struct? IOW, what is the relevance of section > > > > #65521 here? > > > > > > > > > > So what I mean is the problem occur if the sh_info of a RELA section > > > is #65521. > > > > Actually the problem occur if the sh_info of a RELA section is in > > the special section index range(SHN_LORESERVE ~ SHN_HIRESERVE). > > Maybe I should add a is_shndx_special() to check this like > > scripts/mod/modpost.h did? > > > > So if I understand all of this correctly, we are running into a > fundamental issue here, where the linker emits more sections than the > sh_info field can describe, overflowing into the reserved range. > > I don't think papering over it like this is going to be maintainable > going forward. There's an extended section header index section for just that. And recordmcount actually seems to use that as well. I can't seem to find enough of the thread to figure out what the actual problem is though. The lore archive doesn't have anything prior to this message. One should only use st_shndx when >SHN_UDEF and st_shndx != SHN_XINDEX) + if (sym->st_shndx > SHN_UDEF && + sym->st_shndx < SHN_LORESERVE) return w2(sym->st_shndx); - offset = (unsigned long)sym - (unsigned long)symtab; - index = offset / sizeof(*sym); + if (sym->st_shndx == SHN_XINDEX) { + offset = (unsigned long)sym - (unsigned long)symtab; + index = offset / sizeof(*sym); - return w(symtab_shndx[index]); + return w(symtab_shndx[index]); + } + + return 0; } static unsigned int get_shnum(Elf_Ehdr const *ehdr, Elf_Shdr const *shdr0) _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel