This is the mail archive of the binutils@sources.redhat.com 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: Handle SEC_LINK_DUPLICATES_SAME_CONTENTS for arm-linux


On Fri, Aug 20, 2004 at 01:32:40PM -0400, Daniel Jacobowitz wrote:
> Thanks.  How's this?

As you might have guessed from my rather slack review of your previous
patch, I trust you enough to give the OK without proper review.  But
since you asked...  :)

> +	    case SEC_LINK_DUPLICATES_SAME_CONTENTS:
> +	      if (sec->size != l->sec->size)
> +		(*_bfd_error_handler)
> +		  (_("%B: duplicate section `%A' has different size\n"),
> +		   abfd, sec);
> +	      else

I'd be inclined to write "else if (sec->size != 0)" here, and leave out
the NULL content checks below.

> +		{
> +		  bfd_byte *sec_contents, *l_sec_contents;
> +
> +		  if (!bfd_malloc_and_get_section (abfd, sec, &sec_contents))
> +		    (*_bfd_error_handler)
> +		      (_("%B: warning: could not read contents of section `%A'\n"),
> +		       abfd, sec);
> +		  else if (!bfd_malloc_and_get_section (l->sec->owner, l->sec,
> +							&l_sec_contents))
> +		    (*_bfd_error_handler)
> +		      (_("%B: warning: could not read contents of section `%A'\n"),
> +		       l->sec->owner, l->sec);
> +		  else if (sec_contents == NULL && l_sec_contents == NULL)
> +		    /* OK; both sections have 0 size.  */;
> +		  else if (sec_contents != NULL && l_sec_contents != NULL
> +			   && memcmp (sec_contents, l_sec_contents,
> +				      sec->size) != 0)
> +		    (*_bfd_error_handler)
> +		      (_("%B: warning: duplicate section `%A' has different contents\n"),
> +		       abfd, sec);
> +
> +		  if (sec_contents)
> +		    free (sec_contents);
> +		  if (l_sec_contents)
> +		    free (l_sec_contents);
> +		}
> +	      break;
>  	    }
>  
>  	  /* Set the output_section field so that lang_add_section

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


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