Using a native newlib application with shared libraries

Shaun Jackman sjackman@gmail.com
Tue Dec 28 19:23:00 GMT 2004


I'm porting an embedded application that uses newlib to Linux. On
Linux I'm compiling it against a native newlib shared library. I'm
simulating the LCD using Xlib. The Xlib shared library is native to my
system and is built against glibc.

Before I realised that I had pulled in two different libcs to the same
binary, it actually worked for weeks! Of course, once I realised what
I'd done this Schrödinbug presented itself, and now my application
crashes upon calling XFillRectangle. In fact, I believe the problem
presented itself once I started using malloc in my embedded
application. Xlib is using malloc from glibc and the duelling mallocs
beat each other to death.

I'd prefer to avoid recompiling Xlib for newlib. Can I coax the two
libcs to cohabitate peacefully, or is this just asking for trouble?

I've tried using LD_PRELOAD=/usr/lib/libc-newlib.so.0 to hopefully
coerce Xlib to use newlib's malloc instead of glib's malloc. Although
I believe this is sound, the program still crashes.

I've tried compiling the application statically, but Xlib is missing
references to a number of symbols that appear to be glibc specific,
such as __errno_location and _IO_getc.

Thanks in advance if you can supply any brilliance. Regards,
Shaun    (please cc me in your reply)



More information about the Newlib mailing list