When linking a program that has a combination of thread local data that exceeds 2^21 in size (roughly 0x3e8500), the following link error occurs: ../src/upcr_gccupc.c:81: relocation truncated to fit: TPREL22 MYTHREAD The variable being referred to is a single word that is relatively far from the point of reference. I've tried duplicating this by constructing some simple C files with large thread-local declarations, and references to data that should be far away, but was unable to make the failure happen. I can collect the .o's and the ld command line that makes it fail, if needed, but there are 50 in total, so if there is another way to diagnose the problem or workaround it that would be preferred.
*** Bug 2868 has been marked as a duplicate of this bug. ***
Here is the testcase: [hjl@gnu-12 tls-20]$ cat x.c #include <stdio.h> static __thread char x [0x1ffff0]; static __thread char y; void * foo () { return &x; } void * bar () { return &y; } int main () { printf ("foo: %p\n", foo ()); printf ("bar: %p\n", bar ()); return 0; } [hjl@gnu-12 tls-20]$ gcc x.c /tmp/ccKKUwVD.o: In function `bar': x.c:(.text+0x22): relocation truncated to fit: TPREL22 against `y' /usr/local/bin/ld: final link failed: Nonrepresentable section on output collect2: ld returned 1 exit status [hjl@gnu-12 tls-20]$ The IA64 local exec TLS mode has a 2MB limit. You have to change your code to avoid it.
Compiler should generate R_IA64_TPREL64I when the 2MB limit is exceeded.
HJL wrote: "Compiler should generate R_IA64_TPREL64I when the 2MB limit is exceeded" Can the compiler determine that TPREL22 won't work, or might a new compilation switch (ala, -fbig-tls) be needed?
Subject: Re: IA64: relocation truncated to fit: TPREL22 On Thu, 2006-07-06 at 10:47, gary at intrepid dot com wrote: > Can the compiler determine that TPREL22 won't work, or might a new > compilation switch (ala, -fbig-tls) be needed? Try -mtls-size=64. HJ's example compiles fine with that option.