通过readelf查看动态库中的内容

readelf是unix下查看库中链接的内容工具。elf:Executable and Linkable Format

mac下的安装以及使用方法:

1、下载binutils-2.24.tar.gz

2、解压

3、安装(使用disable-werror是为了防止mac上make不通过,参考http://stackoverflow.com/questions/20426213/error-building-ellcc)

./configure --disable-werror
make
make install

4、查看可执行文件中链接进去的内容:

➜  assets  readelf -Ws your_executable_file

Symbol table '.dynsym' contains 162 entries:
   Num:    Value  Size Type    Bind   Vis      Ndx Name
     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 00000000     0 FUNC    GLOBAL DEFAULT  UND __libc_init
     2: 00000000     0 FUNC    GLOBAL DEFAULT  UND __cxa_atexit
     3: 00000000     0 FUNC    GLOBAL DEFAULT  UND __android_log_print
     4: 00000000     0 FUNC    GLOBAL DEFAULT  UND gettimeofday
     5: 00000000     0 FUNC    GLOBAL DEFAULT  UND access
     6: 0001196c     0 FUNC    GLOBAL DEFAULT  UND malloc
     7: 00000000     0 FUNC    GLOBAL DEFAULT  UND exit
     8: 00000000     0 FUNC    GLOBAL DEFAULT  UND inotify_init
     9: 00000000     0 FUNC    GLOBAL DEFAULT  UND inotify_add_watch
    10: 00000000     0 FUNC    GLOBAL DEFAULT  UND read
    11: 00000000     0 FUNC    GLOBAL DEFAULT  UND system
    12: 00000000     0 FUNC    GLOBAL DEFAULT  UND pthread_create
    13: 00000000     0 FUNC    GLOBAL DEFAULT  UND usleep
    14: 00000000     0 FUNC    GLOBAL DEFAULT  UND fopen
    15: 000119d8     0 FUNC    GLOBAL DEFAULT  UND free
    16: 00000000     0 FUNC    GLOBAL DEFAULT  UND time
    17: 00000000     0 FUNC    GLOBAL DEFAULT  UND localtime
    18: 00000000     0 FUNC    GLOBAL DEFAULT  UND asctime
    19: 00000000     0 FUNC    GLOBAL DEFAULT  UND fprintf
    20: 00000000     0 FUNC    GLOBAL DEFAULT  UND fclose
    21: 00000000     0 FUNC    GLOBAL DEFAULT  UND strcpy
    22: 00000000     0 FUNC    GLOBAL DEFAULT  UND strcat
    23: 00000000     0 FUNC    GLOBAL DEFAULT  UND snprintf
    24: 00000000     0 FUNC    GLOBAL DEFAULT  UND inotify_rm_watch
    25: 00000000     0 FUNC    GLOBAL DEFAULT  UND close
    26: 00000000     0 FUNC    GLOBAL DEFAULT  UND __stack_chk_fail
    27: 00000000     0 OBJECT  GLOBAL DEFAULT  UND __stack_chk_guard
    28: 00000000     0 FUNC    GLOBAL DEFAULT  UND fstat
    29: 00000000     0 FUNC    GLOBAL DEFAULT  UND lseek
    30: 00000000     0 FUNC    GLOBAL DEFAULT  UND open
    31: 00000000     0 FUNC    GLOBAL DEFAULT  UND strchr
    32: 00000000     0 FUNC    GLOBAL DEFAULT  UND fwrite
    33: 00000000     0 FUNC    GLOBAL DEFAULT  UND strtoll
    34: 00000000     0 FUNC    GLOBAL DEFAULT  UND isspace
    35: 00000000     0 FUNC    GLOBAL DEFAULT  UND strlen
    36: 00000000     0 FUNC    GLOBAL DEFAULT  UND inet_ntop
    37: 00000000     0 FUNC    GLOBAL DEFAULT  UND tolower
    38: 00000000     0 FUNC    GLOBAL DEFAULT  UND sigaction
    39: 00000000     0 FUNC    GLOBAL DEFAULT  UND alarm
    40: 00000000     0 FUNC    GLOBAL DEFAULT  UND sigsetjmp
    41: 00000000     0 FUNC    GLOBAL DEFAULT  UND siglongjmp
    42: 00000000     0 FUNC    GLOBAL DEFAULT  UND sscanf
    43: 00000000     0 FUNC    GLOBAL DEFAULT  UND fflush
    44: 00000000     0 FUNC    GLOBAL DEFAULT  UND fread
    45: 00000000     0 OBJECT  GLOBAL DEFAULT  UND __sF
    46: 00000000     0 FUNC    GLOBAL DEFAULT  UND __aeabi_memcpy
    47: 00000000     0 FUNC    GLOBAL DEFAULT  UND stat
    48: 00000000     0 FUNC    GLOBAL DEFAULT  UND basename
    49: 00000000     0 FUNC    GLOBAL DEFAULT  UND memcpy
    50: 00000000     0 FUNC    GLOBAL DEFAULT  UND fgets
    51: 00000000     0 FUNC    GLOBAL DEFAULT  UND strtol
    52: 00000000     0 FUNC    GLOBAL DEFAULT  UND strrchr
    53: 00000000     0 FUNC    GLOBAL DEFAULT  UND strncmp
    54: 00000000     0 FUNC    GLOBAL DEFAULT  UND strtok_r
    55: 00000000     0 FUNC    GLOBAL DEFAULT  UND strcmp
    56: 00000000     0 FUNC    GLOBAL DEFAULT  UND qsort
    57: 00000000     0 FUNC    GLOBAL DEFAULT  UND fputs
    58: 00000000     0 FUNC    GLOBAL DEFAULT  UND memmove
    59: 00000000     0 FUNC    GLOBAL DEFAULT  UND strstr
    60: 00000000     0 FUNC    GLOBAL DEFAULT  UND memchr
    61: 00000000     0 FUNC    GLOBAL DEFAULT  UND isdigit
    62: 00000000     0 FUNC    GLOBAL DEFAULT  UND send
    63: 00000000     0 FUNC    GLOBAL DEFAULT  UND __errno
    64: 00000000     0 FUNC    GLOBAL DEFAULT  UND recv
    65: 00000000     0 FUNC    GLOBAL DEFAULT  UND __aeabi_memmove
    66: 00000000     0 FUNC    GLOBAL DEFAULT  UND __aeabi_memset
    67: 00000000     0 FUNC    GLOBAL DEFAULT  UND strncpy
    68: 00000000     0 FUNC    GLOBAL DEFAULT  UND inet_pton
    69: 00000000     0 FUNC    GLOBAL DEFAULT  UND strtoul
    70: 00000000     0 FUNC    GLOBAL DEFAULT  UND getsockname
    71: 00000000     0 FUNC    GLOBAL DEFAULT  UND bind
    72: 00000000     0 FUNC    GLOBAL DEFAULT  UND listen
    73: 00000000     0 FUNC    GLOBAL DEFAULT  UND accept
    74: 00000000     0 FUNC    GLOBAL DEFAULT  UND strcasecmp
    75: 00000000     0 FUNC    GLOBAL DEFAULT  UND isxdigit
    76: 00000000     0 FUNC    GLOBAL DEFAULT  UND socket
    77: 00000000     0 FUNC    GLOBAL DEFAULT  UND ioctl
    78: 00146d5c   160 FUNC    GLOBAL DEFAULT    8 MD5_Init
    79: 00144070   688 FUNC    GLOBAL DEFAULT    8 MD5_Update
    80: 00146908  1108 FUNC    GLOBAL DEFAULT    8 MD5_Final
    81: 00000000     0 FUNC    GLOBAL DEFAULT  UND memcmp
    82: 00000000     0 FUNC    GLOBAL DEFAULT  UND zlibVersion
    83: 00000000     0 FUNC    GLOBAL DEFAULT  UND getenv
    84: 00000000     0 FUNC    GLOBAL DEFAULT  UND sprintf
    85: 00000000     0 FUNC    GLOBAL DEFAULT  UND fputc
    86: 00000000     0 FUNC    GLOBAL DEFAULT  UND atoi
    87: 00000000     0 FUNC    GLOBAL DEFAULT  UND geteuid
    88: 00000000     0 FUNC    GLOBAL DEFAULT  UND getpwuid
    89: 00000000     0 FUNC    GLOBAL DEFAULT  UND fseek
    90: 00000000     0 FUNC    GLOBAL DEFAULT  UND bsd_signal
    91: 00000000     0 FUNC    GLOBAL DEFAULT  UND strncasecmp
    92: 00011d38     0 FUNC    GLOBAL DEFAULT  UND calloc
    93: 00011d2c     0 FUNC    GLOBAL DEFAULT  UND strdup
    94: 00011d20     0 FUNC    GLOBAL DEFAULT  UND realloc
    95: 00000000     0 FUNC    GLOBAL DEFAULT  UND isprint
    96: 00000000     0 FUNC    GLOBAL DEFAULT  UND isalnum
    97: 00000000     0 FUNC    GLOBAL DEFAULT  UND isalpha
    98: 00000000     0 FUNC    GLOBAL DEFAULT  UND isupper
    99: 00000000     0 FUNC    GLOBAL DEFAULT  UND islower
   100: 00000000     0 FUNC    GLOBAL DEFAULT  UND isgraph
   101: 00000000     0 FUNC    GLOBAL DEFAULT  UND getpeername
   102: 00000000     0 FUNC    GLOBAL DEFAULT  UND getsockopt
   103: 00000000     0 FUNC    GLOBAL DEFAULT  UND connect
   104: 00000000     0 FUNC    GLOBAL DEFAULT  UND setsockopt
   105: 00000000     0 FUNC    GLOBAL DEFAULT  UND inflateInit_
   106: 00000000     0 FUNC    GLOBAL DEFAULT  UND inflate
   107: 00000000     0 FUNC    GLOBAL DEFAULT  UND inflateEnd
   108: 00000000     0 FUNC    GLOBAL DEFAULT  UND inflateInit2_
   109: 00000000     0 FUNC    GLOBAL DEFAULT  UND strerror_r
   110: 00000000     0 FUNC    GLOBAL DEFAULT  UND gmtime_r
   111: 00000000     0 FUNC    GLOBAL DEFAULT  UND select
   112: 00000000     0 FUNC    GLOBAL DEFAULT  UND recvfrom
   113: 00000000     0 FUNC    GLOBAL DEFAULT  UND sendto
   114: 00000000     0 FUNC    GLOBAL DEFAULT  UND strlcat
   115: 00000000     0 FUNC    GLOBAL DEFAULT  UND getaddrinfo
   116: 00000000     0 FUNC    GLOBAL DEFAULT  UND freeaddrinfo
   117: 00000000     0 FUNC    GLOBAL DEFAULT  UND fcntl
   118: 00000000     0 FUNC    GLOBAL DEFAULT  UND toupper
   119: 00000000     0 FUNC    GLOBAL DEFAULT  UND gethostname
   120: 00000000     0 FUNC    GLOBAL DEFAULT  UND waitpid
   121: 00000000     0 FUNC    GLOBAL DEFAULT  UND kill
   122: 00000000     0 FUNC    GLOBAL DEFAULT  UND strpbrk
   123: 00000000     0 FUNC    GLOBAL DEFAULT  UND socketpair
   124: 00000000     0 FUNC    GLOBAL DEFAULT  UND fork
   125: 00000000     0 FUNC    GLOBAL DEFAULT  UND dup2
   126: 00000000     0 FUNC    GLOBAL DEFAULT  UND execl
   127: 00000000     0 FUNC    GLOBAL DEFAULT  UND abort
   128: 00000000     0 FUNC    GLOBAL DEFAULT  UND gethostbyname
   129: 00000000     0 FUNC    GLOBAL DEFAULT  UND getservbyname
   130: 00000000     0 FUNC    GLOBAL DEFAULT  UND shutdown
   131: 00000000     0 FUNC    GLOBAL DEFAULT  UND write
   132: 00000000     0 FUNC    GLOBAL DEFAULT  UND perror
   133: 00000000     0 FUNC    GLOBAL DEFAULT  UND ftell
   134: 00000000     0 FUNC    GLOBAL DEFAULT  UND closelog
   135: 00000000     0 FUNC    GLOBAL DEFAULT  UND openlog
   136: 00000000     0 FUNC    GLOBAL DEFAULT  UND syslog
   137: 00000000     0 FUNC    GLOBAL DEFAULT  UND getpid
   138: 00000000     0 FUNC    GLOBAL DEFAULT  UND vfprintf
   139: 00000000     0 FUNC    GLOBAL DEFAULT  UND dlopen
   140: 00000000     0 FUNC    GLOBAL DEFAULT  UND dlerror
   141: 00000000     0 FUNC    GLOBAL DEFAULT  UND dlclose
   142: 00000000     0 FUNC    GLOBAL DEFAULT  UND dlsym
   143: 00000000     0 FUNC    GLOBAL DEFAULT  UND strerror
   144: 00000000     0 FUNC    GLOBAL DEFAULT  UND opendir
   145: 00000000     0 FUNC    GLOBAL DEFAULT  UND readdir
   146: 00000000     0 FUNC    GLOBAL DEFAULT  UND closedir
   147: 00000000     0 FUNC    GLOBAL DEFAULT  UND printf
   148: 00000000     0 FUNC    GLOBAL DEFAULT  UND poll
   149: 00000000     0 FUNC    GLOBAL DEFAULT  UND getuid
   150: 00000000     0 FUNC    GLOBAL DEFAULT  UND setvbuf
   151: 00000000     0 FUNC    GLOBAL DEFAULT  UND chmod
   152: 00000000     0 FUNC    GLOBAL DEFAULT  UND getgid
   153: 00000000     0 FUNC    GLOBAL DEFAULT  UND getegid
   154: 00000000     0 FUNC    GLOBAL DEFAULT  UND raise
   155: 00000000     0 FUNC    WEAK   DEFAULT  UND __gnu_Unwind_Find_exidx
   156: 00000000     0 NOTYPE  WEAK   DEFAULT  UND __cxa_begin_cleanup
   157: 00000000     0 NOTYPE  WEAK   DEFAULT  UND __cxa_type_match
   158: 00000000     0 NOTYPE  WEAK   DEFAULT  UND __cxa_call_unexpected
   159: 001e2d84     0 NOTYPE  GLOBAL DEFAULT  ABS _edata
   160: 001e2d84     0 NOTYPE  GLOBAL DEFAULT  ABS __bss_start
   161: 001e4ea0     0 NOTYPE  GLOBAL DEFAULT  ABS _end
从上面结果看出,这个可执行文件中链接了比如pthread_create、time等



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值