|
|
7729eb |
commit 5f36e5c70107ecb59281ef57f9f1c0e37ec3076d
|
|
|
7729eb |
Author: H.J. Lu <hjl.tools@gmail.com>
|
|
|
7729eb |
Date: Thu Sep 23 09:06:49 2021 -0700
|
|
|
7729eb |
|
|
|
7729eb |
ld.so: Initialize bootstrap_map.l_ld_readonly [BZ #28340]
|
|
|
7729eb |
|
|
|
7729eb |
1. Define DL_RO_DYN_SECTION to initalize bootstrap_map.l_ld_readonly
|
|
|
7729eb |
before calling elf_get_dynamic_info to get dynamic info in bootstrap_map,
|
|
|
7729eb |
2. Define a single
|
|
|
7729eb |
|
|
|
7729eb |
static inline bool
|
|
|
7729eb |
dl_relocate_ld (const struct link_map *l)
|
|
|
7729eb |
{
|
|
|
7729eb |
/* Don't relocate dynamic section if it is readonly */
|
|
|
7729eb |
return !(l->l_ld_readonly || DL_RO_DYN_SECTION);
|
|
|
7729eb |
}
|
|
|
7729eb |
|
|
|
7729eb |
This updates BZ #28340 fix.
|
|
|
7729eb |
|
|
|
7729eb |
(cherry picked from commit 2ec99d8c42b2ff1a1231e4df462a0910a9b7fdef)
|
|
|
7729eb |
|
|
|
7729eb |
diff --git a/elf/rtld.c b/elf/rtld.c
|
|
|
7729eb |
index 405166d62b34847c..d83ac1bdc40a6081 100644
|
|
|
7729eb |
--- a/elf/rtld.c
|
|
|
7729eb |
+++ b/elf/rtld.c
|
|
|
7729eb |
@@ -548,6 +548,7 @@ _dl_start (void *arg)
|
|
|
7729eb |
|
|
|
7729eb |
/* Read our own dynamic section and fill in the info array. */
|
|
|
7729eb |
bootstrap_map.l_ld = (void *) bootstrap_map.l_addr + elf_machine_dynamic ();
|
|
|
7729eb |
+ bootstrap_map.l_ld_readonly = DL_RO_DYN_SECTION;
|
|
|
7729eb |
elf_get_dynamic_info (&bootstrap_map);
|
|
|
7729eb |
|
|
|
7729eb |
#if NO_TLS_OFFSET != 0
|
|
|
7729eb |
diff --git a/sysdeps/generic/dl-relocate-ld.h b/sysdeps/generic/dl-relocate-ld.h
|
|
|
7729eb |
index 5fae206db9941e97..cfb86c2d6a2394c1 100644
|
|
|
7729eb |
--- a/sysdeps/generic/dl-relocate-ld.h
|
|
|
7729eb |
+++ b/sysdeps/generic/dl-relocate-ld.h
|
|
|
7729eb |
@@ -19,14 +19,7 @@
|
|
|
7729eb |
#ifndef _DL_RELOCATE_LD_H
|
|
|
7729eb |
#define _DL_RELOCATE_LD_H
|
|
|
7729eb |
|
|
|
7729eb |
-/* Return true if dynamic section in the shared library L should be
|
|
|
7729eb |
- relocated. */
|
|
|
7729eb |
-
|
|
|
7729eb |
-static inline bool
|
|
|
7729eb |
-dl_relocate_ld (const struct link_map *l)
|
|
|
7729eb |
-{
|
|
|
7729eb |
- /* Don't relocate dynamic section if it is readonly */
|
|
|
7729eb |
- return !l->l_ld_readonly;
|
|
|
7729eb |
-}
|
|
|
7729eb |
+/* The dynamic section is writable. */
|
|
|
7729eb |
+#define DL_RO_DYN_SECTION 0
|
|
|
7729eb |
|
|
|
7729eb |
#endif /* _DL_RELOCATE_LD_H */
|
|
|
7729eb |
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
|
|
|
7729eb |
index ed10953f34b96c49..fcbbf6974827cdf1 100644
|
|
|
7729eb |
--- a/sysdeps/generic/ldsodefs.h
|
|
|
7729eb |
+++ b/sysdeps/generic/ldsodefs.h
|
|
|
7729eb |
@@ -69,6 +69,16 @@ __BEGIN_DECLS
|
|
|
7729eb |
`ElfW(TYPE)' is used in place of `Elf32_TYPE' or `Elf64_TYPE'. */
|
|
|
7729eb |
#define ELFW(type) _ElfW (ELF, __ELF_NATIVE_CLASS, type)
|
|
|
7729eb |
|
|
|
7729eb |
+/* Return true if dynamic section in the shared library L should be
|
|
|
7729eb |
+ relocated. */
|
|
|
7729eb |
+
|
|
|
7729eb |
+static inline bool
|
|
|
7729eb |
+dl_relocate_ld (const struct link_map *l)
|
|
|
7729eb |
+{
|
|
|
7729eb |
+ /* Don't relocate dynamic section if it is readonly */
|
|
|
7729eb |
+ return !(l->l_ld_readonly || DL_RO_DYN_SECTION);
|
|
|
7729eb |
+}
|
|
|
7729eb |
+
|
|
|
7729eb |
/* All references to the value of l_info[DT_PLTGOT],
|
|
|
7729eb |
l_info[DT_STRTAB], l_info[DT_SYMTAB], l_info[DT_RELA],
|
|
|
7729eb |
l_info[DT_REL], l_info[DT_JMPREL], and l_info[VERSYMIDX (DT_VERSYM)]
|
|
|
7729eb |
diff --git a/sysdeps/mips/dl-relocate-ld.h b/sysdeps/mips/dl-relocate-ld.h
|
|
|
7729eb |
index 0c18d9a567cad54f..376ad75dd1695fe3 100644
|
|
|
7729eb |
--- a/sysdeps/mips/dl-relocate-ld.h
|
|
|
7729eb |
+++ b/sysdeps/mips/dl-relocate-ld.h
|
|
|
7729eb |
@@ -19,14 +19,7 @@
|
|
|
7729eb |
#ifndef _DL_RELOCATE_LD_H
|
|
|
7729eb |
#define _DL_RELOCATE_LD_H
|
|
|
7729eb |
|
|
|
7729eb |
-/* Return true if dynamic section in the shared library L should be
|
|
|
7729eb |
- relocated. */
|
|
|
7729eb |
-
|
|
|
7729eb |
-static inline bool
|
|
|
7729eb |
-dl_relocate_ld (const struct link_map *l)
|
|
|
7729eb |
-{
|
|
|
7729eb |
- /* Never relocate dynamic section. */
|
|
|
7729eb |
- return false;
|
|
|
7729eb |
-}
|
|
|
7729eb |
+/* The dynamic section is readonly. */
|
|
|
7729eb |
+#define DL_RO_DYN_SECTION 1
|
|
|
7729eb |
|
|
|
7729eb |
#endif /* _DL_RELOCATE_LD_H */
|
|
|
7729eb |
diff --git a/sysdeps/riscv/dl-relocate-ld.h b/sysdeps/riscv/dl-relocate-ld.h
|
|
|
7729eb |
index 10327454b17a7097..2ab2b8ac6c09af82 100644
|
|
|
7729eb |
--- a/sysdeps/riscv/dl-relocate-ld.h
|
|
|
7729eb |
+++ b/sysdeps/riscv/dl-relocate-ld.h
|
|
|
7729eb |
@@ -19,14 +19,7 @@
|
|
|
7729eb |
#ifndef _DL_RELOCATE_LD_H
|
|
|
7729eb |
#define _DL_RELOCATE_LD_H
|
|
|
7729eb |
|
|
|
7729eb |
-/* Return true if dynamic section in the shared library L should be
|
|
|
7729eb |
- relocated. */
|
|
|
7729eb |
-
|
|
|
7729eb |
-static inline bool
|
|
|
7729eb |
-dl_relocate_ld (const struct link_map *l)
|
|
|
7729eb |
-{
|
|
|
7729eb |
- /* Never relocate dynamic section for ABI compatibility. */
|
|
|
7729eb |
- return false;
|
|
|
7729eb |
-}
|
|
|
7729eb |
+/* The dynamic section is readonly for ABI compatibility. */
|
|
|
7729eb |
+#define DL_RO_DYN_SECTION 1
|
|
|
7729eb |
|
|
|
7729eb |
#endif /* _DL_RELOCATE_LD_H */
|