Fork us on GitHub Follow us on Facebook Follow us on Twitter

Opened 8 years ago

Closed 3 years ago

#339 closed defect (fixed)

Dynamic linker needs full TLS support

Reported by: Jiri Svoboda Owned by: Jiri Svoboda
Priority: major Milestone: 0.7.0
Component: helenos/lib/c Version:
Keywords: Cc:
Blocker for: Depends on:
See also:

Description (last modified by Jiri Svoboda)

Currently the dynamic linker can only handle thread-local variables that are static, because it does cannot resolve module numbers in the TLS runtime functions.

Also, thread-local variables can currently only be in one runtime module (the C library) because of the way global symbols are used to measure tdata and tbss sections.

Change History (10)

comment:1 Changed 8 years ago by Jiri Svoboda

Description: modified (diff)
Owner: changed from Jakub Jermář to Jiri Svoboda
Status: newassigned

There is a special TLS program header that describes the thread-local data section. For this to work tbss should follow tdata (there can be alignment padding between them). From the filesize and memsize of this segment the dynamic loader can derive the beginning and size of tdata and tbss for each module.

comment:2 Changed 8 years ago by Jakub Jermář

Milestone: 0.5.00.5.1

comment:3 Changed 8 years ago by Jakub Jermář

Keywords: gsoc12 added

comment:4 Changed 8 years ago by Jakub Jermář

Keywords: needswork added

comment:5 Changed 8 years ago by Jiri Svoboda

I think the amount of work that needs to be done for this ticket is very small, on the other hand this requires expert knowledge of ELF/HelenOS dynamic linking, so it does not seem very suitable as a GSoC assignment.

comment:6 Changed 8 years ago by Jakub Jermář

Keywords: gsoc12 needswork removed

comment:7 Changed 7 years ago by Jiri Svoboda

There needs to be a program header of type PT_TLS covering the TLS initialization image (.tdata followed by .tbss) (see ELF Handling for Thread-Local Storage 2005 page 4). This is used by the run-time linker.

  • add PHDR of type PT_TLS to linker script
  • RTLD to read TLS initialization image header
  • RTLD to load TLS initialization image
Last edited 7 years ago by Jiri Svoboda (previous) (diff)

comment:8 Changed 7 years ago by Jiri Svoboda

Ad above, to mimic Linux .tdata and .tbss can be put in a separate PT_LOAD segment and at the same time in the PT_TLS segment (thus ensuring they are loaded automatically).

  • rtld needs to assign a number/ID to each loaded module
  • __make_tls(), __free_tls() and friends need to construct TLS, dtv for all loaded modules
  • modify arch's __tls_get_addr() to take module number into account and use dtv
  • dlopen() needs to add the new module's TLS to all existing threads

comment:9 Changed 5 years ago by Jakub Jermář

Milestone: 0.5.10.5.2

comment:10 Changed 3 years ago by Jiri Svoboda

Resolution: fixed
Status: assignedclosed

Merged in mainline,2510.

Note: See TracTickets for help on using tickets.