[PATCH] LoongArch: Use copy relocation for %pc_lo12 against external symbol

Fangrui Song i@maskray.me
Thu Sep 1 07:42:28 GMT 2022


On 2022-09-01, Xi Ruoyao via Binutils wrote:
>On Thu, 2022-09-01 at 09:27 +0800, liuzhensong wrote:
>
>> The R_LARCH_COPY is supported in older versions, we removed this
>> feature and are not going to support.
>
>Hmm, then for
>
>extern int x;
>int f() { return x; }
>
>it will produce a GOT access.  If x is in another TU but not in a shared
>library, such a GOT access and the GOT entry is unneeded.
>
>This will be really a pain for situations like building an OS kernel, or
>with -static or -static-pie.  Even for this simple example, there is no
>way to tell "x" is not in a shared library (maybe, expect LTO or linker
>relaxation, but IIRC LTO or relaxation do not *guarantee* to avoid the
>GOT, just "try to" avoid the GOT).
>
>So is there any serious reason forbidding us from using R_LARCH_COPY? Or
>any options for this "unneeded GOT" issue?
>-- 
>Xi Ruoyao <xry111@xry111.site>
>School of Aerospace Science and Technology, Xidian University

There is a slow trend to eliminate copy relocations for ELF platforms.
If a new port doesn't have copy relocations, leave it.

An architecture can add GOT indirection to PC-relative addressing
optimization if desired.


More information about the Binutils mailing list