[PATCH 2/2] bpf: allow BSS symbols to be global symbols

David Faust david.faust@oracle.com
Fri Apr 23 17:25:50 GMT 2021


Hi YiFei,

I've just checked in both patches to master and GCC 10 on your behalf.

Thanks!

On 4/22/21 11:54 PM, Jose E. Marchesi via Gcc-patches wrote:
> 
> Hi YiFei.
> 
>> Prior to this, a BSS declaration such as:
>>
>>   int foo;
>>   static int bar;
>>
>> Generates:
>>
>>   .global foo
>>   .local  foo
>>   .comm   foo,4,4
>>   .local  bar
>>   .comm	  bar,4,4
>>
>> Creating symbols:
>>
>>   0000000000000000 b foo
>>   0000000000000004 b bar
>>
>> Both symbols are local. However, libbpf bpf_object__variable_offset
>> rquires symbols to be STB_GLOBAL & STT_OBJECT for data section lookup.
>> This patch makes the same declaration generate:
>>
>>   .global foo
>>   .type   foo, @object
>>   .lcomm  foo,4,4
>>   .local  bar
>>   .comm   bar,4,4
>>
>> Creating symbols:
>>
>>   0000000000000000 B foo
>>   0000000000000004 b bar
>>
>> And libbpf will be okay with looking up the global symbol "foo".
> 
> Thanks for the patch.
> This is OK for both master and GCC 10.
> 


More information about the Gcc-patches mailing list