public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Michael Matz <matz@suse.de>
To: Ulf Samuelsson <binutils@emagii.com>
Cc: binutils@sourceware.org, nickc@redhat.com
Subject: Re: [PATCH v1 0/7 SECTOR: Support aligning to flash sector boundary
Date: Fri, 10 Mar 2023 17:30:56 +0000 (UTC)	[thread overview]
Message-ID: <alpine.LSU.2.20.2303101722270.16810@wotan.suse.de> (raw)
In-Reply-To: <b28fdae4-9748-9e94-6fbb-bcb7e701a99a@emagii.com>

Hello.

On Fri, 10 Mar 2023, Ulf Samuelsson wrote:

> >     . = 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.

So, make SECTOR an expression taking an address as well.  Call it 
SECTORSIZE and make it return the sector size for the given argument (an 
address, so that 'dot' can be given in output sections), or 1 if no sector 
is associated with the argument.  Then your alignment expression will 
become

  . = ALIGN(SECTORSIZE(.))

and SECTORSIZE now _can_ make sense in other than output sections (when 
you for instance give it, say, a symbolname defined elsewhere in an 
utput section).

> 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?

Yes.  Such thoughts shouldn't prevent an orthogonal implementation of 
features anyway.  You can also open-code the implementation of SECTORSIZE 
with a helper routine, not resorting to linkerscript expressions at all, 
if you worry about performance of that.

> 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.

I think having it available as expression to be used in ALIGN (or other) 
expressions is the better choice.


Ciao,
Michael.

  reply	other threads:[~2023-03-10 17:30 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-10  0:08 binutils
2023-03-10  0:08 ` [PATCH v1 1/7] SECTOR: NEWS binutils
2023-03-10  0:08 ` [PATCH v1 2/7] SECTOR: ld.texi binutils
2023-03-10  0:08 ` [PATCH v1 3/7] SECTOR: ldlex.l binutils
2023-03-10  0:08 ` [PATCH v1 4/7] SECTOR: ldgram.y binutils
2023-03-10  0:08 ` [PATCH v1 5/7] SECTOR: language additions binutils
2023-03-10  0:08 ` [PATCH v1 6/7] SECTOR: add testsuite binutils
2023-03-10  0:08 ` [PATCH v1 7/7] SECTOR: Makefile.* binutils
2023-03-10  3:46 ` [PATCH v1 0/7 SECTOR: Support aligning to flash sector boundary Alan Modra
2023-03-10 14:13 ` Michael Matz
2023-03-10 17:01   ` Ulf Samuelsson
2023-03-10 17:30     ` Michael Matz [this message]
2023-03-10 17:57       ` Ulf Samuelsson
2023-03-13 13:12         ` Michael Matz
2023-03-13 15:29           ` Ulf Samuelsson
2023-03-13 15:54             ` Michael Matz
2023-03-13 17:26               ` Ulf Samuelsson
2023-03-13 17:35                 ` Michael Matz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LSU.2.20.2303101722270.16810@wotan.suse.de \
    --to=matz@suse.de \
    --cc=binutils@emagii.com \
    --cc=binutils@sourceware.org \
    --cc=nickc@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).