DSO引用libc_nonshared.a(stat.oS)中的隐藏符号"stat" [英] hidden symbol `stat' in libc_nonshared.a(stat.oS) is referenced by DSO

查看:1005
本文介绍了DSO引用libc_nonshared.a(stat.oS)中的隐藏符号"stat"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用共享库(libscplugin.so)中包含的方法.

I'm trying to use methods contained in a shared library (libscplugin.so).

我已经满足所有图书馆的要求:

I have satisfied all of the libraries requirements:

  • libc.so,带有指向libc.so.6
  • 的符号链接
  • libz.so,带有指向libz.so.1.2.8
  • 的符号链接
  • libstdc++.so,带有指向libstdc++.so.6.0.20
  • 的符号链接
  • libc.so with a symlink to libc.so.6
  • libz.so with a symlink to libz.so.1.2.8
  • libstdc++.so with a symlink to libstdc++.so.6.0.20

编译后,出现以下错误消息:

Upon compilation I get the following error message:

$ gcc test.c -o test -L/usr/lib/arm-linux-gnueabihf/ -lscplugin
/usr/bin/ld: test: hidden symbol `stat' in /usr/lib/arm-linux-gnueabihf/libc_nonshared.a(stat.oS) is referenced by DSO
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status

我唯一能找到的对libc_nonshared.a的引用是在/usr/lib/arm-linux-gnueabihf/libc.so中:

The only reference I could find to libc_nonshared.a is in /usr/lib/arm-linux-gnueabihf/libc.so:

$ cat libc.so
/* GNU ld script
   Use the shared library, but some functions are only in
   the static library, so try that secondarily.  */
OUTPUT_FORMAT(elf32-littlearm)
GROUP ( /lib/arm-linux-gnueabihf/libc.so.6 /usr/lib/arm-linux-gnueabihf/libc_nonshared.a  AS_NEEDED ( /lib/arm-linux-gnueabihf/ld-linux-armhf.so.3 ) )

test.c中,我尝试使用共享库的两个功能(与stat完全无关).我该怎么做才能对此进行编译?

In test.c I'm attempting to use two functions of the shared library (totally unrelated to stat). What can I do to get this to compile ?

推荐答案

您的问题在这里:

我已经满足所有图书馆的要求:

I have satisfied all of the libraries requirements:

  • libc.so,带有指向libc.so.6
  • 的符号链接
  • libc.so with a symlink to libc.so.6

这不是glibc的有效设置.正如您在答案末尾看到的那样,libc.so应该是一个文本文件(链接程序脚本).如果您自己建立指向共享库的符号链接,那么您所做的事情就很奇怪而且不必要.使用提供的libc.so(在构建其他共享库时,您需要执行此操作-现在,您的问题是它们的链接错误),并且一切正常.

That is not a valid setup for glibc. libc.so is supposed to be a text file (linker script) as you saw at the end of your answer. You're doing something weird and unnecessary if you're making symlinks to shared libraries like this yourself. Use the libc.so that's provided (and you need to do this when building your other shared libraries -- your problem right now is that they were mis-linked) and everything will work fine.

这篇关于DSO引用libc_nonshared.a(stat.oS)中的隐藏符号"stat"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