Hi Paolo,

Paolo Bonzini wrote:
Both are same.

Ah, I see, the call is optimized out because __emutls_get_address is
const.  You can try

  __thread int a;
  int main () {
    return *(int *)__emutls_get_address ((void *)0) == a;
  }

I don't have an emutls target at hand, but it does fail on Linux.

Which version of gcc did you use? gcc 4.1 (maybe and 4.2) will report error. But gcc 4.3 compiles OK. I tested using x86_64 native gcc from Debian unstable. __emutls_get_address is defined in libgcc even the target has real TLS.

/usr/lib/gcc/x86_64-linux-gnu$ readelf -a ./4.3/libgcc_s.so | grep emutls
28: 0000000000013a80 390 FUNC GLOBAL DEFAULT 12 __emutls_get_address@@GCC_4.3.0 136: 0000000000013970 57 FUNC GLOBAL DEFAULT 12 __emutls_register_common@@GCC_4.3.0


Regards,
Jie

Reply via email to