about summary refs log tree commit diff
path: root/elf/dl-init.c
diff options
context:
space:
mode:
authorSzabolcs Nagy <szabolcs.nagy@arm.com>2022-04-07 18:40:25 +0100
committerSzabolcs Nagy <szabolcs.nagy@arm.com>2022-08-05 19:45:19 +0100
commitd63bc8be874f42090f3a7a51441221863b83f149 (patch)
treeb861bc8a1a69be5f8f10b9fce611dd2438e4db7f /elf/dl-init.c
parentd257d001c3f16ccc4e4692201d3c03f67a0a9b18 (diff)
downloadglibc-d63bc8be874f42090f3a7a51441221863b83f149.tar.gz
glibc-d63bc8be874f42090f3a7a51441221863b83f149.tar.xz
glibc-d63bc8be874f42090f3a7a51441221863b83f149.zip
cheri: elf: elfptr_t fixes for preinit/init/fini array
According to the ELF spec:

 "Each element of this array is a pointer to a function to be executed
  by the dynamic linker."

 "Note that the address of a function need not be the same as a pointer
  to a function as defined by the processor supplement."

so these should be accessed via uintptr_t type instead of ElfW(Addr).
Diffstat (limited to 'elf/dl-init.c')
-rw-r--r--elf/dl-init.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/elf/dl-init.c b/elf/dl-init.c
index deefeb099a..4c8aaae7e0 100644
--- a/elf/dl-init.c
+++ b/elf/dl-init.c
@@ -61,11 +61,11 @@ call_init (struct link_map *l, int argc, char **argv, char **env)
     {
       unsigned int j;
       unsigned int jm;
-      ElfW(Addr) *addrs;
+      elfptr_t *addrs;
 
-      jm = l->l_info[DT_INIT_ARRAYSZ]->d_un.d_val / sizeof (ElfW(Addr));
+      jm = l->l_info[DT_INIT_ARRAYSZ]->d_un.d_val / sizeof (elfptr_t);
 
-      addrs = (ElfW(Addr) *) (init_array->d_un.d_ptr + l->l_addr);
+      addrs = (elfptr_t *) (init_array->d_un.d_ptr + l->l_addr);
       for (j = 0; j < jm; ++j)
 	((dl_init_t) addrs[j]) (argc, argv, env);
     }
@@ -88,16 +88,16 @@ _dl_init (struct link_map *main_map, int argc, char **argv, char **env)
   /* Don't do anything if there is no preinit array.  */
   if (__builtin_expect (preinit_array != NULL, 0)
       && preinit_array_size != NULL
-      && (i = preinit_array_size->d_un.d_val / sizeof (ElfW(Addr))) > 0)
+      && (i = preinit_array_size->d_un.d_val / sizeof (elfptr_t)) > 0)
     {
-      ElfW(Addr) *addrs;
+      elfptr_t *addrs;
       unsigned int cnt;
 
       if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_IMPCALLS))
 	_dl_debug_printf ("\ncalling preinit: %s\n\n",
 			  DSO_FILENAME (main_map->l_name));
 
-      addrs = (ElfW(Addr) *) (preinit_array->d_un.d_ptr + main_map->l_addr);
+      addrs = (elfptr_t *) (preinit_array->d_un.d_ptr + main_map->l_addr);
       for (cnt = 0; cnt < i; ++cnt)
 	((dl_init_t) addrs[cnt]) (argc, argv, env);
     }