From: Xi Ruoyao <xry111@xry111.site>
To: mengqinggang <mengqinggang@loongson.cn>, binutils@sourceware.org
Cc: Nick Clifton <nickc@redhat.com>
Subject: Re: [PATCH] LoongArch: Disallow TLS transition when a section contains TLS_IE64 or TLS_DESC64 reloc
Date: Fri, 26 Jan 2024 16:19:58 +0800 [thread overview]
Message-ID: <bb695c50e6eca47e46c450ddbb4d64f21e6b4ec0.camel@xry111.site> (raw)
In-Reply-To: <bd603d7d4671f39c97e3b34c21529af6d426d02e.camel@xry111.site>
On Fri, 2024-01-26 at 16:12 +0800, Xi Ruoyao wrote:
> On Fri, 2024-01-26 at 09:43 +0800, mengqinggang wrote:
> > Hi,
> >
> > For TLS transition, we want to change to that the instructions that can be
> > converted must have a R_LARCH_RELAX relocation.
So we need something like
diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c
index b62bb424644..63aa7e254b5 100644
--- a/bfd/elfnn-loongarch.c
+++ b/bfd/elfnn-loongarch.c
@@ -818,7 +818,10 @@ loongarch_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
int need_dynreloc = 0;
int only_need_pcrel = 0;
- r_type = loongarch_tls_transition (info, r_type, h, abfd, r_symndx);
+ if (rel + 1 != relocs + sec->reloc_count
+ && ELFNN_R_TYPE (rel[1].r_info) == R_LARCH_RELAX)
+ r_type = loongarch_tls_transition (info, r_type, h, abfd, r_symndx);
+
switch (r_type)
{
case R_LARCH_GOT_PC_HI20:
@@ -2789,7 +2792,12 @@ loongarch_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
BFD_ASSERT (!resolved_local || defined_local);
- relaxed_r_type = loongarch_tls_transition (info, r_type, h, input_bfd, r_symndx);
+ relaxed_r_type = r_type;
+ if (rel + 1 != relend
+ && ELFNN_R_TYPE (rel[1].r_info) == R_LARCH_RELAX)
+ relaxed_r_type = loongarch_tls_transition (info, r_type, h,
+ input_bfd, r_symndx);
+
if (relaxed_r_type != r_type)
{
howto = loongarch_elf_rtype_to_howto (input_bfd, relaxed_r_type);
and this is missing in the master branch?
> > After 32ee2b4b71c78d3dc0c0b1f87f25fe5df8786b71 commit, the gas not
> > emit R_LARCH_RELAX for two register macros.
>
> But with master branch at e14f7abaf81d5d0aa7898570024286de8c188817:
>
> $ cat t.s
> .globl _start
> _start:
> la.tls.ie $a0, $a1, foo
>
> .section .tdata
> foo: .word 114514
> $ gas/as-new t.s -o t.o
> $ ld/ld-new t.o
> [1] 7202 segmentation fault (core dumped) ld/ld-new t.o
>
>
--
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University
next prev parent reply other threads:[~2024-01-26 8:20 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-25 13:36 Xi Ruoyao
2024-01-25 13:49 ` Nick Clifton
2024-01-25 13:52 ` Xi Ruoyao
2024-01-26 1:43 ` mengqinggang
2024-01-26 8:12 ` Xi Ruoyao
2024-01-26 8:19 ` Xi Ruoyao [this message]
2024-01-26 8:40 ` mengqinggang
2024-01-26 9:45 ` Xi Ruoyao
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=bb695c50e6eca47e46c450ddbb4d64f21e6b4ec0.camel@xry111.site \
--to=xry111@xry111.site \
--cc=binutils@sourceware.org \
--cc=mengqinggang@loongson.cn \
--cc=nickc@redhat.com \
/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).