[RFC v0 0/6] ASCII Command for output section
Nick Clifton
nickc@redhat.com
Thu Feb 16 16:31:51 GMT 2023
Hi Ulf,
>> What do you think of this alternative version of your patch ?
OK, I have now applied a tweaked version of the patch.
> 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;
Done.
> 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"
It works. The area assigned will be 45 bytes. I tested it, and included a version
of this expression in the new linker test.
> 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.
Right. As far as I am concerned a leak this small is not important.
Cheers
Nick
More information about the Binutils
mailing list