aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzabolcs Nagy <szabolcs.nagy@arm.com>2022-09-07 17:37:38 +0100
committerSzabolcs Nagy <szabolcs.nagy@arm.com>2022-11-22 14:31:25 +0000
commit9d6a71514dee3ec6bdc6977339de5d31cbef8c4c (patch)
tree58b3459f5db2232097d9a5229f27ef834636f986
parent44388a14fcba267d2b5062a87f72f5ce2a6587ca (diff)
downloadglibc-9d6a71514dee3ec6bdc6977339de5d31cbef8c4c.tar
glibc-9d6a71514dee3ec6bdc6977339de5d31cbef8c4c.tar.gz
glibc-9d6a71514dee3ec6bdc6977339de5d31cbef8c4c.tar.bz2
glibc-9d6a71514dee3ec6bdc6977339de5d31cbef8c4c.zip
TODO(api): cheri: fix dl_iterate_phdr dlpi_addr
The dlpi_addr field is a capability that has value l_addr, but we can only do this for libraries (ET_DYN) where l_addr == l_map_start, otherwise we return l_addr which is normally 0 then (ET_EXEC) so the caller can detect and special case it. For now l_addr != 0 and l_addr != l_map_start case is not supported. Note: this api may be used by the unwinder to find and read .eh_frame data. TODO: dlpi_addr could be address only, but requires unwinder update and agreement about the abi.
-rw-r--r--elf/dl-iteratephdr.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/elf/dl-iteratephdr.c b/elf/dl-iteratephdr.c
index 4d12a8ed50..146850b88a 100644
--- a/elf/dl-iteratephdr.c
+++ b/elf/dl-iteratephdr.c
@@ -61,7 +61,13 @@ __dl_iterate_phdr (int (*callback) (struct dl_phdr_info *info,
for (l = GL(dl_ns)[ns]._ns_loaded; l != NULL; l = l->l_next)
{
+#ifdef __CHERI_PURE_CAPABILITY__
+ info.dlpi_addr = l->l_real->l_addr == l->l_real->l_map_start
+ ? l->l_real->l_map_start
+ : l->l_real->l_addr;
+#else
info.dlpi_addr = l->l_real->l_addr;
+#endif
info.dlpi_name = l->l_real->l_name;
info.dlpi_phdr = l->l_real->l_phdr;
info.dlpi_phnum = l->l_real->l_phnum;