Bug 2869 - IA64: relocation truncated to fit: TPREL22
Summary: IA64: relocation truncated to fit: TPREL22
Status: RESOLVED WONTFIX
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
: 2868 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-06-30 17:20 UTC by Gary Funck
Modified: 2006-07-06 17:47 UTC (History)
1 user (show)

See Also:
Host: ia64-unknown-linux-gnu
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gary Funck 2006-06-30 17:20:21 UTC
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.
Comment 1 Gary Funck 2006-07-01 01:19:41 UTC
*** Bug 2868 has been marked as a duplicate of this bug. ***
Comment 2 H.J. Lu 2006-07-06 17:40:02 UTC
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.
Comment 3 H.J. Lu 2006-07-06 17:43:45 UTC
Compiler should generate R_IA64_TPREL64I when the 2MB limit is exceeded.
Comment 4 Gary Funck 2006-07-06 17:47:59 UTC
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?
Comment 5 wilson@specifix.com 2006-07-08 00:06:29 UTC
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.