work-around: the glibc adobe flash incompatibility

Chris Adams cmadams at
Wed Nov 17 16:25:02 UTC 2010

Once upon a time, John Reiser <jreiser at> said:
> For right now (the immediate present) a work-around is to use the 'memmove'
> subroutine as the resolution of any reference to the symbol 'memcpy'.
> The quick-and-dirty way to do this

It would probably be easier to use an LD_PRELOAD to load a wrapper to
change memcpy() with overlaps to memmove().  This would obviously slow
down all memcpy() calls, but maybe it could just be used for Flash (or
at least just for plugins).  Something like (untested):

/* Library preload to replacing overlapping memcpy() with memmove()
 * Compile with:
 *   gcc -O2 -ldl -fpic -shared -o preload-memcpy.c
 * Use like
 *   LD_PRELOAD=/path/to/; export LD_PRELOAD
 *   <some command>

#define _GNU_SOURCE
#include <string.h>
#include <dlfcn.h>
#include <assert.h>

static void * (*real_memcpy) (void *dest, const void *src, size_t n);
void *memcpy (void *dest, const void *src, size_t n)
	char *d = (char *) dest;
	char *s = (char *) src;

	if (((d < s) && ((d + n - 1) >= s)) ||
	    ((s < d) && ((s + n - 1) >= d)))
		return memmove (dest, src, n);
	if (! real_memcpy)
		assert (real_memcpy = dlsym (RTLD_NEXT, "memcpy"));
	return real_memcpy (dest, src, n);

Chris Adams <cmadams at>
Systems and Network Administrator - HiWAAY Internet Services
I don't speak for anybody but myself - that's enough trouble.

More information about the devel mailing list