]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
riscv: Use elf_machine_rela_relative to handle R_RISCV_RELATIVE
authorKito Cheng <kito.cheng@sifive.com>
Thu, 23 Jun 2022 15:47:04 +0000 (23:47 +0800)
committerPalmer Dabbelt <palmer@rivosinc.com>
Fri, 24 Jun 2022 04:07:19 +0000 (21:07 -0700)
Minor clean-up, we need to change this part in following patch, clean this up
to prevent we duplicated the change twice.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
sysdeps/riscv/dl-machine.h

index a60a45295285e7111b5b6e26914abc98ce9b25cd..4bb858adaac0336f00f583294fba9538afd6e365 100644 (file)
@@ -152,6 +152,14 @@ elf_machine_fixup_plt (struct link_map *map, lookup_t t,
 
 #ifdef RESOLVE_MAP
 
+static inline void
+__attribute__ ((always_inline))
+elf_machine_rela_relative (ElfW(Addr) l_addr, const ElfW(Rela) *reloc,
+                         void *const reloc_addr)
+{
+  *(ElfW(Addr) *) reloc_addr = l_addr + reloc->r_addend;
+}
+
 /* Perform a relocation described by R_INFO at the location pointed to
    by RELOC_ADDR.  SYM is the relocation symbol specified by R_INFO and
    MAP is the object containing the reloc.  */
@@ -182,7 +190,7 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[],
   switch (r_type)
     {
     case R_RISCV_RELATIVE:
-      *addr_field = map->l_addr + reloc->r_addend;
+      elf_machine_rela_relative (map->l_addr, reloc, addr_field);
       break;
     case R_RISCV_JUMP_SLOT:
     case __WORDSIZE == 64 ? R_RISCV_64 : R_RISCV_32:
@@ -258,14 +266,6 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[],
     }
 }
 
-static inline void
-__attribute__ ((always_inline))
-elf_machine_rela_relative (ElfW(Addr) l_addr, const ElfW(Rela) *reloc,
-                         void *const reloc_addr)
-{
-  *(ElfW(Addr) *) reloc_addr = l_addr + reloc->r_addend;
-}
-
 static inline void
 __attribute__ ((always_inline))
 elf_machine_lazy_rel (struct link_map *map, struct r_scope_elem *scope[],