[patch, libgloss] Create nosys.specs

Joey Ye joey.ye@arm.com
Thu Sep 12 15:05:00 GMT 2013

Bare-metal toolchain users often run into missing libgloss symbols problem.
The typical reason is that -lnosys isn't given in the right place. For

# this works
$ arm-none-eabi-gcc a.o -lc -lnosys -o a.axf

# putting object file at end of option, it doesn't work
$ arm-none-eabi-gcc -lc -lnosys -o a.axf a.o
libc.a(lib_a-sbrkr.o): In function `_sbrk_r':
sbrkr.c:(.text._sbrk_r+0x12): undefined reference to `_sbrk'

This patch introduces nosys.specs to group -lnosys with -lc, which is quite
similar to rdimon.specs. With this patch, following simple command line will
$ arm-none-eabi-gcc -specs=nosys.specs -o a.axf a.o

OK to trunk?

libnosys/Makefile.in: install nosys.specs.
libnosys/nosys.specs: New specs.

diff --git a/libgloss/libnosys/Makefile.in b/libgloss/libnosys/Makefile.in
index ff4c416..22828a4 100644
--- a/libgloss/libnosys/Makefile.in
+++ b/libgloss/libnosys/Makefile.in
@@ -77,6 +77,7 @@ GCC_LDFLAGS = `if [ -d ${objroot}/../gcc ] ; \
 	then echo -L${objroot}/../gcc ; fi`
 OUTPUTS = libnosys.a
+SPECS = ${srcdir}/nosys.specs
 # Host specific makefile fragment comes in here.
@@ -101,7 +102,7 @@ distclean maintainer-clean realclean: clean
 .PHONY: install info install-info clean-info
-	@for outputs in ${OUTPUTS}; do\
+	@for outputs in ${OUTPUTS} ${SPECS}; do\
 	 mkdir -p $(DESTDIR)$(tooldir)/lib${MULTISUBDIR}; \
 	 $(INSTALL_DATA) $${outputs} $(DESTDIR)$(tooldir)/lib${MULTISUBDIR};
diff --git a/libgloss/libnosys/nosys.specs b/libgloss/libnosys/nosys.specs
new file mode 100644
index 0000000..dffc28d
--- /dev/null
+++ b/libgloss/libnosys/nosys.specs
@@ -0,0 +1,7 @@
+%rename lib libc
+--start-group %(libc) %(libgloss) --end-group

More information about the Newlib mailing list