Repository navigation
feat: Decode medium-model TLS static relocations in ppc64le - #2724
Merged
Merged
Conversation
marxin
reviewed
Oct 13, 2026
marxin
reviewed
Oct 13, 2026
| //#Config:global-dynamic:pie | ||
| //#CompArgs:-fPIC -ftls-model=global-dynamic | ||
|
|
||
| //#Config:local-exec-no-pie:default |
Member
There was a problem hiding this comment.
How about something that roughly combines this test with the next one. e.g. the following test, which fails:
diff --git a/wild/tests/sources/elf/ppc64-tls/ppc64-tls-dso.c b/wild/tests/sources/elf/ppc64-tls/ppc64-tls-dso.c
index db529ec652..6059c8a00b 100644
--- a/wild/tests/sources/elf/ppc64-tls/ppc64-tls-dso.c
+++ b/wild/tests/sources/elf/ppc64-tls/ppc64-tls-dso.c
@@ -1,4 +1,5 @@
static __thread long dso_tls = 40;
static __thread char dso_tls_byte = 2;
+__thread int imported_tls = 42;
int ppc64_tls_dso_value(void) { return (int)dso_tls + dso_tls_byte; }
diff --git a/wild/tests/sources/elf/ppc64-tls/ppc64-tls.c b/wild/tests/sources/elf/ppc64-tls/ppc64-tls.c
index f472679ffc..dbb27c6417 100644
--- a/wild/tests/sources/elf/ppc64-tls/ppc64-tls.c
+++ b/wild/tests/sources/elf/ppc64-tls/ppc64-tls.c
@@ -26,6 +26,13 @@
//#CompArgs:-fno-pie -ftls-model=local-exec
//#LinkArgs:-no-pie
+//#Config:local-exec-import-no-pie:local-exec-no-pie
+//#CompArgs:-DPPC64_TLS_IMPORT
+//#CompSoArgs:-fPIC
+//#Shared:ppc64-tls-dso.c
+//#ReferenceLinkers:lld
+//#ExpectError:relocation R_PPC64_TPREL16_.*cannot be used against symbol
+
// A local-exec TLS reference inside the shared object itself. The thread-pointer offset is not
// known when linking a DSO. GNU ld accepts this with DF_STATIC_TLS and text relocations; wild
// rejects it.
@@ -49,11 +56,17 @@
extern int ppc64_tls_dso_value(void);
#endif
+#if defined(PPC64_TLS_IMPORT)
+extern __thread int imported_tls;
+#endif
+
static __thread long local_tls = 40;
static __thread char local_tls_byte = 2;
int main(void) {
-#if defined(PPC64_TLS_DSO)
+#if defined(PPC64_TLS_IMPORT)
+ return imported_tls;
+#elif defined(PPC64_TLS_DSO)
return ppc64_tls_dso_value();
#else
return (int)local_tls + local_tls_byte;
davidlattimore
approved these changes
Oct 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Accept local-exec, initial-exec, local-dynamic, and general-dynamic sequences. DTPREL is relative to the TLS segment start plus 0x8000, and an executable's TLSLD GOT offset slot stays zero because
__tls_get_addradds that bias.