[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YL3lQ5QdNV2qwLR/@hirez.programming.kicks-ass.net>
Date: Mon, 7 Jun 2021 11:22:11 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Fāng-ruì Sòng <maskray@...gle.com>
Cc: Nick Desaulniers <ndesaulniers@...gle.com>,
Josh Poimboeuf <jpoimboe@...hat.com>, lma@...ihalf.com,
Guenter Roeck <groeck@...gle.com>,
Juergen Gross <jgross@...e.com>, lb@...ihalf.com,
LKML <linux-kernel@...r.kernel.org>, mbenes@...e.com,
Radosław Biernacki <rad@...ihalf.com>,
upstream@...ihalf.com,
"maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" <x86@...nel.org>,
clang-built-linux <clang-built-linux@...glegroups.com>,
Nathan Chancellor <nathan@...nel.org>,
Sami Tolvanen <samitolvanen@...gle.com>
Subject: Re: [PATCH v3 16/16] objtool,x86: Rewrite retpoline thunk calls
On Mon, Jun 07, 2021 at 09:56:48AM +0200, Peter Zijlstra wrote:
> 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 <peterz@...radead.org> 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 :/
OK, so I'm all confused again...
So a .symtab entry has:
st_name -- strtab offset for the name string
st_value -- where this symbol lives
st_size -- size of symbol in bytes
st_shndx -- section index to interpret the @st_value above
st_info -- type+bind
st_other -- visibility
The thing is, we're adding UNDEF symbols, for the linker to resolve.
UNDEF has:
st_value := 0
st_size := 0
st_shndx := 0
st_info := GLOBAL + NOTYPE
st_other := 0
Per that, sh_shndx isn't >= SHN_LORESERVE, and I figured we all good.
Is the problem that .symtab_shndx is expected to contain the exact same
number of entries as .symtab? And I'm adding to .symtab and not to
.symtab_shndx, hence getting them out of sync?
Let me try adding 0s to .symtab_shndx. See if that makes readelf
happier.
Powered by blists - more mailing lists