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

Ulf Samuelsson binutils@emagii.com
Wed Feb 15 18:29:36 GMT 2023


Den 2023-02-15 kl. 18:28, skrev Nick Clifton:
> Hi Ulf,
>
>   What do you think of this alternative version of your patch ?
>
>   It will still need tweaking so that the tests will work on big-endian
>   architectures, and the documentation will need fixing, but I think
>   that it does most of what you want.

A little closer look reveals that there is some oddities in the white space.
Also, when the string in the ASCII command is longer than the specified
length, only we need to insert a '\0' character at the end.

For this:

     len = size;

must be changed to

     len = size - 1;

===============

The size is specified by a "mustbe_exp"

     | ASCII '(' mustbe_exp ')' NAME

         {
           /* 'value' is a memory leak, do we care?  */
           etree_type *value = $3;
           lang_add_string (value->value.value, $5);
         }

I cannot judge the consequences of having a full expression, instead of 
an INT.

Will the "value->value.value" work, if we do

      ASCII (3 * 15) "Long string"

?

===============

We do a malloc in the "etree_type *value = $3;" statement.
This is thrown away without a "free".

Is that a problem anywhere?

I guess most OSes would reclaim everything once the 'ld' terminates.

There will not be that many ASCII statements in a linker command file.

===============

I enclose a small update to your patch.

Best Regards
Ulf Samuelsson


>
> Cheers
>   Nick
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-ASCII-command.patch
Type: text/x-patch
Size: 21876 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20230215/1d6eacad/attachment-0001.bin>


More information about the Binutils mailing list