Problem with dynamically linked executable on ARM

Michael Troß michael at tross.org
Tue Dec 29 21:02:35 UTC 2009


On Wednesday 16 December 2009 13:33:09 fabrizio gennari wrote:
> Hello.
> 
> I am trying to build an ARM build environment on an Ubuntu
> 9.10
> machine. So far I've compiled binutils and gcc for an arm-linux
> target,
> and cross-compiled uClibc and gdb.
> 
> Then, I wrote a small
> hello world application and used the
> cross-compiler to compile it with
> and without the -static flag.
> 
> I copied the statically compiled binary
> on the ARM device, which
> has a serial shell console. I ran it and
> everything went OK.
> Then I copied the dynamically compiled binary on
> the device. I also
> copied libuClibc-0.9.30.1.so as /lib/libc.so.0
> (glibc was also there,
> but as /lib/libc.so.6) and ld-uClibc-0.9.30.1.
> so as
> /lib/ld-uClibc.so.0 .
> The program segfaults even before getting
> to main.
> By running gdb on the device, I found out that
> __uClibc_main ()
> calls _init (). _init () returns, and, immediately
> afterwards,
> __uClibc_main () calls _dl_app_init_array (), which in its
> turn
> invokes _dl_run_init_array ().
> The SIGSEGV happens almost
> immediately in _dl_run_init_array ().
> By peeking in uClibc's source
> code, I got the suspect that the
> variable _dl_loaded_modules stays
> NULL, instead of being
> initialized. That variable is declared in
> ldso/ldso/dl-symbols.c .
> 
> When is that variable supposed to be
> initialised? And, overall,
> how do I get my program to work?

I found that for some shared libraries the dl_init/fini_array symbols are 
already relocated, when _dl_run_init_array () looks up and relocates again.

The attached patch checks for "addrs[j] < loadaddr" to detect such cases. This 
strategy might not be the right way... it was a quickfix for an ARM based 
system.

Configure uclibc with DODEBUG and SUPPORT_LD_DEBUG, and run your app with 
"LD_DEBUG=all ./app" to get more details.

Michael
-------------- next part --------------
A non-text attachment was scrubbed...
Name: uclibc-ldso.patch
Type: text/x-patch
Size: 1497 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/uclibc/attachments/20091229/8d28152e/attachment.bin>


More information about the uClibc mailing list