This is the mail archive of the newlib@sourceware.org mailing list for the newlib 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: make __sf_fake_std{in,out,err} weak in impure.c


This patch fixes a problem I noted when building some test programs for a target board that has a very small amount of memory. Even though the program did not use stdio features, the references to __sf_fake_std{in,out,err} in impure.c were causing the linker to suck in their definitions in findfp.o, along with all the other stuff in that file, which in turn sucked in _malloc_r.

-Sandra

2007-01-10  Sandra Loosemore  <sandra@codesourcery.com>

        newlib/
        * libc/reent/impure.c (__sf_fake_stdin, __sf_fake_stdout)
	(__sf_fake_stderr): Declare locally with weak attribute.

Index: newlib/libc/reent/impure.c
===================================================================
--- newlib/libc/reent/impure.c	(revision 159740)
+++ newlib/libc/reent/impure.c	(working copy)
@@ -9,6 +9,17 @@
 #define __ATTRIBUTE_IMPURE_DATA__
 #endif
 
+/* Redeclare these symbols locally as weak so that the file containing
+   their definitions (along with a lot of other stuff) isn't sucked in
+   unless they are actually used by other compilation units.  This is
+   important to reduce image size for targets with very small amounts
+   of memory.  */
+#ifdef _REENT_SMALL
+extern const struct __sFILE_fake __sf_fake_stdin __attribute__((weak));
+extern const struct __sFILE_fake __sf_fake_stdout __attribute__((weak));
+extern const struct __sFILE_fake __sf_fake_stderr __attribute__((weak));
+#endif
+
 static struct _reent __ATTRIBUTE_IMPURE_DATA__ impure_data = _REENT_INIT (impure_data);
 #ifdef __CYGWIN__
 extern struct _reent reent_data __attribute__ ((alias("impure_data")));

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