[PATCH 2.4.31 4/9] gcc4: fix undefined strcpy linkage errors

From: Mikael Pettersson
Date: Sun Jun 12 2005 - 06:37:55 EST


gcc4 generates a few link-time errors like:

drivers/sound/sounddrivers.o(.text+0x1d2): In function `sound_insert_unit':
: undefined reference to `strcpy'
drivers/sound/sounddrivers.o(.text+0x7b92): In function `emu10k1_find_control_gpr':
: undefined reference to `strcpy'
make: *** [vmlinux] Error 1

This is because gcc4 by default rewrites trivial forms of
sprintf to equivalent uses of strcpy. The problem is that
the kernel's strcpy is an inline function, so there is no
strcpy symbol available at link-time.

The easiest fix is to use -fno-builtin-sprintf which prevents
gcc from doing this rewrite. This also works with older gcc
versions (tested 2.95.3).

Signed-off-by: Mikael Pettersson <mikpe@xxxxxxxxx>

Makefile | 1 +
1 files changed, 1 insertion(+)

diff -rupN linux-2.4.31/Makefile linux-2.4.31.gcc4-undefined-strcpy-errors/Makefile
--- linux-2.4.31/Makefile 2005-06-01 18:02:21.000000000 +0200
+++ linux-2.4.31.gcc4-undefined-strcpy-errors/Makefile 2005-06-12 11:45:03.000000000 +0200
@@ -93,6 +93,7 @@ CPPFLAGS := -D__KERNEL__ -I$(HPATH)

CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes -Wno-trigraphs -O2 \
-fno-strict-aliasing -fno-common
+CFLAGS += -fno-builtin-sprintf
ifndef CONFIG_FRAME_POINTER
CFLAGS += -fomit-frame-pointer
endif
-
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/