From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from emagii.se (www.emagii.com [185.133.207.17]) by sourceware.org (Postfix) with ESMTPS id CC5393858D32 for ; Fri, 10 Mar 2023 17:01:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CC5393858D32 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=emagii.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=emagii.com Received: from [10.175.196.145] (84-55-68-216.customers.ownit.se [84.55.68.216]) by emagii.se (Postfix) with ESMTPSA id E559B120204; Fri, 10 Mar 2023 18:01:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=emagii.com; s=default; t=1678467711; bh=eYaKepA0806vUt5+MmljEMmiFq2ci3Y4QntgU80Mw5M=; h=Subject:To:From; b=d3u8GU5vvLxW8q6wpvpuKA7MG5UI6FcCqLuNmxV68qNwb+KOeHtVTzu9pBOZsL/CN 0BNm7VbvQR+hSaFw1vVc5Abw2zDe/01v3KiPDSZhum52/JruTQrlwHryzc54lg5wZF 01GrEpAwAOT4ajZa1sYBcv/xkCHYU2Wxtlzk7RU0= Authentication-Results: emagii.beebytevps.io; spf=pass (sender IP is 84.55.68.216) smtp.mailfrom=binutils@emagii.com smtp.helo=[10.175.196.145] Received-SPF: pass (emagii.beebytevps.io: connection is authenticated) Message-ID: Date: Fri, 10 Mar 2023 18:01:47 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Subject: Re: [PATCH v1 0/7 SECTOR: Support aligning to flash sector boundary Content-Language: en-US To: Michael Matz Cc: binutils@sourceware.org, nickc@redhat.com References: <20230310000817.751962-1-binutils@emagii.com> From: Ulf Samuelsson In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-PPP-Message-ID: <167846771094.350318.2836076472108782184@localhost.localdomain> X-PPP-Vhost: emagii.com X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_FAIL,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 2023-03-10 15:13, Michael Matz wrote: > Hello, > > On Fri, 10 Mar 2023, Ulf Samuelsson via Binutils wrote: > >> This can be used later to align a sector to the flash boundary using the >> >> ALIGN_SECTOR command in an output sector. > Please consider implementing new features in terms of existing ones. For > instance there is already an 'ALIGN' expression, that either takes dot or > an arbitrary expression to align, to a certain given value. Your new > feature is basically just a special value for such alignment, so it makes > sense to specify _that_ instead of a new top-level expression. So, > consider accepting something like: > > ALIGN(TOSECTOR) > ALIGN(expr, TOSECTOR) > > so that one would write > > . = ALIGN(TOSECTOR) I considered it, but came to the conclusion that it opens a bag of worms. To fit this into the grammar, TOSECTOR (or maybe just SECTOR) needs to be a valid expression, returning the size of the flash sector where the location counter is. Since expressions are available everywhere, you run into situations where it really does not make sense for "SECTOR" to have a value. It only makes sense when the linker is processing the output section, and even there, it hardly makes sense to use it except as a way to finish the output section. The way it is implemented, it is really more of a subroutine than a function. For each declared sector, there are four assignment statements. One of them is moderately complex. It is not uncommon for larger microcontrollers to have 32 or more flash sectors. I do not rule out that microcontrollers will have 64 or even 128 flash sectors. To create an function which collapses 100+ statements into a single expression may stress the expression evaluator in unpredictable ways. Have the linker been tested with 100-200 lines+ expressions? Another aspect is what part of the code is affected. Right now, everything except flex/bison code is inside a new file (ldsectors.c) The alternative that I could consider is to add it in the Output Section Description There you can specify ALIGN_WITH_INPUT which has a similar syntax as ALIGN_SECTOR so alignment is specified either using an expression or a special keyword already today. It may be possible to have ALIGN '(' SECTOR ')' as a statement (not an expression) Best Regards Ulf Samuelsson > > as usual with alignment of dot. The 'TOSECTOR' token would be the new > thing and make it do what you wanted with ALIGN_SECTOR. > > > Ciao, > Michael.