如何从库/二进制文件中提取函数名称

How to extract function names from a library / binary

我有一个带有调试符号的库,我执行以下操作来提取函数名称

$ objdump -S -D library_name.so > library_name.asm
$ grep -rn ">:" library_name.asm

这给了我想要的:

3101:0000000000002190 <memset@plt>:
3106:00000000000021a0 <close@plt>:

但似乎有点尴尬...有没有更好的方法来实现这个目标?

我认为您正在寻找的实用程序是 nm:

它收集库或任何 ELF 文件中定义的所有静态和动态符号。 输出如下所示:

000000ec T main
000003f0 a REG_HID0
000003f1 a REG_HID1
00000ec4 T RSA_bigint_add
000009e0 T RSA_bigint_clear
00000a0c T RSA_bigint_cmp
00000dd8 T RSA_bigint_gen
00000aa4 T RSA_bigint_get_bitlength
000010f4 T RSA_bigint_intmul
00000c20 T RSA_bigint_lshift
00001330 T RSA_bigint_mod
00001470 T RSA_bigint_modexp
0000142c T RSA_bigint_modmul
0000120c T RSA_bigint_mul
00000aec T RSA_bigint_rshift
00001024 T RSA_bigint_sub
00000238 T RSA_check_data_with_certificate
00000180 T RSA_check_signature
000002d0 T RSA_x509_get_field
000003a4 T RSA_x509_get_int
000008f8 T RSA_x509_parse_certificate
0000042c T RSA_x509_parse_PKI
000007d8 T RSA_x509_parse_signature
0000057c T RSA_x509_parse_tbscertificate