What are .so scrpits, and why do some of them have hardcoded dependencies?
I am trying to create a cross compiled software project for an ARM board.
The board has several libraries in its root files that are not on the host computer. So to make sure the linker can refer to them, I copied the root files to a local directory and used the -Wl,-rpath-link=${Target}
linker to point to it.
Problem:
ld
cannot find glibc.
Analysis:
-Wl,--verbose
ld
Shows with option :
opened script file {Target}/usr/lib/libpthread.so
opened script file {Target}/usr/lib/libc.so
libc.so:
/* GNU ld script
Use the shared library, but some functions are only in
the static library, so try that secondarily. */
OUTPUT_FORMAT(elf32-littlearm)
GROUP ( /lib/libc.so.6 /usr/lib/libc_nonshared.a AS_NEEDED ( /usr/lib/ld-linux-armhf.so.3 ) )
^^^^^ ^^^^^^^^^ ^^^^^^^^^
libpthread.so
/* GNU ld script
Use the shared library, but some functions are only in
the static library, so try that secondarily. */
OUTPUT_FORMAT(elf32-littlearm)
GROUP ( /usr/lib/libpthread.so.0 /usr/lib/libpthread_nonshared.a )
^^^^^^^^ ^^^^^^^^^
So when I point ld
to the libraries I copied from the root directory, they will open these two scripts that have hardcoded dependencies.
However, if I do not use -rpath
, then ld
I will use the scripts that come with the cross-compiler ( /usr/arm-linux-gnueabihf/lib/libpthread.so
and /usr/arm-linux-gnueabihf/lib/libc.so
) who also have hard-coded path in it, but are correct.
Question:
-
What are these scripts used for?
-
Why do some of them have hardcoded paths (
libc.so
,libpthread.so
), but some desn't (libgcc_s.so
)?
Update:
The roots I copied from the board is the Yocto distribution.
The host machine I'm using is Ubuntu14.04 LTS x86-64.
No one has answered this question yet
Check out similar questions: