linux - How to automatically discover implicit dependencies when linking -


I am building an old building where many of the shared libraries do not link against libraries, which they actually depend on We do. There are some circular dependencies from which I have worn our way in construction for years, but I would like to settle it, but if I can do all non-circular dependencies then it will be very simple. Currently, unresolved symbols are resolved on adding executable links - which they managed to implement [unconsciously] circular dependencies.

Here is a short bash script that has been put together to test some ideas:

  #! / bin / bash mkdir -p for objs ((ii = 0; ii <3; ii ++)); Do echo 'zero FUNC () {}' | | G ++ -xc ++ -DFUNC = F $ {ii} -fpic - -c -o objs / t $ {ii} .o G ++ -fpic -shared objs / t $ {ii} .o -o libtest $ {ii} .so in the case of the real world, libjoined.so is not a trivial library # Currently, it links things with other #libraries, so libblah. Therefore (such as boost libraries) Echo | G ++ -xc ++ -shared -fpic -L -Wl, R. -Liteest {0,1,2} - -i libjoined.so G ++ -xc ++ -fpic - -c -o objs / b.o & lt; & Lt; 'EOF' returns zero f0 (); Extra zero F1 (); Extra zero F2 (); Zero blah () {f0 (); f1 (); f2 (); } EOF G ++ - FIPBIC -Shed Objas / BO-L -Wl, R. -ljoined -o libblah.so -Wl, -zdefs   

The last line will touch some undefined symbol errors. If it was Solaris, then the linker would check the other libraries which would otherwise satisfy the dependency completely and provide the signal:

  Undefined first referring symbol in zero (f1) objs / bo ( Symbol is implicit dependence. / Libtest1.so)   

... but I do not see such behavior with GNU Lind.

In the real world case, one hundred libraries and all the external libraries in our construction are dependent on them and executable. After adding -zdefs to build, I get about 10,000+ uncertain references;

I need a fast way to identify missing dependencies.

On the solar side, I might try to create a library such as libjoined.so which is created without all our libraries (where everything without -zdefs ), Then write a script that reduces the link from the log and runs commands with re- -zdefs and links to this other library and gives signals to the text file Or put in some things.

On the Linux side, I'm not sure That's what I can do

I found it to be ld -r -p The way to do it.

I can not copy the code, but I give a mockup. I can not guarantee the following, but you should give a good idea:

 #! / Usr / bin / perl alerts; Strict use; My% symbols; My% libs_missing_stuff; My $ arg (@ARGV) on libraries {# loop and map the form: # $ Symbols {$ symbol} = $ arg my @tmp = (`nm -aa-defined-only $ {arg}` = ~ M {(\ S +) $}); $ {$ Symbols {$ symbol} = $ ag before my $ symbol (@tmp); }} Foreach my $ arg (@ARGV) {# it will eventually give me my @tmp = (`ldd -r -p $ arg 2 & gt; & amp; 1` = ~ m {symbol not found: (\ S +) } Is required); # ^ ~~~~~~~ ^ foreach my $ missing_symbol (@tmp) {if (defined ($ symbols {$ missing_symbol})} {$ libs_missing_stuff {$ arg} {$ symbols {$ missing_symbol}} = 1; %} On # loop at libs_missing_stuff and print   

The output looks like the following:

  somelib: lib1 lib2 lib3 someotherlib: lib3 lib6 lib8. .   

This is not correct, and still satisfies more than one library dependency, or is associated with some static library and appears to satisfy the dependency Happens when in fact it should be linked against other library However, I mean to understand that part .

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -