[lld] r320286 - PPC32: Support R_PPC_PLTREL32 in static mode.

vit9696 via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 10 15:42:06 PST 2017


Hello,

Thanks for pointing out an interesting specialty regarding lld optimisations. I indeed was unaware of fromPlt, since I only looked into PPC-specific code. I have just checked and can confirm that R_PLT_PC also works fine thanks to that feature.

In this case the code could be even cleaner, and one should be safe to replace R_PC by R_PLT_PC. I do not mind submitting a patch for a review that will replace one thing by the other, but since it is an obvious one-line change (which will somebody have to commit it for me anyway), could you please apply the change right away? I attached the diff to the message.

Best regards,
Vit



> 10 дек. 2017 г., в 22:00, Tim Northover <tnorthover at apple.com> написал(а):
> 
> I was just committing a patch that seemed to have a valid review. You want vit9696 to be involved here. I’ve added him to the thread.
> 
> Tim.
> 
>> On 10 Dec 2017, at 18:58, Rafael Avila de Espindola <rafael.espindola at gmail.com <mailto:rafael.espindola at gmail.com>> wrote:
>> 
>> Tim Northover via llvm-commits <llvm-commits at lists.llvm.org <mailto:llvm-commits at lists.llvm.org>> writes:
>> 
>>> Author: tnorthover
>>> Date: Sun Dec 10 00:42:34 2017
>>> New Revision: 320286
>>> 
>>> URL: http://llvm.org/viewvc/llvm-project?rev=320286&view=rev <http://llvm.org/viewvc/llvm-project?rev=320286&view=rev>
>>> Log:
>>> PPC32: Support R_PPC_PLTREL32 in static mode.
>>> 
>>> See https://reviews.llvm.org/D39226 <https://reviews.llvm.org/D39226>
>>> 
>>> Patch by vit9696 <vit9696 at avp.su <mailto:vit9696 at avp.su>>
>>> 
>>> Modified:
>>>    lld/trunk/ELF/Arch/PPC.cpp
>>>    lld/trunk/test/ELF/ppc-relocs.s
>>> 
>>> Modified: lld/trunk/ELF/Arch/PPC.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Arch/PPC.cpp?rev=320286&r1=320285&r2=320286&view=diff <http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Arch/PPC.cpp?rev=320286&r1=320285&r2=320286&view=diff>
>>> ==============================================================================
>>> --- lld/trunk/ELF/Arch/PPC.cpp (original)
>>> +++ lld/trunk/ELF/Arch/PPC.cpp Sun Dec 10 00:42:34 2017
>>> @@ -34,6 +34,15 @@ RelExpr PPC::getRelExpr(RelType Type, co
>>>   case R_PPC_REL24:
>>>   case R_PPC_REL32:
>>>     return R_PC;
>>> +  // In general case R_PPC_PLTREL24 should result in R_PLT_PC, however, since
>>> +  // PLT support is currently not available for PPC32 this workaround at least
>>> +  // allows lld to resolve local symbols when performing static linkage after
>>> +  // LLVM started to forcibly use PLT relocations by default (see D38554).
>>> +  // Non-local symbols will need a full PLT implementation, but once it lands
>>> +  // local symbols should still avoid PLT table with static relocation model.
>>> +  // This is the optimisation that bfd and gold are doing by default as well.
>>> +  case R_PPC_PLTREL24:
>>> +    return R_PC;
>> 
>> The generic optimization (plt -> pc) is implemented in fromPlt in
>> Relocations.cpp. If the desire is to support only local symbols, this
>> could return R_PLT_PC, no?
>> 
>> Cheers,
>> Rafael
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171211/98206f66/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pltrel.patch
Type: application/octet-stream
Size: 1201 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171211/98206f66/attachment.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171211/98206f66/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Message signed with OpenPGP
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171211/98206f66/attachment.sig>


More information about the llvm-commits mailing list