aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf.c
diff options
context:
space:
mode:
Diffstat (limited to 'bfd/elf.c')
-rw-r--r--bfd/elf.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/bfd/elf.c b/bfd/elf.c
index ffc9c8e..3d44ef8 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -4684,11 +4684,24 @@ assign_file_positions_for_load_sections (bfd *abfd,
}
else
{
- if (p->p_type == PT_LOAD)
+ if (p->p_type == PT_LOAD
+ || (this_hdr->sh_type == SHT_NOBITS
+ && (this_hdr->sh_flags & SHF_TLS) != 0
+ && this_hdr->sh_offset == 0))
{
- this_hdr->sh_offset = sec->filepos = off;
- if (this_hdr->sh_type != SHT_NOBITS)
- off += this_hdr->sh_size;
+ 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;
+ }
}
if (this_hdr->sh_type != SHT_NOBITS)