Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3064442pxj; Mon, 7 Jun 2021 01:00:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzXsqFwO1MjAJ6qzCwTfG2t3nZ2wphLsaN2BMuPSQAahL47pXNEYlhbQ4L1tiAkRUvRIqFh X-Received: by 2002:a05:6402:101a:: with SMTP id c26mr19207619edu.19.1623052853094; Mon, 07 Jun 2021 01:00:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623052853; cv=none; d=google.com; s=arc-20160816; b=tnqhnGdc/JXK+Ps7KTG8XuMGxmqFzxuk+tgUHpFQljUNK63YqsINTOyzWIsM3KCJaT NK0GsiZy35W4rhCs513+wDclH6pd4/OFM8p9Q+uK4y63ocmk0ig1NXdAzE4O11/CCQno LoaogJcKjb3qPCxbvjSay4zhGTMRy8duDQCXFTPDm8KqH2X/cn2PuNNdWzuhpBIv16cS 4DVkf0Dixt5YY7sYPgIjvLoVUgQERzm1jBuM2Kq2lIim8RXD/TrtP53qT9ITUN5P1/4B hGw2gSDm4a7/T0MSloT2ePD98uQktMhgJUZU8+btlqJcKy8KnL2tMksmLe6KZ6orVlga VZcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=RI7d+MKqVAlBJe+aXBCqULwS/BkkdRxtZ0dH5H9X58I=; b=VPwF1VcWkQ97Q/9Z4lWrzfbcKF3Gnu6X0y0EOhcMuQZgXEMcapXmNim4SmqrnaIKx3 Mu3ILmRAM6usRsfnLxjWxuz/8+XHnWOvC1PNl+2yPODlvKVQE4Ik1tUEp+ZtTlZnUcqZ DLSslEvAoqRXLJQ2Yd1OZeW30ycn9xMj/5B6CLVs3s8tAe1/PhEfOsISXxzR4Uo1Skn4 RczFLrU9YxIf58xSxevXm8oy5nL6+kex21SHcAz0p0yM40ex0PMjhBudPJO32bFOblyV oT88CoCbzTmIJ3++komr96cRCy3YlrHP3kbWdmXdCEqa4BLbbRj0b55XgM3urOE5c/DV D80Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=qVRE6udM; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f1si11011216ejh.93.2021.06.07.01.00.30; Mon, 07 Jun 2021 01:00:53 -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=@infradead.org header.s=casper.20170209 header.b=qVRE6udM; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230155AbhFGH7A (ORCPT + 99 others); Mon, 7 Jun 2021 03:59:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230197AbhFGH67 (ORCPT ); Mon, 7 Jun 2021 03:58:59 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B60ECC061789 for ; Mon, 7 Jun 2021 00:57:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=RI7d+MKqVAlBJe+aXBCqULwS/BkkdRxtZ0dH5H9X58I=; b=qVRE6udMS5tnbGyy8JKqrT34Iv 1jLseDWxIPn9NMfouRnMjob0gMaJW/dxlfSCXduP45wAmm3qevrB+3pDOACbHLAZj8SKi1t+UHWUc 97/cVu8uLcorWgQ99WNuC9q3laFroUUTe0r34Z7sZCTP+FMIKplMDNgJxmxKnl9biRm5X0BE/d1NJ cfrikyXZ9yRc3xGVSpWfCv9npIlH/9IEdh0ImGgI9VeIO3wtcZMDavH3t6fCX9EPtCy7SQTwbQoOZ 70GthJWZczZ+9oHrDH3Yw5LWeo9VIhJf/21XqWm+ZDp6d6LLVLYw6TD7WZjwUeKXIKZ2rMWnzU9LW xR1NjBJA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94 #2 (Red Hat Linux)) id 1lqA7u-00FVF0-OO; Mon, 07 Jun 2021 07:56:52 +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 00A803001E3; Mon, 7 Jun 2021 09:56:48 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id D06CB2CEABC0E; Mon, 7 Jun 2021 09:56:48 +0200 (CEST) Date: Mon, 7 Jun 2021 09:56:48 +0200 From: Peter Zijlstra To: =?utf-8?B?RsSBbmctcnXDrCBTw7JuZw==?= Cc: Nick Desaulniers , Josh Poimboeuf , lma@semihalf.com, Guenter Roeck , Juergen Gross , lb@semihalf.com, LKML , mbenes@suse.com, =?utf-8?B?UmFkb3PFgmF3?= Biernacki , upstream@semihalf.com, "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , clang-built-linux , Nathan Chancellor , Sami Tolvanen Subject: Re: [PATCH v3 16/16] objtool,x86: Rewrite retpoline thunk calls Message-ID: References: <20210604205018.2238778-1-ndesaulniers@google.com> <20210604235046.w3hazgcpsg4oefex@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jun 05, 2021 at 06:58:39PM -0700, Fāng-ruì Sòng wrote: > On Sat, Jun 5, 2021 at 3:39 AM Peter Zijlstra wrote: > > I think you've absolutely nailed it; but would you have more information > > or a code reference to what you're speaking about? My complete ELF > > and libelf knowledge is very limited and as demonstrated here, I'm not > > at all sure how all that extended index stuff is supposed to work. > > The section index field of an Elf{32,64}_Sym (st_shndx) is 16-bit, so > it cannot represent a section index greater than 0xffff. > ELF actually reserves values in 0xff00~0xff00 for other purposes, so > st_shndx cannot represent a section whose index is greater or equal to > 0xff00. Right, that's about as far as I got, but never could find details on how the extension worked in detail, and I clearly muddled it :/ > To overcome the 16-bit section index limitation, .symtab_shndx was designed. > > http://www.sco.com/developers/gabi/latest/ch4.symtab.html says > > > SHN_XINDEX This value is an escape value. It indicates that the > > symbol refers to a specific location within a section, but that the > > section header index for that section is too large to be represented > > directly in the symbol table entry. The actual section header index > > is found in the associated SHT_SYMTAB_SHNDX section. The entries in > > that section correspond one to one with the entries in the symbol > > table. Only those entries in SHT_SYMTAB_SHNDX that correspond to > > symbol table entries with SHN_XINDEX will hold valid section header > > indexes; all other entries will have value 0. > > You may use https://github.com/llvm/llvm-project/blob/main/llvm/tools/llvm-objcopy/ELF/Object.cpp#L843 > as a reference. Excellent, lemme go read up and attempt to fix this.