gcccentos7devtoolset

nm devtoolset's .so files gives File format not recognized


I am just curious why nm complains:

File format not recognized

if I do:

$ nm /opt/rh/devtoolset-8/root/usr/lib/gcc/x86_64-redhat-linux/8/libstdc++.so
nm: /opt/rh/devtoolset-8/root/usr/lib/gcc/x86_64-redhat-linux/8/libstdc++.so: File format not recognized

However, same command can be executed successfully against the stock one /lib64/libstdc++.so.6


Solution

  • It is not a shared library. It is a ld script used at compile-time and not run-time
    cat /opt/rh/devtoolset-8/root/usr/lib/gcc/x86_64-redhat-linux/8/libstdc++.so

    /* GNU ld script
    Use the shared library, but some functions are only in
    the static library, so try that secondarily. */
    OUTPUT_FORMAT(elf64-x86-64)
    INPUT ( /usr/lib64/libstdc++.so.6 -lstdc++_nonshared )

    For OUTPUT_FORMAT and INPUT explanation : see https://sourceware.org/binutils/docs-2.32/ld/LD-Index.html#LD-Index