* [PATCH] LoongArch: ld: Fix hidden ifunc symbol linker error bug.
@ 2023-01-09 8:35 mengqinggang
0 siblings, 0 replies; only message in thread
From: mengqinggang @ 2023-01-09 8:35 UTC (permalink / raw)
To: binutils
Cc: xuchenghua, liuzhensong, chenglulu, caiyinyu, xry111, i.swmail,
maskray, joseph, mengqinggang
For hidden ifunc symbols, it not have GOT entry, only have gotplt entry. When
process R_LARCH_SOP_PUSH_GPREL, the offset is gotplt entry address minus GOT
address. When call bfd_put_NN(got->contents + offset), the absolute value of
offset is grather than got size, and other memory not belonging to GOT is be
overwritten.
bfd/ChangeLog:
* elfnn-loongarch.c (loongarch_elf_relocate_section): If hidden ifunc
symbol, don't call bfd_put_NN.
---
bfd/elfnn-loongarch.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c
index fafdc7c7458..449fad6d25d 100644
--- a/bfd/elfnn-loongarch.c
+++ b/bfd/elfnn-loongarch.c
@@ -2502,7 +2502,10 @@ loongarch_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
if ((off & 1) != 0)
off &= ~1;
- else
+ /* If h has processed (h->got.offset |= 1) or h is hideen
+ ifunc (h->got.offset == -1), skip it. Hidden ifunc symbol
+ not has got entry, only has got.plt entry. */
+ else if ((h->got.offset & 1) == 0)
{
/* The pr21964-4. Create relocate entry. */
if (is_pic && h->start_stop)
--
2.36.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-01-09 8:35 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-09 8:35 [PATCH] LoongArch: ld: Fix hidden ifunc symbol linker error bug mengqinggang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).