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] cheri: elf: add dl_{rx, rw}_ptr to derive addresses within a map
Date: Thu, 27 Oct 2022 13:55:20 +0000 (GMT)	[thread overview]
Message-ID: <20221027135520.52D813851511@sourceware.org> (raw)

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

commit 016d45e980870f4a158e18c8e3fbf7d5e46e7f24
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
Date:   Mon Aug 8 10:56:14 2022 +0100

    cheri: elf: add dl_{rx,rw}_ptr to derive addresses within a map
    
    To derive pointers within a module from the per module RX and RW caps.

Diff:
---
 sysdeps/generic/ldsodefs.h | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
index 6b256b8388..f8cd388e62 100644
--- a/sysdeps/generic/ldsodefs.h
+++ b/sysdeps/generic/ldsodefs.h
@@ -80,6 +80,34 @@ dl_relocate_ld (const struct link_map *l)
   return !(l->l_ld_readonly || DL_RO_DYN_SECTION);
 }
 
+static inline elfptr_t __attribute__ ((unused))
+dl_get_ptr (elfptr_t cap, ElfW(Addr) base, ElfW(Addr) vaddr)
+{
+#ifdef __CHERI_PURE_CAPABILITY__
+  return __builtin_cheri_address_set (cap, base + vaddr);
+#else
+  return base + vaddr;
+#endif
+}
+
+static inline elfptr_t __attribute__ ((unused))
+dl_rx_ptr (const struct link_map *l, ElfW(Addr) vaddr)
+{
+  return dl_get_ptr (l->l_map_start, l->l_addr, vaddr);
+}
+
+static inline elfptr_t __attribute__ ((unused))
+dl_rw_ptr (const struct link_map *l, ElfW(Addr) vaddr)
+{
+  elfptr_t cap;
+#ifdef __CHERI_PURE_CAPABILITY__
+  cap = l->l_rw_start;
+#else
+  cap = 0; /* Avoid uninitialized warning.  */
+#endif
+  return dl_get_ptr (cap, l->l_addr, vaddr);
+}
+
 /* All references to the value of l_info[DT_PLTGOT],
   l_info[DT_STRTAB], l_info[DT_SYMTAB], l_info[DT_RELA],
   l_info[DT_REL], l_info[DT_JMPREL], and l_info[VERSYMIDX (DT_VERSYM)]

             reply	other threads:[~2022-10-27 13:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-27 13:55 Szabolcs Nagy [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-11-23 14:45 Szabolcs Nagy
2022-10-26 15:16 Szabolcs Nagy

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=20221027135520.52D813851511@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).