ld.so: Replace DL_RO_DYN_SECTION with dl_relocate_ld [BZ #28340]
authorH.J. Lu <hjl.tools@gmail.com>
Thu, 16 Sep 2021 15:15:29 +0000 (08:15 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Wed, 22 Sep 2021 18:12:43 +0000 (11:12 -0700)
commitb413280cfb16834450f66f554bc0d618bb513851
treefda69976f225c3085c1da42c9b9ab191fae6f61f
parent4eff749e8f06d8f6c5fc8b37299e9e0409ed80ec
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>
16 files changed:
elf/Makefile
elf/dl-load.c
elf/dl-reloc-static-pie.c
elf/get-dynamic-info.h
elf/rtld.c
elf/setup-vdso.h
elf/tst-ro-dynamic-mod.c [new file with mode: 0644]
elf/tst-ro-dynamic-mod.map [new file with mode: 0644]
elf/tst-ro-dynamic.c [new file with mode: 0644]
include/link.h
sysdeps/generic/dl-relocate-ld.h [new file with mode: 0644]
sysdeps/generic/ldsodefs.h
sysdeps/mips/dl-relocate-ld.h [new file with mode: 0644]
sysdeps/mips/ldsodefs.h
sysdeps/riscv/dl-relocate-ld.h [new file with mode: 0644]
sysdeps/riscv/ldsodefs.h