[RFC v0 0/6] ASCII Command for output section

Ulf Samuelsson binutils@emagii.com
Wed Feb 15 17:55:27 GMT 2023


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



More information about the Binutils mailing list