aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--elf/dl-load.c4
-rw-r--r--elf/rtld.c4
2 files changed, 6 insertions, 2 deletions
diff --git a/elf/dl-load.c b/elf/dl-load.c
index 7d74214626..b25ddaec05 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -1276,7 +1276,9 @@ _dl_map_object_from_fd (const char *name, const char *origname, int fd,
}
if (l->l_ld != 0)
- l->l_ld = (ElfW(Dyn) *) ((ElfW(Addr)) l->l_ld + l->l_addr);
+ l->l_ld = (ElfW(Dyn) *) (l->l_ld_readonly
+ ? dl_rx_ptr (l, (elfptr_t) l->l_ld)
+ : dl_rw_ptr (l, (elfptr_t) l->l_ld));
elf_get_dynamic_info (l, false, false);
diff --git a/elf/rtld.c b/elf/rtld.c
index 1dac96c94b..41ffb297e5 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -1175,8 +1175,10 @@ rtld_setup_main_map (struct link_map *main_map)
case PT_DYNAMIC:
/* This tells us where to find the dynamic section,
which tells us everything we need to do. */
- main_map->l_ld = (void *) main_map->l_addr + ph->p_vaddr;
main_map->l_ld_readonly = (ph->p_flags & PF_W) == 0;
+ main_map->l_ld = (void *) (main_map->l_ld_readonly
+ ? dl_rx_ptr (main_map, ph->p_vaddr)
+ : dl_rw_ptr (main_map, ph->p_vaddr));
break;
case PT_INTERP:
/* This "interpreter segment" was used by the program loader to