Linker script and alias to a versioned symbol

Nick Clifton nickc@redhat.com
Fri Apr 14 09:02:10 GMT 2023


Hi Vladimir,

> Is it possible with compiler/linker options to change the default version of clock_gettime (or GLIBC) in the test below.

Yes/no...

>> In a linker script, is it possible to make sure that a call to
>> clock_gettime ends up invoking clock_gettime@GLIBC_2.2.5 ?
>>
>> I am familiar with how `__asm__(".symver SYM,SYM@GLIBC_VERSION");`
>> works but that's not what I am looking for.

I am intrigued as to why this solution is not sufficient.


>> I would like to know if
>> there is a way to achieve this goal using only a linker script and
>> nothing else.

Sadly the linker script syntax does not provide the functionality you
desire.  About the closet you can get is to use the INCLUDE directive
to load an object file that contains an __asm__ directive like the one
mentioned above.


>> I tried something like this:
>>
>> PROVIDE( clock_gettime = clock_gettime@GLIBC_2.2.5 );
>>
>> But it doesn't seem to work. Maybe the '@' is an invalid char above?

Yes.  The PROVIDE directive only accepts an ordinary symbol name,
not a versioned name.


Cheers
   Nick



More information about the Binutils mailing list