lkml.org 
[lkml]   [2022]   [May]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: objtool "no non-local symbols" error with tip of tree LLVM
On Wed, May 18, 2022 at 09:17:27AM -0700, Josh Poimboeuf wrote:
> On Wed, May 18, 2022 at 07:30:06AM +0200, Peter Zijlstra wrote:
> > On Tue, May 17, 2022 at 06:24:29PM -0700, Josh Poimboeuf wrote:
> > > On Tue, May 17, 2022 at 05:42:04PM +0200, Peter Zijlstra wrote:
> > > > + for (;;) {
> > > > + symtab_data = elf_getdata(s, symtab_data);
> > > > + if (t)
> > > > + shndx_data = elf_getdata(t, shndx_data);
> > > >
> > > > + if (!symtab_data) {
> > > > + if (!idx) {
> > > > + void *buf;
> > >
> > > I'm confused by whatever this is doing, how is !symtab_data possible,
> > > i.e. why would symtab not have data?
> >
> > Elf_Data *elf_getdata(Elf_Scn *scn, Elf_Data *data);
> >
> > is an iterator, if @data is null it will return the first element, which
> > you then feed into @data the next time to get the next element, once it
> > returns NULL, you've found the end.
> >
> > In our specific case, we iterate the data sections, if idx fits inside
> > the current section, we good, otherwise we lower idx by however many did
> > fit and try the next.
>
> Ok, I think I see. But why are there multiple data blocks to begin
> with? It's because of a previous call to elf_newdata() right?
>
> If so then I don't see how it would "fit" in an existing data block,
> since each block should already be full. Or... is the hole the one you
> just made, by moving the old symbol out?
>
> If so, the function seems weirdly generalized for the two distinct cases
> and the loop seems unnecessary. When adding a symbol at the end, just
> use elf_newdata(). When adding a symbol in the middle, the hole should
> be in the first data block.

Then I went for a bike ride and realized that if adding enough section
symbols to a file which didn't have very many non-locals, the hole might
occur in a later data block.

So yeah, this looks fine :-)

Another idea I had was to forego elf_newdata() entirely in favor of just
rewriting the original data block every time. But this is also fine.

--
Josh

\
 
 \ /
  Last update: 2022-05-18 19:19    [W:0.076 / U:0.828 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site