diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2021-09-16 08:15:29 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2021-09-22 11:12:43 -0700 |
commit | b413280cfb16834450f66f554bc0d618bb513851 (patch) | |
tree | fda69976f225c3085c1da42c9b9ab191fae6f61f /elf/dl-reloc-static-pie.c | |
parent | 4eff749e8f06d8f6c5fc8b37299e9e0409ed80ec (diff) | |
download | glibc-b413280cfb16834450f66f554bc0d618bb513851.tar.gz glibc-b413280cfb16834450f66f554bc0d618bb513851.tar.xz glibc-b413280cfb16834450f66f554bc0d618bb513851.zip |
ld.so: Replace DL_RO_DYN_SECTION with dl_relocate_ld [BZ #28340]
We can't relocate entries in dynamic section if it is readonly: 1. Add a l_ld_readonly field to struct link_map to indicate if dynamic section is readonly and set it based on p_flags of PT_DYNAMIC segment. 2. Replace DL_RO_DYN_SECTION with dl_relocate_ld to decide if dynamic section should be relocated. 3. Remove DL_RO_DYN_TEMP_CNT. 4. Don't use a static dynamic section to make readonly dynamic section in vDSO writable. 5. Remove the temp argument from elf_get_dynamic_info. This fixes BZ #28340. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Diffstat (limited to 'elf/dl-reloc-static-pie.c')
-rw-r--r-- | elf/dl-reloc-static-pie.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/elf/dl-reloc-static-pie.c b/elf/dl-reloc-static-pie.c index 289651b341..68ded176cd 100644 --- a/elf/dl-reloc-static-pie.c +++ b/elf/dl-reloc-static-pie.c @@ -40,7 +40,17 @@ _dl_relocate_static_pie (void) /* Read our own dynamic section and fill in the info array. */ main_map->l_ld = ((void *) main_map->l_addr + elf_machine_dynamic ()); - elf_get_dynamic_info (main_map, NULL); + + const ElfW(Phdr) *ph, *phdr = GL(dl_phdr); + size_t phnum = GL(dl_phnum); + for (ph = phdr; ph < &phdr[phnum]; ++ph) + if (ph->p_type == PT_DYNAMIC) + { + main_map->l_ld_readonly = (ph->p_flags & PF_W) == 0; + break; + } + + elf_get_dynamic_info (main_map); # ifdef ELF_MACHINE_BEFORE_RTLD_RELOC ELF_MACHINE_BEFORE_RTLD_RELOC (main_map->l_info); |