Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

macos - What is the "___emutls_get_address" symbol?

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
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...