[PATCH] lto: fix LTO debug sections copying.

Jakub Jelinek jakub@redhat.com
Tue Oct 6 14:23:27 GMT 2020


On Tue, Oct 06, 2020 at 12:20:14PM +0200, Martin Liška wrote:
> On 10/6/20 10:00 AM, Richard Biener wrote:
> > On Tue, Oct 6, 2020 at 9:01 AM Martin Liška <mliska@suse.cz> wrote:
> > > 
> > > On 10/5/20 6:34 PM, Ian Lance Taylor wrote:
> > > > On Mon, Oct 5, 2020 at 9:09 AM Martin Liška <mliska@suse.cz> wrote:
> > > > > 
> > > > > The previous patch was not correct. This one should be.
> > > > > 
> > > > > Ready for master?
> > > > 
> > > > I don't understand why this code uses symtab_indices_shndx at all.
> > > > There should only be one SHT_SYMTAB_SHNDX section.  There shouldn't be
> > > > any need for the symtab_indices_shndx vector.
> > > 
> > > Well, the question is if we can have multiple .symtab sections in one ELF
> > > file? Theoretically yes, so we should also handle SHT_SYMTAB_SHNDX sections.
> > > Note that the original usage of the SHT_SYMTAB_SHNDX section was motivated
> > > by PR81968 which is about Solaris ld.
> > 
> > It wasn't my code but I suppose this way the implementation was
> > "easiest".  There
> > should be exactly one symtab / shndx section.  Rainer authored this support.
> 
> If we expect at maximum one SHT_SYMTAB_SHNDX section section, then I'm suggesting
> an updated version of the patch. It's what Ian offered.

gABI says on
SHT_SYMTAB/SHT_DYNSYM:
Currently, an object file may have only one section of each type, but this restriction may be relaxed in the future.
SHT_SYMTAB_SHNDX:
This section is associated with a symbol table section and is required if any of the section header indexes referenced by that symbol table contain the escape value SHN_XINDEX.
So, I guess only at most one SHT_SYMTAB_SHNDX can appear in ET_REL objects
which we are talking about, and at most two SHT_SYMTAB_SHNDX in
ET_EXEC/ET_DYN (though only in the very unlikely case that the binary/dso
contains more than 65536-epsilon sections and both .symtab and .dynsym need
to refer to those.  One would need to play with linker scripts to convince
ld.bfd to create many sections in ET_EXEC/ET_DYN.

	Jakub



More information about the Gcc-patches mailing list