From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by sourceware.org (Postfix) with ESMTPS id 7A5A73858C52 for ; Sat, 13 May 2023 11:13:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7A5A73858C52 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-6439e6f5a33so6621995b3a.2 for ; Sat, 13 May 2023 04:13:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683976434; x=1686568434; h=content-disposition:mime-version:message-id:subject:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=SnHhaKHAqKx6ao+/aG1g5S4DvOscNOKawAkYbKSOXJs=; b=pfBZev9GtNonNn7fAFyiy+jGbamQCtglCABNtbyQ8Wo/9bf96tC6f/5WBllHb7CRN/ eqtmXQWXILXxLBNUWtlm+EAxZS+q/xlQRc9905O6f7cAltUq8WBReZkILVWAkZXb8yd4 2D2x504kdAzUOkx2Fvd9PNi7Ypxz6lvFBaT7xaNRf8G4KUre6kri4lQ0S/Hwz7/YhdyK zZ70/XCwGf+WqI4mmcjYSPMiPeUx4syz3WGr3uKdcbXiGNlCLMhssByIf+d2ONFUwcOs mV+Akrng1IhYfZToOcHe0H/HbDDP855FkqKtDsrbH92aEI+yvg3RGF7ymTTYKDIdk1HM qtSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683976434; x=1686568434; h=content-disposition:mime-version:message-id:subject:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=SnHhaKHAqKx6ao+/aG1g5S4DvOscNOKawAkYbKSOXJs=; b=M8H2G6nBzTbMzWRbPqAeku6y48kHkEJPD2iG/6pqFyL6DnHeidaAYBfcy/6rxLwO2G +9D91b10Ib3Y55khETAusYdoqiJgeDakOXU+b5QQTUQfHUA6ZQ6BSBm4Kyt3N6tdHjmn 7422n9sAUNVDJUWe0bBRAqRLMkLicmLu9wlirw3yKPhI1BGe9ikgZs0V1YLVprmiCh9p yWP8g13j3s+a19m9M/+BZEQJQpPRREGiOnoVcW5yLnKYxXe9pz0l+3Z0y3BqTIQ7wJRY gdWBvFinafEf/X2pjfDxqCy8MwZGEOeeRo7bJ/eg1dy0V2OQ3K66vpoeDNKxDfHuvNf5 rrSQ== X-Gm-Message-State: AC+VfDxGSGnRog29xlcIstY51238gPRT9TVB8HpnTUVC1CvB5BMIyBOE Q+5SQRAVPk7hQdjPJ3o9/Zifmphb4Vk= X-Google-Smtp-Source: ACHHUZ6bwauzvvAkDXmq2HQg9f0uLfnDleyrWp2C80M25z7pw8nVA0Vc+wDu91ZyIGvobEmBAxvR/Q== X-Received: by 2002:a17:902:b08c:b0:1a1:ee8c:eef7 with SMTP id p12-20020a170902b08c00b001a1ee8ceef7mr29468935plr.48.1683976433908; Sat, 13 May 2023 04:13:53 -0700 (PDT) Received: from squeak.grove.modra.org (158.106.96.58.static.exetel.com.au. [58.96.106.158]) by smtp.gmail.com with ESMTPSA id ji1-20020a170903324100b001a9b7584824sm9566913plb.159.2023.05.13.04.13.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 May 2023 04:13:53 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 805C2114038D; Sat, 13 May 2023 20:43:50 +0930 (ACST) Date: Sat, 13 May 2023 20:43:50 +0930 From: Alan Modra To: binutils@sourceware.org Subject: PR28902, -T script with INSERT ordering Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3034.9 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: The answer to PR28902 may be deduced from the existing INSERT documentation that says the default script is parsed after the -T INSERT script, if you assume (correctly) that nothing special is done when inserting into -T scripts overriding the default script. In both cases INSERT handling looks for the specified output section later on the internal list of parsed script commands. This isn't obvious though, so make the ordering explicit, and mention that section assignments are the same too. PR 28902 * ld.texi (INSERT): Specify ordering when -T is used both to override the default script and to augment. diff --git a/ld/ld.texi b/ld/ld.texi index 012eec2e809..8038de39106 100644 --- a/ld/ld.texi +++ b/ld/ld.texi @@ -1085,7 +1085,8 @@ a linker bug report. @item -T @var{scriptfile} @itemx --script=@var{scriptfile} Use @var{scriptfile} as the linker script. This script replaces -@command{ld}'s default linker script (rather than adding to it), so +@command{ld}'s default linker script (rather than adding to it), +unless the script contains @code{INSERT}, so @var{commandfile} must specify everything necessary to describe the output file. @xref{Scripts}. If @var{scriptfile} does not exist in the current directory, @code{ld} looks for it in the directories @@ -4442,6 +4443,12 @@ SECTIONS INSERT AFTER .text; @end smallexample +Note that when @samp{-T} is used twice, once to override the default +script and once to augment that script using @code{INSERT} the order +of parsing and section assignments apply as for the default script. +The script with @code{INSERT} should be specified @emph{first} on the +command line. + @item NOCROSSREFS(@var{section} @var{section} @dots{}) @kindex NOCROSSREFS(@var{sections}) @cindex cross references -- Alan Modra Australia Development Lab, IBM