public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Ulf Samuelsson <binutils@emagii.com>
To: Nick Clifton <nickc@redhat.com>, binutils@sourceware.org
Subject: Re: [RFC v0 0/6] ASCII Command for output section
Date: Wed, 15 Feb 2023 18:55:27 +0100	[thread overview]
Message-ID: <6ae85247-4274-fea7-78e3-fcf49a20fda1@emagii.com> (raw)
In-Reply-To: <ce2103c9-5df7-bb59-ef38-07eeb35e1313@redhat.com>


Den 2023-02-15 kl. 18:07, skrev Nick Clifton:
> Hi Ulf,
>
>> I would like to support
>>
>>     ASCII <size> , <string>
>>
>> when I try, and add
>>         ASCII  32 , "mystring"
>>
>> I get a "syntax error", and would like to understand why.
>
> Whilst I have not gone into this too deeply, I think that the
> short answer is "because that is the way that the linker's
> parser works".  It expects numerical expressions, including
> constant integer values, to be enclosed in parentheses.

I did a small trick allowing me to turn on yydebug.

     | DEBUG ON
         {
           yydebug = 1;
         }
     | DEBUG OFF
         {
           yydebug = 0;
         }

so I saw that it is parsed as 'ASCII', 'NAME' and not 'ASCII', 'INT'

>
>> If I do:
>>     ASCII (<size>) <string>
>> I do not get a syntax error when I do
>>
>>     ASCII (32) "mystring"
>
> Since this method works, I would suggest just sticking with it.
>
If we are forced to do

    ASCII (32) , "mystring"

it is no advantage, so I guess I have to give up my original idea.

> Also, whilst using sprintf() to process escape sequences is a
> nice idea, it will not work.  Escape sequences are a C language
> feature not a C library feature, so sprintf and its friends will
> not translate them for you.
>
Yes, You are right.


> Cheers
>   Nick
>
>
Best Regards

Ulf Samuelsson


  reply	other threads:[~2023-02-15 17:55 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-15 11:40 binutils
2023-02-15 11:40 ` [PATCH v0 1/6] Add testsuite for ASCII command binutils
2023-02-15 11:40 ` [PATCH v0 2/6] Add ASCII command info to NEWS binutils
2023-02-15 11:40 ` [PATCH v0 3/6] Add ASCII to info file binutils
2023-02-15 11:40 ` [PATCH v0 4/6] ldlex.l: add ASCII binutils
2023-02-15 11:44   ` Ulf Samuelsson
2023-02-15 11:40 ` [PATCH v0 5/6] ldgram.y: " binutils
2023-02-15 11:40 ` [PATCH v0 6/6] ldlang.*: parse ASCII command binutils
2023-02-15 17:07 ` [RFC v0 0/6] ASCII Command for output section Nick Clifton
2023-02-15 17:55   ` Ulf Samuelsson [this message]
2023-02-15 17:28 ` Nick Clifton
2023-02-15 17:52   ` Ulf Samuelsson
2023-02-15 18:29   ` Ulf Samuelsson
2023-02-16 16:31     ` Nick Clifton

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=6ae85247-4274-fea7-78e3-fcf49a20fda1@emagii.com \
    --to=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).