[PATCH] gas: copy st_size only if unset

Jan Beulich jbeulich@suse.com
Mon Apr 4 11:27:06 GMT 2022


On 01.04.2022 03:33, Fangrui Song wrote:
> On 2022-03-31, Jan Beulich wrote:
>> On 31.03.2022 05:37, Fangrui Song wrote:
>>> For
>>> ```
>>> .size foo1, 1
>>> foo1:
>>>
>>> .set bar1, foo1
>>> .size bar1, 2
>>> .size bar2, 2
>>> .set bar2, foo1
>>>
>>> .set bar3, foo2
>>> .size bar3, 2
>>> .size bar4, 2
>>> .set bar4, foo2
>>>
>>> .size foo2, 1
>>> foo2:
>>> ```
>>>
>>> bar1's size is 2 while bar2, bar3, bar4's is 1. The behavior of bar1 makes sense
>>> (generally directives on the new symbol should win) and is relied upon by glibc
>>> stdio-common/errlist.c:
>>
>> But what about
>>
>> foo1:
>> 	.size foo1, 1
>> foo2:
>> 	.size foo2, 2
>> 	.set bar, foo1
>> 	.set bar, foo2
>>
>> I would think bar's size should end up being 2 in this case, whereas I
>> think it would end up being 1 with your change.
>>
>> Jan
> 
> bar's size is 2. The patch has no effect, because `dest` variables for the two
> invocations are (surprisingly) different!
> 
> bar is a volatile symbol (created by .set instead of .equiv). The
> second .set directive creates calls gas.c/read.c:3273 symbol_clone (symbolP, 1).

Ah, yes.

> That said, I think it makes sense to add tests for this as well.
> I'll use the following if this patch is accepted.
> 
>    .text
>    
>    .size foo1, 1
>    foo1:
>    
>    .set bar1, foo1
>    .size bar1, 2
>    .size bar2, 2
>    .set bar2, foo1
>    
>    .set bar3, foo2
>    .size bar3, 2
>    .size bar4, 2
>    .set bar4, foo2
>    
>    .set bar5, foo1
>    .set bar6, foo2
>    
>    .size foo2, 3
>    foo2:
>    
>    .set bar7, foo1
>    .set bar7, foo2

Patch is okay with the extended testcase.

Jan



More information about the Binutils mailing list