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.

+3
gcc linux ld


source to share


No one has answered this question yet

Check out similar questions:

1470
What ":-!!" in C code?
nine
Missing library in ldd after using gcc -l
2
Linux runtime linker error
1
Parsing .NET Core Console Application Crash from Linux (ARM32, Debian, RaspberryPi3B +) via lldb failed
1
Link the Ubuntu armhf libraries libxcb.so.1 and libXdmcp.so.6
1
g ++ libc.so absolute path cross-compilation error
0
how to install these libs for qmake lib error?
0
ARM toolkit looking for wrong directory for libraries
0
Gcc link error: cmake cross compile cannot find additional libraries even if rpath is installed with cmake
0
Even though rpath is installed, one dll not found



All Articles