Issue Details (XML | Word | Printable)

Key: PCC-341
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Anders Magnusson
Reporter: Iain Hibbert
Votes: 0
Watchers: 0

If you were logged in you would be able to see more operations.

-g causes "relocation truncated to fit: R_X86_64_32 against `.text'"

Created: 01/May/11 06:37 PM   Updated: 03/May/11 10:07 PM
Component/s: amd64 target
Affects Version/s: None
Fix Version/s: None

Environment: NetBSD/amd64

 Description  « Hide
I found a problem linking code compiled with -g flag on amd64. The example code is
just a structure definition (which might be irrelevant anyway?)

struct foo {
        int a;
        short b;

when compiled with the following command

  pcc -g -c d.c

then trying to link with the following command (as per building a kernel with text section in high 2Gb of RAM, I think)

  /usr/tools/bin/x86_64--netbsd-ld -Ttext 0xffffffff80100000 -o d d.o

will fail with messages about truncated relocations

d.o:(.stab+0x14): relocation truncated to fit: R_X86_64_32 against `.text'
d.o:(.stab+0xc8): relocation truncated to fit: R_X86_64_32 against `.text'
d.o:(.stab+0xd4): relocation truncated to fit: R_X86_64_32 against `.text'
d.o:(.stab+0xe0): relocation truncated to fit: R_X86_64_32 against `.text'

this works with gcc and I'm not sure what the problem is.. looking at the generated assembler output

.stabs "/tmp/ctm.10018a",100,0,0,.LL10
.stabs "int:t1=r1;-2147483648;2147483647;",128,0,0,0
.stabs "char:t2=r2;0;127;",128,0,0,0
.stabs "short:t3=r1;-32768;32767;",128,0,0,0
.stabs "long:t4=r1;-9223372036854775808;9223372036854775807;",128,0,0,0
.stabs "long long:t5=r1;-9223372036854775808;9223372036854775807;",128,0,0,0
.stabs "unsigned char:t6=r1;0;255;",128,0,0,0
.stabs "unsigned short:t7=r1;0;65535;",128,0,0,0
.stabs "unsigned int:t8=r1;0;4294967295;",128,0,0,0
.stabs "unsigned long:t9=r1;0;-1;",128,0,0,0
.stabs "unsigned long long:t10=r1;0;-1;",128,0,0,0
.stabs "float:t11=r1;4;0;",128,0,0,0
.stabs "double:t12=r1;8;0;",128,0,0,0
.stabs "long double:t13=r1;12;0;",128,0,0,0
.stabs "void:t14=r14",128,0,0,0
.stabs "debugsyms.c",132,0,0,.LL11
.stabs "debugsyms.c",132,0,0,.LL12
.stabs "",100,0,0,.LL13
.ident "PCC: pcc 1.1.0.DEVEL (netbsd)"

I believe it could be that the .LL?? symbols are stored in the .text section but maybe should
be elsewhere, or represented differently..

for what its worth, gcc produces different assembler but uses a .quad to store reference to
labels from the .text section, and a .long to reference labels in a 'debug_info,"",@progbits'

 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Anders Magnusson added a comment - 03/May/11 01:27 PM
pcc only emits stabs, but I assume gcc uses dwarf2 for debugging. I don't know how well supported stabs is.

Iain Hibbert added a comment - 03/May/11 09:55 PM
Ah I see, gcc can emit stabs also using -gstabs, but I note that this also fails to link
using a high text section start address..

I guess the stabs values are limited to 32-bit, and this would not be a pcc bug (except
that stabs is old hat, dwarf is the newer target but I don't know which is more useful)

Anders Magnusson added a comment - 03/May/11 10:07 PM
I think dwarf is many times better, but more difficult to write also.
There should be dwarf support added though. Anyway, closing this issue.