This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

TLS variables access for -static -lpthread executables


Hi,

Reproducer:
gcc -g -o tlsvar tlsvar.c -pthread -static; gdb ./tlsvar -ex 'b 12' -ex r -ex 'info thread' -ex 'p *thread_local_p'

Actual output:
Cannot find executable file `.../tlsvar' in dynamic linker's load module list

Expected output:
$1 = 10 (or 20 or 30)

With -static there is no _r_debug, no link_map, no '.dynamic' section so there
is nothing to pass as 'psaddr_t __map_address' for td_thr_tls_get_addr.

Attached GDB fix that uses td_thr_tlsbase() instead of td_thr_tls_get_addr()
and pass 'modid' as value 1.  But I haven't found it documented anywhere.

Is such patch acceptable for upstream GDB or is there some better way with
glibc?


Thanks,
Jan

Attachment: tlsvar.c
Description: Text document

Attachment: staticexectls.patch
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]