This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] Fix PE linker scripts vs. ".text.*" sections.
- From: Dave Korn <dave dot korn dot cygwin at googlemail dot com>
- To: "binutils at sourceware dot org" <binutils at sourceware dot org>
- Date: Thu, 03 Sep 2009 14:45:58 +0100
- Subject: [PATCH] Fix PE linker scripts vs. ".text.*" sections.
[re: http://sourceware.org/ml/binutils/2009-09/threads.html#00059 ]
Hi,
Given that there's a release just round the corner, I decided not to do
anything too destabilising.
This patch fixes the currently-failing GCC g++.dg/tree-prof/partition1.C
execution tests which were failing when the .text.unlikely section wasn't part
of the final output .text section and as a consequence wasn't writable, which
it needs to be for auto-import to work at load-time. It does so just by
bundling up any alternative .text.* sections along with the main .text section
just like everyone else does. There are a couple of knock-on fixes to the
testsuite.
ld/ChangeLog:
* scripttempl/pe.sc (.text): Add "*(.text.*)" in order to catch
new GCC hot/cold/unlikely partitions.
* scripttempl/pep.sc: Likewise.
* scripttempl/epocpe.sc: Likewise.
* scripttempl/mcorepe.sc: Likewise.
* scripttempl/ppcpe.sc: Likewise.
ld/testsuite/ChangeLog:
* ld-pe/longsecn.d: Adjusted to match new .text section merging
in default PE linker scripts.
* ld-pe/longsecn-1.d: Likewise.
* ld-pe/longsecn-2.d: Likewise.
I'm just running regression tests for a list of 16 assorted PE targets:
arm-epoc-pe arm-wince-pe i386-pc-netbsdpe i386-pc-pe i586-pc-interix
i586-unknown-beospe i686-pc-cygwin i686-pc-mingw32 mcore-unknown-pe
powerpcle-unknown-pe sh-unknown-pe thumb-epoc-pe x86_64-pc-mingw32 arm-cegcc
arm-mingw32ce i386-mingw32ce
and will commit it later if there are no problems.
cheers,
DaveK
Index: ld/scripttempl/epocpe.sc
===================================================================
RCS file: /cvs/src/src/ld/scripttempl/epocpe.sc,v
retrieving revision 1.1
diff -p -u -r1.1 epocpe.sc
--- ld/scripttempl/epocpe.sc 2 Dec 1999 11:49:19 -0000 1.1
+++ ld/scripttempl/epocpe.sc 3 Sep 2009 06:16:33 -0000
@@ -52,6 +52,7 @@ SECTIONS
${R_TEXT}
*(.glue_7t)
*(.glue_7)
+ ${RELOCATING+ *(.text.*)}
${CONSTRUCTING+ ___CTOR_LIST__ = .; __CTOR_LIST__ = . ;
LONG (-1); *(.ctors); *(.ctor); LONG (0); }
${CONSTRUCTING+ ___DTOR_LIST__ = .; __DTOR_LIST__ = . ;
Index: ld/scripttempl/mcorepe.sc
===================================================================
RCS file: /cvs/src/src/ld/scripttempl/mcorepe.sc,v
retrieving revision 1.4
diff -p -u -r1.4 mcorepe.sc
--- ld/scripttempl/mcorepe.sc 11 Aug 1999 09:21:38 -0000 1.4
+++ ld/scripttempl/mcorepe.sc 3 Sep 2009 06:16:33 -0000
@@ -56,6 +56,7 @@ SECTIONS
${RELOCATING+ *(.init)}
*(.text)
${R_TEXT}
+ ${RELOCATING+ *(.text.*)}
*(.glue_7t)
*(.glue_7)
${CONSTRUCTING+ ___CTOR_LIST__ = .; __CTOR_LIST__ = . ;
Index: ld/scripttempl/pe.sc
===================================================================
RCS file: /cvs/src/src/ld/scripttempl/pe.sc,v
retrieving revision 1.20
diff -p -u -r1.20 pe.sc
--- ld/scripttempl/pe.sc 3 Jul 2009 10:44:57 -0000 1.20
+++ ld/scripttempl/pe.sc 3 Sep 2009 06:16:33 -0000
@@ -69,6 +69,7 @@ SECTIONS
${RELOCATING+ *(.init)}
*(.text)
${R_TEXT}
+ ${RELOCATING+ *(.text.*)}
*(.glue_7t)
*(.glue_7)
${CONSTRUCTING+ ___CTOR_LIST__ = .; __CTOR_LIST__ = . ;
Index: ld/scripttempl/pep.sc
===================================================================
RCS file: /cvs/src/src/ld/scripttempl/pep.sc,v
retrieving revision 1.8
diff -p -u -r1.8 pep.sc
--- ld/scripttempl/pep.sc 3 Jul 2009 10:44:57 -0000 1.8
+++ ld/scripttempl/pep.sc 3 Sep 2009 06:16:33 -0000
@@ -69,6 +69,7 @@ SECTIONS
${RELOCATING+ *(.init)}
*(.text)
${R_TEXT}
+ ${RELOCATING+ *(.text.*)}
*(.glue_7t)
*(.glue_7)
${CONSTRUCTING+. = ALIGN(8);}
Index: ld/scripttempl/ppcpe.sc
===================================================================
RCS file: /cvs/src/src/ld/scripttempl/ppcpe.sc,v
retrieving revision 1.1.1.1
diff -p -u -r1.1.1.1 ppcpe.sc
--- ld/scripttempl/ppcpe.sc 3 May 1999 07:29:08 -0000 1.1.1.1
+++ ld/scripttempl/ppcpe.sc 3 Sep 2009 06:16:33 -0000
@@ -32,6 +32,7 @@ SECTIONS
{
${RELOCATING+ *(.init);}
*(.text)
+ ${RELOCATING+ *(.text.*)}
*(.gcc_except_table)
${CONSTRUCTING+ ___CTOR_LIST__ = .; __CTOR_LIST__ = . ;
LONG (-1); *(.ctors); *(.ctor); LONG (0); }
Index: ld/testsuite/ld-pe/longsecn-1.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-pe/longsecn-1.d,v
retrieving revision 1.1
diff -p -u -r1.1 longsecn-1.d
--- ld/testsuite/ld-pe/longsecn-1.d 18 Feb 2009 18:23:08 -0000 1.1
+++ ld/testsuite/ld-pe/longsecn-1.d 3 Sep 2009 06:16:34 -0000
@@ -8,17 +8,15 @@
Sections:
Idx Name Size VMA +LMA +File off Algn
0 \.text [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ 2\*\*[0-9]
- CONTENTS, ALLOC, LOAD, READONLY, CODE
- 1 \.text\.ve [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ 2\*\*[0-9]
CONTENTS, ALLOC, LOAD, READONLY, CODE, DATA
- 2 \.data [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ 2\*\*[0-9]
+ 1 \.data [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ 2\*\*[0-9]
CONTENTS, ALLOC, LOAD, DATA
- 3 \.rodata [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ 2\*\*[0-9]
+ 2 \.rodata [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ 2\*\*[0-9]
CONTENTS, ALLOC, LOAD, DATA
- 4 \.data\.ve [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ 2\*\*[0-9]
+ 3 \.data\.ve [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ 2\*\*[0-9]
CONTENTS, ALLOC, LOAD, DATA
- 5 \.rodata\. [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ 2\*\*[0-9]
+ 4 \.rodata\. [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ 2\*\*[0-9]
CONTENTS, ALLOC, LOAD, DATA
- 6 \.idata [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ 2\*\*[0-9]
+ 5 \.idata [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ 2\*\*[0-9]
CONTENTS, ALLOC, LOAD, DATA
Index: ld/testsuite/ld-pe/longsecn-2.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-pe/longsecn-2.d,v
retrieving revision 1.1
diff -p -u -r1.1 longsecn-2.d
--- ld/testsuite/ld-pe/longsecn-2.d 18 Feb 2009 18:23:08 -0000 1.1
+++ ld/testsuite/ld-pe/longsecn-2.d 3 Sep 2009 06:16:34 -0000
@@ -8,16 +8,14 @@
Sections:
Idx Name Size VMA +LMA +File off Algn
0 \.text [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ 2\*\*[0-9]
- CONTENTS, ALLOC, LOAD, READONLY, CODE
- 1 \.text\.very\.long\.section\.name [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ 2\*\*[0-9]
CONTENTS, ALLOC, LOAD, READONLY, CODE, DATA
- 2 \.data [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ 2\*\*[0-9]
+ 1 \.data [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ 2\*\*[0-9]
CONTENTS, ALLOC, LOAD, DATA
- 3 \.rodata [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ 2\*\*[0-9]
+ 2 \.rodata [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ 2\*\*[0-9]
CONTENTS, ALLOC, LOAD, DATA
- 4 \.data\.very\.long\.section [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ 2\*\*[0-9]
+ 3 \.data\.very\.long\.section [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ 2\*\*[0-9]
CONTENTS, ALLOC, LOAD, DATA
- 5 \.rodata\.very.long\.section [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ 2\*\*[0-9]
+ 4 \.rodata\.very.long\.section [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ 2\*\*[0-9]
CONTENTS, ALLOC, LOAD, DATA
- 6 \.idata [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ 2\*\*[0-9]
+ 5 \.idata [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ 2\*\*[0-9]
CONTENTS, ALLOC, LOAD, DATA
Index: ld/testsuite/ld-pe/longsecn.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-pe/longsecn.d,v
retrieving revision 1.1
diff -p -u -r1.1 longsecn.d
--- ld/testsuite/ld-pe/longsecn.d 18 Feb 2009 18:23:08 -0000 1.1
+++ ld/testsuite/ld-pe/longsecn.d 3 Sep 2009 06:16:34 -0000
@@ -8,17 +8,15 @@
Sections:
Idx Name Size VMA +LMA +File off Algn
0 \.text [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ 2\*\*[0-9]
- CONTENTS, ALLOC, LOAD, READONLY, CODE
- 1 \.text\.ve [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ 2\*\*[0-9]
CONTENTS, ALLOC, LOAD, READONLY, CODE, DATA
- 2 \.data [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ 2\*\*[0-9]
+ 1 \.data [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ 2\*\*[0-9]
CONTENTS, ALLOC, LOAD, DATA
- 3 \.rodata [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ 2\*\*[0-9]
+ 2 \.rodata [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ 2\*\*[0-9]
CONTENTS, ALLOC, LOAD, DATA
- 4 \.data\.ve [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ 2\*\*[0-9]
+ 3 \.data\.ve [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ 2\*\*[0-9]
CONTENTS, ALLOC, LOAD, DATA
- 5 \.rodata\. [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ 2\*\*[0-9]
+ 4 \.rodata\. [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ 2\*\*[0-9]
CONTENTS, ALLOC, LOAD, DATA
- 6 \.idata [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ 2\*\*[0-9]
+ 5 \.idata [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ 2\*\*[0-9]
CONTENTS, ALLOC, LOAD, DATA