From: mengqinggang <mengqinggang@loongson.cn>
To: Xi Ruoyao <xry111@xry111.site>, 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:40:19 +0800 [thread overview]
Message-ID: <dbd6e191-0647-a371-9ea7-6bb63160dcba@loongson.cn> (raw)
In-Reply-To: <bb695c50e6eca47e46c450ddbb4d64f21e6b4ec0.camel@xry111.site>
We will send a patch to fix this and some other questions today.
在 2024/1/26 下午4:19, Xi Ruoyao 写道:
> 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
>>
>>
next prev parent reply other threads:[~2024-01-26 8:40 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
2024-01-26 8:40 ` mengqinggang [this message]
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=dbd6e191-0647-a371-9ea7-6bb63160dcba@loongson.cn \
--to=mengqinggang@loongson.cn \
--cc=binutils@sourceware.org \
--cc=nickc@redhat.com \
--cc=xry111@xry111.site \
/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).