about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSzabolcs Nagy <szabolcs.nagy@arm.com>2022-08-08 09:22:44 +0100
committerSzabolcs Nagy <szabolcs.nagy@arm.com>2022-11-22 14:31:25 +0000
commitf70a0f9a14ebb996d2d914b3067e6fcf4faf5ee0 (patch)
treea9aa37bdc5bfcdcc1b0a975721177cadfc980ff0
parent607b660f896b541c0702b4369d33e513f504881d (diff)
downloadglibc-f70a0f9a14ebb996d2d914b3067e6fcf4faf5ee0.tar.gz
glibc-f70a0f9a14ebb996d2d914b3067e6fcf4faf5ee0.tar.xz
glibc-f70a0f9a14ebb996d2d914b3067e6fcf4faf5ee0.zip
cheri: elf: add an RW capability to link_map
For each module keep an RX and an RW root capability.  Use the existing
l_map_start for RX (covering all load segments) and add l_rw_start for
RW (covering all writable load segments).

For relocation processing, we also need individual RW ranges to decide
which objects need to be derived from RW and RX capabilities.  In
practice most modules have exactly one RW segment and it's unlikely
that any module needs more than four distinct ranges to tightly cover
the RW mappings.

Only added on CHERI targets so always has to be used behind ifdef.
-rw-r--r--include/link.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/include/link.h b/include/link.h
index 7632ae33d3..79c8a57690 100644
--- a/include/link.h
+++ b/include/link.h
@@ -256,6 +256,18 @@ struct link_map
     ElfW(Addr) l_map_end;
     /* End of the executable part of the mapping.  */
     ElfW(Addr) l_text_end;
+#ifdef __CHERI_PURE_CAPABILITY__
+    /* Writable part of the mapping (may have non-writable holes).  */
+    elfptr_t l_rw_start;
+# define DL_MAX_RW_COUNT 4
+    /* Writable ranges: objects are writable in these ranges.  */
+    int l_rw_count;
+    struct rw_range
+    {
+      ElfW(Addr) start;
+      ElfW(Addr) end;
+    } l_rw_range[DL_MAX_RW_COUNT];
+#endif
 
     /* Default array for 'l_scope'.  */
     struct r_scope_elem *l_scope_mem[4];