[uClibc] arm toolchain/static binaries

David Muse dmuse at 4accesscommunications.com
Fri Jun 18 17:07:46 UTC 2004


On 17 Jun 2004 10:06:50 -0700
David Meggy <dmeggy at techsol.ca> wrote:

> On Wed, 2004-06-16 at 08:04, David Muse wrote:
> > I've been using an arm-uclibc toolchain based on uclibc-0.9.21 for a
> while now and I recently tried to upgrade to a toolchain based on the
> current cvs snapshot.  I have been able to compile a complete toolchain
> and it can build most of my code, but every now and then, it generates a
> static binary.  If I rebuild the same code base again, the same binaries
> get linked statically, so it's not exactly random, but I can't figure
> out why it's linking them statically.  I'm not passing any flags that
> would cause static linking, dynamic versions of each of the libraries
> that need to be linked in are available, and the 0.9.21 toolchain builds
> dynamically linked binaries.  It's kind of a subtle bug, I didn't notice
> it for a while until one day I just noticed that the size of the jffs2
> filesystem image that my build process generates was larger than I
> remember.
> 
> What you have just described sounds like a problem with your build
> scripts.  You have to find out where in your build scripts it is
> creating these static binaries, and the complete command line to the
> compiler/linker.
> 
> David

Ok, I rebuilt my toolchain from a recent CVS snapshot and did some
playing around...

Now I have 2 toolchains:
one based on uclibc-0.9.21, gcc-3.3.1 and binutils-2.14.90.0.5
and another based on uclibc-0.9.26-cvs, gcc-3.3.3 and binutils-2.14.90.0.7

In each, I modified the makefile to build for arm, and accepted the default
prompts during the uclibc build, except I selected the xscale cpu.

If I create a simple test program like this:

#include <stdlib.h>
 
main() {
        exit(1);
}

And I compile it using the uclibc-0.9.21-based toolchain like this 

arm-uclibc-gcc -o test test.c

It works and creates a dynamic binary:
[mused at neptune mused]$ file test
test: ELF 32-bit LSB executable, ARM, version 1 (ARM), for GNU/Linux
2.0.0, dynamically linked (uses shared libs), not stripped


However, if I compile it using the uclibc-0.9.26-based toolchain like this:

arm-linux-uclibc-gcc -o test test.c -ldl

then I get a static binary:
[mused at neptune mused]$ file test
test: ELF 32-bit LSB executable, ARM, version 1 (ARM), for GNU/Linux
2.0.0, statically linked, not stripped

I tried passing the linker explicit instructions to create a dynamic binary
using these commands:

arm-linux-uclibc-gcc -Wl,-Bdynamic -o test test.c
arm-linux-uclibc-gcc -Wl,-dy -o test test.c
arm-linux-uclibc-gcc -Wl,-call_shared test test.c

But the result was the same.

I'm going to play around and see if maybe turning on xscale optimization
is somehow causing the problem.  Is it possible that this uClibc build option
is causing problems:

Only load shared libraries which can share their text segment
(FORCE_SHAREABLE_TEXT_SEGMENTS) [N/y/?] (NEW)

I accepted the default (N).

David Muse
dmuse at 4accesscommunications.com



More information about the uClibc mailing list