public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "yanzhang.wang at intel dot com" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug dynamic-link/31317] [RISCV] static PIE crashes during self relocation
Date: Fri, 23 Feb 2024 03:06:56 +0000	[thread overview]
Message-ID: <bug-31317-131-djQk3CZ9Hs@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-31317-131@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=31317

--- Comment #6 from Wang, Yanzhang <yanzhang.wang at intel dot com> ---
I think the l_relocated is enough too.

I have did some investigation about this in the GNU ld and mold. If I
understand  correctly, the mold will fill the relocated field if the command
option --apply-dynamic-relocs is true, whose default value is true.

But for GNU ld, this is ignored and skipped at
elfnn-riscv.c:riscv_elf_relocate_section

              sreloc = elf_section_data (input_section)->sreloc;
              riscv_elf_append_rela (output_bfd, sreloc, &outrel);
              if (!relocate)
                continue;

Although the relative rel has been computed but the relocate is true, so we do
nothing.

It seems this is not defined explicit somewhere and all the two different
behaviors seems right.

For this case, the l_scope in dl_main_map is a pointer and need relocate. In
the mold linker, the value in relocated field will be the value of global
dl_main_map's location. But in GNU ld, the value will be 0.

So we need only to use the l_relocated, it's a value which will not be relocaed
and will be set at the end of _dl_relocate_static_pie.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  parent reply	other threads:[~2024-02-23  3:06 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-30 13:25 [Bug dynamic-link/31317] New: " schwab@linux-m68k.org
2024-02-22 18:44 ` [Bug dynamic-link/31317] " palmer at gcc dot gnu.org
2024-02-22 21:47 ` schwab@linux-m68k.org
2024-02-22 22:53 ` palmer at gcc dot gnu.org
2024-02-22 23:01 ` vineet.gupta at linux dot dev
2024-02-22 23:16 ` schwab@linux-m68k.org
2024-02-22 23:26 ` palmer at gcc dot gnu.org
2024-02-23  3:06 ` yanzhang.wang at intel dot com [this message]
2024-03-06 14:44 ` rjones at redhat dot com
2024-03-25 14:20 ` cvs-commit at gcc dot gnu.org
2024-03-26 13:47 ` schwab@linux-m68k.org

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=bug-31317-131-djQk3CZ9Hs@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sourceware.org \
    /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).