Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add support for Mach-O thread local variables #68

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Popax21 wants to merge 1 commit into netwide-assembler:master
base: master
Choose a base branch
Loading
from Popax21:patch-1

Conversation

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.

nike4613 and Nomis101 reacted with thumbs up emoji
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.
Copy link
Contributor

sezero commented Oct 11, 2023

Has this been reviewed?

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.

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

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /