From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by sourceware.org (Postfix) with ESMTPS id A07863858D3C for ; Mon, 28 Nov 2022 02:02:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A07863858D3C 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-x432.google.com with SMTP id w129so9089899pfb.5 for ; Sun, 27 Nov 2022 18:02:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=oxLYGFXHmCzgzl8vsc2WuCyC4j65gEFYlpCZs/bxtSw=; b=dBj0VVt+sKFU/YAYUL7Ua+XFWy3R7MEmBYKIhLMAzy2p1N4bHn76qMJm/u3wPsAKDR jwUrgPmRrqQoDhv1UQuct3ySHXuVvbZeqeWD2f7CPwYT8fk9lZe7YkGQRbDCoWFx5XTl gLs484lEzYHARa1eQprJ7CvCTSooRgzSDRZxt7s/4Se9APqVKpGYhtUHnehWQGDLjIiL 4D42Ns838q74G01P1PO7a8HEZd67tCsPxdbUaquh67YuVYXUH4+G7ahndcfe3E33jl8e FYHWrWCXOLM+rNFShKHbcoYbF9EX1dYNKArLcGUs4V7SZPLn2Rhh34JBRdV3FFfixgq2 Irbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=oxLYGFXHmCzgzl8vsc2WuCyC4j65gEFYlpCZs/bxtSw=; b=b7IzuGJTwL/FVPb9JmrzSSgZ6QLKJBAbD4i35v9/0wbgOIQVNE5Vya+lIpgLuf/Qt8 WGexI4XwJTMVskp1Gx3nJXxgQTdoLq8oFizIGjeqczaAmY+HgOtAZbTUEx9HJCoht5FW V0YHUVjL44DpexWioJN9nAW5dBnmFGPjwo5Zl1se/eXLEvG9VK5EtuokeYOBvf3gpJ4v cc2RfmX1TAH+PhfFSLl78+fa7Yt+cWzkXs2qLpKraLTFuqbMj+7qOzptqhZLbq7feqEn FlUPi2MJTwUTLRCu/O583CV2qbRr/4yBPibPz8D9rICBWIq8xOgBpsWPEkZbzS6MwnnB FQAQ== X-Gm-Message-State: ANoB5pk/TfMTATPmPp/QgC6VrC3Tv/V1tdewf1ecT2y91plMlODbGRfX WYVzNmnG/bDdkRDlndruX+c7w7Fh/p4= X-Google-Smtp-Source: AA0mqf6Pi4kcteGCDNyA94br06UQZJ7yjFL48/UpZZKipy6n6FGk/IFlZOF+4ZxlNYIgs7te6S72cg== X-Received: by 2002:a63:dd16:0:b0:476:d2d9:5151 with SMTP id t22-20020a63dd16000000b00476d2d95151mr24028445pgg.487.1669600975941; Sun, 27 Nov 2022 18:02:55 -0800 (PST) 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 q4-20020a170902dac400b00188f6cbd950sm7458015plx.226.2022.11.27.18.02.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Nov 2022 18:02:55 -0800 (PST) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id C42EC114075D; Mon, 28 Nov 2022 12:32:52 +1030 (ACDT) Date: Mon, 28 Nov 2022 12:32:52 +1030 From: Alan Modra To: Michael Matz Cc: binutils@sourceware.org Subject: Re: [PATCH] Fix msp430 section name scribbling and tests Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-3036.1 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 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: On Fri, Nov 25, 2022 at 04:00:05PM +0000, Michael Matz via Binutils wrote: > msp430 upper/lower section selector simply overwrites section names > without going through bfd_rename_section. This doesn't really work: Right. > as soon as the generic routine to map to output section names is used > (e.g. by having a complicated selector, or simply by adding an early-out > into analyze_walk_wild_section_handler for always use the generic > matcher) it iterates over the new names and so sees e.g. '.either..data' > and makes that orphan (because of no output statement matching that), > and then errors out because there may be no output statements for > .upper.data or .lower.data. In the testcases that works because that > .data is actually empty, and when using the non-generic routines for > section matching it can use the per-bfd section-name-hash. Because that > one still is unchanged it will find the section formerly named .data for > which an output statement exists, put it into that section, and makes it > not ortphan. That works because the actual section is empty and hence > this placement is harmless. > > But it's really not how this all is expected to work, one can't just > change section->name alone. So to make it reliably work we either > would have to force users to write at least .lower.XYZ statements for > the three usual sections (.text, .data, .bss), even if the input is empty, > or to check if renaming to .either.XYZ is going to do any good. > > Here we do the latter, we check before renaming and then actually do > rename properly. I'm inclined to think that you should just apply the single line bfd_rename_section change, and adjust the testsuite script file. The standard scripts do contain the lower/upper/either variants for .text, .data and .bss. Something like this. * emultempl/msp430.em (add_region_prefix ): Use bfd_rename_section. * testsuite/ld-msp430-elf/msp430-tiny-rom.ld: Handle varian data and bss input sections. diff --git a/ld/emultempl/msp430.em b/ld/emultempl/msp430.em index f188b46b4aa..048e3ebfe5a 100644 --- a/ld/emultempl/msp430.em +++ b/ld/emultempl/msp430.em @@ -417,7 +417,7 @@ add_region_prefix (bfd *abfd ATTRIBUTE_UNUSED, asection *s, bfd_rename_section (s, concat (".lower", curr_name, NULL)); break; case REGION_EITHER: - s->name = concat (".either", curr_name, NULL); + bfd_rename_section (s, concat (".either", curr_name, NULL)); break; default: /* Unreachable. */ diff --git a/ld/testsuite/ld-msp430-elf/msp430-tiny-rom.ld b/ld/testsuite/ld-msp430-elf/msp430-tiny-rom.ld index 3e263796948..c88442377d1 100644 --- a/ld/testsuite/ld-msp430-elf/msp430-tiny-rom.ld +++ b/ld/testsuite/ld-msp430-elf/msp430-tiny-rom.ld @@ -26,13 +26,19 @@ SECTIONS .data : { . = ALIGN(2); + *(.lower.data.* .lower.data) *(.data.* .data) + *(.either.data.* .either.data) + *(.upper.data.* .upper.data) } > RAM AT> ROM .bss : { . = ALIGN(2); + *(.lower.bss.* .lower.bss) *(.bss.* .bss) + *(.either.bss.* .either.bss) + *(.upper.bss.* .upper.bss) } > RAM .upper.text : -- Alan Modra Australia Development Lab, IBM