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] aarch64: Handle fewer relocations for RTLD_BOOTSTRAP
Date: Thu, 16 Jun 2022 02:21:56 +0000 (GMT)	[thread overview]
Message-ID: <20220616022156.585AF3858407@sourceware.org> (raw)

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

commit e89913d0aa36597e5824baec870dfcec525fab1a
Author: Fangrui Song <maskray@google.com>
Date:   Wed Jun 15 19:21:53 2022 -0700

    aarch64: Handle fewer relocations for RTLD_BOOTSTRAP
    
    The RTLD_BOOTSTRAP branch is used to relocate ld.so itself.  It only
    needs to handle RELATIVE, GLOB_DAT, and JUMP_SLOT.
    TLSDESC/TLS_DTPMOD/TLS_DTPREL handling can be removed.  Remove
    `case AARCH64_R(RELATIVE)` as well as elf_machine_rela has checked it.
    
    Tested on aarch64-linux-gnu.

Diff:
---
 sysdeps/aarch64/dl-machine.h | 33 +++++++++++++++------------------
 1 file changed, 15 insertions(+), 18 deletions(-)

diff --git a/sysdeps/aarch64/dl-machine.h b/sysdeps/aarch64/dl-machine.h
index 292abe5152..ae8b14425a 100644
--- a/sysdeps/aarch64/dl-machine.h
+++ b/sysdeps/aarch64/dl-machine.h
@@ -178,7 +178,9 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[],
       return;
   else
     {
+# ifndef RTLD_BOOTSTRAP
       const ElfW(Sym) *const refsym = sym;
+# endif
       struct link_map *sym_map = RESOLVE_MAP (map, scope, &sym, version,
 					      r_type);
       ElfW(Addr) value = SYMBOL_ADDRESS (sym_map, sym, true);
@@ -191,6 +193,18 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[],
 
       switch (r_type)
 	{
+	case AARCH64_R(GLOB_DAT):
+	case AARCH64_R(JUMP_SLOT):
+	  *reloc_addr = value + reloc->r_addend;
+	  break;
+
+# ifndef RTLD_BOOTSTRAP
+	case AARCH64_R(ABS32):
+#  ifdef __LP64__
+	case AARCH64_R(ABS64):
+#  endif
+	  *reloc_addr = value + reloc->r_addend;
+	  break;
 	case AARCH64_R(COPY):
 	  if (sym == NULL)
 	      break;
@@ -210,30 +224,17 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[],
 		  ? sym->st_size : refsym->st_size);
 	  break;
 
-	case AARCH64_R(RELATIVE):
-	case AARCH64_R(GLOB_DAT):
-	case AARCH64_R(JUMP_SLOT):
-	case AARCH64_R(ABS32):
-#ifdef __LP64__
-	case AARCH64_R(ABS64):
-#endif
-	  *reloc_addr = value + reloc->r_addend;
-	  break;
-
 	case AARCH64_R(TLSDESC):
 	  {
 	    struct tlsdesc volatile *td =
 	      (struct tlsdesc volatile *)reloc_addr;
-#ifndef RTLD_BOOTSTRAP
 	    if (! sym)
 	      {
 		td->arg = (void*)reloc->r_addend;
 		td->entry = _dl_tlsdesc_undefweak;
 	      }
 	    else
-#endif
 	      {
-#ifndef RTLD_BOOTSTRAP
 # ifndef SHARED
 		CHECK_STATIC_TLS (map, sym_map);
 # else
@@ -245,7 +246,6 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[],
 		  }
 		else
 # endif
-#endif
 		  {
 		    td->arg = (void*)(sym->st_value + sym_map->l_tls_offset
 				      + reloc->r_addend);
@@ -256,14 +256,10 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[],
 	  }
 
 	case AARCH64_R(TLS_DTPMOD):
-#ifdef RTLD_BOOTSTRAP
-	  *reloc_addr = 1;
-#else
 	  if (sym_map != NULL)
 	    {
 	      *reloc_addr = sym_map->l_tls_modid;
 	    }
-#endif
 	  break;
 
 	case AARCH64_R(TLS_DTPREL):
@@ -286,6 +282,7 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[],
 	    value = elf_ifunc_invoke (value);
 	  *reloc_addr = value;
 	  break;
+# endif /* !RTLD_BOOTSTRAP */
 
 	default:
 	  _dl_reloc_bad_type (map, r_type, 0);


                 reply	other threads:[~2022-06-16  2:21 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=20220616022156.585AF3858407@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).