Software cross-ldd
Tuesday, 13 July 2010 07:00

cross-ldd

Written by  Carl Shaw
Rate this item
(0 votes)

cross-ldd is a cross-utility for listing the load-time dynamic dependencies of a program or library built for a non-native architecture.

ldd is a unix utility to list dynamic dependencies of a program or library. i.e. given a program or library, it will display what other libraries it requires to run and what libraries they depend on to run, etc.

In order to obtain this information on Linux systems, the dynamic linker is actually run and it starts preparing the program to run without actually running it. ldd is actually just a script on most modern Linux systems which just calls the appropriate dynamic linker (on 64 bit systems there may be two - e.g. /lib64/ld-linux-x86-64.so.2 as well as /lib/ld-linux.so.2).

For example, the following two commands will produce the same results on a 32 bit Linux system: /lib/ld-linux.so.2 --list /bin/bash and ldd /bin/bash

But what about if you want to quickly check the library dependencies of a cross-compiled program? Then this simple utility will help you. Instead of trying to execute the program, it examines the file and extracts the names of the libraries it requires. It does this by extracting ELF file DT_NEEDED and INTERP fields.

There are two disadvantages to this technique:

  • The load address cannot be obtained as there is no interaction with the kernel to obtain this
  • Runtime loaded libraries (opened with dlopen) will not be reported

However, for a simple check this utility is useful. At MathEmbedded.com we use it to create minimal application-specific root filesystems. Starting with a set of embedded applications, we can extract which libraries they need and add only these libraries to a new root filesystem. This minimises the root filesystem size and stops unnecessary programs being included in the root filesystem therefore increasing system security and auditability.

Carl Shaw

Carl Shaw

E-mail: This e-mail address is being protected from spambots. You need JavaScript enabled to view it

Related items (by tag)

1 Comment

  • Comment Link Patrice Tisserand Thursday, 17 May 2012 05:14 posted by Patrice Tisserand

    Hi, I have found that cross-ldd segfault when .interp don't contains a '/'

    The following patch fixed this issue:

    diff -r -u cross-ldd-0.10.orig/ldd.c cross-ldd-0.10/ldd.c
    --- cross-ldd-0.10.orig/ldd.c 2012-05-17 04:34:14.479231970 +0000
    +++ cross-ldd-0.10/ldd.c 2012-05-17 04:34:57.107230070 +0000
    @@ -411,7 +411,7 @@
    interp = strdup(s);
    interp_dir = strdup(s);
    tmp = strrchr(interp_dir, '/');
    - if (*tmp)
    + if (NULL != tmp)
    *tmp = '\0';
    else {
    free(interp_dir);

Leave a comment

Make sure you enter the (*) required information where indicated.
Basic HTML code is allowed.

Login Form