diff options
author | Szabolcs Nagy <szabolcs.nagy@arm.com> | 2022-04-07 17:04:59 +0100 |
---|---|---|
committer | Szabolcs Nagy <szabolcs.nagy@arm.com> | 2022-11-22 14:31:25 +0000 |
commit | e252e5f0827ecbe82058c9c602f2dc5671072cdc (patch) | |
tree | 15489e430454c12e663379d35234df6daf56244f /elf/rtld.c | |
parent | 81c2de89c6f6e9ade26f28e2ff65c5c0510600da (diff) | |
download | glibc-e252e5f0827ecbe82058c9c602f2dc5671072cdc.tar.gz glibc-e252e5f0827ecbe82058c9c602f2dc5671072cdc.tar.xz glibc-e252e5f0827ecbe82058c9c602f2dc5671072cdc.zip |
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.
Diffstat (limited to 'elf/rtld.c')
-rw-r--r-- | elf/rtld.c | 11 |
1 files changed, 5 insertions, 6 deletions
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) { |