From e252e5f0827ecbe82058c9c602f2dc5671072cdc Mon Sep 17 00:00:00 2001 From: Szabolcs Nagy Date: Thu, 7 Apr 2022 17:04:59 +0100 Subject: cheri: elf: use RX, RW capabilities to derive pointers Instead of map->l_addr + offset use dl_rx_ptr (map, offset) dl_rw_ptr (map, offset) depending on RX or RW permission requirement. --- elf/rtld.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'elf/rtld.c') diff --git a/elf/rtld.c b/elf/rtld.c index 26af99305e..1dac96c94b 100644 --- a/elf/rtld.c +++ b/elf/rtld.c @@ -722,8 +722,7 @@ match_version (const char *string, struct link_map *map) /* The file has no symbol versioning. */ return 0; - def = (ElfW(Verdef) *) ((char *) map->l_addr - + map->l_info[VERDEFTAG]->d_un.d_ptr); + def = (ElfW(Verdef) *) dl_rx_ptr (map, map->l_info[VERDEFTAG]->d_un.d_ptr); while (1) { ElfW(Verdaux) *aux = (ElfW(Verdaux) *) ((char *) def + def->vd_aux); @@ -1186,8 +1185,8 @@ rtld_setup_main_map (struct link_map *main_map) dlopen call or DT_NEEDED entry, for something that wants to link against the dynamic linker as a shared library, will know that the shared object is already loaded. */ - _dl_rtld_libname.name = ((const char *) main_map->l_addr - + ph->p_vaddr); + _dl_rtld_libname.name = (const char *) dl_rx_ptr (main_map, + ph->p_vaddr); /* _dl_rtld_libname.next = NULL; Already zero. */ GL(dl_rtld_map).l_libname = &_dl_rtld_libname; @@ -1304,7 +1303,7 @@ rtld_setup_main_map (struct link_map *main_map) the executable is actually an ET_DYN object. */ if (main_map->l_tls_initimage != NULL) main_map->l_tls_initimage - = (char *) main_map->l_tls_initimage + main_map->l_addr; + = (void *) dl_rx_ptr (main_map, (ElfW(Addr)) main_map->l_tls_initimage); if (! main_map->l_map_end) main_map->l_map_end = ~0; if (! main_map->l_text_end) @@ -2251,7 +2250,7 @@ dl_main (const ElfW(Phdr) *phdr, continue; strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]); - ent = (ElfW(Verneed) *) (map->l_addr + dyn->d_un.d_ptr); + ent = (ElfW(Verneed) *) dl_rx_ptr (map, dyn->d_un.d_ptr); if (first) { -- cgit 1.4.1