public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Fangrui Song <maskray@sourceware.org>
To: glibc-cvs@sourceware.org
Subject: [glibc] riscv: Change the relocations handled for RTLD_BOOTSTRAP
Date: Thu, 16 Jun 2022 01:42:06 +0000 (GMT)	[thread overview]
Message-ID: <20220616014206.196093858407@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=57919813e732dff2c6cfd1c95056cbc265058bc2

commit 57919813e732dff2c6cfd1c95056cbc265058bc2
Author: Fangrui Song <maskray@google.com>
Date:   Wed Jun 15 18:42:03 2022 -0700

    riscv: Change the relocations handled for RTLD_BOOTSTRAP
    
    The RTLD_BOOTSTRAP branch is used to relocate ld.so itself.  It only
    needs to handle RELATIVE, GLOB_DAT, and the symbolic relocation type
    (R_RISCV_{32,64}).  NONE and IRELATIVE can be removed.
    
    The code relies on ld.so having DT_RELACOUNT so that the RTLD_BOOTSTRAP
    branch does not need handle RELATIVE.  Drop this minor size
    optimization for clarity.
    
    Acked-by: Palmer Dabbelt <palmer@rivosinc.com>

Diff:
---
 sysdeps/riscv/dl-machine.h | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/sysdeps/riscv/dl-machine.h b/sysdeps/riscv/dl-machine.h
index 9e026ae011..a60a452952 100644
--- a/sysdeps/riscv/dl-machine.h
+++ b/sysdeps/riscv/dl-machine.h
@@ -181,7 +181,15 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[],
 
   switch (r_type)
     {
-#ifndef RTLD_BOOTSTRAP
+    case R_RISCV_RELATIVE:
+      *addr_field = map->l_addr + reloc->r_addend;
+      break;
+    case R_RISCV_JUMP_SLOT:
+    case __WORDSIZE == 64 ? R_RISCV_64 : R_RISCV_32:
+      *addr_field = value;
+      break;
+
+# ifndef RTLD_BOOTSTRAP
     case __WORDSIZE == 64 ? R_RISCV_TLS_DTPMOD64 : R_RISCV_TLS_DTPMOD32:
       if (sym_map)
 	*addr_field = sym_map->l_tls_modid;
@@ -232,13 +240,6 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[],
 	memcpy (reloc_addr, (void *)value, size);
 	break;
       }
-#endif
-
-#if !defined RTLD_BOOTSTRAP
-    case R_RISCV_RELATIVE:
-      *addr_field = map->l_addr + reloc->r_addend;
-      break;
-#endif
 
     case R_RISCV_IRELATIVE:
       value = map->l_addr + reloc->r_addend;
@@ -247,13 +248,9 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[],
       *addr_field = value;
       break;
 
-    case R_RISCV_JUMP_SLOT:
-    case __WORDSIZE == 64 ? R_RISCV_64 : R_RISCV_32:
-      *addr_field = value;
-      break;
-
     case R_RISCV_NONE:
       break;
+# endif /* !RTLD_BOOTSTRAP */
 
     default:
       _dl_reloc_bad_type (map, r_type, 0);


                 reply	other threads:[~2022-06-16  1:42 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20220616014206.196093858407@sourceware.org \
    --to=maskray@sourceware.org \
    --cc=glibc-cvs@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).