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/dl-load.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/dl-load.c')
-rw-r--r-- | elf/dl-load.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/elf/dl-load.c b/elf/dl-load.c index 1ad0868dad..7d74214626 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c @@ -866,7 +866,7 @@ _dl_init_paths (const char *llp, const char *source, void _dl_process_pt_gnu_property (struct link_map *l, int fd, const ElfW(Phdr) *ph) { - const ElfW(Nhdr) *note = (const void *) (ph->p_vaddr + l->l_addr); + const ElfW(Nhdr) *note = (const void *) dl_rx_ptr (l, ph->p_vaddr); const ElfW(Addr) size = ph->p_memsz; const ElfW(Addr) align = ph->p_align; @@ -1314,7 +1314,7 @@ _dl_map_object_from_fd (const char *name, const char *origname, int fd, } else /* Adjust the PT_PHDR value by the runtime load address. */ - l->l_phdr = (ElfW(Phdr) *) ((ElfW(Addr)) l->l_phdr + l->l_addr); + l->l_phdr = (ElfW(Phdr) *) dl_rx_ptr (l, (ElfW(Addr)) l->l_phdr); if (__glibc_unlikely ((stack_flags &~ GL(dl_stack_flags)) & PF_X)) { @@ -1369,7 +1369,8 @@ cannot enable executable stack as shared object requires"); /* Adjust the address of the TLS initialization image. */ if (l->l_tls_initimage != NULL) - l->l_tls_initimage = (char *) l->l_tls_initimage + l->l_addr; + l->l_tls_initimage + = (void *) dl_rw_ptr (l, (ElfW(Addr)) l->l_tls_initimage); /* Process program headers again after load segments are mapped in case processing requires accessing those segments. Scan program @@ -1402,7 +1403,7 @@ cannot enable executable stack as shared object requires"); /* If this is ET_EXEC, we should have loaded it as lt_executable. */ assert (type != ET_EXEC || l->l_type == lt_executable); - l->l_entry += l->l_addr; + l->l_entry = dl_rx_ptr (l, l->l_entry); if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_FILES)) _dl_debug_printf ("\ |