public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Szabolcs Nagy <nsz@sourceware.org>
To: glibc-cvs@sourceware.org
Subject: [glibc/arm/morello/main] TODO(l_addr): cheri: in static exe initialize l_addr to a zero capability
Date: Fri,  5 Aug 2022 19:34:24 +0000 (GMT)	[thread overview]
Message-ID: <20220805193424.57B073857355@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=d257d001c3f16ccc4e4692201d3c03f67a0a9b18

commit d257d001c3f16ccc4e4692201d3c03f67a0a9b18
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
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


                 reply	other threads:[~2022-08-05 19:34 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220805193424.57B073857355@sourceware.org \
    --to=nsz@sourceware.org \
    --cc=glibc-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).