public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Ulf Samuelsson <ulf@emagii.com>
To: Jan Beulich <jbeulich@suse.com>, Ulf Samuelsson <binutils@emagii.com>
Cc: Binutils <binutils@sourceware.org>,
	Nick Clifton <nickc@redhat.com>, Andreas Schwab <schwab@suse.de>
Subject: Re: [PATCH v1 4/7] ld.texi: Add ASCII to info file
Date: Mon, 8 Jul 2024 14:10:48 +0200	[thread overview]
Message-ID: <c5446ae1-d547-c39e-ea0d-2f797019c026@emagii.com> (raw)
In-Reply-To: <0e98838d-55aa-43a9-bf24-5b510d77b643@suse.com>


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


  reply	other threads:[~2024-07-08 12:10 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-28 21:46 [PATCH v1 0/7] ASCII output section command binutils
2024-06-28 21:46 ` [PATCH v1 1/7] ldlex.l: Add ASCII token binutils
2024-06-28 21:46 ` [PATCH v1 2/7] ldgram.y: Add ASCII parsing binutils
2024-06-28 21:46 ` [PATCH v1 3/7] ldlang.*: process ASCII command binutils
2024-07-01  6:35   ` Jan Beulich
2024-06-28 21:46 ` [PATCH v1 4/7] ld.texi: Add ASCII to info file binutils
2024-07-01  6:50   ` Jan Beulich
     [not found]     ` <6FDD8EBD-2371-40DB-B25B-052278BCBF49@emagii.com>
2024-07-02  8:12       ` Jan Beulich
2024-07-05 15:38         ` Ulf Samuelsson
2024-07-08  6:18           ` Jan Beulich
2024-07-08 10:57             ` Ulf Samuelsson
2024-07-08 11:07               ` Jan Beulich
2024-07-08 11:19                 ` Ulf Samuelsson
2024-07-08 11:18               ` Andreas Schwab
2024-07-08 11:29                 ` Ulf Samuelsson
2024-07-08 11:40                   ` Jan Beulich
2024-07-08 12:10                     ` Ulf Samuelsson [this message]
2024-07-08 11:48                   ` Andreas Schwab
2024-07-08 12:01                     ` Ulf Samuelsson
2024-07-08 12:16                       ` Andreas Schwab
2024-07-08 12:22                         ` Ulf Samuelsson
2024-06-28 21:46 ` [PATCH v1 5/7] Add testsuite for ASCII command binutils
2024-06-28 21:46 ` [PATCH v1 6/7] NEWS: Add " binutils
2024-06-28 21:46 ` [PATCH v1 7/7] ChangeLog: " binutils
2024-07-01  6:38   ` Jan Beulich
     [not found]     ` <094CF629-FDF8-436D-8B5B-62D35C3EA396@emagii.com>
2024-07-02  8:37       ` Jan Beulich

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=c5446ae1-d547-c39e-ea0d-2f797019c026@emagii.com \
    --to=ulf@emagii.com \
    --cc=binutils@emagii.com \
    --cc=binutils@sourceware.org \
    --cc=jbeulich@suse.com \
    --cc=nickc@redhat.com \
    --cc=schwab@suse.de \
    /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).