tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] debug info broken


From: grischka
Subject: Re: [Tinycc-devel] debug info broken
Date: Thu, 28 Dec 2017 18:41:31 +0100
User-agent: Thunderbird 2.0.0.23 (Windows/20090812)

grischka wrote:
But why, as the comment suggests, some versions of GDB work better if
dwarf info is broken remains a mystery to me.  Maybe these won't
load stabs if dwarf is ok.

If it were me I'd still just remove that "&& (s->sh_flags & SHF_ALLOC))".

Ok, I was able to reproduce the original problem on an suse 10.2
from 2007.

It is that in debug mode, tcc includes all sections in the image,
that is also reloc sections that already have been applied. See:

alloc_sec_names():
        } else if (s1->do_debug ||
            file_type == TCC_OUTPUT_OBJ ||
            (s->sh_flags & SHF_ALLOC) ||
            i == (s1->nb_sections - 1)) {
            /* we output all sections if debug or object file */
            s->sh_size = s->data_offset;

Now on that system it seems that the gdb (6.5) if it finds these
relocations, it will apply them to the dwarf info and this actually
properly works, except that it doesn't work at all if the same
relocations were applied by tcc already. See

final_sections_reloc():
        if (s->reloc && s != s1->got) // && (s->sh_flags & SHF_ALLOC))
            relocate_section(s1, s);

Tested with using tcc as a linker for objects from gcc:
    $ ./configure && make
    $ ./tcc -B. -g *.o -ldl && gdb a.out

On other systems however gdb doesn't act like that, which means that
tcc must apply the dwarf relocation itself always.

In any case, the proper fix for this is probably:
- relocate dwarf in tcc : always
- write relocations to file : never (except for dynsym of course)

Which is what gcc seems to do too.

-- grischka




reply via email to

[Prev in Thread] Current Thread [Next in Thread]