PATCH: PR ld/4701: binutils generates invalid klibc-based binary on Linux x86_64
H. J. Lu
hjl@lucon.org
Wed Jun 27 18:44:00 GMT 2007
More information about the Binutils mailing list
Wed Jun 27 18:44:00 GMT 2007
- Previous message (by thread): PATCH: PR ld/4701: binutils generates invalid klibc-based binary on Linux x86_64
- Next message (by thread): PATCH: PR ld/4701: binutils generates invalid klibc-based binary on Linux x86_64
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Wed, Jun 27, 2007 at 11:09:03AM -0700, H. J. Lu wrote: > 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. > > Here is the updated patch with a small testcase. H.J. ---- bfd/ 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. ld/testsuite/ 2007-06-27 H.J. Lu <hongjiu.lu@intel.com> PR ld/4701 * ld-elf/noload-2.d: New. --- binutils/bfd/elf.c.bss 2007-06-26 10:15:25.000000000 -0700 +++ binutils/bfd/elf.c 2007-06-27 11:39:32.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; --- binutils/ld/testsuite/ld-elf/noload-2.d.bss 2007-06-27 11:27:55.000000000 -0700 +++ binutils/ld/testsuite/ld-elf/noload-2.d 2007-06-27 11:38:42.000000000 -0700 @@ -0,0 +1,8 @@ +#source: noload-1.s +#ld: -T noload-1.t -z max-page-size=0x200000 +#readelf: -Sl --wide +#target: *-*-linux* + +#... + +LOAD +0x200000 +0x0+ +0x0+ +0x0+ +0x0+1 +RW +0x200000 +#pass
- Previous message (by thread): PATCH: PR ld/4701: binutils generates invalid klibc-based binary on Linux x86_64
- Next message (by thread): PATCH: PR ld/4701: binutils generates invalid klibc-based binary on Linux x86_64
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Binutils mailing list