How to find all executables dependent on a library?

Using applications, configuring, problems
Post Reply
Message
Author
toddyjoe
Posts: 122
Joined: Thu 23 Mar 2006, 21:07

How to find all executables dependent on a library?

#1 Post by toddyjoe »

I know that one can use "ldd" followed by the name of an executable file to find and list all the library files that the executable file is dependent upon and requires. However, is there anything that does the opposite, i.e., lists all executable files that depend upon a given library file? I thought Jonathan Marsden worked on something like that in an older version of Puppy but I could never get the commands he was using to work on the Puppy versions I had. I am trying to customize my own Puppy and want to efficiently figure out which library files can be safely deleted after certain executable files are also deleted.

User avatar
Dougal
Posts: 2502
Joined: Wed 19 Oct 2005, 13:06
Location: Hell more grotesque than any medieval woodcut

#2 Post by Dougal »

I remember Jonathan Marsden's script, I tried it and it worked for me. I think I had to create some bash script that run his perl script.

I can try searching for it later and possibly post it here tomorrow, if you're interested.
What's the ugliest part of your body?
Some say your nose
Some say your toes
But I think it's your mind

toddyjoe
Posts: 122
Joined: Thu 23 Mar 2006, 21:07

#3 Post by toddyjoe »

If you find it, I would be interested in seeing it. It may make my efforts a whole lot less time-consuming. Thanks!

User avatar
Dougal
Posts: 2502
Joined: Wed 19 Oct 2005, 13:06
Location: Hell more grotesque than any medieval woodcut

#4 Post by Dougal »

Ok, here we go:

The "scripts" tarball contains the Jonathan M perl script with the bash script that runs it. (I didn't try it again, but I don't see why it shouldn't work.)

I also wrote a bash script that does the same job and more: it creates a file with a list of the libraries missing and one of "orphaned" libraries- that nothing depends on, so they might not be needed (not for sure, but at least worth investigating).
Attachments
list-dependents.sh.gz
creates three files:
/root/dependents.txt
/root/missing.txt
/root/orphaned.txt
(1.28 KiB) Downloaded 276 times
scripts.tar.gz
(510 Bytes) Downloaded 247 times
What's the ugliest part of your body?
Some say your nose
Some say your toes
But I think it's your mind

User avatar
fluxit
Posts: 326
Joined: Sat 24 Jun 2006, 04:14
Location: Ketchikan, AK USA

#5 Post by fluxit »

Keep in mind that executables which have been compressed by upx can't be read by ldd. They have the same dependencies as executables that are not compressed.

--Lee

toddyjoe
Posts: 122
Joined: Thu 23 Mar 2006, 21:07

#6 Post by toddyjoe »

Thanks for the files, Dougal, and thanks for the information, fluxit! I will try them out tonight.

User avatar
Dougal
Posts: 2502
Joined: Wed 19 Oct 2005, 13:06
Location: Hell more grotesque than any medieval woodcut

#7 Post by Dougal »

Lee: I'm ashamed to say I don't know what upx compressed execs are...
However, I don't think Puppy has any.

Anyway, there is another problem: "find" doesn't seem to recognise some directories!
I tried my best to get it to find files within the /usr/lib/perl5 directory and it just wouldn't do it!
I'll probably post a bug report about it tomorrow...
What's the ugliest part of your body?
Some say your nose
Some say your toes
But I think it's your mind

User avatar
fluxit
Posts: 326
Joined: Sat 24 Jun 2006, 04:14
Location: Ketchikan, AK USA

#8 Post by fluxit »

http://upx.sourceforge.net/

I usually upx executables that I install into my Puppy save file to save space.

--Lee

User avatar
Dougal
Posts: 2502
Joined: Wed 19 Oct 2005, 13:06
Location: Hell more grotesque than any medieval woodcut

#9 Post by Dougal »

Looks interesting, but I assume it's pointless for files inside a squashfs file, right? Otherwise it could be useful to use on the iso...
What's the ugliest part of your body?
Some say your nose
Some say your toes
But I think it's your mind

User avatar
Dougal
Posts: 2502
Joined: Wed 19 Oct 2005, 13:06
Location: Hell more grotesque than any medieval woodcut

#10 Post by Dougal »

Toddyjoe: look at the message I posted about the problem with "find".

I actually have another script, which goes over all the paths and finds everything, but it's much slower. If you want I can post it here for you.

Lee, I could actually add an exception for UPX in my script -- have each UPX file extracted to a temp folder and then lld'd...
What's the ugliest part of your body?
Some say your nose
Some say your toes
But I think it's your mind

toddyjoe
Posts: 122
Joined: Thu 23 Mar 2006, 21:07

#11 Post by toddyjoe »

It seems to me I saw similar problems and discussions with the "find" function pop up somewhere else when I was first researching Linux in general. I will follow these two threads and revise the script you already provided as developments and progress are made. Thank you for the warning!

User avatar
fluxit
Posts: 326
Joined: Sat 24 Jun 2006, 04:14
Location: Ketchikan, AK USA

#12 Post by fluxit »

Dougal,

Yeah, compressing already compressed files often leads to more overhead thus taking up more space instead of less.

You're right, singling out the upx's and decompressing them will definitely work. I'm not sure what the exact header id string is for UPX, but it has UPX in it :)

--Lee

Post Reply