pc
环境下可以很方便使用 ldd
来查看动态库依赖,嵌入式平台下可以使用 readelf
来完成相同的功能
pc
下
$ ldd /lib32/libc-2.26.so
/lib/ld-linux.so.2 (0xf7f8f000)
linux-gate.so.1 => (0xf7f8d000)
而使用交叉编译工具链编译不能使用 ldd
查看
$ ldd output/out.elf
not a dynamic executable
使用 readelf
查看依赖
$ arm-linux-gnueabihf-readelf -d output/out.elf
Dynamic section at offset 0x42f79c contains 29 entries:
Tag Type Name/Value
0x00000001 (NEEDED) Shared library: [libstdc++.so.6]
0x00000001 (NEEDED) Shared library: [libpthread.so.0]
0x00000001 (NEEDED) Shared library: [libm.so.6]
0x00000001 (NEEDED) Shared library: [librt.so.1]
0x00000001 (NEEDED) Shared library: [libgcc_s.so.1]
0x00000001 (NEEDED) Shared library: [libc.so.6]
0x0000000c (INIT) 0x1a964
0x0000000d (FINI) 0x2c5e10
0x00000019 (INIT_ARRAY) 0x43f000
0x0000001b (INIT_ARRAYSZ) 212 (bytes)
0x0000001a (FINI_ARRAY) 0x43f0d4
0x0000001c (FINI_ARRAYSZ) 4 (bytes)
0x00000004 (HASH) 0x10194
0x00000005 (STRTAB) 0x156dc
0x00000006 (SYMTAB) 0x1192c
0x0000000a (STRSZ) 16199 (bytes)
0x0000000b (SYMENT) 16 (bytes)
0x00000015 (DEBUG) 0x0
0x00000003 (PLTGOT) 0x44f8ac
0x00000002 (PLTRELSZ) 2336 (bytes)
0x00000014 (PLTREL) REL
0x00000017 (JMPREL) 0x1a044
0x00000011 (REL) 0x19f0c
0x00000012 (RELSZ) 312 (bytes)
0x00000013 (RELENT) 8 (bytes)
0x6ffffffe (VERNEED) 0x19ddc
0x6fffffff (VERNEEDNUM) 6
0x6ffffff0 (VERSYM) 0x19624
0x00000000 (NULL) 0x0