diff options
author | Xi Ruoyao <xry111@xry111.site> | 2023-12-06 03:05:47 +0800 |
---|---|---|
committer | liuzhensong <liuzhensong@loongson.cn> | 2023-12-19 15:42:20 +0800 |
commit | 15aacf324fb871871e2162ea8769a9f82c043909 (patch) | |
tree | a4f12f3eadd776c3b7b8cc5a42206edceba004f0 /elfcpp | |
parent | b3fa92f12a83d284db3124e0992e15d1ff31a3d8 (diff) | |
download | gdb-15aacf324fb871871e2162ea8769a9f82c043909.zip gdb-15aacf324fb871871e2162ea8769a9f82c043909.tar.gz gdb-15aacf324fb871871e2162ea8769a9f82c043909.tar.bz2 |
LoongArch: Allow la.got -> la.pcrel relaxation for shared object
Even in shared objects, la.got -> la.pcrel relaxation can still be
performed for symbols with hidden visibility. For example, if a.c is:
extern int x;
int f() { return x++; }
and b.c is:
int x = 114514;
If compiling and linking with:
gcc -shared -fPIC -O2 -fvisibility=hidden a.c b.c
Then the la.got in a.o should be relaxed to la.pcrel, and the resulted f
should be like:
pcaddi $t0, x
ldptr.w $a0, $t0, 0
addi.w $t1, $a0, 1
stptr.w $t1, $t0, 0
ret
Remove bfd_link_executable from the condition of la.got -> la.pcrel
relaxation so this will really happen. The SYMBOL_REFERENCES_LOCAL
check is enough not to wrongly relax preemptable symbols (for e.g.
when -fvisibility=hidden is not used).
Note that on x86_64 this is also relaxed and the produced code is like:
lea x(%rip), %rdx
mov (%rdx), %rax
lea 1(%rax), %ecx
mov %ecx, (%rdx)
ret
Tested by running ld test suite, bootstrapping and regtesting GCC with
the patched ld, and building and testing Glibc with the patched ld. No
regression is observed.
Signed-off-by: Xi Ruoyao <xry111@xry111.site>
Diffstat (limited to 'elfcpp')
0 files changed, 0 insertions, 0 deletions