Bug 33355

Summary: gcc/ld ia64 relocation truncated to fit: PCREL21B
Product: [Retired] Red Hat Linux Reporter: John Reiser <jreiser>
Component: binutilsAssignee: Jakub Jelinek <jakub>
Status: CLOSED WORKSFORME QA Contact: David Lawrence <dkl>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.3CC: paul
Target Milestone: ---   
Target Release: ---   
Hardware: ia64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2001-03-27 17:10:27 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description John Reiser 2001-03-27 05:40:49 UTC
From Bugzilla Helper:
User-Agent: Mozilla/4.75 [en] (X11; U; Linux 2.2.5-15 i586)


main.o:main.c:588: relocation truncated to fit: PCREL21B get_run_time
main.o: In function `captured_main':
main.o(.text+0x2df2): relocation truncated to fit: PCREL21B get_run_time
collect2: ld returned 1 exit status

These messages appeared when trying to load a "checked"
version of gdb, in order to try to track down bugs in gdb.
So the first complaint is that loading failed.
More important, it is unclear what I should try to change
to avoid the PCREL21B problem.  Bug reports 33288 (lots
of functions) and 33354 (lots of string constants) are
the result of some guesses about what might be wrong,
but I cannot reproduce the PCREL21B message yet.

If I knew what to change in the compiling of get_run_time,
captured_main, or main.o, then I'd try that.
What's really wrong here?
(What are the flags to specify for "compile for unreasonably
large numbers of everything"?  [-fpic does not succeed.])


Reproducible: Always
Steps to Reproduce:
1.load my checked version of gdb.
  (Yes, it is not included in this bug report,
   so >you< cannot reproduce it directly.
   But the problem is not intermittent in any way.)
2.
3.
	

Actual Results:  main.o: In function `captured_main':
main.o(.text+0x1922): relocation truncated to fit: PCREL21B get_run_time
main.o(.text+0xd362): relocation truncated to fit: PCREL21B get_run_time


Expected Results:  Successful load with no complaint.

Comment 1 John Reiser 2001-03-27 17:10:20 UTC
Here is a recipe to reproduce:
Compile and run the generator program genfunc2.c, getting 1024 f*.c files,
each with one function which calls all the rest.
Compile the f*.c files, and load with a main().
Each f*.o has 32KB of .text; 1024 of them total 32MB.
So the problem is: being hobbled by 20(21?) bit offset
field in br.call instruction, with no compile flag
that generates code some other way for very large programs.

-----genfunc2.c
#include <stdio.h>

main()
{
	int f0,f1,g,h;
    for (h=0; h<1024; ++h) {
	char buf[10];
	FILE *file;
	sprintf(buf, "f%d.c", h);
	file = fopen(buf, "w");
	for (f0=0; f0<128; ++f0) {
		fprintf(file, "extern void ");
		for (f1=8; --f1>=0; ) {
			fprintf(file, "f%d()%s",
				(f0<<3)|f1, ((0!=f1) ? "," : ";\n") );
		}
	}
	fprintf(file, "void f%d(){\n", h);
	for (f0=0; f0<128; ++f0) {
		fprintf(file, "\t");
		for (f1=8; --f1>=0; ) if (h!=((f0<<3)|f1)) {
			fprintf(file, "f%d();", (f0<<3)|f1 );
		}
		fprintf(file, "\n");
	}
	fprintf(file, "}\n");
    	fflush(file);
	fclose(file);
    }
	return 0;
}
-----end genfunc2.c

----main.c
extern void f128();
main()
{
	f128();
}
----end main.c

-----shell commands
gcc genfunc2.c
./a.out
gcc -c f*.c
gcc main.o f*.o
-----end shell commands

-----output
	...
f0.o(.text+0x7c02): relocation truncated to fit: PCREL21B f999
f0.o(.text+0x7c22): relocation truncated to fit: PCREL21B f998
f0.o(.text+0x7c42): relocation truncated to fit: PCREL21B f997
f0.o(.text+0x7c62): relocation truncated to fit: PCREL21B f996
f0.o(.text+0x7c82): relocation truncated to fit: PCREL21B f995
f0.o(.text+0x7ca2): relocation truncated to fit: PCREL21B f994
	...
-----



Comment 2 Jakub Jelinek 2001-04-25 15:33:56 UTC
-Wl,-relax
should cure this.