On Tue, 22 Jan 2013 19:19:04 +0100, Mark Wielaard wrote:
> On Tue, Jan 22, 2013 at 06:28:03PM +0100, Jan Kratochvil wrote:
> > On Tue, 22 Jan 2013 18:03:26 +0100, Mark Wielaard wrote:
> > >   int first_global = mod->first_global;
> > >   if (first_global > 0 && mod->aux_symdata != NULL)
> > >     first_global += mod->aux_first_global - 1;
> > >   search_table (first_global == 0 ? 1 : first_global, syments);
> > 
> > This is OK as long as there cannot happen:
> >     mod->first_global == 0 && mod->aux_symdata != NULL
> >     and therefore also:       mod->aux_first_global > 0
> 
> If that happens then first_global = 0. Which means we just don't know
> where the first global is in the table. And so we will just search the
> whole table (1, syments). That means we just don't do the optimization

It has functionality impact, that means we will ignore the first global symbol
of minidebuginfo as search_table will be called with (1, syments) as you say
but in such case symbol #0 is a valid one - from minidebuginfo (shifted to
number #1 there).

The later call to search even local symbols
        search_table (1, first_global);

will again ignore the first entry of minidebuginfo (either local or global
one).


> BTW. I don't think this will ever happen since for first_global = 0
> we must have found the dynsym table through the phdrs and so most
> likely there are no shdrs. Without shdrs we won't be able to find the
> auxiliary table.

Yes, and this is a bug.  In the testcase below are perfectly valid shdrs.

1003            case DWFL_E_NO_SYMTAB:
1004              if (symscn != NULL)
1005                {
1006                  /* We still have the dynamic symbol table.  */
1007                  mod->symerr = DWFL_E_NOERROR;
1008    
1009                  /* The dynsym table might be extended by an auxiliary 
table.  */
1010                  find_aux_sym (mod, &aux_symscn, &aux_xndxscn, 
&aux_strshndx);
1011                  break;
1012                }

minidebuginfo may exist even if there is no .symtab/.dynsym and therefore
SYMSCN == NULL.

Attached such example.

echo 'int main (void) { return 0; }' >3.c
gcc -o 3 3.c -Wall -static -s
objcopy --add-section 
.gnu_debugdata=/path/to/gdb/testsuite/gdb.base/gnu-debugdata.mini_debuginfo.xz 3

GDB in such cas displays symbols from minidebuginfo correctly (it complains
a bit as this testcase is unclean but the purpose works).

But dwfl_module_getsymtab() returns 0.

http://people.redhat.com/jkratoch/3.gz


Thanks,
Jan
_______________________________________________
elfutils-devel mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/elfutils-devel

Reply via email to