public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Xi Ruoyao <xry111@xry111.site>
To: binutils@sourceware.org
Cc: liuzhensong <liuzhensong@loongson.cn>,
	Lulu Cheng <chenglulu@loongson.cn>, Wang Xuerui <i@xen0n.name>,
	Chenghua Xu <xuchenghua@loongson.cn>,
	Xi Ruoyao <xry111@xry111.site>
Subject: [PATCH v2 0/2] Fix two bugs breaking IFUNC in static PIE
Date: Tue, 20 Sep 2022 14:09:28 +0800	[thread overview]
Message-ID: <20220920060930.33357-1-xry111@xry111.site> (raw)

To generate a static PIE, the compiler should pass "-static -pie
--no-dynamic-linker -z text" options to the linker [1].  But, LoongArch
BFD linker currently produces wrong result (missing R_LARCH_IRELATIVE
relocs) with IFUNC and those options, causing test failures in Glibc if
static PIE is enabled.  Fix them now.

For the detailed analysis of the bugs see the commit messages.

Changes v1 -> v2:

- Stop writing into GOT for local ifunc.
- Add a test case for R_LARCH_IRELATIVE insertion.

[1]: https://gcc.gnu.org/r13-2728

Xi Ruoyao (2):
  LoongArch: Don't write into GOT for local ifunc
  LoongArch: Fix R_LARCH_IRELATIVE insertion after elf_link_sort_relocs

 bfd/elfnn-loongarch.c                         | 46 +++++++++++--------
 .../ld-loongarch-elf/ld-loongarch-elf.exp     |  1 +
 .../ld-loongarch-elf/local-ifunc-reloc.d      | 12 +++++
 .../ld-loongarch-elf/local-ifunc-reloc.s      | 28 +++++++++++
 4 files changed, 68 insertions(+), 19 deletions(-)
 create mode 100644 ld/testsuite/ld-loongarch-elf/local-ifunc-reloc.d
 create mode 100644 ld/testsuite/ld-loongarch-elf/local-ifunc-reloc.s

-- 
2.37.0


             reply	other threads:[~2022-09-20  6:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-20  6:09 Xi Ruoyao [this message]
2022-09-20  6:09 ` [PATCH v2 1/2] LoongArch: Don't write into GOT for local ifunc Xi Ruoyao
2022-09-20  6:09 ` [PATCH v2 2/2] LoongArch: Fix R_LARCH_IRELATIVE insertion after elf_link_sort_relocs Xi Ruoyao
2022-09-20  9:29 ` [PATCH v2 0/2] Fix two bugs breaking IFUNC in static PIE liuzhensong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220920060930.33357-1-xry111@xry111.site \
    --to=xry111@xry111.site \
    --cc=binutils@sourceware.org \
    --cc=chenglulu@loongson.cn \
    --cc=i@xen0n.name \
    --cc=liuzhensong@loongson.cn \
    --cc=xuchenghua@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).