From: "H.J. Lu" <hjl.tools@gmail.com>
To: libc-alpha@sourceware.org
Cc: Florian Weimer <fweimer@redhat.com>
Subject: [PATCH] ld.so: Initialize bootstrap_map.l_ld_readonly [BZ #28340]
Date: Thu, 23 Sep 2021 09:14:18 -0700 [thread overview]
Message-ID: <20210923161418.1491862-1-hjl.tools@gmail.com> (raw)
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(+)
diff --git a/elf/rtld.c b/elf/rtld.c
index 8d2bba3d43..27e9f12560 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -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
diff --git a/sysdeps/generic/dl-relocate-ld.h b/sysdeps/generic/dl-relocate-ld.h
index 5fae206db9..09c7ba0448 100644
--- a/sysdeps/generic/dl-relocate-ld.h
+++ b/sysdeps/generic/dl-relocate-ld.h
@@ -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. */
diff --git a/sysdeps/mips/dl-relocate-ld.h b/sysdeps/mips/dl-relocate-ld.h
index 0c18d9a567..2c4edbe9f4 100644
--- a/sysdeps/mips/dl-relocate-ld.h
+++ b/sysdeps/mips/dl-relocate-ld.h
@@ -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. */
diff --git a/sysdeps/riscv/dl-relocate-ld.h b/sysdeps/riscv/dl-relocate-ld.h
index 10327454b1..240f85b79e 100644
--- a/sysdeps/riscv/dl-relocate-ld.h
+++ b/sysdeps/riscv/dl-relocate-ld.h
@@ -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. */
--
2.31.1
next reply other threads:[~2021-09-23 16:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-23 16:14 H.J. Lu [this message]
2021-09-28 14:07 ` Florian Weimer
2021-09-28 15:49 ` H.J. Lu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210923161418.1491862-1-hjl.tools@gmail.com \
--to=hjl.tools@gmail.com \
--cc=fweimer@redhat.com \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).