Skip to content

Instantly share code, notes, and snippets.

@code2k
Created June 2, 2012 15:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save code2k/2858794 to your computer and use it in GitHub Desktop.
Save code2k/2858794 to your computer and use it in GitHub Desktop.
Print dependency graph for libcamera.so
#!/usr/bin/env ruby
def get_dependencies(library, indent)
if !library.match(/^\w.*\.so$/) || library.match(/^libstdc\+\+.so$/) ||
library.match(/^libc.so$/) || library.match(/^libdl.so$/) || indent == 4
return
end
for i in 0..indent-1
print(" ")
end
puts library
`greadelf -d #{library}`.each_line do |line|
if match = /^.*NEEDED.*\[(?<slib>.*.so)\]/.match(line)
get_dependencies(match['slib'], indent+1)
end
end
return
end
get_dependencies("libcamera.so", 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment