[PATCH v1 4/7] ld.texi: Add ASCII to info file

Ulf Samuelsson ulf@emagii.com
Mon Jul 8 12:10:48 GMT 2024


Den 2024-07-08 kl. 13:40, skrev Jan Beulich:
> On 08.07.2024 13:29, Ulf Samuelsson wrote:
>> Den 2024-07-08 kl. 13:18, skrev Andreas Schwab:
>>> On Jul 08 2024, Ulf Samuelsson wrote:
>>>
>>>> Given *ASCII 16, "This is 16 bytes*"  size == 16 and strlen("This is 16
>>>> bytes") == 16,
>>>> the linker should add a 16 byte area without a terminating NUL,
>>>>
>>>> If the string is shorter, then the linker should pad with NUL.
>>>>
>>>> If the string is longer, then the linker should truncate the string adding
>>>> a NUL
>>>> at the end, still fitting in the area. A warning should be issued.
>>> This inonsistency is confusing.  The directive should either always use
>>> the first size characters from the string, only padding with nulls when
>>> the string is shorter, or reject longer strings at all.
>>>
>> I do not see that the user can be confused if the user reads the warning
>> message:
>>
>> "warning: ASCII string does not fit in allocated space, truncated"
> Well, paying attention to this warning is just one thing. Yet even if you
> do, you still won't know _how_ the truncation was carried out. And for a
> directive named ASCII I for one would expect "plain" truncation. Much
> like you also do not warn when size == len.

You know what happens if you look at the output data from the linker.

It is of course possible to clarify this in the warning or include it in 
the documentation.

size == len is a valid case, and therefore no warning.

While I suspect the main use is to add a zero-terminated string,
there is nothing that stop the user from copying a fixed number of 
characters
before use


>
> Jan

-- 
Best Regards,
Ulf Samuelsson
eMagii
+46 722 427437
ulf@emagii.com



More information about the Binutils mailing list