[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug gold/19291] New: constant strings still don't always get relocated
From: |
martin.dorey at hds dot com |
Subject: |
[Bug gold/19291] New: constant strings still don't always get relocated properly in a relocatable built with gold --script |
Date: |
Wed, 25 Nov 2015 08:31:46 +0000 |
https://sourceware.org/bugzilla/show_bug.cgi?id=19291
Bug ID: 19291
Summary: constant strings still don't always get relocated
properly in a relocatable built with gold --script
Product: binutils
Version: 2.25
Status: NEW
Severity: normal
Priority: P2
Component: gold
Assignee: ccoutant at gmail dot com
Reporter: martin.dorey at hds dot com
CC: ian at airs dot com
Target Milestone: ---
Created attachment 8813
--> https://sourceware.org/bugzilla/attachment.cgi?id=8813&action=edit
the source and binaries, including gold 2.25-built relocatable.o
This is a similar test case to Bug 6992, derived from the same code base. The
test case attached to that bug now works for us, with your kind fix, thanks,
but we're still having a similar problem, albeit probably in fewer
circumstances. Again, we're trying gold -r --script. This time we perhaps
need to add a little -O2 realism, fprintf instead of printf and a + 1.
address@hidden:~/tmp/D116822/new$ cat main.cpp
#include <stdio.h>
int
main() {
fprintf(stderr, "hello world\n" + 1);
}
address@hidden:~/tmp/D116822/new$ cat buildit.sh
LD=${LD:-'ld'}
g++ -O2 -g -c main.cpp
$LD -r -o relocatable.o --script script.lnk main.o
g++ -g -o main relocatable.o
./main
address@hidden:~/tmp/D116822/new$
Works with ld, goes mad with gold:
address@hidden:~/tmp/D116822/new$ bash buildit.sh
ello world
address@hidden:~/tmp/D116822/new$ LD=ld.gold bash buildit.sh
/usr/bin/ld: relocatable.o: access beyond end of merged section (38)
;(address@hidden:~/tmp/D116822/new$
In Ian's original fixes, he found three places in the gold source where
relocatable links should use zero instead of the section address. The results
below might suggest that there's a fourth place that could use similar
attention.
When built with gold, the relocations are offset by the VMA of rodata:
address@hidden:~/tmp/D116822/new$ readelf --relocs relocatable.o | grep LC
000000000016 00090000000a R_X86_64_32 0000000000000026 .LC0 + 1
00000000032b 000900000001 R_X86_64_64 0000000000000026 .LC0 + 1
address@hidden:~/tmp/D116822/new$ readelf --section-headers relocatable.o |
grep rodata
[ 4] .rodata PROGBITS 0000000000000026 00000068
address@hidden:~/tmp/D116822/new$
When built with ld, they're not:
address@hidden:~/tmp/D116822/new$ readelf --relocs relocatable.o | grep LC
000000000016 00100000000a R_X86_64_32 0000000000000000 .LC0 + 1
00000000032b 001000000001 R_X86_64_64 0000000000000000 .LC0 + 1
address@hidden:~/tmp/D116822/new$ readelf --section-headers relocatable.o |
grep rodata
[ 3] .rodata PROGBITS 0000000000000026 00000066
address@hidden:~/tmp/D116822/new$
--
You are receiving this mail because:
You are on the CC list for the bug.
- [Bug gold/19291] New: constant strings still don't always get relocated properly in a relocatable built with gold --script,
martin.dorey at hds dot com <=