On Fri, Jan 18, 2013 at 5:31 AM, Saul Tamari <stamari@xxxxxxxxx> wrote: > On Fri, Jan 18, 2013 at 12:43 AM, Ian Lance Taylor <iant@xxxxxxxxxx> wrote: >> >> On Thu, Jan 17, 2013 at 2:11 PM, Saul Tamari <stamari@xxxxxxxxx> wrote: >> > Is there a way to verify if there are wrongly initialized TLS >> > variables in some application or I can only detect such cases when the >> > application fails? >> >> You could probably look at the dynamic relocations and see if there >> are any TLS relocations in the shared library that are not global >> dynamic. > > > I tried the following: > [root@vm0 ~]# readelf -s ./mylib.so | grep TLS > 808: 00000418 4 TLS GLOBAL DEFAULT 16 _ZN24MonitorWorkItemOpera > 914: 00000008 4 TLS GLOBAL DEFAULT 16 _ZN12TQQQScheduler9_instan > 1176: 00000414 4 TLS GLOBAL DEFAULT 16 time_monitor_list > 2577: 00000000 4 TLS WEAK DEFAULT 16 _ZZN6Remote23MultiplexCli > 2788: 00000004 4 TLS WEAK DEFAULT 16 _ZZN6Remote23MultiplexCli > 249: 0000000c 4 TLS LOCAL DEFAULT 16 _ZL17pthread_qqq_owner > 435: 00000010 1 TLS LOCAL DEFAULT 16 _ZL11g_in_syslog > 436: 00000011 1024 TLS LOCAL DEFAULT 16 _ZL9g_tls_buf > 2230: 00000418 4 TLS GLOBAL DEFAULT 16 _ZN24MonitorWorkItemOpera > 2467: 00000000 4 TLS WEAK DEFAULT 16 _ZZN6Remote23MultiplexCli > 3375: 00000008 4 TLS GLOBAL DEFAULT 16 _ZN12QQQScheduler9_instan > 3660: 00000414 4 TLS GLOBAL DEFAULT 16 time_monitor_list > 3766: 00000004 4 TLS WEAK DEFAULT 16 _ZZN6Remote23MultiplexCli > > So I see several TLS entries reported as WEAK and LOCAL and they could > cause the TLS issues I was experiencing? Those are the symbols. The issue here is the relocations, displayed by readelf -r. Dynamic and non-dynamic references to TLS symbols use different relocations. Ian