How can I find which ELF dependency is not fulfilled?
This looks like what happens when the ELF interpreter is missing.
Ensure that /lib/ld-lsb.so.2
(or similar; varies by LSB version and architecture) exists. ldd
and readelf -l
will be able to show the ELF interpreter your executable is requesting.
(lsbcc
(or something in the LSB toolchain) overrides the system's default /lib/ld-linux.so.2
, probably by passing -Wl,--dynamic-linker=/lib/ld-lsb.so.2
to the compiler, for reasons I think are rather silly (Glibc has always provided fairly excellent backwards-compatibility here), but there you have it.)
How to know which dynamic libraries are needed by an ELF?
/usr/bin/ldd
is your friend. Usage:
ldd /bin/ls
Sample output:
linux-vdso.so.1 => (0x00007ffd14f79000)
libselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1 (0x00007f2d875fc000)
libacl.so.1 => /lib/x86_64-linux-gnu/libacl.so.1 (0x00007f2d873f4000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f2d8702f000)
libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f2d86df1000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f2d86bed000)
/lib64/ld-linux-x86-64.so.2 (0x00007f2d8781f000)
libattr.so.1 => /lib/x86_64-linux-gnu/libattr.so.1 (0x00007f2d869e8000)
Determine direct shared object dependencies of a Linux binary?
You can use readelf
to explore the ELF headers. readelf -d
will list the direct dependencies as NEEDED
sections.
$ readelf -d elfbin
Dynamic section at offset 0xe30 contains 22 entries:
Tag Type Name/Value
0x0000000000000001 (NEEDED) Shared library: [libssl.so.1.0.0]
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
0x000000000000000c (INIT) 0x400520
0x000000000000000d (FINI) 0x400758
...
In an elf file, how to find which compile unit the variable is defined?
The DWARF standard includes an optional section, .debug_pubnames
, that provides name-to-offset translation for global objects and functions.
Another approach is to use the symbol table. If it has an entry for the variable then you can use its address with the optional .debug_aranges
section or, failing that, read every DW_TAG_compile_unit
looking for the one with the enclosing address range.
How to find out where a program is looking for libraries
Probably you need the strace
command
Take a look here http://www.thegeekstuff.com/2011/11/strace-examples/
readelf reports so file as NEEDED, but no functions (or other symbols) is used from it
The DT_NEEDED
tagging is generated by the link editor (ld
) based on the -l
flags provided. The default for the GNU link editor and most other editors, with some exceptions, is to create a DT_NEEDED
tag for each -l
flag provided.
When using GNU ld
or gold
, you can pass --as-needed
before the -l
flags to only emit DT_NEEDED
tags for the libraries that are indeed used. This may still emit not obvious tags if the symbols are actually used indirectly.
I have actually written a significant amount about --as-needed
and how it works, so you can look through my blog posts if you are more curious.
Android shell don't find the file to execute
Your executable is missing a library. The most likely reason is that you just built a Linux ARM executable (not an Android one) which is linked against some libc
version other than Android Bionic.
You could either learn how to build proper Android executables or a statically linked binary might just work for your purpose.
Related Topics
When to Use Kernel Threads VS Workqueues in the Linux Kernel
Can You Prevent a Command from Going into the Bash Shell Command History
Linux Usb: Turning the Power on and Off
Replace Whitespaces with Tabs in Linux
What Is Raw Socket in Socket Programming
Using Grep to Search for a String That Has a Dot in It
Control Mouse by Writing to /Dev/Input/Mice
Redirect All Output to File Using Bash on Linux
Convert All File Extensions to Lower-Case
Colors with Unix Command "Watch"
How to Read a .Properties File Which Contains Keys That Have a Period Character Using Shell Script
How to De-Optimize the Linux Kernel to and Compile It with -O0
Why Does C99 Complain About Storage Sizes
Deleting Old Files Using Crontab