[Gc] "relocation truncated to fit" link error

Dan Bonachea bonachea at cs.berkeley.edu
Sun Apr 3 14:17:27 PDT 2005

Has anybody seen this link error before?:

gc.a(os_dep.o)(.text+0xac1): In function `GC_init_linux_data_start':
os_dep.c:350: relocation truncated to fit: GPREL22 _end
gc.a(os_dep.o)(.text+0x1220): In function `GC_register_data_segments':
os_dep.c:1442: relocation truncated to fit: GPREL22 _end

I'm seeing it on Itanium/Linux2.4.21 when linking the static collector library 
(libgc.a) into executables using gcc-3.3.3 or gcc-3.4.3. I'm not even certain 
what the error means - is the collector sometimes limited to 22 bits (4MB) of 
static data?

The link error occurs even on gctest built from a clean configure with the 
default options, if the link command is changed to use libgc.a instead of 
libgc.so. These link errors on gctest disappear if the collector is configured 
with --disable-shared, but they come right back if you add this line to the 
top of test.c (to artificially inflate the static data to "real program" 
    char pad[8*1024*1024];

I've tried many different linker options, and nothing seems to help - the only 
thing that reliably makes it go away is a fully static link (gcc -static), but 
that brings a whole host of other problems and is often impractical.

Ideas are appreciated...

More information about the Gc mailing list