public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: 刘振松 <liuzhensong@loongson.cn>
To: "Xi Ruoyao" <xry111@xry111.site>
Cc: binutils@sourceware.org, xuchenghua@loongson.cn,
	 mengqinggang@loongson.cn, "WANG Xuerui" <i.swmail@xen0n.name>
Subject: Re: Re: [PATCH 1/5 v1] LoongArch: bfd: Add new reloc types.
Date: Tue, 19 Jul 2022 14:31:23 +0800 (GMT+08:00)	[thread overview]
Message-ID: <604275f7.62a5.18215277298.Coremail.liuzhensong@loongson.cn> (raw)
In-Reply-To: <46caab90f1c0dd619ce2d609ba7038dd8ca8e179.camel@xry111.site>




&gt; -----原始邮件-----
&gt; 发件人: "Xi Ruoyao" <xry111@xry111.site>
&gt; 发送时间: 2022-07-19 13:40:02 (星期二)
&gt; 收件人: liuzhensong <liuzhensong@loongson.cn>, binutils@sourceware.org
&gt; 抄送: xuchenghua@loongson.cn, mengqinggang@loongson.cn, "WANG Xuerui" <i.swmail@xen0n.name>
&gt; 主题: Re: [PATCH 1/5 v1] LoongArch: bfd: Add new reloc types.
&gt; 
&gt; On Tue, 2022-07-19 at 12:29 +0800, Xi Ruoyao via Binutils wrote:
&gt; &gt; On Mon, 2022-07-18 at 16:43 +0800, liuzhensong wrote:
&gt; &gt; &gt; @@ -2427,7 +2453,7 @@ loongarch_elf_relocate_section (bfd
&gt; &gt; &gt; *output_bfd,
&gt; &gt; &gt; struct bfd_link_info *info,
&gt; &gt; &gt; &nbsp;
&gt; &gt; &gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (h != NULL)
&gt; &gt; &gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {
&gt; &gt; &gt; -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; off = h-&gt;got.offset;
&gt; &gt; &gt; +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; off = h-&gt;got.offset &amp; (~1);
&gt; &gt; &gt; &nbsp;
&gt; &gt; &gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (off == MINUS_ONE
&gt; &gt; &gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &amp;&amp; h-&gt;type != STT_GNU_IFUNC)
&gt; &gt; &gt; @@ -2455,79 +2481,76 @@ loongarch_elf_relocate_section (bfd
&gt; &gt; &gt; *output_bfd, struct bfd_link_info *info,
&gt; &gt; 
&gt; &gt; This cannot be correct: after "off = h-&gt;got.offset &amp; (~1)", how could
&gt; &gt; "off == MINUS_ONE" be true?
&gt; &gt; 
&gt; &gt; Either you calculated "off" wrong, or you should remove the dead code.
&gt; 
&gt; I guess you need the following changes.  With those changes Glibc ifunc
&gt; tests passed:
&gt; 
&gt; diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c
&gt; index 44b8d6dca9b..4d22ba037c8 100644
&gt; --- a/bfd/elfnn-loongarch.c
&gt; +++ b/bfd/elfnn-loongarch.c
&gt; @@ -2730,7 +2730,7 @@ loongarch_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
&gt;  	    {
&gt;  	      off = h-&gt;got.offset &amp; (~1);
&gt;  
&gt; -	      if (off == MINUS_ONE
&gt; +	      if (h-&gt;got.offset == MINUS_ONE
&gt;  		  &amp;&amp; h-&gt;type != STT_GNU_IFUNC)
&gt;  		{
&gt;  		  fatal = (loongarch_reloc_is_fatal
&gt; @@ -2742,7 +2742,7 @@ loongarch_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
&gt;  
&gt;  	      /* Hidden symbol not has .got entry, only .got.plt entry
&gt;  		 so gprel is (plt - got).  */
&gt; -	      if (off == MINUS_ONE
&gt; +	      if (h-&gt;got.offset == MINUS_ONE
&gt;  		  &amp;&amp; h-&gt;type == STT_GNU_IFUNC)
&gt;  		{
&gt;  		  if (h-&gt;plt.offset == (bfd_vma) -1)
&gt; 
&gt; -- 
&gt; Xi Ruoyao <xry111@xry111.site>
&gt; School of Aerospace Science and Technology, Xidian University

Thanks for reviews.

Your modification is correct, this code valid for R_LARCH_SOP_PUSH_GPREL.
I have tested glibc testcases, there is no failed testcase about ifunc, does your environment generate new relocations?

Results of glibc with test args "make check subdirs=elf".
UNSUPPORTED: elf/tst-env-setuid
UNSUPPORTED: elf/tst-env-setuid-tunables
XPASS: elf/tst-protected1a
XPASS: elf/tst-protected1b
UNSUPPORTED: elf/tst-valgrind-smoke
Summary of test results:
    312 PASS
      3 UNSUPPORTED
      2 XPASS</xry111@xry111.site></i.swmail@xen0n.name></liuzhensong@loongson.cn></xry111@xry111.site>

本邮件及其附件含有龙芯中科的商业秘密信息,仅限于发送给上面地址中列出的个人或群组。禁止任何其他人以任何形式使用(包括但不限于全部或部分地泄露、复制或散发)本邮件及其附件中的信息。如果您错收本邮件,请您立即电话或邮件通知发件人并删除本邮件。 
This email and its attachments contain confidential information from Loongson Technology , which is intended only for the person or entity whose address is listed above. Any use of the information contained herein in any way (including, but not limited to, total or partial disclosure, reproduction or dissemination) by persons other than the intended recipient(s) is prohibited. If you receive this email in error, please notify the sender by phone or email immediately and delete it. 

  reply	other threads:[~2022-07-19  6:31 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-18  8:43 liuzhensong
2022-07-18  8:43 ` [PATCH 2/5 v1] LoongArch:opcodes: " liuzhensong
2022-07-18  8:43 ` [PATCH 3/5 v1] LoongArch: gas: " liuzhensong
2022-07-18  8:43 ` [PATCH 4/5 v1] LoongArch: Move ifunc info to rela.dyn from rela.plt liuzhensong
2022-07-18 11:45   ` Xi Ruoyao
2022-07-18 16:27   ` Xi Ruoyao
2022-07-19  7:26     ` liuzhensong
2022-07-18  8:43 ` [PATCH 5/5 v1] LoongArch: Delete R_LARCH_NONE from dynamic info liuzhensong
2022-07-18 10:06 ` [PATCH 1/5 v1] LoongArch: bfd: Add new reloc types WANG Xuerui
2022-07-18 11:33   ` Xi Ruoyao
2022-07-18 12:11     ` WANG Xuerui
2022-07-18 12:18       ` WANG Xuerui
2022-07-19  3:57       ` Fangrui Song
2022-07-20  7:47         ` liuzhensong
2022-07-20  2:07       ` liuzhensong
2022-07-20  4:03         ` WANG Xuerui
2022-07-20  5:19           ` Xi Ruoyao
2022-07-20 12:54           ` liuzhensong
2022-07-19  7:32   ` liuzhensong
2022-07-20  2:42   ` liuzhensong
2022-07-19  4:29 ` Xi Ruoyao
2022-07-19  5:40   ` Xi Ruoyao
2022-07-19  6:31     ` 刘振松 [this message]
2022-07-19  6:34       ` 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=604275f7.62a5.18215277298.Coremail.liuzhensong@loongson.cn \
    --to=liuzhensong@loongson.cn \
    --cc=binutils@sourceware.org \
    --cc=i.swmail@xen0n.name \
    --cc=mengqinggang@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).