[PATCH v1 0/7 SECTOR: Support aligning to flash sector boundary
Ulf Samuelsson
binutils@emagii.com
Fri Mar 10 17:57:00 GMT 2023
Since the proposal defines the begin, end and size of a sector as symbols,
you can do already today.
. = ALIGN(”bank00#04#size”).
Right now, the symbols are defined late, but that is easily changed.
Best Regards
Ulf Samuelsson
> 10 mars 2023 kl. 18:31 skrev Michael Matz <matz@suse.de>:
>
> 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.
More information about the Binutils
mailing list