This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: bug: GOLD handling of Sparc PLTREL
David Miller <davem@davemloft.net> writes:
> From: Ian Lance Taylor <iant@google.com>
> Date: Mon, 08 Feb 2010 21:53:50 -0800
>
>> David Miller <davem@davemloft.net> writes:
>>
>>> Several test cases in GOLD fail on sparc because of how it lays out
>>> the .rela.plt and .rela.dyn sections.
>>>
>>> On Sparc, the .rela.dyn must include .rela.plt in it's range. If this
>>> is not followed, the dynamic linker will reference past the end of the
>>> relocations. This is true on 32-bit PowerPC and 32-bit S390 as well.
>>>
>>> But GOLD isn't doing this, it makes the size of .rela.dyn only include
>>> the .rela.dyn relocs, it doesn't include the .rela.plt reloc size
>>> too.
>>
>> I don't see how this could be a problem, since the only thing the
>> dynamic linker sees are the segments and the dynamic tags. The
>> dynamic linker doesn't see anything about the .rela.dyn or .rela.plt
>> sections.
>
> It is a problem, GLIBC has code which does the following when the
> macro ELF_MACHINE_PLTREL_OVERLAP is defined:
Yes, but to be pedantically clear, the problem there is not that
.rela.dyn and .rela.plt are separate. The problem is that the DT_RELA
dynamic tag does not include the PLT relocations.
>> I see a few calls to add_local_relative and add_global_relative that
>> are not passing down elfcpp::R_SPARC_RELATIVE as the reloc type. That
>> is rather suspicious and seems like it could cause this sort of
>> problem.
>
> It has nothing to do with these crashes.
It is a problem, though, because it will cause DT_RELACOUNT to be
incorrect.
> I'm playng around with the following patch to fix this:
Looks like a reasonable approach. I prefer boolean variables to have
names which read correctly with if, so perhaps dynrel_includes_plt
instead of of pltrel_overlap. Also no need to duplicate the entire
union in Output_data_dynamic.
Another approach would be to in fact put the PLT into the .rela.dyn
output section. That could be done by just changing the call to
layout->add_output_section_data to use .rela.dyn in both SHT_RELA
calls in sparc.cc.
Ian