Re: Inflation of vmlinux by linker on x86_64

From: H. Peter Anvin
Date: Fri Sep 26 2008 - 14:52:35 EST


Joris van Rantwijk wrote:
#endif
- memcpy(dest,
- output + phdr->p_offset,
- phdr->p_filesz);
+ src = output + phdr->p_offset;
+
+ /* order the copying to avoid overwriting */
+ if ((direction == 1 && dest <= src) ||
+ (direction == -1 && dest > src)) {
+ /* note: unlike standard memcpy, this one
+ * is safe to use when dest and src overlap.
+ */
+ memcpy(dest, src, phdr->p_filesz);
+ }
+
break;

Instead of adding a comment like this, we should simply rename it memmove().

Furthermore, we probably spend enough time copying that using a real memmove() implementation, using string instructions, would be good.

-hpa
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/