diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2022-10-28 15:09:01 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2022-10-28 15:09:01 +0000 |
commit | 8841f89d635f19aa590de32596454f706e4698ba (patch) | |
tree | c68d47b53e8405f39bdbed4e3a4a4579c88a4683 /gnu | |
parent | 1806d1aa95630f4062f022e475802bad19ae1ac8 (diff) |
Implement DT_MIPS_RLD_MAP_REL support and add such an entry to PIE
executables.
ok deraadt@
Diffstat (limited to 'gnu')
-rw-r--r-- | gnu/usr.bin/binutils-2.17/bfd/elfxx-mips.c | 22 | ||||
-rw-r--r-- | gnu/usr.bin/binutils-2.17/include/elf/mips.h | 4 |
2 files changed, 23 insertions, 3 deletions
diff --git a/gnu/usr.bin/binutils-2.17/bfd/elfxx-mips.c b/gnu/usr.bin/binutils-2.17/bfd/elfxx-mips.c index 97d8854871d..39945ba674b 100644 --- a/gnu/usr.bin/binutils-2.17/bfd/elfxx-mips.c +++ b/gnu/usr.bin/binutils-2.17/bfd/elfxx-mips.c @@ -5943,7 +5943,7 @@ _bfd_mips_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) } if ((IRIX_COMPAT (abfd) == ict_irix5 || IRIX_COMPAT (abfd) == ict_none) - && !info->shared + && info->executable && bfd_get_section_by_name (abfd, ".rld_map") == NULL) { s = bfd_make_section_with_flags (abfd, ".rld_map", @@ -6020,6 +6020,11 @@ _bfd_mips_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) if (! bfd_elf_link_record_dynamic_symbol (info, h)) return FALSE; + } + + if (info->executable) + { + const char *name; if (! mips_elf_hash_table (info)->use_rld_obj_head) { @@ -7421,7 +7426,7 @@ _bfd_mips_elf_size_dynamic_sections (bfd *output_bfd, of .text section. So put a dummy. XXX */ s->size += htab->function_stub_size; } - else if (! info->shared + else if (info->executable && ! mips_elf_hash_table (info)->use_rld_obj_head && strncmp (name, ".rld_map", 8) == 0) { @@ -7496,6 +7501,16 @@ _bfd_mips_elf_size_dynamic_sections (bfd *output_bfd, return FALSE; } } + else if (info->pie) + { + if (!MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_RLD_MAP_REL, 0)) + return FALSE; + if (!SGI_COMPAT (output_bfd)) + { + if (!MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_DEBUG, 0)) + return FALSE; + } + } else { /* Shared libraries on traditional mips have DT_DEBUG. */ @@ -8246,7 +8261,7 @@ _bfd_mips_elf_finish_dynamic_symbol (bfd *output_bfd, if (IRIX_COMPAT (output_bfd) == ict_irix6) mips_elf_irix6_finish_dynamic_symbol (output_bfd, name, sym); - if (! info->shared) + if (info->executable) { if (! mips_elf_hash_table (info)->use_rld_obj_head && (strcmp (name, "__rld_map") == 0 @@ -8695,6 +8710,7 @@ _bfd_mips_elf_finish_dynamic_sections (bfd *output_bfd, break; case DT_MIPS_RLD_MAP: + case DT_MIPS_RLD_MAP_REL: dyn.d_un.d_ptr = mips_elf_hash_table (info)->rld_value; break; diff --git a/gnu/usr.bin/binutils-2.17/include/elf/mips.h b/gnu/usr.bin/binutils-2.17/include/elf/mips.h index a0b1d606338..88285c56e68 100644 --- a/gnu/usr.bin/binutils-2.17/include/elf/mips.h +++ b/gnu/usr.bin/binutils-2.17/include/elf/mips.h @@ -659,6 +659,10 @@ extern void bfd_mips_elf32_swap_reginfo_out /* Address of auxiliary .dynamic. */ #define DT_MIPS_AUX_DYNAMIC 0x70000031 + +/* Relative address of run time loader map, used for debugging. */ +#define DT_MIPS_RLD_MAP_REL 0x70000035 + /* Flags which may appear in a DT_MIPS_FLAGS entry. */ |