Bug 7047

Summary: ld incorectly sets versions of symbols for ALSA
Product: binutils Reporter: Denis Silakov <silakov>
Component: ldAssignee: Alan Modra <amodra>
Status: RESOLVED FIXED    
Severity: enhancement CC: bug-binutils
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Host: Target:
Build: Last reconfirmed: 2008-11-25 23:54:18

Description Denis Silakov 2008-11-24 20:24:53 UTC
Alsa's libasound tries to be backward compatible and sets appropriate versions 
for every binary symbol. However, some time ago it was found that actual 
versions were not set as expected, i.e. as specified by the file passed to ld 
using '--version-script'.

More particular, version assignment starts properly but since some moment all 
symbols obtain the default version, not the specified one. 

After such a mismatch was discovered for a first time, the problematic version 
nodes (that didn't have any effect) were simply dropped from the Version script,
so for experiments one should use not the very fresh release of alsa; let's 
take 1.0.15, for example:

ftp://ftp.alsa-project.org/pub/lib/alsa-lib-1.0.15.tar.bz2

The script passed to ld with '--version-script' is src/Versions one, created 
from the src/Versions.in by configure.

The file contains version nodes with names from ALSA_0.9 to ALSA_1.0.14. The 
resulting library has symbols with ALSA_0.9, ALSA_0.9.0, ALSA_0.9.3, ... 
ALSA_0.9.7 ... and all. Starting with ALSA_0.9.8, versions are not assigned; 
instead of them, corresponding symbols obtain ALSA_0.9 version as the default 
one for all snd_* symbols.

If we move snd_* from ALSA_0.9 to ALSA_1.0.14 node (the latest one), then 
everything is ok - we see all problematic symbols to have proper versions 
(surely, symbols not mentioned directly in the file now have ALSA_1.0.14 
instead of ALSA_0.9, so this is not the solution).

So the question is - why the default version is set even for symbols for which 
a separate entry in the Version file exists? Looks like a bug in ld.

The problem occurs with almost all versions of ld - haven't tried binutils 2.19 
and head, but our investigation of distributions show that there is no 
distribution that provides libasound where at least one symbol exists with 
version ALSA_0.9.8 and higher.
Comment 1 Alan Modra 2008-11-24 22:23:01 UTC
This isn't a bug.  You asked for all the symbols mentioned in various version
nodes to match the default version with the pattern snd_* in the default version
node!  Yes, it would be nice if a non-wildcard pattern would override a
wildcard, but ld doesn't do that except in the special case of "*".
Comment 2 Denis Silakov 2008-11-25 08:37:27 UTC
Oh, so our interpretation of how version assignment works was simply wrong? 
Thanks for explanations.

Indeed, it would be nice to add possibility to override a pattern with a 
specific symbol name.

However, I'm a little confused about single "*" pattern. In case of the 
following script:

ALSA_0.9 {
  global:
    *;
};

...

ALSA_0.9.5 {
  global:

    alsa_lisp;
} ALSA_0.9.3;

alsa_lisp symbol obtains ALSA_0.9 version. I'd expect it to have ALSA_0.9.5 
one...

Comment 3 Alan Modra 2008-11-25 09:13:00 UTC
Hmm, yes it appears that "*" only works for local.  I guess that's a bug since
we say in ld.info that it ought to work for global too.  Not that there is much
reason to use "*" in global, since symbols are global by default.
Comment 4 Alan Modra 2008-11-26 02:20:25 UTC
Please note the warning I added to ld.texinfo.
http://sourceware.org/ml/binutils-cvs/2008-11/msg00131.html
http://sourceware.org/ml/binutils/2008-11/msg00299.html