[prev in list] [next in list] [prev in thread] [next in thread] 

List:       binutils-bugs
Subject:    [Bug gold/19291] New: constant strings still don't always get relocated properly in a relocatable bu
From:       "martin.dorey at hds dot com" <sourceware-bugzilla () sourceware ! org>
Date:       2015-11-25 8:31:46
Message-ID: bug-19291-70 () http ! sourceware ! org/bugzilla/
[Download RAW message or body]

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.

martind@swiftboat:~/tmp/D116822/new$ cat main.cpp 
#include <stdio.h>

int
main() {
    fprintf(stderr, "hello world\n" + 1);
}
martind@swiftboat:~/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
martind@swiftboat:~/tmp/D116822/new$

Works with ld, goes mad with gold:

martind@swiftboat:~/tmp/D116822/new$ bash buildit.sh 
ello world
martind@swiftboat:~/tmp/D116822/new$ LD=ld.gold bash buildit.sh 
/usr/bin/ld: relocatable.o: access beyond end of merged section (38)
;(martind@swiftboat:~/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:

martind@swiftboat:~/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
martind@swiftboat:~/tmp/D116822/new$ readelf --section-headers relocatable.o |
grep rodata
  [ 4] .rodata           PROGBITS         0000000000000026  00000068
martind@swiftboat:~/tmp/D116822/new$ 

When built with ld, they're not:

martind@swiftboat:~/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
martind@swiftboat:~/tmp/D116822/new$ readelf --section-headers relocatable.o |
grep rodata
  [ 3] .rodata           PROGBITS         0000000000000026  00000066
martind@swiftboat:~/tmp/D116822/new$

-- 
You are receiving this mail because:
You are on the CC list for the bug.

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic