]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
TODO(l_addr): cheri: in static exe initialize l_addr to a zero capability
authorSzabolcs Nagy <szabolcs.nagy@arm.com>
Thu, 24 Jun 2021 12:29:19 +0000 (13:29 +0100)
committerSzabolcs Nagy <szabolcs.nagy@arm.com>
Fri, 5 Aug 2022 18:45:19 +0000 (19:45 +0100)
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.

elf/dl-support.c

index 4af0b5b2ce23a762bd78d29747f50b0e1210680d..599efb1d08b80cdb146754f41544500b846b7c3c 100644 (file)
@@ -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