public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Linker script and alias to a versioned symbol
@ 2023-02-10 18:35 amb
  2023-02-10 19:09 ` Vladimir Mezentsev
  2023-04-14  0:57 ` Vladimir Mezentsev
  0 siblings, 2 replies; 7+ messages in thread
From: amb @ 2023-02-10 18:35 UTC (permalink / raw)
  To: binutils

Hi,

I would like to know whether it is possible, in a linker script, to
define an alias to a versioned symbol.

As an example, let me use these two versioned symbols in glibc:

  XXXX: 00000000000XXXX   119 FUNC    GLOBAL DEFAULT   15
clock_gettime@GLIBC_2.2.5
  XXXX: 00000000000XXXX   119 FUNC    GLOBAL DEFAULT   15
clock_gettime@@GLIBC_2.17

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 would like to know if
there is a way to achieve this goal using only a linker script and
nothing else.

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?

Thanks

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Linker script and alias to a versioned symbol
  2023-02-10 18:35 Linker script and alias to a versioned symbol amb
@ 2023-02-10 19:09 ` Vladimir Mezentsev
  2023-04-14  0:57 ` Vladimir Mezentsev
  1 sibling, 0 replies; 7+ messages in thread
From: Vladimir Mezentsev @ 2023-02-10 19:09 UTC (permalink / raw)
  To: binutils



On 2/10/23 10:35, amb via Binutils wrote:
> Hi,
>
> I would like to know whether it is possible, in a linker script, to
> define an alias to a versioned symbol.
>
> As an example, let me use these two versioned symbols in glibc:
>
>    XXXX: 00000000000XXXX   119 FUNC    GLOBAL DEFAULT   15
> clock_gettime@GLIBC_2.2.5
>    XXXX: 00000000000XXXX   119 FUNC    GLOBAL DEFAULT   15
> clock_gettime@@GLIBC_2.17
>
> 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 ?

+1.
We need this.

>
> I am familiar with how `__asm__(".symver SYM,SYM@GLIBC_VERSION");`
> works but that's not what I am looking for. I would like to know if
> there is a way to achieve this goal using only a linker script and
> nothing else.
>
> I tried something like this:
>
> PROVIDE( clock_gettime = clock_gettime@GLIBC_2.2.5 );

   This should work:
      int (*clock_gettime_2_2_5)(clockid_t clk_id, struct timespec *tp) 
= dlvsym (RTLD_NEXT, "clock_gettime ", "GLIBC_2.2.5");
clock_gettime_2_2_5( YOUR_ARGS_FOR_CLOCK_GETTIME );


-Vladimir

>
> But it doesn't seem to work. Maybe the '@' is an invalid char above?
>
> Thanks


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Linker script and alias to a versioned symbol
  2023-02-10 18:35 Linker script and alias to a versioned symbol amb
  2023-02-10 19:09 ` Vladimir Mezentsev
@ 2023-04-14  0:57 ` Vladimir Mezentsev
  2023-04-14  9:00   ` Frédéric Pétrot
  2023-04-14  9:02   ` Nick Clifton
  1 sibling, 2 replies; 7+ messages in thread
From: Vladimir Mezentsev @ 2023-04-14  0:57 UTC (permalink / raw)
  To: amb, binutils

  Hi Experts,

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

Thank you,
-Vladimir

On 2/10/23 10:35, amb via Binutils wrote:
> Hi,
>
> I would like to know whether it is possible, in a linker script, to
> define an alias to a versioned symbol.
>
> As an example, let me use these two versioned symbols in glibc:
>
>    XXXX: 00000000000XXXX   119 FUNC    GLOBAL DEFAULT   15
> clock_gettime@GLIBC_2.2.5
>    XXXX: 00000000000XXXX   119 FUNC    GLOBAL DEFAULT   15
> clock_gettime@@GLIBC_2.17
>
> 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 would like to know if
> there is a way to achieve this goal using only a linker script and
> nothing else.
>
> 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?
>
> Thanks


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Linker script and alias to a versioned symbol
  2023-04-14  0:57 ` Vladimir Mezentsev
@ 2023-04-14  9:00   ` Frédéric Pétrot
  2023-04-14  9:04     ` Nick Clifton
  2023-04-14  9:02   ` Nick Clifton
  1 sibling, 1 reply; 7+ messages in thread
From: Frédéric Pétrot @ 2023-04-14  9:00 UTC (permalink / raw)
  To: Vladimir Mezentsev, amb, binutils

