فهرست منبع

[PATCH] x86_64: Don't define string functions to builtin

gcc should handle this anyways, and it causes problems when
sprintf is turned into strcpy by gcc behind our backs and
the C fallback version of strcpy is actually defining __builtin_strcpy

Then drop -ffreestanding from the main Makefile because it isn't
needed anymore and implies -fno-builtin, which is wrong now.
(it was only added for x86-64, so dropping it should be safe)

Noticed by Roman Zippel

Cc: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Andi Kleen 19 سال پیش
والد
کامیت
6edfba1b33
3فایلهای تغییر یافته به همراه7 افزوده شده و 16 حذف شده
  1. 1 2
      Makefile
  2. 3 0
      arch/i386/Makefile
  3. 3 14
      include/asm-x86_64/string.h

+ 1 - 2
Makefile

@@ -306,8 +306,7 @@ LINUXINCLUDE    := -Iinclude \
 CPPFLAGS        := -D__KERNEL__ $(LINUXINCLUDE)
 CPPFLAGS        := -D__KERNEL__ $(LINUXINCLUDE)
 
 
 CFLAGS 		:= -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
 CFLAGS 		:= -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
-	  	   -fno-strict-aliasing -fno-common \
-		   -ffreestanding
+	  	   -fno-strict-aliasing -fno-common
 AFLAGS		:= -D__ASSEMBLY__
 AFLAGS		:= -D__ASSEMBLY__
 
 
 # Read KERNELRELEASE from .kernelrelease (if it exists)
 # Read KERNELRELEASE from .kernelrelease (if it exists)

+ 3 - 0
arch/i386/Makefile

@@ -39,6 +39,9 @@ include $(srctree)/arch/i386/Makefile.cpu
 
 
 cflags-$(CONFIG_REGPARM) += -mregparm=3
 cflags-$(CONFIG_REGPARM) += -mregparm=3
 
 
+# temporary until string.h is fixed
+cflags-y += -ffreestanding
+
 # Disable unit-at-a-time mode on pre-gcc-4.0 compilers, it makes gcc use
 # Disable unit-at-a-time mode on pre-gcc-4.0 compilers, it makes gcc use
 # a lot more stack due to the lack of sharing of stacklots:
 # a lot more stack due to the lack of sharing of stacklots:
 CFLAGS				+= $(shell if [ $(call cc-version) -lt 0400 ] ; then echo $(call cc-option,-fno-unit-at-a-time); fi ;)
 CFLAGS				+= $(shell if [ $(call cc-version) -lt 0400 ] ; then echo $(call cc-option,-fno-unit-at-a-time); fi ;)

+ 3 - 14
include/asm-x86_64/string.h

@@ -40,26 +40,15 @@ extern void *__memcpy(void *to, const void *from, size_t len);
 
 
 
 
 #define __HAVE_ARCH_MEMSET
 #define __HAVE_ARCH_MEMSET
-#define memset __builtin_memset
+void *memset(void *s, int c, size_t n);
 
 
 #define __HAVE_ARCH_MEMMOVE
 #define __HAVE_ARCH_MEMMOVE
 void * memmove(void * dest,const void *src,size_t count);
 void * memmove(void * dest,const void *src,size_t count);
 
 
-/* Use C out of line version for memcmp */ 
-#define memcmp __builtin_memcmp
 int memcmp(const void * cs,const void * ct,size_t count);
 int memcmp(const void * cs,const void * ct,size_t count);
-
-/* out of line string functions use always C versions */ 
-#define strlen __builtin_strlen
 size_t strlen(const char * s);
 size_t strlen(const char * s);
-
-#define strcpy __builtin_strcpy
-char * strcpy(char * dest,const char *src);
-
-#define strcat __builtin_strcat
-char * strcat(char * dest, const char * src);
-
-#define strcmp __builtin_strcmp
+char *strcpy(char * dest,const char *src);
+char *strcat(char * dest, const char * src);
 int strcmp(const char * cs,const char * ct);
 int strcmp(const char * cs,const char * ct);
 
 
 #endif /* __KERNEL__ */
 #endif /* __KERNEL__ */