更详细的内容见man page。这里举例说明: nm -u hello.o 显示hello.o 中的未定义符号,需要和其他对象文件进行链接. nm -A /usr/lib/* 2>/dev/null | grep "T memset" 在 /usr/lib/ 目录下找出哪个库文件定义了memset函数.
[root@localhost memzone]# nm -n -C build/app/TestMalloc | grep rte_malloc 00000000005b1b54 T rte_malloc_socket 00000000005b1bfc T rte_malloc 00000000005b1d40 T rte_malloc_validate 00000000005b1dc0 T rte_malloc_get_socket_stats 00000000005b1e20 T rte_malloc_dump_stats 00000000005b1f48 T rte_malloc_set_limit 00000000005b1f60 T rte_malloc_virt2iova 00000000005b23f4 T rte_malloc_dump_heaps 00000000005b2464 T rte_malloc_heap_get_socket 00000000005b2584 T rte_malloc_heap_socket_is_external 00000000005b2638 T rte_malloc_heap_memory_add 00000000005b2838 T rte_malloc_heap_memory_remove 00000000005b29a8 T rte_malloc_heap_memory_attach 00000000005b29d8 T rte_malloc_heap_memory_detach 00000000005b2a08 T rte_malloc_heap_create 00000000005b2b94 T rte_malloc_heap_destroy [root@localhost memzone]# ldd build/app/TestMalloc linux-vdso.so.1 => (0x0000ffff88e20000) librt.so.1 => /lib64/librt.so.1 (0x0000ffff88dd0000) libm.so.6 => /lib64/libm.so.6 (0x0000ffff88d10000) libnuma.so.1 => /lib64/libnuma.so.1 (0x0000ffff88ce0000) libdl.so.2 => /lib64/libdl.so.2 (0x0000ffff88cb0000) libpthread.so.0 => /lib64/libpthread.so.0 (0x0000ffff88c70000) libc.so.6 => /lib64/libc.so.6 (0x0000ffff88ae0000) libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x0000ffff88aa0000) /lib/ld-linux-aarch64.so.1 (0x0000ffff88e30000)
[root@localhost memzone]# readelf -d build/app/TestMalloc Dynamic section at offset 0x9efab0 contains 29 entries: Tag Type Name/Value 0x0000000000000001 (NEEDED) Shared library: [librt.so.1] 0x0000000000000001 (NEEDED) Shared library: [libm.so.6] 0x0000000000000001 (NEEDED) Shared library: [libnuma.so.1] 0x0000000000000001 (NEEDED) Shared library: [libdl.so.2] 0x0000000000000001 (NEEDED) Shared library: [libpthread.so.0] 0x0000000000000001 (NEEDED) Shared library: [libc.so.6] 0x000000000000000c (INIT) 0x463ce8 0x000000000000000d (FINI) 0xba6210 0x0000000000000019 (INIT_ARRAY) 0xdff400 0x000000000000001b (INIT_ARRAYSZ) 1696 (bytes) 0x000000000000001a (FINI_ARRAY) 0xdffaa0 0x000000000000001c (FINI_ARRAYSZ) 8 (bytes) 0x000000006ffffef5 (GNU_HASH) 0x4002d0 0x0000000000000005 (STRTAB) 0x436f08 0x0000000000000006 (SYMTAB) 0x40d250 0x000000000000000a (STRSZ) 163405 (bytes) 0x000000000000000b (SYMENT) 24 (bytes) 0x0000000000000015 (DEBUG) 0x0 0x0000000000000003 (PLTGOT) 0xdfffe8 0x0000000000000002 (PLTRELSZ) 5544 (bytes) 0x0000000000000014 (PLTREL) RELA 0x0000000000000017 (JMPREL) 0x462740 0x0000000000000007 (RELA) 0x4625c0 0x0000000000000008 (RELASZ) 384 (bytes) 0x0000000000000009 (RELAENT) 24 (bytes) 0x000000006ffffffe (VERNEED) 0x462510 0x000000006fffffff (VERNEEDNUM) 5 0x000000006ffffff0 (VERSYM) 0x45ed56 0x0000000000000000 (NULL) 0x0 [root@localhost memzone]#
[root@localhost memzone]# nm -Au build/app/TestMalloc | grep rte_malloc [root@localhost memzone]# nm -A build/app/TestMalloc | grep rte_malloc build/app/TestMalloc:00000000005b1bfc T rte_malloc build/app/TestMalloc:00000000005b23f4 T rte_malloc_dump_heaps build/app/TestMalloc:00000000005b1e20 T rte_malloc_dump_stats build/app/TestMalloc:00000000005b1dc0 T rte_malloc_get_socket_stats build/app/TestMalloc:00000000005b2a08 T rte_malloc_heap_create build/app/TestMalloc:00000000005b2b94 T rte_malloc_heap_destroy build/app/TestMalloc:00000000005b2464 T rte_malloc_heap_get_socket build/app/TestMalloc:00000000005b2638 T rte_malloc_heap_memory_add build/app/TestMalloc:00000000005b29a8 T rte_malloc_heap_memory_attach build/app/TestMalloc:00000000005b29d8 T rte_malloc_heap_memory_detach build/app/TestMalloc:00000000005b2838 T rte_malloc_heap_memory_remove build/app/TestMalloc:00000000005b2584 T rte_malloc_heap_socket_is_external build/app/TestMalloc:00000000005b1f48 T rte_malloc_set_limit build/app/TestMalloc:00000000005b1b54 T rte_malloc_socket build/app/TestMalloc:00000000005b1d40 T rte_malloc_validate build/app/TestMalloc:00000000005b1f60 T rte_malloc_virt2iova [root@localhost memzone]# nm -u build/app/TestMalloc | grep rte_malloc [root@localhost memzone]# nm -a build/app/TestMalloc | grep rte_malloc 00000000005b1bfc T rte_malloc 0000000000000000 a rte_malloc.c 00000000005b23f4 T rte_malloc_dump_heaps 00000000005b1e20 T rte_malloc_dump_stats 00000000005b1dc0 T rte_malloc_get_socket_stats 00000000005b2a08 T rte_malloc_heap_create 00000000005b2b94 T rte_malloc_heap_destroy 00000000005b2464 T rte_malloc_heap_get_socket 00000000005b2638 T rte_malloc_heap_memory_add 00000000005b29a8 T rte_malloc_heap_memory_attach 00000000005b29d8 T rte_malloc_heap_memory_detach 00000000005b2838 T rte_malloc_heap_memory_remove 00000000005b2584 T rte_malloc_heap_socket_is_external 00000000005b1f48 T rte_malloc_set_limit 00000000005b1b54 T rte_malloc_socket 00000000005b1d40 T rte_malloc_validate 00000000005b1f60 T rte_malloc_virt2iova