]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
cheri: Setup RX, RW capabilities for static linking
authorSzabolcs Nagy <szabolcs.nagy@arm.com>
Wed, 7 Sep 2022 09:38:29 +0000 (10:38 +0100)
committerSzabolcs Nagy <szabolcs.nagy@arm.com>
Wed, 12 Oct 2022 13:22:03 +0000 (14:22 +0100)
At least tls image access requires RX capability of the main link_map.

elf/dl-support.c
sysdeps/unix/sysv/linux/dl-parse_auxv.h

index 599efb1d08b80cdb146754f41544500b846b7c3c..8551e18eb2b5a6263023303bd54db40cf2bb214e 100644 (file)
@@ -263,6 +263,11 @@ _dl_aux_init (ElfW(auxv_t) *av)
   for (int i = 0; i < array_length (auxv_values); ++i)
     auxv_values[i] = 0;
   _dl_parse_auxv (av, auxv_values);
+
+# ifdef __CHERI_PURE_CAPABILITY__
+  _dl_main_map.l_map_start = auxv_values[AT_CHERI_EXEC_RX_CAP];
+  _dl_main_map.l_rw_start = auxv_values[AT_CHERI_EXEC_RW_CAP];
+# endif
 }
 #endif
 
index 48ca7736a086e2c113b7233d1487233ff30e4556..a0770b4412b8448080eee59eb36ee3c3badb9fcd 100644 (file)
 #include <ldsodefs.h>
 #include <link.h>
 
-typedef elfptr_t dl_parse_auxv_t[AT_MINSIGSTKSZ + 1];
+#ifdef __CHERI_PURE_CAPABILITY__
+# define AT_MAX AT_ENVP
+#else
+# define AT_MAX AT_MINSIGSTKSZ
+#endif
+typedef elfptr_t dl_parse_auxv_t[AT_MAX + 1];
 
 /* Copy the auxiliary vector into AUXV_VALUES and set up GLRO
    variables.  */
@@ -39,7 +44,7 @@ void _dl_parse_auxv (ElfW(auxv_t) *av, dl_parse_auxv_t auxv_values)
   auxv_values[AT_MINSIGSTKSZ] = CONSTANT_MINSIGSTKSZ;
 
   for (; av->a_type != AT_NULL; av++)
-    if (av->a_type <= AT_MINSIGSTKSZ)
+    if (av->a_type <= AT_MAX)
       auxv_values[av->a_type] = av->a_un.a_val;
 
   GLRO(dl_pagesize) = auxv_values[AT_PAGESZ];