aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2007-03-07 02:14:40 +0000
committerAlan Modra <amodra@gmail.com>2007-03-07 02:14:40 +0000
commit0e922b770e416241597521a0ed6c1a34aba2877a (patch)
treec1a5384f1709d631d188c15797e61a9bfea6150d /bfd
parent5a95d5a9695da6770d68aa512ee423dc034e4b42 (diff)
downloadgdb-0e922b770e416241597521a0ed6c1a34aba2877a.zip
gdb-0e922b770e416241597521a0ed6c1a34aba2877a.tar.gz
gdb-0e922b770e416241597521a0ed6c1a34aba2877a.tar.bz2
PR 4144
* elf.c (assign_file_positions_for_load_sections): Don't adjust p_memsz for !SEC_LOAD section vma modulo page size. Instead, use the same lma based adjustment for SEC_LOAD sections.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog8
-rw-r--r--bfd/elf.c34
2 files changed, 20 insertions, 22 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 37b3c2d..915b689 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,11 @@
+2007-03-07 Alan Modra <amodra@bigpond.net.au>
+
+ PR 4144
+ * elf.c (assign_file_positions_for_load_sections): Don't
+ adjust p_memsz for !SEC_LOAD section vma modulo page size.
+ Instead, use the same lma based adjustment for SEC_LOAD
+ sections.
+
2007-03-01 Bob Wilson <bob.wilson@acm.org>
* elf32-xtensa.c (analyze_relocations): Zero src_count if not relaxing.
diff --git a/bfd/elf.c b/bfd/elf.c
index e2b0f05..d882882 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -1,7 +1,7 @@
/* ELF executable support for BFD.
Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
- 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+ 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
@@ -4495,11 +4495,13 @@ assign_file_positions_for_load_sections (bfd *abfd,
if (p->p_type == PT_LOAD
|| p->p_type == PT_TLS)
{
- bfd_signed_vma adjust;
+ bfd_signed_vma adjust = sec->lma - (p->p_paddr + p->p_filesz);
- if ((flags & SEC_LOAD) != 0)
+ if ((flags & SEC_LOAD) != 0
+ || ((flags & SEC_ALLOC) != 0
+ && ((flags & SEC_THREAD_LOCAL) == 0
+ || p->p_type == PT_TLS)))
{
- adjust = sec->lma - (p->p_paddr + p->p_filesz);
if (adjust < 0)
{
(*_bfd_error_handler)
@@ -4507,25 +4509,13 @@ assign_file_positions_for_load_sections (bfd *abfd,
abfd, sec, (unsigned long) sec->lma);
adjust = 0;
}
- off += adjust;
- p->p_filesz += adjust;
- p->p_memsz += adjust;
- }
- /* .tbss is special. It doesn't contribute to p_memsz of
- normal segments. */
- else if ((flags & SEC_ALLOC) != 0
- && ((flags & SEC_THREAD_LOCAL) == 0
- || p->p_type == PT_TLS))
- {
- /* The section VMA must equal the file position
- modulo the page size. */
- bfd_size_type page = align;
- if (page < maxpagesize)
- page = maxpagesize;
- adjust = vma_page_aligned_bias (sec->vma,
- p->p_vaddr + p->p_memsz,
- page);
p->p_memsz += adjust;
+
+ if ((flags & SEC_LOAD) != 0)
+ {
+ off += adjust;
+ p->p_filesz += adjust;
+ }
}
}