为什么 ld、nm、objdump 在这个共享对象中报告 'no symbols',当符号似乎存在时?

Why do ld, nm, objdump report 'no symbols' in this shared object, when symbols appear to exist?

我有一个未记录的共享对象 libXSAL.so,我想 link 反对它。

我已经编写了一个包含我需要的函数的部分头文件,带有从 Ghidra 逆向工程推断的签名。

gcc 在 link 时失败:undefined reference to 'function_name' 我使用的每个函数。

nm -D libXSAL.so

nm: libXSAL.so: No symbols

objdump -t libXSAL.so

libXSAL.so:     file format elf32-little

SYMBOL TABLE:
no symbols

但是,Ghidra 发现了符号 table 中给定的函数名称,并且通过手动选择 hexdump,我也可以看到它们。

据我所知,库中和我自己的代码中都没有名称修改;库好像是C的,我的代码也是。

我的目标是能够 link 按原样访问此库。

为什么有些工具可以看到符号,而有些则看不到?

此共享 object 没有部分 header:

libXSAL.so: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), invalid note alignment 0x1, dynamically linked, no section header

根据ELF标准:

Files used during linking must have a section header table; other object files may or may not have one.

您也许可以重建 header table 部分,但祝您好运。

这是故意的(大概是 strip)所以你不能 link 反对文件。

strip 的选项如下:

  -s --strip-all                   Remove all symbol and relocation information