Bug 21430 - gold misplaces a relaxed section on AArch64
Summary: gold misplaces a relaxed section on AArch64
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: gold (show other bugs)
Version: 2.29
: P2 critical
Target Milestone: ---
Assignee: Cary Coutant
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-04-26 10:41 UTC by Igor Kudrin
Modified: 2017-05-12 22:32 UTC (History)
2 users (show)

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


Attachments
The fix for the issue (2.55 KB, patch)
2017-04-26 10:52 UTC, Igor Kudrin
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Igor Kudrin 2017-04-26 10:41:24 UTC
Steps to reproduce:

$ cat > test.s << EOF
.globl _start, foo, bar

.section ".text.start", "ax"
_start:
    bl foo
    .space 0x7000000

.section ".text.bar", "ax"
bar:
    .space 0x1000000
    .size bar, .-bar

.section ".text.foo", "ax"
foo:
    b _start
EOF
$ aarch64-linux-gnu-as test.s -o test.o
$ ./gold-master test.o -o test.out
$ nm -S test.out | grep "foo\|bar"
00000000074000c4 0000000001000000 T bar
00000000084000b4 T foo

As you can see, the symbol 'foo' lays inside the content of 'bar'. If you use something like "objdump -d test.out" you will see that the content of the input section ".text.foo" is written on top of the section ".text.bar", so that it becomes crippled.
Comment 1 Igor Kudrin 2017-04-26 10:52:38 UTC
Created attachment 10018 [details]
The fix for the issue

Here is the fix for the issue.
Comment 2 Igor Kudrin 2017-04-26 11:06:35 UTC
Comment on attachment 10018 [details]
The fix for the issue

gold/ChangeLog

	* aarch64.cc
        (AArch64_relobj::convert_input_section_to_relaxed_section):
        Set the section offset to -1ULL.
        (Target_aarch64::relocate_section): Adjust the view in case
        of a relaxed input section.
        * testsuite/Makefile.am (pr21430): New test.
        * testsuite/Makefile.in: Regenerate
        * testsuite/pr21430.s: New test source file.
        * testsuite/pr21430.sh: New test script.
Comment 3 cvs-commit@gcc.gnu.org 2017-05-12 22:25:32 UTC
The master branch has been updated by Cary Coutant <ccoutant@sourceware.org>:

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

commit 6bf56e7482e220ff98655b5285736a37dd602c17
Author: Igor Kudrin <ikudrin@accesssoftek.com>
Date:   Fri May 12 15:24:32 2017 -0700

    Fix misplacement of a relaxed section on AArch64.
    
    gold/ChangeLog
    	PR gold/21430
    	* aarch64.cc
    	(AArch64_relobj::convert_input_section_to_relaxed_section):
    	Set the section offset to -1ULL.
    	(Target_aarch64::relocate_section): Adjust the view in case
    	of a relaxed input section.
    	* testsuite/Makefile.am (pr21430): New test.
    	* testsuite/Makefile.in: Regenerate
    	* testsuite/pr21430.s: New test source file.
    	* testsuite/pr21430.sh: New test script.
Comment 4 Cary Coutant 2017-05-12 22:32:38 UTC
Fixed on trunk.