summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2015-04-20 08:32:45 -0700
committerH.J. Lu <hjl.tools@gmail.com>2015-04-20 12:57:30 -0700
commit9acd786df49d30f422f4fa6d747c5ea5aec6c31b (patch)
tree2b2433359b7e33890842c37e6c7b0fefd935d28c
parentc923726a882c54f32eb9e3a6439291117d6b23cd (diff)
downloadbinutils-gdb-users/hjl/compress.tar.gz
Place .shstrtab before debug sectionsusers/hjl/compress
-rw-r--r--bfd/elf.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/bfd/elf.c b/bfd/elf.c
index 2ba43f473b2..94069f68d0f 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -5616,7 +5616,7 @@ static bfd_boolean
_bfd_elf_assign_file_positions_for_non_load (bfd *abfd)
{
file_ptr off;
- Elf_Internal_Shdr **shdrpp, **end_shdrpp;
+ Elf_Internal_Shdr **shdrpp, **end_shdrpp, **debug_shdrpp = NULL;
Elf_Internal_Shdr *shdrp;
Elf_Internal_Ehdr *i_ehdrp;
const struct elf_backend_data *bed;
@@ -5677,14 +5677,18 @@ _bfd_elf_assign_file_positions_for_non_load (bfd *abfd)
name, FALSE))
return FALSE;
+ if (debug_shdrpp == NULL)
+ debug_shdrpp = shdrpp;
+
/* Update section size and contents. */
shdrp->sh_size = sec->size;
shdrp->contents = sec->contents;
shdrp->bfd_section->contents = NULL;
}
- off = _bfd_elf_assign_file_position_for_section (shdrp,
- off,
- TRUE);
+ else
+ off = _bfd_elf_assign_file_position_for_section (shdrp,
+ off,
+ TRUE);
}
}
}
@@ -5696,6 +5700,15 @@ _bfd_elf_assign_file_positions_for_non_load (bfd *abfd)
shdrp->sh_size = _bfd_elf_strtab_size (elf_shstrtab (abfd));
off = _bfd_elf_assign_file_position_for_section (shdrp, off, TRUE);
+ /* Place DWARF debug sections after section name section. */
+ if (debug_shdrpp)
+ for (shdrpp = debug_shdrpp; shdrpp < end_shdrpp; shdrpp++)
+ {
+ shdrp = *shdrpp;
+ if (shdrp->sh_offset == -1)
+ off = _bfd_elf_assign_file_position_for_section (shdrp, off, TRUE);
+ }
+
/* Place the section headers. */
i_ehdrp = elf_elfheader (abfd);
bed = get_elf_backend_data (abfd);