From b413280cfb16834450f66f554bc0d618bb513851 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Thu, 16 Sep 2021 08:15:29 -0700 Subject: 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 --- sysdeps/mips/dl-relocate-ld.h | 32 ++++++++++++++++++++++++++++++++ sysdeps/mips/ldsodefs.h | 4 ---- 2 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 sysdeps/mips/dl-relocate-ld.h (limited to 'sysdeps/mips') diff --git a/sysdeps/mips/dl-relocate-ld.h b/sysdeps/mips/dl-relocate-ld.h new file mode 100644 index 0000000000..0c18d9a567 --- /dev/null +++ b/sysdeps/mips/dl-relocate-ld.h @@ -0,0 +1,32 @@ +/* Check if dynamic section should be relocated. MIPS version. + Copyright (C) 2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _DL_RELOCATE_LD_H +#define _DL_RELOCATE_LD_H + +/* Return true if dynamic section in the shared library L should be + relocated. */ + +static inline bool +dl_relocate_ld (const struct link_map *l) +{ + /* Never relocate dynamic section. */ + return false; +} + +#endif /* _DL_RELOCATE_LD_H */ diff --git a/sysdeps/mips/ldsodefs.h b/sysdeps/mips/ldsodefs.h index 4db7c60e38..36fd09a8bd 100644 --- a/sysdeps/mips/ldsodefs.h +++ b/sysdeps/mips/ldsodefs.h @@ -75,10 +75,6 @@ struct La_mips_64_retval; struct La_mips_64_retval *, \ const char *); -/* The MIPS ABI specifies that the dynamic section has to be read-only. */ - -#define DL_RO_DYN_SECTION 1 - #include_next /* The 64-bit MIPS ELF ABI uses an unusual reloc format. Each -- cgit v1.2.3