Hello,
I think that in newlib/libc/stdlib/getopt.c, optarg should not be
initialized (like in glibc).
Otherwise, if the user code contains a non-initialized "optarg" variable
the linker will "magically" pull the whole getopt.o from Newlib, which
is not desirable (especially if the user code actually contains a
redefinition of getopt & co, as it will result in "multiply defined"
errors).
Small patch as follows:
Index: newlib/libc/stdlib/getopt.c
===================================================================
--- newlib/libc/stdlib/getopt.c (revision 637)
+++ newlib/libc/stdlib/getopt.c (working copy)
@@ -103,7 +103,7 @@ typedef enum GETOPT_ORDERING_T
} GETOPT_ORDERING_T;
/* globally-defined variables */
-char *optarg = 0;
+char *optarg;
int optind = 0;