Are there any tools for checking characters in crossed compiled .so files?

I have an application that downloads .so files as plugins at startup using dlopen()

The build environment runs on x86 hardware, but the application is cross-compiled for another platform.

It would be great if I could (as part of the automatic build process) do a check to make sure that the combination of .so files and the application does not have any unresolved characters without actually deploying the application.

Before writing a script to test characters using output nm, I wonder if anyone knows about a utility that already does this?


edit 1: the description has changed a bit - I'm not just trying to check the characters in .so, but rather in a combination of several .so and the application itself - i.e. after the application has downloaded all .so, were there any unresolved characters.

As suggested in the answers (thanks to Martin v. Löwis and tgamblin), it nmwill be easy to identify missing characters in one file, but it will not be easy to identify which of these characters were allowed in one of the other loaded modules.

+3
source share
3 answers

Ideally, the cross-nm tool is part of your cross-compiler suite. For example, if you create GNU binutils for cross-compiling, cross-nm will also be provided (along with cross-objdump).

+2

ldd? -, , script, . , , , , .so. , .so , ldd .

, , . GNU ld --no-allow-shlib- undefined, , .so, . GNU ld:

   --no-undefined
       Report  unresolved  symbol  references  from regular object files.
       This is done even if the linker is creating a non-symbolic shared 
       library.  The switch --[no-]allow-shlib-undefined controls the 
       behaviour for reporting  unresolved references found in shared
       libraries being linked in.

   --allow-shlib-undefined
   --no-allow-shlib-undefined
       Allows (the default) or disallows undefined symbols in shared 
       libraries.  This switch is  similar  to  --no-undefined  except
       that  it determines the behaviour when the undefined symbols are
       in a shared library rather than a regular object file.  It does 
       not affect how undefined symbols in regular object files are 
       handled.

       The reason that --allow-shlib-undefined is the default is that the 
       shared library being specified  at  link  time may  not  be  the  
       same as the one that is available at load time, so the symbols might 
       actually be resolvable at load time.  Plus there are some systems, 
       (eg BeOS) where undefined symbols in shared libraries is  normal.   
       (The kernel patches them at load time to select which function is most
       appropriate for the current architecture.  This is used for example to
       dynamically select an appropriate memset function).  Apparently it is 
       also normal for HPPA shared libraries to have undefined symbols.

, , nm - , , . grep 'U' , , script .

+1

nm , . , nm .

readelf .

readelf, script, : , ( .so) - , .

, .

If this is done for the executable and all dlopen()ed.so files , it will give a good check for unresolved dependencies that will occur at run time.

+1
source

Source: https://habr.com/ru/post/1699248/


All Articles