libpayload: Add -Os to the CFLAGS
authorJordan Crouse <jordan.crouse@amd.com>
Thu, 20 Mar 2008 01:13:28 +0000 (01:13 +0000)
committerUwe Hermann <uwe@hermann-uwe.de>
Thu, 20 Mar 2008 01:13:28 +0000 (01:13 +0000)
Adding -Os to the CFLAGS gains us about 25% smaller code (give or take).
Unfortunately, it exposes a strange issue where strcpy() suddenly goes
missing - we think that strcpy() is being provided by libgcc, and that
for some reason, -Os changes the beahavior.  Oh, well - add a quick
strcpy() function and we're good.

Signed-off-by: Jordan Crouse <jordan.crouse@amd.com>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@3175 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1

payloads/libpayload/Makefile
payloads/libpayload/libc/string.c

index f2f87abc5360391992af49ddd623307d695a2413..8d28c2dcca157bfc165cb7ee79be73bd76939b9a 100644 (file)
@@ -61,7 +61,7 @@ include $(PLATFORM-y) $(BUILD-y)
 
 INCLUDES := -I./include
 INCLUDES += -I$(shell $(CC) -print-search-dirs | head -n 1 | cut -d' ' -f2)include
-CFLAGS := -Werror -fno-stack-protector -nostdinc $(INCLUDES)
+CFLAGS := -Werror -Os -fno-stack-protector -nostdinc $(INCLUDES)
 
 libpayload.a: $(TARGETS-y)
        $(AR) rc $@ $(TARGETS-y)
index c9f0603387543ea338bea9fc942cb81af4451ea9..f71d1c3af6d2b68bf3126b7d09c3a0bf39789fce 100644 (file)
@@ -142,6 +142,11 @@ char *strncpy(char *d, const char *s, int n)
        return d;
 }
 
+char *strcpy(char *d, const char *s)
+{
+       return strncpy(d, s, strlen(s));
+}
+
 char *strncat(char *d, const char *s, int n)
 {
        char *p = d + strlen(d);