From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1944) id 57B073857355; Fri, 5 Aug 2022 19:34:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 57B073857355 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] TODO(l_addr): cheri: in static exe initialize l_addr to a zero capability X-Act-Checkin: glibc X-Git-Author: Szabolcs Nagy X-Git-Refname: refs/heads/arm/morello/main X-Git-Oldrev: 8536404f41d411e2e6deaafdd51c9c6dfb3ba22a X-Git-Newrev: d257d001c3f16ccc4e4692201d3c03f67a0a9b18 Message-Id: <20220805193424.57B073857355@sourceware.org> Date: Fri, 5 Aug 2022 19:34:24 +0000 (GMT) X-BeenThere: glibc-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Aug 2022 19:34:24 -0000 https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=d257d001c3f16ccc4e4692201d3c03f67a0a9b18 commit d257d001c3f16ccc4e4692201d3c03f67a0a9b18 Author: Szabolcs Nagy Date: Thu Jun 24 13:29:19 2021 +0100 TODO(l_addr): cheri: in static exe initialize l_addr to a zero capability The base should be 0, but also a valid capability. Initialize to a zero capability instead of relying on AT_BASE. TODO: this is a hack. we will need stricter bounds and possibly separate l_addr and bounds info. Diff: --- elf/dl-support.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/elf/dl-support.c b/elf/dl-support.c index 4af0b5b2ce..599efb1d08 100644 --- a/elf/dl-support.c +++ b/elf/dl-support.c @@ -248,6 +248,14 @@ _dl_aux_init (ElfW(auxv_t) *av) GL(dl_sysinfo) = DL_SYSINFO_DEFAULT; #endif +#ifdef __CHERI_PURE_CAPABILITY__ + /* Base is 0 in non-pie static executable, but it needs to be a valid + capability. Use the zero capability instead of AT_BASE. */ + elfptr_t zerocap; + asm volatile ("cvtd %0,xzr" : "=r"(zerocap)); + _dl_main_map.l_addr = zerocap; +#endif + _dl_auxv = av; dl_parse_auxv_t auxv_values; /* Use an explicit initialization loop here because memset may not