cheri: Setup RX, RW capabilities for static linking

At least tls image access requires RX capability of the main link_map.
This commit is contained in:
Szabolcs Nagy 2022-09-07 10:38:29 +01:00
parent a66d563c9e
commit 87dffcda13
2 changed files with 12 additions and 2 deletions

View 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

View File

@ -22,7 +22,12 @@
#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];