This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
PATCH: PR ld/4701: binutils generates invalid klibc-based binary on Linux x86_64
- From: "H. J. Lu" <hjl at lucon dot org>
- To: binutils at sources dot redhat dot com
- Cc: amodra at bigpond dot net dot au
- Date: Wed, 27 Jun 2007 11:09:03 -0700
- Subject: PATCH: PR ld/4701: binutils generates invalid klibc-based binary on Linux x86_64
I don't think we can skip segment alignment on disk when its offset
< alignment. This patch fixes it. I will try to find a small testcase.
H.J.
---
2007-06-27 H.J. Lu <hongjiu.lu@intel.com>
PR ld/4701
* elf.c (assign_file_positions_for_load_sections): Skip segment
alignment on disk only if its offset >= alignment.
--- bfd/elf.c.bss 2007-06-26 10:15:25.000000000 -0700
+++ bfd/elf.c 2007-06-27 10:59:45.000000000 -0700
@@ -4518,21 +4518,24 @@ assign_file_positions_for_load_sections
adjust = vma_page_aligned_bias (m->sections[0]->vma, off, align);
if (adjust != 0)
{
- /* If the first section isn't loadable, the same holds
- for any other sections. We don't need to align the
- segment on disk since the segment doesn't need file
- space. */
- i = 0;
- while (elf_section_type (m->sections[i]) == SHT_NOBITS)
+ if ((ufile_ptr) off >= align)
{
- /* If a segment starts with .tbss, we need to look
- at the next section to decide whether the segment
- has any loadable sections. */
- if ((elf_section_flags (m->sections[i]) & SHF_TLS) == 0
- || ++i >= m->count)
+ /* If the first section isn't loadable, the same holds
+ for any other sections. We don't need to align the
+ segment on disk since the segment doesn't need file
+ space. */
+ i = 0;
+ while (elf_section_type (m->sections[i]) == SHT_NOBITS)
{
- adjust = 0;
- break;
+ /* If a segment starts with .tbss, we need to look
+ at the next section to decide whether the segment
+ has any loadable sections. */
+ if (!(elf_section_flags (m->sections[i]) & SHF_TLS)
+ || ++i >= m->count)
+ {
+ adjust = 0;
+ break;
+ }
}
}
off += adjust;