1--- newlib/libc/stdio/fprintf_chk.c	1969-12-31 19:00:00.000000000 -0500
2+++ newlib/libc/stdio/fprintf_chk.c	2009-02-26 19:02:53.000000000 -0500
3@@ -0,0 +1,21 @@
4+#include <stdarg.h>
5+#include <stdio.h>
6+
7+/*
8+ * Stub implementation of __fprintf_chk adapted from glibc 2.7.  This
9+ * doesn't actually implement any buffer overflow protection.  It just makes
10+ * the linker happy :)
11+*/
12+int
13+__fprintf_chk (FILE *fp, int flag, const char *format, ...)
14+{
15+  va_list ap;
16+  int done;
17+
18+  va_start (ap, format);
19+  done = vfprintf (fp, format, ap);
20+  va_end (ap);
21+
22+  return done;
23+}
24+
25--- newlib/libc/stdio/Makefile.am	2007-08-02 16:23:06.000000000 -0400
26+++ newlib/libc/stdio/Makefile.am	2009-02-26 18:14:53.000000000 -0500
27@@ -20,6 +20,7 @@
28 	flags.c			\
29 	fopen.c			\
30 	fprintf.c			\
31+	fprintf_chk.c		\
32 	fputc.c			\
33 	fputs.c			\
34 	fread.c			\
35@@ -65,6 +66,7 @@
36 	sniprintf.c			\
37 	snprintf.c			\
38 	sprintf.c			\
39+	sprintf_chk.c			\
40 	sscanf.c			\
41 	stdio.c			\
42 	tmpfile.c			\
43--- newlib/libc/stdio/Makefile.in	2007-12-19 17:36:38.000000000 -0500
44+++ newlib/libc/stdio/Makefile.in	2009-02-26 18:43:52.000000000 -0500
45@@ -63,7 +63,8 @@
46 	lib_a-fgets.$(OBJEXT) lib_a-fileno.$(OBJEXT) \
47 	lib_a-findfp.$(OBJEXT) lib_a-fiprintf.$(OBJEXT) \
48 	lib_a-flags.$(OBJEXT) lib_a-fopen.$(OBJEXT) \
49-	lib_a-fprintf.$(OBJEXT) lib_a-fputc.$(OBJEXT) \
50+	lib_a-fprintf.$(OBJEXT) lib_a-fprintf_chk.$(OBJEXT) \
51+	lib_a-fputc.$(OBJEXT) \
52 	lib_a-fputs.$(OBJEXT) lib_a-fread.$(OBJEXT) \
53 	lib_a-freopen.$(OBJEXT) lib_a-fscanf.$(OBJEXT) \
54 	lib_a-fiscanf.$(OBJEXT) lib_a-fseek.$(OBJEXT) \
55@@ -86,6 +87,7 @@
56 	lib_a-setvbuf.$(OBJEXT) lib_a-siprintf.$(OBJEXT) \
57 	lib_a-siscanf.$(OBJEXT) lib_a-sniprintf.$(OBJEXT) \
58 	lib_a-snprintf.$(OBJEXT) lib_a-sprintf.$(OBJEXT) \
59+	lib_a-sprintf_chk.$(OBJEXT) \
60 	lib_a-sscanf.$(OBJEXT) lib_a-stdio.$(OBJEXT) \
61 	lib_a-tmpfile.$(OBJEXT) lib_a-tmpnam.$(OBJEXT) \
62 	lib_a-ungetc.$(OBJEXT) lib_a-vdiprintf.$(OBJEXT) \
63@@ -122,15 +124,15 @@
64 LTLIBRARIES = $(noinst_LTLIBRARIES)
65 am__objects_4 = clearerr.lo fclose.lo fdopen.lo feof.lo ferror.lo \
66 	fflush.lo fgetc.lo fgetpos.lo fgets.lo fileno.lo findfp.lo \
67-	fiprintf.lo flags.lo fopen.lo fprintf.lo fputc.lo fputs.lo \
68-	fread.lo freopen.lo fscanf.lo fiscanf.lo fseek.lo fsetpos.lo \
69+	fiprintf.lo flags.lo fopen.lo fprintf.lo fprintf_chk.lo fputc.lo \
70+	fputs.lo fread.lo freopen.lo fscanf.lo fiscanf.lo fseek.lo fsetpos.lo \
71 	ftell.lo fvwrite.lo fwalk.lo fwrite.lo getc.lo getchar.lo \
72 	getc_u.lo getchar_u.lo getdelim.lo getline.lo gets.lo \
73 	iprintf.lo iscanf.lo makebuf.lo perror.lo printf.lo putc.lo \
74 	putchar.lo putc_u.lo putchar_u.lo puts.lo refill.lo remove.lo \
75 	rename.lo rewind.lo rget.lo scanf.lo sccl.lo setbuf.lo \
76 	setbuffer.lo setlinebuf.lo setvbuf.lo siprintf.lo siscanf.lo \
77-	sniprintf.lo snprintf.lo sprintf.lo sscanf.lo stdio.lo \
78+	sniprintf.lo snprintf.lo sprintf.lo sprintf_chk.lo sscanf.lo stdio.lo \
79 	tmpfile.lo tmpnam.lo ungetc.lo vdiprintf.lo vdprintf.lo \
80 	viprintf.lo viscanf.lo vprintf.lo vscanf.lo vsiprintf.lo \
81 	vsiscanf.lo vsnprintf.lo vsniprintf.lo vsprintf.lo vsscanf.lo \
82@@ -344,6 +346,7 @@
83 	flags.c			\
84 	fopen.c			\
85 	fprintf.c			\
86+	fprintf_chk.c			\
87 	fputc.c			\
88 	fputs.c			\
89 	fread.c			\
90@@ -389,6 +392,7 @@
91 	sniprintf.c			\
92 	snprintf.c			\
93 	sprintf.c			\
94+	sprintf_chk.c			\
95 	sscanf.c			\
96 	stdio.c			\
97 	tmpfile.c			\
98@@ -508,6 +512,7 @@
99 	siprintf.def		\
100 	siscanf.def		\
101 	sprintf.def		\
102+	sprintf_chk.def		\
103 	sscanf.def		\
104 	tmpfile.def		\
105 	tmpnam.def		\
106@@ -678,6 +683,12 @@
107 lib_a-fprintf.obj: fprintf.c
108 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fprintf.obj `if test -f 'fprintf.c'; then $(CYGPATH_W) 'fprintf.c'; else $(CYGPATH_W) '$(srcdir)/fprintf.c'; fi`
109
110+lib_a-fprintf_chk.o: fprintf_chk.c
111+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fprintf_chk.o `test -f 'fprintf_chk.c' || echo '$(srcdir)/'`fprintf_chk.c
112+
113+lib_a-fprintf_chk.obj: fprintf_chk.c
114+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fprintf_chk.obj `if test -f 'fprintf_chk.c'; then $(CYGPATH_W) 'fprintf_chk.c'; else $(CYGPATH_W) '$(srcdir)/fprintf_chk.c'; fi`
115+
116 lib_a-fputc.o: fputc.c
117 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fputc.o `test -f 'fputc.c' || echo '$(srcdir)/'`fputc.c
118
119@@ -948,6 +959,12 @@
120 lib_a-sprintf.obj: sprintf.c
121 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-sprintf.obj `if test -f 'sprintf.c'; then $(CYGPATH_W) 'sprintf.c'; else $(CYGPATH_W) '$(srcdir)/sprintf.c'; fi`
122
123+lib_a-sprintf_chk.o: sprintf_chk.c
124+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-sprintf_chk.o `test -f 'sprintf_chk.c' || echo '$(srcdir)/'`sprintf_chk.c
125+
126+lib_a-sprintf_chk.obj: sprintf_chk.c
127+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-sprintf_chk.obj `if test -f 'sprintf_chk.c'; then $(CYGPATH_W) 'sprintf_chk.c'; else $(CYGPATH_W) '$(srcdir)/sprintf_chk.c'; fi`
128+
129 lib_a-sscanf.o: sscanf.c
130 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-sscanf.o `test -f 'sscanf.c' || echo '$(srcdir)/'`sscanf.c
131
132--- newlib/libc/stdio/sprintf_chk.c	1969-12-31 19:00:00.000000000 -0500
133+++ newlib/libc/stdio/sprintf_chk.c	2009-02-26 19:02:26.000000000 -0500
134@@ -0,0 +1,21 @@
135+#include <stdarg.h>
136+#include <stdio.h>
137+
138+/*
139+ * Stub implementation of __sprintf_chk adapted from glibc 2.7.  This
140+ * doesn't actually implement any buffer overflow protection.  It just makes
141+ * the linker happy :)
142+*/
143+int
144+__sprintf_chk (char *s, int flags, size_t slen, const char *format, ...)
145+{
146+  va_list arg;
147+  int done;
148+
149+  va_start (arg, format);
150+  done = vsprintf (s, format, arg);
151+  va_end (arg);
152+
153+  return done;
154+}
155+
156