This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] bfd/elf.c: fix section overlap warning again


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]