Skip to content

Libcinfo tsd tls refactor#10

Draft
dalehamel wants to merge 6 commits into
mainfrom
libcinfo-tsd-tls-refactor
Draft

Libcinfo tsd tls refactor#10
dalehamel wants to merge 6 commits into
mainfrom
libcinfo-tsd-tls-refactor

Conversation

@dalehamel
Copy link
Copy Markdown
Owner

@dalehamel dalehamel commented Nov 4, 2025

Moving my upstreaming efforts from #7 here, to avoid adding the ruby stuff since that gets complicated.

What

Refactor's tpbase to be libc package, as it provides additional info about libc.

In particular, this adds DTV introspection information and bundles this with the TSD info into a new LibcInfo.

Why

We need the DTV information to look up TLS variables when TLS descriptors are not available.

How

This adds disassembler code for extracting the DTV information from __tls_get_addr if it is present in the libc.

It should be supported for musl and glibc, on both x86_64 and aarch64, and test cases from different libc versions and architectures are added to validate that this is the case.

The tpbase package is renamed to libc, and related functions are renamed to be more generic, but otherwise the functionality is unchanged.

Nothing actually uses the new DTV data yet, another PR will follow up to add that for Ruby which reads the execution context from a TLS variable.

@dalehamel dalehamel force-pushed the libcinfo-tsd-tls-refactor branch from df049e5 to 0ee2d73 Compare November 4, 2025 23:00
Comment thread libc/libc.go Outdated
Comment thread libc/libc.go
fabled and others added 6 commits November 6, 2025 17:31
Co-authored-by: Mackenzie <mackenzie.jomard@datadoghq.com>
Co-authored-by: Florian Lehner <florianl@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
The DTV variables read from extracted __tls_get_addr can be used to
read TLS variables.

If this symbol is missing, empty introspection data is returned.
@dalehamel dalehamel force-pushed the libcinfo-tsd-tls-refactor branch from 08a54d2 to 23da4c0 Compare November 11, 2025 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants