From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by sourceware.org (Postfix) with ESMTPS id DE0C4385841A for ; Fri, 19 Jan 2024 19:45:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DE0C4385841A 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 DE0C4385841A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1031 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705693559; cv=none; b=ZtJJQaqlBuW2xVB1LVMH0xPb1NwdqVL+nK+DD5PrybkwAcWCqmoyZ+9az0KiTSVQAU3p96AlMkRBxAM1deJfjvZLjGh4c8K+oMJ99XFiglpayxCtEJGVypXHJRoVSMhSAdGu2wIES9cuhmqPeP76HCjgnO4/ZZfrBtyA3/fTcug= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705693559; c=relaxed/simple; bh=/PW9VfQn+sArDORMkTt0tikVlFmOWf5Xhu1LohU4l+I=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=BSnwxvY3LmUKom0h1cAVY3nLT5mGcfVJ1TPguuJ4wM4NxxQse28THt1HZR3Bx67UgSGlvaYJ3dBZ2BoU3TYO+jBkPwhCHq4WNqqJcmhPbOT0xTNzNuyoCCGQibiNk4mIjXL2v1QFegyNdhHNFyiLSIw4V88peh8P1NOM0rtuBYM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pj1-x1031.google.com with SMTP id 98e67ed59e1d1-28ffc37b63cso890480a91.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:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=ToY1HvDcgkZZHHfkAkZGMYOZS1t3wIKEDFR2vJ/hijw=; b=RBOzHDipql+V+SusbtZdhzMo3lLH5nx+ltNcwcIxYJvYcKxMELj8K/vGKCD78WDUJI NGqjq6cNxKheW1AL9KIs8da9zb23vxrgcD2bxQVMXBQ391hlzClkbqMLEwIwphvkKLWK eViMEkRqnsABJEEWimXb90JPywgHE3EETXTffwy05pa7eugVSfS/5m20uvGbc4Tjtvsl KESyGasgf0wxFEXFDDf2hRfJkMtTrnO+LKNjRQy7hk5lUiaRcUwO5yApS+Vljdgt5xdr ujJ6L99SwnELPRmTUgUmicv+kSDSWUSd6gwH5HoCNDonmlyMB3qF4lrxUKQEQdPG44yo spgA== 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:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ToY1HvDcgkZZHHfkAkZGMYOZS1t3wIKEDFR2vJ/hijw=; b=Lbwtqw7EzhTK2d0eX07d2T+BX9yRjnFtFxAZA6SGyyI6+Yar4p2pZ82105YtJxu3xT IwcOAddwk5FvAcKtMMFpjIsThM4bCZTUXfM/LVCdfMqmvsuVBs1xwr0QYtpardkf4YRJ 9SESua6VfWPUYwCW4KDtCh59mqDAOjr7Z9atwfTxFdpYoKmVttwrTROTVFmW0c9DCjQK Epza/C6uMjbaQXFhpQBO2aCgkqJmiGyGMdwVVoj/zcwlJ5SNXgNnMrVVgR9abhRAJPlo /9TgRF19xq9Np8BzF1tupW7zh1thTBDv6UfZdJ7PztZcVcCQlRlvZqX4K2tM/fWAFU0f uuJA== X-Gm-Message-State: AOJu0YyiAv2kKsQhgr0//a0trtHKsJ1OieGtLFgQVbvOz/BWR55w7NGo LxKtIkO1VBk89QBil5AmBe6UBz+zttvak4Ft/b9dPPnLw1RxXrJwL+n8TdHP X-Google-Smtp-Source: AGHT+IEKt3bKPtw85ZjYNvSEPLj3xVmJj125zc4EvJniPT6IcimITuNuw4O4EanZ7jDVVgQfSO7+aw== X-Received: by 2002:a17:90a:9306:b0:28d:d3bb:7359 with SMTP id p6-20020a17090a930600b0028dd3bb7359mr508015pjo.8.1705693554620; 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 kf11-20020a17090305cb00b001d5eb987f30sm3414095plb.131.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 AB0027401F9; 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 0/4] ld: Add --text-section-ordering-file FILE Date: Fri, 19 Jan 2024 11:45:48 -0800 Message-ID: <20240119194552.1255481-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3018.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,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: Add --text-section-ordering-file FILE to specify the text section ordering file. Inside the text section ordering file, when seeing an input file name without section list and the file name starts with '.', treat the filename as a section name and create a wild card as the file name. A text section ordering file which contains text section wildcards: --- text_section_foo* text_section_b?r text_section_name --- can be used to group input text sections together to: 1. Reduce gaps between text sections. 2. Put hot text sections close to each other. Text sections in the text section ordering file are placed at the beginning of the output text section and code text sections are moved toward the end so that the first section in the text section ordering file is aligned to the output section alignment. --text-section-ordering-file must be placed before -T/--script option so that the text section ordering file can always be included in linker scripts. Nested INCLUDE in the text section order file is disallowed. --text-section-ordering-file FILE is supported only in ELF and PE COFF linkers which support input .text.* sections. NB: Gold has the command-line option, --section-ordering-file FILE, to layout sections in the order specified. --text-section-ordering-file supports the same section ordering file format, but it applies only to text sections. H.J. Lu (4): ld: Add --text-section-ordering-file FILE ld: Include the text section order file in all ELF linker scripts ld: Include the text section order file in PE COFF linker scripts ld: Document --text-section-ordering-file FILE ld/NEWS | 3 + ld/ld.h | 3 + ld/ld.texi | 11 ++++ ld/ldfile.c | 74 +++++++++++++++++++++++-- ld/ldlang.c | 39 +++++++++++-- ld/ldlex.h | 3 + ld/ldlex.l | 7 +++ ld/lexsup.c | 11 ++++ ld/scripttempl/arclinux.sc | 5 +- ld/scripttempl/avr.sc | 1 + ld/scripttempl/dlx.sc | 1 + ld/scripttempl/elf.sc | 5 +- ld/scripttempl/elf32cr16.sc | 1 + ld/scripttempl/elf32crx.sc | 1 + ld/scripttempl/elf32msp430.sc | 1 + ld/scripttempl/elf64bpf.sc | 5 +- ld/scripttempl/elf64hppa.sc | 1 + ld/scripttempl/elfarc.sc | 1 + ld/scripttempl/elfarcv2.sc | 1 + ld/scripttempl/elfd10v.sc | 1 + ld/scripttempl/elfd30v.sc | 1 + ld/scripttempl/elfm68hc11.sc | 1 + ld/scripttempl/elfm68hc12.sc | 1 + ld/scripttempl/elfm9s12z.sc | 1 + ld/scripttempl/elfmicroblaze.sc | 1 + ld/scripttempl/elfxgate.sc | 1 + ld/scripttempl/elfxtensa.sc | 1 + ld/scripttempl/ft32.sc | 1 + ld/scripttempl/i386beos.sc | 1 + ld/scripttempl/i386go32.sc | 1 + ld/scripttempl/iq2000.sc | 1 + ld/scripttempl/mcorepe.sc | 1 + ld/scripttempl/mep.sc | 1 + ld/scripttempl/mmo.sc | 1 + ld/scripttempl/nds32elf.sc | 5 +- ld/scripttempl/pe.sc | 1 + ld/scripttempl/pep.sc | 1 + ld/scripttempl/pru.sc | 1 + ld/scripttempl/v850.sc | 1 + ld/scripttempl/v850_rh850.sc | 1 + ld/scripttempl/visium.sc | 1 + ld/scripttempl/xstormy16.sc | 1 + ld/testsuite/ld-scripts/start.s | 14 +++++ ld/testsuite/ld-scripts/text-order-1a.d | 17 ++++++ ld/testsuite/ld-scripts/text-order-1a.s | 8 +++ ld/testsuite/ld-scripts/text-order-1a.t | 5 ++ ld/testsuite/ld-scripts/text-order-1b.d | 17 ++++++ ld/testsuite/ld-scripts/text-order-1b.s | 8 +++ ld/testsuite/ld-scripts/text-order-1b.t | 4 ++ ld/testsuite/ld-scripts/text-order-1c.d | 6 ++ ld/testsuite/ld-scripts/text-order-1c.t | 5 ++ ld/testsuite/ld-scripts/text-order.exp | 43 ++++++++++++++ 52 files changed, 311 insertions(+), 17 deletions(-) create mode 100644 ld/testsuite/ld-scripts/start.s create mode 100644 ld/testsuite/ld-scripts/text-order-1a.d create mode 100644 ld/testsuite/ld-scripts/text-order-1a.s create mode 100644 ld/testsuite/ld-scripts/text-order-1a.t create mode 100644 ld/testsuite/ld-scripts/text-order-1b.d create mode 100644 ld/testsuite/ld-scripts/text-order-1b.s create mode 100644 ld/testsuite/ld-scripts/text-order-1b.t create mode 100644 ld/testsuite/ld-scripts/text-order-1c.d create mode 100644 ld/testsuite/ld-scripts/text-order-1c.t create mode 100644 ld/testsuite/ld-scripts/text-order.exp -- 2.43.0