public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* Symbol versioning for secondary libraries is not effective
@ 2018-01-26 10:41 Florian Weimer
  2018-01-26 13:55 ` Joseph Myers
  0 siblings, 1 reply; 4+ messages in thread
From: Florian Weimer @ 2018-01-26 10:41 UTC (permalink / raw)
  To: GNU C Library

I looked at underlinking issues in the upcoming Fedora 28 distribution. 
It is fairly common that functions from <dlfcn.h> are called from DSOs 
which are not linked with -ldl.  The net result is that the references 
to dlsym etc. are not properly versioned.  <pthread.h> and <math.h> are 
also affected.

In the past, we have seen actual bugs related to missing symbol versions 
for functions from librt.

In short, I think this affects all secondary libraries besides 
libc.so.6.  This means that bumping symbol versions for those libraries 
is not an effective way to maintain backwards compatibility.  This is 
something to keep in mind for future changes.  It is also a mild 
argument in favor of moving symbols into libc.so.6, I think.

(Technically, those DSOs are of course incorrectly linked and not 
ABI-compliant, but that doesn't help users who are stuck with them.)

Thanks,
Florian

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

* Re: Symbol versioning for secondary libraries is not effective
  2018-01-26 10:41 Symbol versioning for secondary libraries is not effective Florian Weimer
@ 2018-01-26 13:55 ` Joseph Myers
  2018-01-29 14:00   ` Florian Weimer
  0 siblings, 1 reply; 4+ messages in thread
From: Joseph Myers @ 2018-01-26 13:55 UTC (permalink / raw)
  To: Florian Weimer; +Cc: GNU C Library

On Fri, 26 Jan 2018, Florian Weimer wrote:

> in mind for future changes.  It is also a mild argument in favor of moving
> symbols into libc.so.6, I think.

Suppose you make the libc.so linker script reference some or all of the 
other libraries inside AS_NEEDED.  Do that result in them being 
automatically linked into shared libraries that use symbols from them, or 
does it only work for executables?

Referencing libraries inside AS_NEEDED is arguably friendlier to users 
anyway - e.g. those not familiar with Unix conventions may not expect to 
need to use -lm.  And POSIX has no notion of a separate -ldl (or -lcrypt) 
being needed to get some standard interfaces.  (There are other ways in 
which an implementation of the POSIX c99 utility is not a completely 
trivial wrapper round "gcc", e.g. the POSIX rules about -D and -U option 
ordering, but there's no need for the library to make it more complicated 
than necessary.)

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: Symbol versioning for secondary libraries is not effective
  2018-01-26 13:55 ` Joseph Myers
@ 2018-01-29 14:00   ` Florian Weimer
  2018-01-29 23:58     ` Carlos O'Donell
  0 siblings, 1 reply; 4+ messages in thread
From: Florian Weimer @ 2018-01-29 14:00 UTC (permalink / raw)
  To: Joseph Myers; +Cc: GNU C Library

On 01/26/2018 01:46 PM, Joseph Myers wrote:
> On Fri, 26 Jan 2018, Florian Weimer wrote:
> 
>> in mind for future changes.  It is also a mild argument in favor of moving
>> symbols into libc.so.6, I think.
> 
> Suppose you make the libc.so linker script reference some or all of the
> other libraries inside AS_NEEDED.  Do that result in them being
> automatically linked into shared libraries that use symbols from them, or
> does it only work for executables?

This will not work for libpthread because some libraries really prefer 
to link against the libc.so.6 definitions, at least for the time being, 
where the libc and libpthread implementations offer different trade-offs.

For libm and libld, this approach appears to work.  The AS_NEEDED 
directive is even overriden by an explicit -lm or -ldl on the command, 
which is good.  It looks like this is something to consider for the next 
release.

> Referencing libraries inside AS_NEEDED is arguably friendlier to users
> anyway - e.g. those not familiar with Unix conventions may not expect to
> need to use -lm.

Yes, a missing -lm seems to be a common obstacle.

Thanks,
Florian

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

* Re: Symbol versioning for secondary libraries is not effective
  2018-01-29 14:00   ` Florian Weimer
@ 2018-01-29 23:58     ` Carlos O'Donell
  0 siblings, 0 replies; 4+ messages in thread
From: Carlos O'Donell @ 2018-01-29 23:58 UTC (permalink / raw)
  To: Florian Weimer, Joseph Myers; +Cc: GNU C Library

On 01/29/2018 12:58 AM, Florian Weimer wrote:
> On 01/26/2018 01:46 PM, Joseph Myers wrote:
>> On Fri, 26 Jan 2018, Florian Weimer wrote:
>>
>>> in mind for future changes.  It is also a mild argument in favor of moving
>>> symbols into libc.so.6, I think.
>>
>> Suppose you make the libc.so linker script reference some or all of the
>> other libraries inside AS_NEEDED.  Do that result in them being
>> automatically linked into shared libraries that use symbols from them, or
>> does it only work for executables?
> 
> This will not work for libpthread because some libraries really prefer to link against the libc.so.6 definitions, at least for the time being, where the libc and libpthread implementations offer different trade-offs.
> 
> For libm and libld, this approach appears to work.  The AS_NEEDED directive is even overriden by an explicit -lm or -ldl on the command, which is good.  It looks like this is something to consider for the next release.
> 
>> Referencing libraries inside AS_NEEDED is arguably friendlier to users
>> anyway - e.g. those not familiar with Unix conventions may not expect to
>> need to use -lm.
> 
> Yes, a missing -lm seems to be a common obstacle.

I think an AS_NEEDED for -lm and -ldl would be a step in the right direction.

The only complaint might be that the accidental use of such a symbol will pull
in the new library instead of generating an error, but it's hard to argue this
case. You can always later remove the reference and recompile the program.

-- 
Cheers,
Carlos.

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

end of thread, other threads:[~2018-01-29 21:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-26 10:41 Symbol versioning for secondary libraries is not effective Florian Weimer
2018-01-26 13:55 ` Joseph Myers
2018-01-29 14:00   ` Florian Weimer
2018-01-29 23:58     ` Carlos O'Donell

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).