Skip to content

Conversation

@Popax21
Copy link

@Popax21 Popax21 commented Feb 28, 2023

This patch adds support for thread local sections, which were previously unimplemented. Specifically, it allows the user to emit sections with the types S_THREAD_LOCAL_REGULAR (for .tdata and the new thread_data section attribute) and S_THREAD_LOCAL_ZEROFILL (for .tbss and the new thread_bss/zerofill attribute). Additionally, it also maps specific section names to the section types S_THREAD_LOCAL_VARIABLES (__thread_vars), S_THREAD_LOCAL_VARIABLE_POINTERS (__thread_ptrs) and S_THREAD_LOCAL_INIT_FUNCTION_POINTERS (__thread_init - note that I couldn't determine how this section type is usually named, so I chose my own name). These special section names don't have an associated Unix section name, yet are sometimes still required when interacting with thread local variables.

I hereby sign off the Developer’s Certificate of Origin 1.1.

This patch adds support for thread local sections, which were previously unimplemented. Specifically, it allows the user to emit sections with the types `S_THREAD_LOCAL_REGULAR` (for `.tdata` and the new `thread_data` section attribute) and `S_THREAD_LOCAL_ZEROFILL` (for `.tbss` and the new `thread_bss/zerofill` attribute). Additionally, it also maps specific section names to the section types `S_THREAD_LOCAL_VARIABLES` (`__thread_vars`), `S_THREAD_LOCAL_VARIABLE_POINTERS` (`__thread_ptrs`) and `S_THREAD_LOCAL_INIT_FUNCTION_POINTERS` (`__thread_init` - note that I couldn't determine how this section type is usually named, so I chose my own name). These special section names don't have an associated Unix section name, yet are sometimes still required when interacting with thread local variables.

I hereby sign off the Developer’s Certificate of Origin 1.1.
@sezero
Copy link
Contributor

sezero commented Oct 11, 2023

Has this been reviewed?

@hpax
Copy link
Member

hpax commented Oct 6, 2025

This is great, but it needs documentation. It might possibly be nicer to use "wrt ..tls" for compatibility with ELF, though.

@hpax
Copy link
Member

hpax commented Oct 17, 2025

Question: right now we don't have anyone on the NASM team who is familiar with the intricacies of MachO. Would you be able to help with information and/or validation if we need to make changes that affect the MachO backend?

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.

3 participants