Re: Undefined references to 'memcpy' when compiling Linux Kernel

From: Tom Leete (
Date: Fri Jun 16 2000 - 20:09:10 EST

Richard Henderson wrote:
> On Fri, Jun 16, 2000 at 07:20:03PM -0400, Tom Leete wrote:
> > By exporting it you take its address, which runs afoul of inlining.
> Do you have any idea what you're talking about?
> r~


In current i386 memcpy is a macro. It inlines either
__constant_memcpy() or __memcpy(), themselves macros. I have
reason to know that explicit inlining is regarded as
paramount there.

To export memcpy it must be an addressable function.

static __inline__ void *memcpy(void *dest, void *src, size_t
        /* define me */
        return dest;
will fail to inline for any compilation unit in which memcpy
is referenced directly -- ie wherever ksyms is.

inline void *memcpy(void *dest, void *src, size_t len)
        /* define me */
        return dest;
fails to provide an addressable copy.

This will work:

#define MEMCPY_CODE(d,s,l) { /* code */ return d; }
extern __inline__
void *memcpy(void *dest, void *src, sizet len)
somewhere in arch/*/lib/ or arch/*/mm/
#include <asm/string.h>

void *memcpy(void *dest, void *src, sizet len) MEMCPY_CODE(dest,src,len) ________________

The new C Standard also provides an inline construct for this, but I havent tried any new std compilers yet. The standard will break all the storage class modified inline declarations in the kernel. One more backward flag, one of these days.

Ref. $ info gcc # node "C Extensions::Inline"


- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to Please read the FAQ at

This archive was generated by hypermail 2b29 : Fri Jun 23 2000 - 21:00:13 EST