This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [patch] bfd/elf.c: fix section overlap warning again
- From: Alan Modra <amodra at gmail dot com>
- To: DJ Delorie <dj at redhat dot com>
- Cc: binutils at sourceware dot org
- Date: Thu, 15 Jul 2010 13:08:10 +0930
- Subject: Re: [patch] bfd/elf.c: fix section overlap warning again
- References: <201007090018.o690Ipn5012630@greed.delorie.com>
On Thu, Jul 08, 2010 at 08:18:51PM -0400, DJ Delorie wrote:
> @@ -4457,9 +4457,16 @@ assign_file_positions_for_load_sections
> && ((this_hdr->sh_flags & SHF_TLS) == 0
> || p->p_type == PT_TLS))))
> {
> - bfd_vma adjust = sec->lma - (p->p_paddr + p->p_memsz);
> -
> - if (sec->lma < p->p_paddr + p->p_memsz)
> + /* This is the end VMA for the previous segment. */
s/segment/section/ "segment" is what the program header describes.
> + bfd_vma p_end = p->p_paddr + p->p_memsz;
> + /* This is the gap between segments. */
same
> + bfd_vma adjust = sec->lma - p_end;
> +
> + /* The first comparison checks for the usual case. The
> + second checks for segments which overflow the address
> + space. */
> + if (sec->lma < p->p_paddr + p->p_memsz
> + || (p_end < p->p_paddr && p->p_paddr < sec->lma))
Isn't it an overflow if p->p_addr == sec->lma in the second case?
I'd write
if (sec->lma < p_end
|| (p_end < p->p_paddr && sec->lma >= p->p_paddr))
> {
> (*_bfd_error_handler)
> (_("%B: section %A lma 0x%lx overlaps previous sections"),
--
Alan Modra
Australia Development Lab, IBM