From: Szabolcs Nagy Date: Thu, 24 Jun 2021 12:29:19 +0000 (+0100) Subject: TODO(l_addr): cheri: in static exe initialize l_addr to a zero capability X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d257d001c3f16ccc4e4692201d3c03f67a0a9b18;p=thirdparty%2Fglibc.git 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 --git a/elf/dl-support.c b/elf/dl-support.c index 4af0b5b2ce2..599efb1d08b 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