ld.so: Initialize bootstrap_map.l_ld_readonly [BZ #28340]
Checks
Context |
Check |
Description |
dj/TryBot-apply_patch |
success
|
Patch applied to master at the time it was sent
|
dj/TryBot-32bit |
success
|
Build for i686
|
Commit Message
Before calling elf_get_dynamic_info to get dynamic info in bootstrap_map,
initalize bootstrap_map.l_ld_readonly with BOOTSTRAP_MAP_RO_DYN_SECTION.
This updates BZ #28340 fix.
---
elf/rtld.c | 1 +
sysdeps/generic/dl-relocate-ld.h | 3 +++
sysdeps/mips/dl-relocate-ld.h | 3 +++
sysdeps/riscv/dl-relocate-ld.h | 4 ++++
4 files changed, 11 insertions(+)
Comments
* H. J. Lu:
> Before calling elf_get_dynamic_info to get dynamic info in bootstrap_map,
> initalize bootstrap_map.l_ld_readonly with BOOTSTRAP_MAP_RO_DYN_SECTION.
I think we should bring back DL_RO_DYN_SECTION and use that to define
one (generic) version of dl_relocate_ld, perhaps like this:
static inline bool
dl_relocate_ld (const struct link_map *l)
{
/* Don't relocate dynamic section if it is readonly */
return !(l->l_ld_readonly || DL_RO_DYN_SECTION);
}
Thanks,
Florian
On Tue, Sep 28, 2021 at 7:07 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> * H. J. Lu:
>
> > Before calling elf_get_dynamic_info to get dynamic info in bootstrap_map,
> > initalize bootstrap_map.l_ld_readonly with BOOTSTRAP_MAP_RO_DYN_SECTION.
>
> I think we should bring back DL_RO_DYN_SECTION and use that to define
> one (generic) version of dl_relocate_ld, perhaps like this:
>
> static inline bool
> dl_relocate_ld (const struct link_map *l)
> {
> /* Don't relocate dynamic section if it is readonly */
> return !(l->l_ld_readonly || DL_RO_DYN_SECTION);
> }
Like this?
https://sourceware.org/pipermail/libc-alpha/2021-September/131495.html
@@ -547,6 +547,7 @@ _dl_start (void *arg)
/* Read our own dynamic section and fill in the info array. */
bootstrap_map.l_ld = (void *) bootstrap_map.l_addr + elf_machine_dynamic ();
+ bootstrap_map.l_ld_readonly = BOOTSTRAP_MAP_RO_DYN_SECTION;
elf_get_dynamic_info (&bootstrap_map);
#if NO_TLS_OFFSET != 0
@@ -19,6 +19,9 @@
#ifndef _DL_RELOCATE_LD_H
#define _DL_RELOCATE_LD_H
+/* The dynamic section in bootstrap_map is writable. */
+#define BOOTSTRAP_MAP_RO_DYN_SECTION 0
+
/* Return true if dynamic section in the shared library L should be
relocated. */
@@ -19,6 +19,9 @@
#ifndef _DL_RELOCATE_LD_H
#define _DL_RELOCATE_LD_H
+/* The dynamic section in bootstrap_map is readonly. */
+#define BOOTSTRAP_MAP_RO_DYN_SECTION 1
+
/* Return true if dynamic section in the shared library L should be
relocated. */
@@ -19,6 +19,10 @@
#ifndef _DL_RELOCATE_LD_H
#define _DL_RELOCATE_LD_H
+/* The dynamic section in bootstrap_map is writable. This is ignored
+ on RISC-V. */
+#define BOOTSTRAP_MAP_RO_DYN_SECTION 0
+
/* Return true if dynamic section in the shared library L should be
relocated. */