arch-specific funcs in libgloss to override libnosys

Mike Frysinger
Thu Sep 23 08:08:00 GMT 2010

i'm not terribly familiar with libgloss' source layout.  ive reviewed the
porting doc, but it seems some pieces are out of date, and it doesnt exactly
explain how one folds a bsp lib from libgloss into gcc's default linker

in my case, i'm looking at overriding the default _exit() symbol.  the
libnosys code attempts to trigger a divide-by-zero exception which doesnt
exist on Blackfin parts.  atm, our local tree is doing:
#ifdef __BFIN__
  asm ("EXCPT 0;");
  /* Default stub just causes a divide by 0 exception.  */
  int x = rc / INT_MAX;
  x = 4 / x;
  asm volatile ("" : : "r" (x));
clearly this goes against the whole point of libnosys :)

there is also an additional support function i need to add that is Blackfin-
specific and required by gcc (for clearing caches).

so what i'm thinking is that i declare a new libbsp.a in bfin/,
stick a _exit.c file in there as well as the Blackfin-specific files, and then
build them up as part of libgloss.

then i modify the Blackfin elf gcc spec like so:
-#define LIB_SPEC "--start-group -lc %{msim:-lsim}%{!msim:-lnosys} --end-group \
+#define LIB_SPEC "--start-group -lc %{msim:-lsim}%{!msim:-lbsp -lnosys} --end-group \

is this the way to go ?  or am i completely off base ?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <>

More information about the Newlib mailing list