From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1944) id 939B0385E001; Wed, 12 Oct 2022 14:17:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 939B0385E001 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1665584251; bh=5w4joGNiGMmN2x415YQ8l2PTda4dVivWZ8jq4rqRQYA=; h=From:To:Subject:Date:From; b=U9hBzc9rSXSO2cuC3xf1hI1RBp+y/1DxTpje9kvAGE9MCI8Hlsm1e+UB92K6cK5OZ 88y3z9OGsJ4xX/jw5a5/9558j58FcmBhqNXBeByjhg2eZTTn1gMcc+RvWLO/PN9Jui gneVN9u2QziuNHfn2XjXhwCoeSB/5PhcgK54yta4= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Szabolcs Nagy To: glibc-cvs@sourceware.org Subject: [glibc/arm/morello/main] cheri: Setup RX, RW capabilities for static linking X-Act-Checkin: glibc X-Git-Author: Szabolcs Nagy X-Git-Refname: refs/heads/arm/morello/main X-Git-Oldrev: a66d563c9e33cffbf646e1327bdd73423a10ef76 X-Git-Newrev: 87dffcda136a7d1b0c0f81ccf9ac084178181321 Message-Id: <20221012141731.939B0385E001@sourceware.org> Date: Wed, 12 Oct 2022 14:17:31 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=87dffcda136a7d1b0c0f81ccf9ac084178181321 commit 87dffcda136a7d1b0c0f81ccf9ac084178181321 Author: Szabolcs Nagy Date: Wed Sep 7 10:38:29 2022 +0100 cheri: Setup RX, RW capabilities for static linking At least tls image access requires RX capability of the main link_map. Diff: --- elf/dl-support.c | 5 +++++ sysdeps/unix/sysv/linux/dl-parse_auxv.h | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/elf/dl-support.c b/elf/dl-support.c index 599efb1d08..8551e18eb2 100644 --- a/elf/dl-support.c +++ b/elf/dl-support.c @@ -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 diff --git a/sysdeps/unix/sysv/linux/dl-parse_auxv.h b/sysdeps/unix/sysv/linux/dl-parse_auxv.h index 48ca7736a0..a0770b4412 100644 --- a/sysdeps/unix/sysv/linux/dl-parse_auxv.h +++ b/sysdeps/unix/sysv/linux/dl-parse_auxv.h @@ -22,7 +22,12 @@ #include #include -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];