[PATCH] Re: Don't relax undefined symbols on ppc.

Douglas B Rupp rupp@adacore.com
Tue Jul 24 04:20:00 GMT 2018


While I was working in gdb trying to figure this out I noted that 
abfd->filename contained the name of the input object, so I believe your 
contention that abfd is a constant cannot be correct.

I'm assuming then that toff, which is indeed the symbol index, must be 
the index w.r.t. the symbols in the input object, leading to the 
uniqueness problem.

--Doug

On 07/23/2018 08:03 PM, Douglas B Rupp wrote:
> 
> 
> On 07/23/2018 07:01 PM, Alan Modra wrote:
>> On Mon, Jul 23, 2018 at 07:38:44AM -0700, Douglas B Rupp wrote:
>>>
>>>
>>> On 07/09/2018 06:27 PM, Alan Modra wrote:
>>>> On Mon, Jul 09, 2018 at 01:58:33PM -0700, Douglas B Rupp wrote:
>>>>> There is a problem with --relax in the partial link trying to relax 
>>>>> the
>>>>> undefined symbols, leading to the RTP failing at startup with 
>>>>> signal 11.
>>>>
>>>> Please describe the problem in detail.  ld -r --relax non-pic is
>>>> supposed to work for ppc32, with a branch to an undefined symbol being
>>>> resolved to a trampoline which has relocations to the symbol.  Are the
>>>> emitted relocations wrong?
>>>>
>>>>> I solicit comments on the attached patch, which causes undefined 
>>>>> symbols to
>>>>> be ignored during the relax process.  Leaving them to be relaxed and
>>>>> resolved during the final link.
>>>>
>>>> If ld -r mashes together sections such that the resulting output
>>>> section size exceeds the reach of a branch, then it may not be
>>>> possible to for branches to reach trampolines placed at the end of the
>>>> section.  That's the problem ld -r --relax is trying to solve, by
>>>> placing trampolines at the end of each input section.
>>>>
>>>
>>> The problem is that "tsec" is the undefined section and basically a 
>>> no-op in
>>> the following line, so existing trampolines are found when they 
>>> shouldn't be
>>> found.
>>>
>>> elf32-ppc.c: if (f->tsec == tsec && f->toff == toff)
>>
>> But for undefined syms and relocatable linking, toff is the symbol
>> index.  Or at least it is supposed to be.  I do see a bug where the
>> reloc addend could be added to toff, but that is unlikely to trigger.
>>
>>>
>>> The attached patch fixes it.
>>
>> I don't see how adding "abfd" to the branch fixup struct can possibly
>> help.  "abfd" is a constant for any one invocation of
>> ppc_elf_relax_section!
>>
> 
> I don't know what to tell you, it does fix the problem.
> I can take another look at it at some future date and try to provide 
> more detail.
> --Doug
> 



More information about the Binutils mailing list