From patchwork Sat May 13 11:13:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 93504 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp5703800vqo; Sat, 13 May 2023 04:14:05 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ74e9254Kq67rRzgMagr1pzXEN/5qiIIcvf6aDmmv5gJOVrL+kZqPqfmHSPskc07aigwF9o X-Received: by 2002:a17:907:eab:b0:969:813c:9868 with SMTP id ho43-20020a1709070eab00b00969813c9868mr19077807ejc.18.1683976445492; Sat, 13 May 2023 04:14:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683976445; cv=none; d=google.com; s=arc-20160816; b=HCLPkFsKhOfpDEolSHbO6rLN4fBb8H+tViPlIX0GwikSQKBF4DeKPsvZa0pafPwDzB weNAu7FpTbzQlTteLgMv60dfU0p7AxBe38y+oDRqDnPBkd2jnktdOnl7wbkFMwjZSBMh t0oatMJqg/PLCwE8gVA37oFrSl2lEbNaXgg3aes8yEYU8JCEtpZ2UUKsZxIlW0D+PeYK 72u0uiqDGn20iB1TeZKdfIPrFsA15HLMKMWsz8z3AHQGgvjB5xwlpZgyQUiK3PJdLMee /W8dGcP+rOeker9UJgR3so0V5qgrn1SPlt8UrIY7uF1kqo9P9I44Kdsp6bzhSqoBHOxO IiNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=SnHhaKHAqKx6ao+/aG1g5S4DvOscNOKawAkYbKSOXJs=; b=Ysf/mDe9DB0IF4zZpD2o1Ol60Gtd6FtZcu45OAxKr9F+MkUPEosAQMTQODv8a+y6aH D1IMYYlt9tl/WaItxSz2Ub9GqD0hyW+Or328AV45JKGyKl8AS3aDJ4/QGM8AXjZrYACb 8Ux45Gp/uK43XhbTsMqzYi9C78vv14o76eEspjQ8U4qd7y5RshPuKQyBpvvfD1vSToPw YhW9NzKvjusGtCHBxpeAy9iBq0da1yDLnRfads4I8pXFLGpOS8ETsw9ehfKNnV+vJAJO CktK1CeH72tze14bruyvjQnTifPxIHFnjp0cSaLZM2xJIPkAEIDCijyFfCzckCjYMHB3 DhEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=oQ41ACaG; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id e23-20020a170906249700b0095f4c5ccc35si8872821ejb.270.2023.05.13.04.14.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 May 2023 04:14:05 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=oQ41ACaG; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2AAEC385840A for ; Sat, 13 May 2023 11:14:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2AAEC385840A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1683976444; bh=SnHhaKHAqKx6ao+/aG1g5S4DvOscNOKawAkYbKSOXJs=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=oQ41ACaGABK0N7quZ2HrgUgq9mWYLDUH9FsZj2tTRwJEetA5oHLr1mxKCBM/d1XKI MyEvgpH6d0CSv0rW0yi06SKuskeY5Zc4Jrq0b9i0a85mLlZdKkmUDWYzjK2hgiOptI 6QBip/lNGyazJoGl8y0KjxsxwCnEzmn4I7afnLIs= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org 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 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-6439e6f5a33so6621995b3a.2 for ; Sat, 13 May 2023 04:13:55 -0700 (PDT) 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-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 To: binutils@sourceware.org Subject: PR28902, -T script with INSERT ordering Message-ID: MIME-Version: 1.0 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 X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Alan Modra via Binutils From: Alan Modra Reply-To: Alan Modra Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765777285501638265?= X-GMAIL-MSGID: =?utf-8?q?1765777285501638265?= 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