[PATCH 2/2] IPA symver: support visibility and static symbols.

Martin Liška mliska@suse.cz
Wed Aug 26 11:16:32 GMT 2020


On 8/26/20 11:22 AM, Jan Hubicka wrote:
>> On 8/25/20 8:46 PM, Jan Hubicka wrote:
>>> What will happen here with protected visibility?
>>
>> I forgot about it. Should it be mapped also to "local"?
>>
>> +  const char *visibility = NULL;
>> +  if (!TREE_PUBLIC (origin_decl))
>> +    visibility = "remove";
>> +  else if (DECL_VISIBILITY (origin_decl) == VISIBILITY_INTERNAL
>> +          || DECL_VISIBILITY (origin_decl) == VISIBILITY_PROTECTED)
>> +    visibility = "local";
>> +  else if (DECL_VISIBILITY (origin_decl) == VISIBILITY_HIDDEN)
>> +    visibility = "hidden";
> 
> I have no idea (depends what gas will do), you need to check if the
> resulting symbol will indeed have right visibility in all of the cases.
> If some of them are not possible, I suppose we could just reject the
> comination.

Ok, so I experimented a bit with the .symver attribute I don't see how
is the new syntax handy (I mean .symver foo, foo@VERS_2, hidden and
.symver foo, foo@VERS_1, local)?

For instance:

$ cat vi2.c
int
__attribute__((visibility ("hidden")))
hidden_object;

extern int
__attribute__ ((__symver__ ("foo@@VERS_2")))
__attribute__ ((alias ("hidden_object")))
symver_foo_v1;

$ gcc vi2.c -S
$ cat vi2.s | grep '\.symver'
	.symver	symver_foo_v1, foo@@VERS_2

$ readelf -s vi2.o -W
...
      8: 0000000000000000     4 OBJECT  GLOBAL HIDDEN     3 hidden_object
      9: 0000000000000000     4 OBJECT  GLOBAL DEFAULT    3 symver_foo_v1
     10: 0000000000000000     4 OBJECT  GLOBAL DEFAULT    3 foo@@VERS_2

Which seems fine to me. Similarly one can directly modify visibility of
symver_foo_v1 with:
.hidden	symver_foo_v1

Or do I miss something?

Martin

> 
> Honza
>>
>> Thanks,
>> Martin



More information about the Gcc-patches mailing list