Fix valgrind nm complaint: memcpy to == from

Alan Modra amodra@bigpond.net.au
Thu Nov 13 03:17:00 GMT 2008


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.

> 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.  ;-)

-- 
Alan Modra
Australia Development Lab, IBM



More information about the Binutils mailing list