什么是“___ emutls_get_address”符号? [英] What is the "___emutls_get_address" symbol?

查看:1696
本文介绍了什么是“___ emutls_get_address”符号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

哦,我是GCC,MAC和Makefile的新手。今天,我打算使用MAC OS X和GCC 4.4.2构建一个动态库,但是当链接.o文件时,编译器会像这样抱怨:

 未定义符号:
___emutls_get_address,引用自:
michael.o中的_malloc
michael.o中的$ _malloc
ld:符号(s)未找到

我搜索了这个信息,但是我无法理解结果,我不知道符号是什么意思是,为什么很多程序有这个链接错误。我也想知道这个错误的可能原因是什么,链接命令是:

  g ++ -Dx86 -D_GNU_SOURCE -D_REENTRANT -Wall -m32 \ 
-fno-strict-aliasing -fno-pic -O3 -ggdb \
michael.o malloc_new.o -o libmichael.so \
-lpthread -lm - lstdc ++ -shared


解决方案

此符号是TLS本地存储)通过海湾合作委员会为Mac Os X模拟。有关gcc bugzilla中的一些错误,例如: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39888


在Darwin
上使用线程本地存储(例如OpenMP ThreadPrivate变量)需要通过-lgcc_s.so.1或-lgcc_eh手动链接到TLS emutls b
$ b

请参阅线程:
http://gcc.gnu.org/毫升/ GCC / 2008-12 /米sg00145.html
http:// gcc。 gnu.org/ml/gcc/2008-12/msg00107.html



从上面的线索可以看出,这显然非常糟糕。然而,由于我只是
位,所以我希望有一个跟踪问题的bug。



...



如果我手动链接到gcc_s.so.1或gcc_eh,TLS可以正常工作。


因此,可能的解决方案之一是将 -lgcc_s.so.1 -lgcc_eh 选项添加到链接步骤。其他的是更新你的gcc,因为这是gcc的bug。


Oh, I am a newbie in GCC and MAC and Makefile. Today I intended to build a dynamic lib using MAC OS X and GCC 4.4.2, but when linking the .o files, the compiler complains like this:

Undefined symbols:
  "___emutls_get_address", referenced from:
      _malloc in michael.o
      _malloc in michael.o
ld: symbol(s) not found

I googled this info, but I can't understand the results well, I wonder what does the symbol mean, and why lots of programs have this linking error. I also wonder what is the possible cause for this error, the linking command is:

g++ -Dx86 -D_GNU_SOURCE -D_REENTRANT  -Wall -m32 \
    -fno-strict-aliasing -fno-pic -O3 -ggdb \
    michael.o malloc_new.o -o libmichael.so \
    -lpthread -lm -lstdc++  -shared

解决方案

This symbol is part of TLS (thread-local storage) emulation by gcc for Mac Os X. There are some bugs in gcc bugzilla about this, e.g.: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39888

Using thread local storage (e.g. OpenMP ThreadPrivate variables) on Darwin requires manually linking to TLS emutls, via either -lgcc_s.so.1 or -lgcc_eh

See the threads: http://gcc.gnu.org/ml/gcc/2008-12/msg00145.html http://gcc.gnu.org/ml/gcc/2008-12/msg00107.html

From the above threads, this is evidently quite a mess. However, as I was just bit by this I hoped it useful to have a bug tracking the issue.

...

TLS works fine if I manually link to gcc_s.so.1 or gcc_eh as mentioned above.

So, one of possible solutions is to add -lgcc_s.so.1 or -lgcc_eh option to linking step. And other is to update your gcc, because this is bug of gcc.

这篇关于什么是“___ emutls_get_address”符号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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