分析出动态库

 1 #! /bin/bash                                                                                                       
 2 LIB_CUR_REL=
 3 LIB_CUR_ABS=
 4 
 5 get_binary_dependency()
 6 {
 7     readelf -d $1 | grep NEEDED | sed -n 's,.*\[\(.*\)\],\1,p'
 8 }
 9 
10 expand_path()
11 {
12     LIB_CUR_ABS=
13     for i in /lib /usr/lib ${LD_LIBRARY_PATH}
14     do
15         for j in $@
16         do      
17             if [ -f ${i}/${j} ]
18             then    
19                 LIB_CUR_ABS="${LIB_CUR_ABS} ${i}/${j}"
20             fi      
21         done    
22     done    
23 }
24 
25 get_abs_dependency()
26 {
27     TMP=$(get_binary_dependency $@)
28 }
29 
30 LIB_CUR_REL="$(get_binary_dependency $@)"
31 expand_path ${LIB_CUR_REL}
32 
33 #for i in ${LIB_CUR_ABS}
34 #do
35 #   echo $i
36 #done
37 
38 echo $LIB_CUR_ABS | tr " " "\n"

 

posted on 2013-06-05 22:34  阿加  阅读(149)  评论(0编辑  收藏  举报

导航