public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/arm/morello/main] cheri: elf: add dl_{rx, rw}_ptr to derive addresses within a map
@ 2022-11-23 14:45 Szabolcs Nagy
  0 siblings, 0 replies; 3+ messages in thread
From: Szabolcs Nagy @ 2022-11-23 14:45 UTC (permalink / raw)
  To: glibc-cvs

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

commit 055042833f84bad40aacb4f952eae63351cf5fb3
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)]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [glibc/arm/morello/main] cheri: elf: add dl_{rx, rw}_ptr to derive addresses within a map
@ 2022-10-27 13:55 Szabolcs Nagy
  0 siblings, 0 replies; 3+ messages in thread
From: Szabolcs Nagy @ 2022-10-27 13:55 UTC (permalink / raw)
  To: glibc-cvs

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)]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [glibc/arm/morello/main] cheri: elf: add dl_{rx, rw}_ptr to derive addresses within a map
@ 2022-10-26 15:16 Szabolcs Nagy
  0 siblings, 0 replies; 3+ messages in thread
From: Szabolcs Nagy @ 2022-10-26 15:16 UTC (permalink / raw)
  To: glibc-cvs

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

commit 627ec124a269523f97f743eabb2d16b1a8ee9fca
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)]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-11-23 14:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-23 14:45 [glibc/arm/morello/main] cheri: elf: add dl_{rx, rw}_ptr to derive addresses within a map Szabolcs Nagy
  -- strict thread matches above, loose matches on Subject: below --
2022-10-27 13:55 Szabolcs Nagy
2022-10-26 15:16 Szabolcs Nagy

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).