public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Lulu Cai <cailulu@loongson.cn>
To: Xi Ruoyao <xry111@xry111.site>, binutils@sourceware.org
Cc: xuchenghua@loongson.cn, chenglulu@loongson.cn,
	liuzhensong@loongson.cn, mengqinggang@loongson.cn,
	i.swmail@xen0n.name, maskray@google.com, luweining@loongson.cn,
	wanglei@loongson.cn, hejinyang@loongson.cn
Subject: Re: [PATCH 1/2] LoongArch: Delete extra instructions when TLS type transition
Date: Sat, 27 Jan 2024 10:06:57 +0800	[thread overview]
Message-ID: <60e6e56c-385f-ee4f-ff74-90cf0b9e753d@loongson.cn> (raw)
In-Reply-To: <f75d5c73fb178517863368bb684f763d9d6a9a94.camel@xry111.site>

On 1/27/24 2:22 AM, Xi Ruoyao wrote:
> On Fri, 2024-01-26 at 21:55 +0800, Lulu Cai wrote:
>> This modification mainly changes the timing of type transition,
>> adds relaxation to the old LE instruction sequence, and fixes
>> bugs in extreme code models.
> I'd suggest to separate the bug fixes (requiring R_LARCH_RELAX for DESC
> and IE transition) out into one separate commit and apply it for 2.42.
> And the old LE relaxation & instruction deletion should be only applied
> for trunk (2.43).  We are just toooooo close to the 2.42 release, and
> deleting instructions is always "dangerous" even if we do it very
> carefully.
>
> /* snip */


Thanks for reminding. I will send a new patch with a separate bug fix later.


>> +loongarch_can_trans_tls (bfd *input_bfd,
>> +			 struct bfd_link_info *info,
>> +			 struct elf_link_hash_entry *h,
>> +			 const Elf_Internal_Rela *rel,
>> +			 unsigned int r_type)
>>   {
>>     char symbol_tls_type;
>>     unsigned int reloc_got_type;
>> +  unsigned int r_symndx = ELFNN_R_SYM (rel->r_info);
>>   
>> -  if (! (IS_LOONGARCH_TLS_DESC_RELOC (r_type)
>> -	 || IS_LOONGARCH_TLS_IE_RELOC (r_type)))
>> +  /* Only TLS DESC/IE in normal code mode will perform type
>> +     transition.  */
>> +  if (! (IS_LOONGARCH_TLS_TRANS_RELOC (r_type)
>> +	  && ELFNN_R_TYPE ((rel + 1)->r_info) == R_LARCH_RELAX))
> We need to check if rel is the last relocation of the section, or rel +
> 1 may be an OOB read.
>

Agreed, I will pay attention to these later.


>>   static bool
>>   loongarch_relax_tls_le (bfd *abfd, asection *sec,
>> @@ -4165,31 +4198,56 @@ loongarch_relax_tls_le (bfd *abfd, asection *sec,
>>     uint32_t insn = bfd_get (32, abfd, contents + rel->r_offset);
>>     static uint32_t insn_rj,insn_rd;
>>     symval = symval - elf_hash_table (link_info)->tls_sec->vma;
>> -  /* Whether the symbol offset is in the interval (offset < 0x800).  */
>> -  if (ELFNN_R_TYPE ((rel + 1)->r_info == R_LARCH_RELAX) && (symval < 0x800))
>> +  /* The old LE instruction sequence can be relaxed when the symbol offset
>> +     is smaller than the 12-bit range.  */
>> +  if (ELFNN_R_TYPE ((rel + 1)->r_info) == R_LARCH_RELAX && (symval <= 0xfff))
> Likewise.
>


      reply	other threads:[~2024-01-27  2:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-26 13:55 Lulu Cai
2024-01-26 13:55 ` [PATCH 2/2] LoongArch: Fix some test cases for TLS transition and relax Lulu Cai
2024-01-26 18:22 ` [PATCH 1/2] LoongArch: Delete extra instructions when TLS type transition Xi Ruoyao
2024-01-27  2:06   ` Lulu Cai [this message]

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=60e6e56c-385f-ee4f-ff74-90cf0b9e753d@loongson.cn \
    --to=cailulu@loongson.cn \
    --cc=binutils@sourceware.org \
    --cc=chenglulu@loongson.cn \
    --cc=hejinyang@loongson.cn \
    --cc=i.swmail@xen0n.name \
    --cc=liuzhensong@loongson.cn \
    --cc=luweining@loongson.cn \
    --cc=maskray@google.com \
    --cc=mengqinggang@loongson.cn \
    --cc=wanglei@loongson.cn \
    --cc=xry111@xry111.site \
    --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).