From 51d71fd2cc99f309cb792cc48ae910baeb92b2a0 Mon Sep 17 00:00:00 2001 From: Nikola Veljkovic Date: Thu, 25 Dec 2014 12:08:00 -0800 Subject: Add support for the new tag DT_MIPS_RLD_MAP2. DT_MIPS_RLD_MAP2 is used by the loader to communicate shared library information of a PIE to the GDB. Signed-off-by: Raghu Gandham --- binutils-2.25/bfd/elfxx-mips.c | 33 ++++++++++++++++++++++++++++++--- binutils-2.25/binutils/readelf.c | 1 + binutils-2.25/include/elf/mips.h | 3 +++ 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/binutils-2.25/bfd/elfxx-mips.c b/binutils-2.25/bfd/elfxx-mips.c index 2bd45d20..200dae88 100644 --- a/binutils-2.25/bfd/elfxx-mips.c +++ b/binutils-2.25/bfd/elfxx-mips.c @@ -7622,7 +7622,7 @@ _bfd_mips_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) htab->sstubs = s; if (!mips_elf_hash_table (info)->use_rld_obj_head - && !info->shared + && info->executable && bfd_get_linker_section (abfd, ".rld_map") == NULL) { s = bfd_make_section_anyway_with_flags (abfd, ".rld_map", @@ -7686,7 +7686,7 @@ _bfd_mips_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) (void) bfd_set_section_alignment (abfd, s, MIPS_ELF_LOG_FILE_ALIGN (abfd)); } - if (!info->shared) + if (info->executable) { const char *name; @@ -9727,7 +9727,7 @@ _bfd_mips_elf_size_dynamic_sections (bfd *output_bfd, info->combreloc = 0; } } - else if (! info->shared + else if (info->executable && ! mips_elf_hash_table (info)->use_rld_obj_head && CONST_STRNEQ (name, ".rld_map")) { @@ -9790,6 +9790,10 @@ _bfd_mips_elf_size_dynamic_sections (bfd *output_bfd, && !MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_RLD_MAP, 0)) return FALSE; + if (info->executable + && !MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_RLD_MAP2, 0)) + return FALSE; + /* The DT_DEBUG entry may be filled in by the dynamic linker and used by the debugger. */ if (info->executable @@ -11501,6 +11505,27 @@ _bfd_mips_elf_finish_dynamic_sections (bfd *output_bfd, } break; + case DT_MIPS_RLD_MAP2: + { + struct elf_link_hash_entry *h; + bfd_vma dt_addr, rld_addr; + h = mips_elf_hash_table (info)->rld_symbol; + if (!h) + { + dyn_to_skip = MIPS_ELF_DYN_SIZE (dynobj); + swap_out_p = FALSE; + break; + } + s = h->root.u.def.section; + + dt_addr = (sdyn->output_section->vma + sdyn->output_offset + + b - sdyn->contents); + rld_addr = (s->output_section->vma + s->output_offset + + h->root.u.def.value); + dyn.d_un.d_ptr = rld_addr - dt_addr; + } + break; + case DT_MIPS_OPTIONS: s = (bfd_get_section_by_name (output_bfd, MIPS_ELF_OPTIONS_SECTION_NAME (output_bfd))); @@ -15418,6 +15443,8 @@ _bfd_mips_elf_get_target_dtag (bfd_vma dtag) return "MIPS_HIPAGENO"; case DT_MIPS_RLD_MAP: return "MIPS_RLD_MAP"; + case DT_MIPS_RLD_MAP2: + return "MIPS_RLD_MAP2"; case DT_MIPS_DELTA_CLASS: return "MIPS_DELTA_CLASS"; case DT_MIPS_DELTA_CLASS_NO: diff --git a/binutils-2.25/binutils/readelf.c b/binutils-2.25/binutils/readelf.c index 997b463d..d630684b 100644 --- a/binutils-2.25/binutils/readelf.c +++ b/binutils-2.25/binutils/readelf.c @@ -1618,6 +1618,7 @@ get_mips_dynamic_type (unsigned long type) case DT_MIPS_GOTSYM: return "MIPS_GOTSYM"; case DT_MIPS_HIPAGENO: return "MIPS_HIPAGENO"; case DT_MIPS_RLD_MAP: return "MIPS_RLD_MAP"; + case DT_MIPS_RLD_MAP2: return "MIPS_RLD_MAP2"; case DT_MIPS_DELTA_CLASS: return "MIPS_DELTA_CLASS"; case DT_MIPS_DELTA_CLASS_NO: return "MIPS_DELTA_CLASS_NO"; case DT_MIPS_DELTA_INSTANCE: return "MIPS_DELTA_INSTANCE"; diff --git a/binutils-2.25/include/elf/mips.h b/binutils-2.25/include/elf/mips.h index a76dae74..f3589fff 100644 --- a/binutils-2.25/include/elf/mips.h +++ b/binutils-2.25/include/elf/mips.h @@ -748,6 +748,9 @@ extern void bfd_mips_elf32_swap_reginfo_out /* Points to the base of a writable PLT. */ #define DT_MIPS_RWPLT 0x70000034 + +/* Address of run time loader map, used for debugging. */ +#define DT_MIPS_RLD_MAP2 0x70000035 /* Flags which may appear in a DT_MIPS_FLAGS entry. */ -- cgit v1.2.3