Hello Vladimir,

    I believe what you are looking for is the VERSION command of the linker
    script.
    This is documented in section 3.9 of the manual.

    Hope this helps,
    Frédéric

Le 14/04/2023 à 02:57, Vladimir Mezentsev via Binutils a écrit :
>   Hi Experts,
> 
> Is it possible with compiler/linker options to change the default version of 
> clock_gettime (or GLIBC) in the test below.
> 
> Thank you,
> -Vladimir
> 
> On 2/10/23 10:35, amb via Binutils wrote:
>> Hi,
>>
>> I would like to know whether it is possible, in a linker script, to
>> define an alias to a versioned symbol.
>>
>> As an example, let me use these two versioned symbols in glibc:
>>
>>    XXXX: 00000000000XXXX   119 FUNC    GLOBAL DEFAULT   15
>> clock_gettime@GLIBC_2.2.5
>>    XXXX: 00000000000XXXX   119 FUNC    GLOBAL DEFAULT   15
>> clock_gettime@@GLIBC_2.17
>>
>> 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 would like to know if
>> there is a way to achieve this goal using only a linker script and
>> nothing else.
>>
>> 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?
>>
>> Thanks
> 

-- 
+---------------------------------------------------------------------------+
| Frédéric Pétrot,                            Pr. Grenoble INP-Ensimag/TIMA |
| Mob/Pho: +33 6 74 57 99 65/+33 4 76 57 48 70      Ad augusta  per angusta |
| http://tima.univ-grenoble-alpes.fr frederic.petrot@univ-grenoble-alpes.fr |
+---------------------------------------------------------------------------+


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Linker script and alias to a versioned symbol
  2023-04-14  0:57 ` Vladimir Mezentsev
  2023-04-14  9:00   ` Frédéric Pétrot
@ 2023-04-14  9:02   ` Nick Clifton
  1 sibling, 0 replies; 7+ messages in thread
From: Nick Clifton @ 2023-04-14  9:02 UTC (permalink / raw)
  To: Vladimir Mezentsev, amb, binutils

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Linker script and alias to a versioned symbol
  2023-04-14  9:00   ` Frédéric Pétrot
@ 2023-04-14  9:04     ` Nick Clifton
  2023-04-14  9:18       ` Frédéric Pétrot
  0 siblings, 1 reply; 7+ messages in thread
From: Nick Clifton @ 2023-04-14  9:04 UTC (permalink / raw)
  To: Frédéric Pétrot, Vladimir Mezentsev, amb, binutils

Hi Frédéric,

> I believe what you are looking for is the VERSION command of the linker
> script.

I looked at this, but I did not see a way to using the version scripting
language to create an alias of a versioned symbol.  I may be wrong however,
as I am not an expert in this area.

Cheers
   Nick



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Linker script and alias to a versioned symbol
  2023-04-14  9:04     ` Nick Clifton
@ 2023-04-14  9:18       ` Frédéric Pétrot
  0 siblings, 0 replies; 7+ messages in thread
From: Frédéric Pétrot @ 2023-04-14  9:18 UTC (permalink / raw)
  To: Nick Clifton, Vladimir Mezentsev, amb, binutils

Hi Nick,

   you are perfectly right, I spoke of the top of my head and a quick
   check would have avoided embarrassing me, ...

   Frédéric

Le 14/04/2023 à 11:04, Nick Clifton a écrit :
> Hi Frédéric,
> 
>> I believe what you are looking for is the VERSION command of the linker
>> script.
> 
> I looked at this, but I did not see a way to using the version scripting
> language to create an alias of a versioned symbol.  I may be wrong however,
> as I am not an expert in this area.
> 
> Cheers
>    Nick
> 
> 

-- 
+---------------------------------------------------------------------------+
| Frédéric Pétrot,                            Pr. Grenoble INP-Ensimag/TIMA |
| Mob/Pho: +33 6 74 57 99 65/+33 4 76 57 48 70      Ad augusta  per angusta |
| http://tima.univ-grenoble-alpes.fr frederic.petrot@univ-grenoble-alpes.fr |
+---------------------------------------------------------------------------+

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-04-14  9:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-10 18:35 Linker script and alias to a versioned symbol amb
2023-02-10 19:09 ` Vladimir Mezentsev
2023-04-14  0:57 ` Vladimir Mezentsev
2023-04-14  9:00   ` Frédéric Pétrot
2023-04-14  9:04     ` Nick Clifton
2023-04-14  9:18       ` Frédéric Pétrot
2023-04-14  9:02   ` Nick Clifton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).