This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
PATCH: PR ld/3314: ELF linker aligns empty section
- From: "H. J. Lu" <hjl at lucon dot org>
- To: binutils at sources dot redhat dot com
- Date: Fri, 6 Oct 2006 06:39:08 -0700
- Subject: PATCH: PR ld/3314: ELF linker aligns empty section
When we are outputing an empty loadable section, we consider it not
loadable. But we still align it at page boundary. This patch fixes
it.
H.J.
----
2006-10-06 H.J. Lu <hongjiu.lu@intel.com>
PR ld/3314
* elf.c (assign_file_positions_for_non_load_sections): Don't
page align empty SHF_ALLOC sections.
--- bfd/elf.c.empty 2006-09-29 09:00:21.000000000 -0700
+++ bfd/elf.c 2006-10-06 06:23:25.000000000 -0700
@@ -4661,18 +4661,22 @@ assign_file_positions_for_non_load_secti
else if ((hdr->sh_flags & SHF_ALLOC) != 0)
{
if (hdr->sh_size != 0)
- ((*_bfd_error_handler)
- (_("%B: warning: allocated section `%s' not in segment"),
+ {
+ /* We don't need to adjust section offset for empty
+ sections. */
+ ((*_bfd_error_handler)
+ (_("%B: warning: allocated section `%s' not in segment"),
abfd,
(hdr->bfd_section == NULL
- ? "*unknown*"
+ ? "*unknown*"
: hdr->bfd_section->name)));
- if ((abfd->flags & D_PAGED) != 0)
- off += vma_page_aligned_bias (hdr->sh_addr, off,
- bed->maxpagesize);
- else
- off += vma_page_aligned_bias (hdr->sh_addr, off,
- hdr->sh_addralign);
+ if ((abfd->flags & D_PAGED) != 0)
+ off += vma_page_aligned_bias (hdr->sh_addr, off,
+ bed->maxpagesize);
+ else
+ off += vma_page_aligned_bias (hdr->sh_addr, off,
+ hdr->sh_addralign);
+ }
off = _bfd_elf_assign_file_position_for_section (hdr, off,
FALSE);
}