diff options
author | Szabolcs Nagy <szabolcs.nagy@arm.com> | 2022-09-02 14:07:06 +0100 |
---|---|---|
committer | Szabolcs Nagy <szabolcs.nagy@arm.com> | 2022-11-22 14:31:25 +0000 |
commit | 681ddc91e1f9cb33cf3b1370bd36ab9296f9be38 (patch) | |
tree | 35d503f4a16ad48c0b9cf0c5e1628605dcf40f33 /elf/dl-load.c | |
parent | 647e35b6ab9dc6a76c5bcb3aead5a4caaf1708cf (diff) | |
download | glibc-681ddc91e1f9cb33cf3b1370bd36ab9296f9be38.tar.gz glibc-681ddc91e1f9cb33cf3b1370bd36ab9296f9be38.tar.xz glibc-681ddc91e1f9cb33cf3b1370bd36ab9296f9be38.zip |
cheri: elf: Use RW permissions for l_ld when needed
The dynamic section of an executable needs to be written to set the DT_DEBUG entry for debuggers (unless the target has some other place to store r_debug). For this reason we make l_ld writable whenever the dynamic section is writable. The ld.so l_ld is kept RX, since it does not have DT_DEBUG. (Note: relocating the dynamic section is not allowed on cheri and that's the only other reason glibc would write to it.)
Diffstat (limited to 'elf/dl-load.c')
-rw-r--r-- | elf/dl-load.c | 4 |
1 files changed, 3 insertions, 1 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); |