This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH][gold] Use attributes of existing sections when placing orphan sections.
- From: Igor Kudrin <ikudrin at accesssoftek dot com>
- To: Ian Lance Taylor <iant at google dot com>
- Cc: "binutils at sourceware dot org" <binutils at sourceware dot org>, Cary Coutant <ccoutant at gmail dot com>
- Date: Wed, 9 Nov 2016 13:16:52 +0000
- Subject: Re: [PATCH][gold] Use attributes of existing sections when placing orphan sections.
- Authentication-results: sourceware.org; auth=none
- References: <1477049134485.42788@accesssoftek.com>,<CAKOQZ8xhimPxuoTEiMsTVkPOXQByLeQJ_NArNtD_Zwd5U=Oogg@mail.gmail.com>,<1477315581018.12769@accesssoftek.com>
Ping.
________________________________________
From: binutils-owner@sourceware.org <binutils-owner@sourceware.org> on behalf of Igor Kudrin <ikudrin@accesssoftek.com>
Sent: Monday, October 24, 2016 7:24 PM
To: Ian Lance Taylor
Cc: binutils@sourceware.org; Cary Coutant
Subject: Re: [PATCH][gold] Use attributes of existing sections when placing orphan sections.
Hi Ian,
The main reason I made this patch is that, in our case, gold places
orphan sections differently than GNU ld does. I tried not to affect
the current behaviour in other cases. At least, all the existing tests pass.
Here is the comparison of results of GNU ld, gold and the patched gold:
$ cat > test.s << EOF
.section CODE, "ax"
nop
.section DATA2, "aw"
.word 0
.section CODE2, "ax"
nop
.section DATA, "aw"
.word 0
EOF
$ cat > test.t << EOF
SECTIONS
{
DATA : { *(DATA) }
CODE : { *(CODE) }
}
EOF
$ as test.s -o test.o
$ ./ld test.o -T test.t -o test.ld.out
$ ./gold test.o -T test.t -o test.gold.out
$ ./gold-patched test.o -T test.t -o test.gold-patched.out
$ readelf -SW test.ld.out
...
[ 1] DATA PROGBITS 0000000000000000 200000 000002 00 WA 0 0 1
[ 2] DATA2 PROGBITS 0000000000000002 200002 000002 00 WA 0 0 1
[ 3] CODE PROGBITS 0000000000000004 200004 000001 00 AX 0 0 1
[ 4] CODE2 PROGBITS 0000000000000005 200005 000001 00 AX 0 0 1
...
$ readelf -SW test.gold.out
...
[ 1] DATA PROGBITS 0000000000000000 001000 000002 00 WA 0 0 1
[ 2] .text PROGBITS 0000000000000002 001002 000000 00 AX 0 0 1
[ 3] CODE2 PROGBITS 0000000000000002 001002 000001 00 AX 0 0 1
[ 4] .data PROGBITS 0000000000000003 001003 000000 00 WA 0 0 1
[ 5] DATA2 PROGBITS 0000000000000003 001003 000002 00 WA 0 0 1
[ 6] .bss NOBITS 0000000000000005 001005 000000 00 WA 0 0 1
[ 7] CODE PROGBITS 0000000000000024 001024 000001 00 AX 0 0 1
...
$ readelf -SW test.gold-patched.out
...
[ 1] DATA PROGBITS 0000000000000000 001000 000002 00 WA 0 0 1
[ 2] .data PROGBITS 0000000000000002 001002 000000 00 WA 0 0 1
[ 3] DATA2 PROGBITS 0000000000000002 001002 000002 00 WA 0 0 1
[ 4] .bss NOBITS 0000000000000004 001004 000000 00 WA 0 0 1
[ 5] CODE PROGBITS 0000000000000020 001020 000001 00 AX 0 0 1
[ 6] .text PROGBITS 0000000000000021 001021 000000 00 AX 0 0 1
[ 7] CODE2 PROGBITS 0000000000000021 001021 000001 00 AX 0 0 1
...
Best regards,
Igor
________________________________________
From: Ian Lance Taylor <iant@google.com>
Sent: Friday, October 21, 2016 7:12 PM
To: Igor Kudrin
Cc: binutils@sourceware.org; Cary Coutant
Subject: Re: [PATCH][gold] Use attributes of existing sections when placing orphan sections.
On Fri, Oct 21, 2016 at 4:24 AM, Igor Kudrin <ikudrin@accesssoftek.com> wrote:
>
> The current version of gold uses names of described output sections
> to find places where to put orphan sections. If the sections in the
> linker script have different names, gold fails to find the right place
> for orphans. This patch addresses the issue by analyzing attributes
> of existing section if they have unfamiliar names.
One of the goals of gold's orphan section placement is to be
approximately the same as GNU ld's orphan section placement. How does
GNU ld behave in the scenarios you are looking at?
Ian