From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by sourceware.org (Postfix) with ESMTPS id C1E853858C33 for ; Fri, 19 Jan 2024 19:45:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C1E853858C33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C1E853858C33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::52b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705693559; cv=none; b=T/V6EmMyd31L7sL3g8cNgbPvjyajhwo7OcZNJeMmcqcrpGPjvIO83jc8VQq9WHI3+cv/JsoZC3KLtBfcAPQ1a4U+LXAWbQw4sphL2gdfRf62Z01Elu+ibdLa7TIdJDZ+374AvfLv+mLxtE0SledYNCxXz6bqWae/B49EIIcR9xw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705693559; c=relaxed/simple; bh=SYIE1jHi1b+MG75+0veaTsPPTaFcK7u73ZwBJcxBzaE=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=J2bg6l53KlxYscEftwLLW6eKfg5yqV3oNsif4D4V+i65lOztise6JsJvUajgWWcxWhhF3+Jgm6/184NMOgDKkzP/yqBGXdUQmKBUipT2oCjGaytiej8QilLjVtfib1umKsBuSzYrnwvCye/XXh1S0Pel6euqr5ABOrSG5opzRVw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pg1-x52b.google.com with SMTP id 41be03b00d2f7-5cf495b46caso728865a12.1 for ; Fri, 19 Jan 2024 11:45:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705693555; x=1706298355; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/xveZzabHWfIPuR73+/NXRfYOpF7WGKeVxb6u6saKKo=; b=bEAwJ3n7LUeyDxDcVj+sCb/7RK0Usrt9PYt3PVWVZQEOJ/GEZZJG4nixMfUHihfyhq GvOJ173QvnHmgxHPGfVdvZYfZB+X2azqsIoDR9/yqiVg8sFfmAdkH6lhbCatINoMM/1I QDoP6fhg2cNvpt2mt5D9fC8MlJ4dRKw1UoDkhcI4zsSnwZKLX8MOJGC78mfSMuQVdeYD aVGDzrtq1TjtCO0pZAmewdf7+ZoLPWmYVXVxi/QjmKGjc5NzBOFl10g7MuCyZzqrOiho azkPZSX/gDwB7m62NmUAIjr/iY9cLi96KjJdMY0IIfezAZsvlCMNeDfJNCzIcu+qsPUt vGOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705693555; x=1706298355; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/xveZzabHWfIPuR73+/NXRfYOpF7WGKeVxb6u6saKKo=; b=XCE3G1C8DpAwkqAENjdScYr0UVzBd4J9/M4NLwazR+vk0TFhAAetTgp927QBmWgWJS GFbA5pem/oxBjSsT5T3+2ihzGBOX2KXjLG8c5IJ/VLjqywftdAAlV0STAUzSDMS5WPRz x+RZtyg7T/DSDzeTTNAYtxERViR/dGsjciouMjaK+c3D1DIfBRdMzjLFh/w1TXLioq1+ PsfeBbOGHp/JjCe5Kn1u3f7xvjr4IvXoPO0HW7W+QtDclwy4XG1odw5fm8ZwZF1OEc/M uj7uYmaMNkJ5oAleFdAES56wL0dKfdagAgjqN08rwP05EIvIlrRwADttMEOGx+BMyuI3 boIg== X-Gm-Message-State: AOJu0YzD5nt8A6XQGYwkMPQbZ74HpUIVNwlurLjihBJmKCYn5oF9YDss MX3UNN0a//TymzUTje1pCgdhatDjkffspzwZP0k4UrJ++uzbwV/sXdDspAQf X-Google-Smtp-Source: AGHT+IFeCUmfV3Ab4fLVuHIM1/SpNQOWR07YW/7/z85AzO8hbCQdArhdVBbqPE2TTv75dbl/g06GSQ== X-Received: by 2002:a17:90a:ae01:b0:28c:be2e:a676 with SMTP id t1-20020a17090aae0100b0028cbe2ea676mr234215pjq.53.1705693554750; Fri, 19 Jan 2024 11:45:54 -0800 (PST) Received: from gnu-cfl-3.localdomain ([172.56.168.9]) by smtp.gmail.com with ESMTPSA id j24-20020a17090a7e9800b0028cbfdbd804sm4423755pjl.45.2024.01.19.11.45.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jan 2024 11:45:54 -0800 (PST) Received: from gnu-cfl-3.. (localhost [IPv6:::1]) by gnu-cfl-3.localdomain (Postfix) with ESMTP id CECD07403BE; Fri, 19 Jan 2024 11:45:52 -0800 (PST) From: "H.J. Lu" 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 Message-ID: <20240119194552.1255481-4-hjl.tools@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240119194552.1255481-1-hjl.tools@gmail.com> References: <20240119194552.1255481-1-hjl.tools@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3024.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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