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: Fix valgrind nm complaint: memcpy to == from


> Date: Thu, 13 Nov 2008 13:46:47 +1030
> From: Alan Modra <amodra@bigpond.net.au>

> On Thu, Nov 13, 2008 at 03:57:33AM +0100, Hans-Peter Nilsson wrote:
> > While this and the other calls in ld.log were simple to == from
> > cases and could avoid the call to memcpy at all, it seems the
> > code is intended to also have partial overlapping to and from,
> 
> No, we'll never have partial overlaps.  size is that of one symbol.

Hm, right, it's element-by-element.  I guess I was misled by the
"compact them downward to get rid of the rest" head comment.
Mea culpa.

> > so it's memmove, not memcpy that should be used.  No regressions
> > for the binutils testsuite, fixes the valgrind nm complaints.
> 
> I think it's better to use
> 
> 	  if (to != from)
> 	    memcpy (to, from, size);
> 
> if for no other reason than memmove will lead people to think there
> may be partial overlaps.  ;-)

That's my first thought, so will test & commit with that.

brgds, H-P


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