[PATCH v5 0/1] ASCII output section command
Jan Beulich
jbeulich@suse.com
Thu Jul 18 13:15:09 GMT 2024
On 18.07.2024 15:01, Ulf Samuelsson wrote:
> I changed the syntax, so it looked more like the ASCIZ without the paranthesis.
>
> It would be strange to have the ASCII command within paranthesis and the ASCIZ without paranthesis.
>
> The primary use for this, as I see it is in a header.
> The header defines certain fields, and you may need to have labels at the start of each field.
>
> You could force the string to be exactly <size> long, but I do not see why you would want to force the user to keep counting sizes of strings. Therefore adding NUL characters at the end to fit exactly into the field make sense.
>
> Someone may want to use the header fields differently, so you might want to put a string in two consecutive fields. Therefore an a field of size <size> can contain exactly <size> characters, so reporting it as an error is not a good idea, placing an unneccessary restriction.
>
> So then you have the case where the string is longer than the allocated size.
> Since the main characteristic of the command is the size of the block, the user is not going to get the string he describes in the linker command file.
>
> Since it is very likely that he expects a zero terminated string to be present, there will be a run time error which can write kilobytes if stuff to a terminal as a result.
> Adding a warning and cutting the message short by a NUL character seems to be the most useful way of avoiding this run time error.
You appear to have very specific expectations towards how this is going to
be used. Elsewhere simply truncating may end up more "useful".
> I am open to change the name of the command, but ASCIIZ is not something that is helpful. It is just going to add confusion.
I did only suggest to have Z at the end in case nul-terminated strings would
only ever be put there. If you dropped the nul-termination (while keeping
the nul-padding for shorter strings), all would be fine with the name as is,
at least as far as I'm concerned.
Just to remind you, there was also another syntax concern of mine: Most
other directives emitting data are followed by parentheses, enclosing the
argument(s). While I realize ASCIZ already deviates from that, I wonder if
it should (have had). Yet then again I'm not really a linker script expert
in the first place.
Jan
More information about the Binutils
mailing list