summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@bigpond.net.au>2011-06-24 03:39:31 +0000
committerAlan Modra <amodra@bigpond.net.au>2011-06-24 03:39:31 +0000
commitb9e33aadcd5685970d975a28e17cdba5bffc48d1 (patch)
treece4d4c023bb513799a912373bc1120ded4e506c8
parent77f75d3189c3d7789ba883385378e2b970faea51 (diff)
downloadbinutils-redhat-b9e33aadcd5685970d975a28e17cdba5bffc48d1.tar.gz
PR ld/12921
* elf.c (assign_file_positions_for_load_sections): Don't align sh_offset for all SHT_NOBITS sections here, just .tbss sections that don't get a PT_LOAD.
-rw-r--r--bfd/ChangeLog7
-rw-r--r--bfd/elf.c36
2 files changed, 26 insertions, 17 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index f75c78d100..2d09b5f217 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,10 @@
+2011-06-24 Alan Modra <amodra@gmail.com>
+
+ PR ld/12921
+ * elf.c (assign_file_positions_for_load_sections): Don't align
+ sh_offset for all SHT_NOBITS sections here, just .tbss sections
+ that don't get a PT_LOAD.
+
2011-06-22 Alan Modra <amodra@gmail.com>
* elflink.c (_bfd_elf_merge_symbol): Allow type changes for
diff --git a/bfd/elf.c b/bfd/elf.c
index b57f88ca3b..27ee4cfeab 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -4667,24 +4667,26 @@ assign_file_positions_for_load_sections (bfd *abfd,
}
else
{
- if (p->p_type == PT_LOAD
- || (this_hdr->sh_type == SHT_NOBITS
- && (this_hdr->sh_flags & SHF_TLS) != 0
- && this_hdr->sh_offset == 0))
+ if (p->p_type == PT_LOAD)
{
- if (this_hdr->sh_type == SHT_NOBITS)
- {
- /* These sections don't really need sh_offset,
- but give them one anyway. */
- bfd_vma adjust = vma_page_aligned_bias (this_hdr->sh_addr,
- off, align);
- this_hdr->sh_offset = sec->filepos = off + adjust;
- }
- else
- {
- this_hdr->sh_offset = sec->filepos = off;
- off += this_hdr->sh_size;
- }
+ this_hdr->sh_offset = sec->filepos = off;
+ if (this_hdr->sh_type != SHT_NOBITS)
+ off += this_hdr->sh_size;
+ }
+ else if (this_hdr->sh_type == SHT_NOBITS
+ && (this_hdr->sh_flags & SHF_TLS) != 0
+ && this_hdr->sh_offset == 0)
+ {
+ /* This is a .tbss section that didn't get a PT_LOAD.
+ (See _bfd_elf_map_sections_to_segments "Create a
+ final PT_LOAD".) Set sh_offset to the value it
+ would have if we had created a zero p_filesz and
+ p_memsz PT_LOAD header for the section. This
+ also makes the PT_TLS header have the same
+ p_offset value. */
+ bfd_vma adjust = vma_page_aligned_bias (this_hdr->sh_addr,
+ off, align);
+ this_hdr->sh_offset = sec->filepos = off + adjust;
}
if (this_hdr->sh_type != SHT_NOBITS)