Opened 13 years ago

Closed 8 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 by Jiri Svoboda, 13 years ago

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 by Jakub Jermář, 12 years ago

Milestone: 0.5.00.5.1

comment:3 by Jakub Jermář, 12 years ago

Keywords: gsoc12 added

comment:4 by Jakub Jermář, 12 years ago

Keywords: needswork added

comment:5 by Jiri Svoboda, 12 years ago

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 by Jakub Jermář, 12 years ago

Keywords: gsoc12 needswork removed

comment:7 by Jiri Svoboda, 11 years ago

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 11 years ago by Jiri Svoboda (previous) (diff)

comment:8 by Jiri Svoboda, 11 years ago

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 by Jakub Jermář, 10 years ago

Milestone: 0.5.10.5.2

comment:10 by Jiri Svoboda, 8 years ago

Resolution: fixed
Status: assignedclosed

Merged in mainline,2510.

Note: See TracTickets for help on using tickets.