From: "H.J. Lu" <hjl.tools@gmail.com>
To: binutils@sourceware.org
Cc: goldstein.w.n@gmail.com
Subject: [PATCH 3/4] ld: Include the text section order file in PE COFF linker scripts
Date: Fri, 19 Jan 2024 11:45:51 -0800 [thread overview]
Message-ID: <20240119194552.1255481-4-hjl.tools@gmail.com> (raw)
In-Reply-To: <20240119194552.1255481-1-hjl.tools@gmail.com>
Include the text section order file in PE COFF linker scripts and enable
--text-section-ordering-file tests for PE COFF targets.
* scripttempl/i386beos.sc: Include the text section order file.
* scripttempl/i386go32.sc: Likewise.
* scripttempl/mcorepe.sc: Likewise.
* scripttempl/pe.sc: Likewise.
* scripttempl/pep.sc: Likewise.
* testsuite/ld-scripts/text-order-1a.d: Remove target.
* testsuite/ld-scripts/text-order-1b.d: Likewise.
* testsuite/ld-scripts/text-order-1c.d: Likewise.
* testsuite/ld-scripts/text-order.exp: Only run for ELF and PE
COFF targets.
---
ld/scripttempl/i386beos.sc | 1 +
ld/scripttempl/i386go32.sc | 1 +
ld/scripttempl/mcorepe.sc | 1 +
ld/scripttempl/pe.sc | 1 +
ld/scripttempl/pep.sc | 1 +
ld/testsuite/ld-scripts/start.s | 2 ++
ld/testsuite/ld-scripts/text-order-1a.d | 1 -
ld/testsuite/ld-scripts/text-order-1b.d | 1 -
ld/testsuite/ld-scripts/text-order-1c.d | 1 -
ld/testsuite/ld-scripts/text-order.exp | 3 ++-
10 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/ld/scripttempl/i386beos.sc b/ld/scripttempl/i386beos.sc
index 6c512e67760..cc3d737b21c 100644
--- a/ld/scripttempl/i386beos.sc
+++ b/ld/scripttempl/i386beos.sc
@@ -60,6 +60,7 @@ SECTIONS
{
${RELOCATING+ __text_start__ = . ;}
${RELOCATING+ KEEP (*(SORT_NONE(.init)))}
+ ${RELOCATING+INCLUDE config.text_section_ordering_file}
*(.text)
${R_TEXT}
*(.glue_7t)
diff --git a/ld/scripttempl/i386go32.sc b/ld/scripttempl/i386go32.sc
index 9b992279e4e..3a229319988 100644
--- a/ld/scripttempl/i386go32.sc
+++ b/ld/scripttempl/i386go32.sc
@@ -34,6 +34,7 @@ ${RELOCATING+ENTRY (${ENTRY})}
SECTIONS
{
.text ${RELOCATING+ ${TARGET_PAGE_SIZE}+SIZEOF_HEADERS} : {
+ ${RELOCATING+INCLUDE config.text_section_ordering_file}
*(.text)
${RELOCATING+*(.text.*)}
${RELOCATING+*(.gnu.linkonce.t*)}
diff --git a/ld/scripttempl/mcorepe.sc b/ld/scripttempl/mcorepe.sc
index 3262102e85e..13dc5b1c89e 100644
--- a/ld/scripttempl/mcorepe.sc
+++ b/ld/scripttempl/mcorepe.sc
@@ -66,6 +66,7 @@ SECTIONS
.text ${RELOCATING+ __image_base__ + __section_alignment__ } :
{
${RELOCATING+ KEEP (*(SORT_NONE(.init)))}
+ ${RELOCATING+INCLUDE config.text_section_ordering_file}
*(.text)
${R_TEXT}
${RELOCATING+ *(.text.*)}
diff --git a/ld/scripttempl/pe.sc b/ld/scripttempl/pe.sc
index 70f5194b02f..b2691e0ef18 100644
--- a/ld/scripttempl/pe.sc
+++ b/ld/scripttempl/pe.sc
@@ -91,6 +91,7 @@ SECTIONS
.text ${RELOCATING+ __image_base__ + ( __section_alignment__ < ${TARGET_PAGE_SIZE} ? . : __section_alignment__ )} :
{
${RELOCATING+KEEP (*(SORT_NONE(.init)))}
+ ${RELOCATING+INCLUDE config.text_section_ordering_file}
*(.text)
${R_TEXT}
${RELOCATING+ *(.text.*)}
diff --git a/ld/scripttempl/pep.sc b/ld/scripttempl/pep.sc
index 63039f11574..f35e50c9430 100644
--- a/ld/scripttempl/pep.sc
+++ b/ld/scripttempl/pep.sc
@@ -92,6 +92,7 @@ SECTIONS
.text ${RELOCATING+ __image_base__ + ( __section_alignment__ < ${TARGET_PAGE_SIZE} ? . : __section_alignment__ )} :
{
${RELOCATING+KEEP (*(SORT_NONE(.init)))}
+ ${RELOCATING+INCLUDE config.text_section_ordering_file}
*(.text)
${R_TEXT}
${RELOCATING+ *(.text.*)}
diff --git a/ld/testsuite/ld-scripts/start.s b/ld/testsuite/ld-scripts/start.s
index 4d8239479a6..3f646267716 100644
--- a/ld/testsuite/ld-scripts/start.s
+++ b/ld/testsuite/ld-scripts/start.s
@@ -5,6 +5,8 @@ start:
_start:
.global __start
__start:
+ .global _mainCRTStartup /* Used by PE targets. */
+_mainCRTStartup:
.global main /* Used by HPPA targets. */
main:
.globl _main /* Used by LynxOS targets. */
diff --git a/ld/testsuite/ld-scripts/text-order-1a.d b/ld/testsuite/ld-scripts/text-order-1a.d
index d6f976f42ad..3aca3d6d5e9 100644
--- a/ld/testsuite/ld-scripts/text-order-1a.d
+++ b/ld/testsuite/ld-scripts/text-order-1a.d
@@ -3,7 +3,6 @@
#source: start.s
#ld: --text-section-ordering-file text-order-1a.t
#nm: -n
-#target: [is_elf_format]
#...
[0-9a-f]+ T yyy
diff --git a/ld/testsuite/ld-scripts/text-order-1b.d b/ld/testsuite/ld-scripts/text-order-1b.d
index 3d6f4fd8d66..c9d83276da6 100644
--- a/ld/testsuite/ld-scripts/text-order-1b.d
+++ b/ld/testsuite/ld-scripts/text-order-1b.d
@@ -3,7 +3,6 @@
#source: start.s
#ld: --text-section-ordering-file text-order-1b.t
#nm: -n
-#target: [is_elf_format]
#...
[0-9a-f]+ T yyy
diff --git a/ld/testsuite/ld-scripts/text-order-1c.d b/ld/testsuite/ld-scripts/text-order-1c.d
index 4166d634606..91f0a6bee4d 100644
--- a/ld/testsuite/ld-scripts/text-order-1c.d
+++ b/ld/testsuite/ld-scripts/text-order-1c.d
@@ -3,5 +3,4 @@
#source: start.s
#ld: --text-section-ordering-file text-order-1c.t
#nm: -n
-#target: [is_elf_format]
#error: .*: nested include 'text-order-1b.t' in the text section ordering file: 'text-order-1c.t'
diff --git a/ld/testsuite/ld-scripts/text-order.exp b/ld/testsuite/ld-scripts/text-order.exp
index 30cb531137e..2e51fd6f62a 100644
--- a/ld/testsuite/ld-scripts/text-order.exp
+++ b/ld/testsuite/ld-scripts/text-order.exp
@@ -18,7 +18,8 @@
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
# MA 02110-1301, USA.
-if { !([is_elf_format] && ![is_generic]) } {
+# ELF and PE COFF linker targets support input .text.* sections.
+if { !([is_elf_format] || [is_pecoff_format]) } {
return
}
--
2.43.0
next prev parent reply other threads:[~2024-01-19 19:45 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-19 19:45 [PATCH 0/4] ld: Add --text-section-ordering-file FILE H.J. Lu
2024-01-19 19:45 ` [PATCH 1/4] " H.J. Lu
2024-01-19 21:50 ` Fangrui Song
[not found] ` <DS7PR12MB5765A2B98C7E1217F8C374B9CB702@DS7PR12MB5765.namprd12.prod.outlook.com>
2024-01-19 22:13 ` H.J. Lu
2024-01-19 23:15 ` Fangrui Song
2024-01-22 7:37 ` Jan Beulich
2024-01-22 12:51 ` H.J. Lu
2024-01-22 18:22 ` Noah Goldstein
2024-01-22 18:45 ` H.J. Lu
2024-01-24 14:41 ` H.J. Lu
[not found] ` <DS7PR12MB5765059CCA55EC755F8132ACCB702@DS7PR12MB5765.namprd12.prod.outlook.com>
2024-01-20 14:12 ` H.J. Lu
2024-01-19 19:45 ` [PATCH 2/4] ld: Include the text section order file in all ELF linker scripts H.J. Lu
2024-01-19 20:00 ` Noah Goldstein
2024-01-19 20:18 ` H.J. Lu
2024-01-19 20:38 ` Noah Goldstein
2024-01-19 20:40 ` H.J. Lu
2024-01-19 21:07 ` Noah Goldstein
2024-01-19 19:45 ` H.J. Lu [this message]
2024-01-19 19:45 ` [PATCH 4/4] ld: Document --text-section-ordering-file FILE H.J. Lu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240119194552.1255481-4-hjl.tools@gmail.com \
--to=hjl.tools@gmail.com \
--cc=binutils@sourceware.org \
--cc=goldstein.w.n@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).