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

liuzhensong liuzhensong@loongson.cn
Thu Sep 1 02:09:16 GMT 2022


在 2022/9/1 上午9:41, Xi Ruoyao 写道:
> 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?
https://maskray.me/blog/2021-01-09-copy-relocations-canonical-plt-entries-and-protected



More information about the Binutils mailing list