Skip to content

Correctly find TLS block in aarch64.#58

Merged
gnurizen merged 2 commits into
mainfrom
arm_tls
Apr 7, 2025
Merged

Correctly find TLS block in aarch64.#58
gnurizen merged 2 commits into
mainfrom
arm_tls

Conversation

@umanwizard

Copy link
Copy Markdown
Collaborator

Previously, we were just hardcoding the assumption that the TLS block for the main binary starts 16 bytes after the thread control block.

This is usually true, but not always, so let's follow the spec more carefully by actually chasing the required pointers to get the correct address.

Previously, we were just hardcoding the assumption that the TLS block
for the main binary starts 16 bytes after the thread control block.

This is _usually_ true, but not always, so let's follow the spec more
carefully by actually chasing the required pointers to get the correct address.
@umanwizard umanwizard requested a review from gnurizen April 3, 2025 17:11
@umanwizard

Copy link
Copy Markdown
Collaborator Author

The demo in https://github.com/umanwizard/materialize-1/tree/test-custom-labels doesn't work without this change.

@gnurizen

gnurizen commented Apr 4, 2025

Copy link
Copy Markdown
Collaborator

Can we include a test for this and include a link to the “spec” in the code as well?

@umanwizard

Copy link
Copy Markdown
Collaborator Author

@gnurizen we do already have a test for native custom labels in customlabels_test.go , so as long as that is still working I think this is okay.

It's hard to write a test that would specifically fail due to this bug (i.e., that wouldn't have passed before this PR) because I haven't figured out exactly what causes the TLS block to not be located 16 bytes after the beginning of the thread control block. It seems to only happen in certain large programs (the only one I reproduced it in was Materialize's environmentd). Any small test program I compile would have already worked with the old code.

@gnurizen gnurizen merged commit 09f0ddd into main Apr 7, 2025
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.

2 participants