]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
cheri: elf: Prepare support for dynamic relocation processing
authorSzabolcs Nagy <szabolcs.nagy@arm.com>
Thu, 20 Oct 2022 16:12:36 +0000 (17:12 +0100)
committerSzabolcs Nagy <szabolcs.nagy@arm.com>
Thu, 27 Oct 2022 13:46:54 +0000 (14:46 +0100)
Type of relocation addresses must be changed from ElfW(Addr) to
elfptr_t to cover both traditional and CHERI ABIs.

And relative relocation processing must have access to the link_map
to derive pointers from the right per module capability.

elf/do-rel.h
elf/dynamic-link.h

index 694b3a6bd711f77a055860952c611749011d3372..219fad23183979ec42b6d65e7e383049a2e4a175 100644 (file)
@@ -41,7 +41,7 @@
 
 static inline void __attribute__ ((always_inline))
 elf_dynamic_do_Rel (struct link_map *map, struct r_scope_elem *scope[],
-                   ElfW(Addr) reladdr, ElfW(Addr) relsize,
+                   elfptr_t reladdr, ElfW(Addr) relsize,
                    __typeof (((ElfW(Dyn) *) 0)->d_un.d_val) nrelative,
                    int lazy, int skip_ifunc)
 {
index debbb8c9f769563bc3fa82bb253258b7b6089021..e189de49ebb94236e70ede888b2199f5cc23f117 100644 (file)
@@ -46,9 +46,14 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[],
                  const ElfW(Rela) *reloc, const ElfW(Sym) *sym,
                  const struct r_found_version *version, void *const reloc_addr,
                  int skip_ifunc);
+#  ifdef __CHERI_PURE_CAPABILITY__
+static inline void __attribute__((always_inline))
+elf_machine_rela_relative (struct link_map *map, const ElfW(Rela) *reloc);
+#  else
 static inline void __attribute__((always_inline))
 elf_machine_rela_relative (ElfW(Addr) l_addr, const ElfW(Rela) *reloc,
                           void *const reloc_addr);
+#  endif
 # endif
 # if ELF_MACHINE_NO_RELA || defined ELF_MACHINE_PLT_REL
 static inline void __attribute__((always_inline))
@@ -80,7 +85,7 @@ elf_machine_lazy_rel (struct link_map *map, struct r_scope_elem *scope[],
 
 # define _ELF_DYNAMIC_DO_RELOC(RELOC, reloc, map, scope, do_lazy, skip_ifunc, test_rel) \
   do {                                                                       \
-    struct { ElfW(Addr) start, size;                                         \
+    struct { elfptr_t start; ElfW(Addr) size;                                        \
             __typeof (((ElfW(Dyn) *) 0)->d_un.d_val) nrelative; int lazy; }  \
       ranges[2] = { { 0, 0, 0, 0 }, { 0, 0, 0, 0 } };                        \
                                                                              \
@@ -97,7 +102,7 @@ elf_machine_lazy_rel (struct link_map *map, struct r_scope_elem *scope[],
     if ((map)->l_info[DT_PLTREL]                                             \
        && (!test_rel || (map)->l_info[DT_PLTREL]->d_un.d_val == DT_##RELOC)) \
       {                                                                              \
-       ElfW(Addr) start = D_PTR ((map), l_info[DT_JMPREL]);                  \
+       elfptr_t start = D_PTR ((map), l_info[DT_JMPREL]);                    \
        ElfW(Addr) size = (map)->l_info[DT_PLTRELSZ]->d_un.d_val;             \
                                                                              \
        if (ranges[0].start == 0)                                             \