This is the mail archive of the mailing list for the glibc 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]

[PATCH] glibc 2.7 compilation failure with GCC 4.2.x due to 486+-specific memmove() redeclaration and _FORTIFY_SOURCEry

(A bug may have been raised for this already, but glibc bugzilla appears
to be down: at least I'm getting zero results for *any* query, no matter
how broad...)

Compilation of glibc 2.7 with GCC 4.2.x fails with this error:

loki 14 /usr/packages/glibc/libc-patched/debug% gcc warning-nop.c -c -std=gnu99 -fgnu89-inline -O2 -Wall -Winline -Wwrite-strings -fmerge-all-constants -march=native -pipe -Wstrict-prototypes -mpreferred-stack-boundary=2  -g0 -O2 -fomit-frame-pointer -D__USE_STRING_INLINES    -I../include -I/usr/packages/glibc/i686-esperi/debug -I/usr/packages/glibc/i686-esperi -I../sysdeps/i386/elf -I../nptl/sysdeps/unix/sysv/linux/i386/i686 -I../nptl/sysdeps/unix/sysv/linux/i386 -I../sysdeps/unix/sysv/linux/i386 -I../nptl/sysdeps/unix/sysv/linux -I../nptl/sysdeps/pthread -I../sysdeps/pthread -I../sysdeps/unix/sysv/linux -I../sysdeps/gnu -I../sysdeps/unix/common -I../sysdeps/unix/mman -I../sysdeps/unix/inet -I../sysdeps/unix/sysv/i386 -I../nptl/sysdeps/unix/sysv -I../sysdeps/unix/sysv -I../sysdeps/unix/i386 -I../nptl/sysdeps/unix -I../sysdeps/unix -I../sysdeps/posix -I../sysdeps/i386/i686/fpu -I../nptl/sysdeps/i386/i686 -I../sysdeps/i386/i686 -I../sysdeps/i386/i486 -I../nptl/sysdeps/i386/i486 -I../sysdeps/i386/fpu -I../nptl/sysdeps/i386 -I../sysdeps/i386 -I../sysdeps/wordsize-32 -I../sysdeps/ieee754/ldbl-96 -I../sysdeps/ieee754/dbl-64 -I../sysdeps/ieee754/flt-32 -I../sysdeps/ieee754 -I../sysdeps/generic/elf -I../sysdeps/generic -I../nptl  -I.. -I../libio -I. -I /lib/modules/ -D_LIBC_REENTRANT -include ../include/libc-symbols.h       -o /usr/packages/glibc/i686-esperi/debug/warning-nop.o -MD -MP -MF /usr/packages/glibc/i686-esperi/debug/warning-nop.o.dt -MT /usr/packages/glibc/i686-esperi/debug/warning-nop.o
In file included from ../include/bits/string3.h:1,
                 from ../string/string.h:428,
                 from ../include/string.h:49,
                 from warning-nop.c:53:
../string/bits/string3.h:58: error: redefinition of ‘memmove’
../string/string.h:59: warning: ‘memset’ declared inline after being called

The cause of the error is quite obvious: memmove() is declared in
string/string.h as

/* Copy N bytes of SRC to DEST, guaranteeing
   correct behavior for overlapping strings.  */
extern void *memmove (void *__dest, __const void *__src, size_t __n)
     __THROW __nonnull ((1, 2));

and then defined in bits/i386/i486/bits/string.h as

memmove (void *__dest, __const void *__src, size_t __n)

and then *redefined* in string/bits/string3.h as

__extern_always_inline void *
__NTH (memmove (void *__restrict __dest, __const void *__restrict __src,
		size_t __len))
  return __builtin___memmove_chk (__dest, __src, __len, __bos0 (__dest));

This doesn't happen for any other string functions because all the other
functions in bits/i386/i486/string.h are either defined as macros that
call optimized functions with other names, or are not fortified
(e.g. memcmp()).

To be blunt I can't see how this would ever work: are gnu_inline
functions permitted to override functions with identical names declared
earlier in GCC HEAD, or something?

(The similar warning under _FORTIFY_SOURCE,

../string/string.h:59: warning: 'memset' declared inline after being called

is harder to avoid and doesn't break the build so I haven't fixed it here;
but it might break autoconf tests so probably should be fixed.)

A possible fix in the spirit of the other code in that file (tested on
i686-pc-linux-gnu, `make check' doesn't have any suspicious-looking

2007-10-21  Nix  <>

	* sysdeps/i386/i486/bits/string.h (memmove): New macro.
	Function of that name renamed to...
	* sysdeps/i386/i486/bits/string.h (__memmove_g): ... this.

Index: libc-patched/sysdeps/i386/i486/bits/string.h
--- libc-patched.orig/sysdeps/i386/i486/bits/string.h	2007-10-20 19:46:17.000000000 +0100
+++ libc-patched/sysdeps/i386/i486/bits/string.h	2007-10-21 17:31:06.000000000 +0100
@@ -143,10 +143,13 @@
 #define _HAVE_STRING_ARCH_memmove 1
+#define memmove(dest, src, n) \
+  __memmove_g ((dest), (src), (n))
 /* Copy N bytes of SRC to DEST, guaranteeing
    correct behavior for overlapping strings.  */
-memmove (void *__dest, __const void *__src, size_t __n)
+__memmove_g (void *__dest, __const void *__src, size_t __n)
   register unsigned long int __d0, __d1, __d2;
   register void *__tmp = __dest;

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