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 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.

> > elf_create_section_symbol(struct elf *elf, struct section *sec)
> > {
> > struct section *symtab, *symtab_shndx;
> > - Elf_Data *shndx_data = NULL;
> > - struct symbol *sym;
> > - Elf32_Word shndx;
> > + Elf32_Word first_non_local, new;
> > + struct symbol *sym, *old;
> > + int size;
> > +
> > + if (elf->ehdr.e_ident[EI_CLASS] == ELFCLASS32)
> > + size = sizeof(Elf32_Sym);
> > + else
> > + size = sizeof(Elf64_Sym);
>
> This should probably be called 'entsize' and I think you can just get it
> from symtab->sh.sh_entsize.

Ok, that would be easier, I'll check.

> > + /*
> > + * Either way, we added a LOCAL symbol.
> > + */
> > + symtab->sh.sh_info += 1;
> > +
> > elf_add_symbol(elf, sym);
>
> Not sure if it matters here, but elf_add_symbol() doesn't set sym->alias
> and sym->pv_target, and both of those are unconditionally initialized in
> read_symbols(). Should elf_add_symbol() be changed to initialize them?

I'll go have a look, breakfast first though! :-)

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