Bug 14217 - internal error in set_offset
Summary: internal error in set_offset
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: gold (show other bugs)
Version: 2.24
: P2 normal
Target Milestone: ---
Assignee: Cary Coutant
URL:
Keywords:
: 15449 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-06-10 15:13 UTC by H.J. Lu
Modified: 2015-03-22 05:33 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2012-06-10 15:13:31 UTC
[hjl@gnu-6 ld]$ cat /export/gnu/import/git/binutils/ld/testsuite/ld-elf/tdata3s
s       .globl main
	.globl start
	.globl _start
	.globl __start
	.text
main:
start:
_start:
__start:
	.byte 0

	.section .tdata,"awT",%progbits
	.type	tdata,%object
	.size	tdata,1
tdata:
	.byte 17

	.section .tbss,"awT",%nobits
	.p2align 10
	.type	tbss, %object
	.size	tbss, 1024
tbss:
	.zero	1024
[hjl@gnu-6 ld]$ /export/build/gnu/binutils/build-x86_64-linux/ld/../gas/as-new    -o tmpdir/tdata3.o /export/gnu/import/git/binutils/ld/testsuite/ld-elf/tdata3.s
[hjl@gnu-6 ld]$ ld.gold -o tmpdir/tdata3 -z relro tmpdir/tdata3.o
ld.gold: internal error in set_offset, at /net/gnu-6/export/linux/src/binutils/binutils/gold/output.cc:4567
[hjl@gnu-6 ld]$
Comment 1 Will Newton 2015-02-10 06:40:50 UTC
*** Bug 15449 has been marked as a duplicate of this bug. ***
Comment 2 Sourceware Commits 2015-03-22 05:31:42 UTC
The master branch has been updated by Cary Coutant <ccoutant@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=bccffdfdf268a84533131d6e4d6208f9873892ee

commit bccffdfdf268a84533131d6e4d6208f9873892ee
Author: Cary Coutant <ccoutant@gmail.com>
Date:   Sat Mar 21 22:30:44 2015 -0700

    Fix internal error with -z relro when .tbss is last relro section.
    
    When calculating the padding necessary to align the end of the relro
    segment to a page boundary, gold erroneously ignores the .tdata section
    when checking to see if there are any relro sections (so if .tdata
    is the only relro section, we fail to align the segment properly),
    and erroneously pads the cumulative size of the segment based on
    the alignment of .tbss. If there are no relro sections following .tbss,
    it then fails to note the padding needed at the end of .tdata.
    
    This patch fixes both problems. is_first_section_relro() will return
    true when it sees a .tdata section, and we do not align the cumulative
    size until after checking for the .tbss section.
    
    gold/
    	PR gold/14217
    	* output.cc (Output_segment::is_first_section_relro): Don't ignore
    	.tdata section.
    	(Output_segment::set_section_addresses): Don't align size of relro
    	segment for .tbss.
Comment 3 Cary Coutant 2015-03-22 05:33:30 UTC
Fixed on trunk.