Skip to contentSkip to conversation

problem with versioned symbols and shared libraries

DISCUSSION Rene Rebe 3 participants 5 messages Jan 16, 2004 – Jan 17, 2004

lore
Share & tools
lore

Rene Rebe

author
#0 lore raw

Hi all,

we experience a fairly strange problem with the versioned symbols in the libasound.so. We have a C++ wrapper library which is normally linked as shared obkect, too. But for some strange reasonsthe linker does not map stuff like "snd_pcm_hw_params_get_channels_max" and friends (with a pointer to the val at the end, now) to the correct symbol.

Of course when linked statically into a single binary it works fine.

Example log of some testing:

Let's link a normal object and a shared obeject of the ALSAHelper:

rene@idefix:~/develop/trunk/lowlevel/src$ g++   -g -Wall   -I. -I../include -I../../dam/include -I../../utility/include -c -o ALSAHelper.o ALSAHelper.cc
rene@idefix:~/develop/trunk/lowlevel/src$ g++ --shared  -g -Wall   -I. -I../include -I../../dam/include -I../../utility/include -o ALSAHelper.so ALSAHelper.cc

And now let's link the test application:

First the shared object:

rene@idefix:~/develop/trunk2/lowlevel/tests$ g++   -g -Wall   -I. -I../include -I../../dam/include -I../../utility/include -o ALSAHelper ALSAHelper.cc ../src/ALSAHelper.so  -lasound
rene@idefix:~/develop/trunk2/lowlevel/tests$ ./ALSAHelper
Format 16 bit
Channels min: 268513264
Channels max: 268513264
Rate min: 0
Rate max: 0
Periods min: 0
Periods max: 0
Period Size: 0
Get periods: 0

Hm - quite incorrect values - let's see which symbol is used:

gdb) bt
#0 0x0ff433f0 in __old_snd_pcm_hw_params_get_channels_max (params=0x10013498)

    at pcm.c:6407

#1 0x0ffdc438 in GSMP::ALSAPCM::GetChannelsMax() (this=0x7ffff4e0)
at ALSAHelper.cc:342
#2 0x10002238 in main () at ALSAHelper.cc:67

Hm - but it works fine linked statically with the normal obcject:

rene@idefix:~/develop/trunk2/lowlevel/tests$ g++   -g -Wall   -I. -I../include -I../../dam/include -I../../utility/include -o ALSAHelper ALSAHelper.cc ../src/ALSAHelper.o  -lasound
rene@idefix:~/develop/trunk2/lowlevel/tests$ ./ALSAHelper
Format 16 bit
Channels min: 2
Channels max: 2
Rate min: 44100
Rate max: 48000
Periods min: 1
Periods max: 32
Period Size: 2048
Get periods: 4

;-) - and which symbol is used:

(gdb) bt
#0 __snd_pcm_hw_params_get_channels_max (params=0x10017f68, val=0x7fffe48c)

    at pcm.c:3334

#1 0x10003cac in GSMP::ALSAPCM::GetChannelsMax() (this=0x7ffff4e0)
at ALSAHelper.cc:342
#2 0x10001c00 in main () at ALSAHelper.cc:67

Any idea what is happening to ALSA's symbol versioning using shared objects?

In the case it matters, this is all on PowerPC (ROCK Linux) ...

gcc (GCC) 3.2.3
GNU C Library stable release version 2.3.2, by Roland McGrath et al. GNU ld version 2.14.90.0.4.1 20030523
GNU assembler 2.14.90.0.4.1 20030523

Thanks in advance - yours,
René

Signature · 12 lines
René Rebe - Europe/Germany/Berlin
  [email protected] [email protected]
http://www.rocklinux.org http://www.rocklinux-consulting.de
http://gsmp.tfh-berlin.de/gsmp http://gsmp.tfh-berlin.de/rene



-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
#1 lore raw

Hi, René

This is exactly the same problem I'm having with a dynamically linked C++ (extern "C") plugin of mine, which links dynamically with ALSA through PortAudio. I made a not so aptly titled post about it earlier, "Problem with __OLD_GET". I was still a bit confused as to what was going on .. :)

Regards

Arve Knudsen

Quoted 97 lines · Rene Rebe

Hi all,

we experience a fairly strange problem with the versioned symbols in the libasound.so. We have a C++ wrapper library which is normally linked as shared obkect, too. But for some strange reasonsthe linker does not map stuff like "snd_pcm_hw_params_get_channels_max" and friends (with a pointer to the val at the end, now) to the correct symbol.

Of course when linked statically into a single binary it works fine.

Example log of some testing:

Let's link a normal object and a shared obeject of the ALSAHelper:

rene@idefix:~/develop/trunk/lowlevel/src$ g++   -g -Wall   -I. 
-I../include -I../../dam/include -I../../utility/include -c -o 
ALSAHelper.o ALSAHelper.cc
rene@idefix:~/develop/trunk/lowlevel/src$ g++ --shared  -g -Wall   -I. 
-I../include -I../../dam/include -I../../utility/include -o 
ALSAHelper.so ALSAHelper.cc

And now let's link the test application:

First the shared object:

rene@idefix:~/develop/trunk2/lowlevel/tests$ g++   -g -Wall   -I. 
-I../include -I../../dam/include -I../../utility/include -o ALSAHelper 
ALSAHelper.cc ../src/ALSAHelper.so  -lasound
rene@idefix:~/develop/trunk2/lowlevel/tests$ ./ALSAHelper
Format 16 bit
Channels min: 268513264
Channels max: 268513264
Rate min: 0
Rate max: 0
Periods min: 0
Periods max: 0
Period Size: 0
Get periods: 0

Hm - quite incorrect values - let's see which symbol is used:

gdb) bt
#0 0x0ff433f0 in __old_snd_pcm_hw_params_get_channels_max (params=0x10013498)

    at pcm.c:6407

#1 0x0ffdc438 in GSMP::ALSAPCM::GetChannelsMax() (this=0x7ffff4e0)
at ALSAHelper.cc:342
#2 0x10002238 in main () at ALSAHelper.cc:67

Hm - but it works fine linked statically with the normal obcject:

rene@idefix:~/develop/trunk2/lowlevel/tests$ g++   -g -Wall   -I. 
-I../include -I../../dam/include -I../../utility/include -o ALSAHelper 
ALSAHelper.cc ../src/ALSAHelper.o  -lasound
rene@idefix:~/develop/trunk2/lowlevel/tests$ ./ALSAHelper
Format 16 bit
Channels min: 2
Channels max: 2
Rate min: 44100
Rate max: 48000
Periods min: 1
Periods max: 32
Period Size: 2048
Get periods: 4

;-) - and which symbol is used:

(gdb) bt
#0 __snd_pcm_hw_params_get_channels_max (params=0x10017f68, val=0x7fffe48c)

    at pcm.c:3334

#1 0x10003cac in GSMP::ALSAPCM::GetChannelsMax() (this=0x7ffff4e0)
at ALSAHelper.cc:342
#2 0x10001c00 in main () at ALSAHelper.cc:67

Any idea what is happening to ALSA's symbol versioning using shared objects?

In the case it matters, this is all on PowerPC (ROCK Linux) ...

gcc (GCC) 3.2.3
GNU C Library stable release version 2.3.2, by Roland McGrath et al. GNU ld version 2.14.90.0.4.1 20030523
GNU assembler 2.14.90.0.4.1 20030523

Thanks in advance - yours,
René

--
René Rebe - Europe/Germany/Berlin
[email protected] [email protected]
http://www.rocklinux.org http://www.rocklinux-consulting.de
http://gsmp.tfh-berlin.de/gsmp http://gsmp.tfh-berlin.de/rene

Quoted 9 lines

-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004 Premiere Conference on Open Tools Development and Integration See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
Alsa-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel

-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004 Premiere Conference on Open Tools Development and Integration See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn

#2 lore raw
In reply to Rene Rebe
Quoted 9 lines · Rene Rebe

Let's link a normal object and a shared obeject of the ALSAHelper:

rene@idefix:~/develop/trunk/lowlevel/src$ g++ -g -Wall -I. -I../include
-I../../dam/include -I../../utility/include -c -o ALSAHelper.o
ALSAHelper.cc
rene@idefix:~/develop/trunk/lowlevel/src$ g++ --shared -g -Wall -I.
-I../include -I../../dam/include -I../../utility/include -o
ALSAHelper.so ALSAHelper.cc

I tried that and it seems that you MUST link also this shared module against the asound library:

g++ --shared -g -Wall -I. -I../include -I../../dam/include -I../../utility/include -lasound -o ALSAHelper.so ALSAHelper.cc

                        ^^^^^^^^

Otherwise the versioned symbol are not applied. Here is the correct nm output:

perex@pnote:~/src/1/svn.rocklinux-consulting.de/gsmp/trunk/lowlevel/src> nm ALSAHelper.so | grep snd_pcm_hw_params_get_channels_max

         U snd_pcm_hw_params_get_channels_max@@ALSA_0.9.0rc4

					Have fun,
						Jaroslav

-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, SuSE Labs

-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004 Premiere Conference on Open Tools Development and Integration See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn

author
#3 lore raw

Hi,

On: Sat, 17 Jan 2004 12:18:07 +0100 (CET),

Quoted 14 lines · Jaroslav Kysela
Quoted 3 lines
rene@idefix:~/develop/trunk/lowlevel/src$ g++ --shared -g -Wall -I.
-I../include -I../../dam/include -I../../utility/include -o
ALSAHelper.so ALSAHelper.cc

I tried that and it seems that you MUST link also this shared module against the asound library:

g++ --shared -g -Wall -I. -I../include -I../../dam/include -I../../utility/include -lasound -o ALSAHelper.so ALSAHelper.cc

                        ^^^^^^^^

Otherwise the versioned symbol are not applied. Here is the correct nm output:

Quoted 6 lines

perex@pnote:~/src/1/svn.rocklinux-consulting.de/gsmp/trunk/lowlevel/src> nm ALSAHelper.so | grep snd_pcm_hw_params_get_channels_max

         U snd_pcm_hw_params_get_channels_max@@ALSA_0.9.0rc4

					Have fun,
						Jaroslav

Ineed that did the trick! Thank you!

Have a nice weekend,
René Rebe

Signature · 12 lines
René Rebe - Europe/Germany/Berlin
  [email protected] [email protected]
http://www.rocklinux.org http://www.rocklinux-consulting.de
http://gsmp.tfh-berlin.de/gsmp http://gsmp.tfh-berlin.de/rene



-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
#4 lore raw
In reply to Jaroslav Kysela

Ah, thanks. That did the trick indeed.

Arve Knudsen

Quoted 35 lines · Jaroslav Kysela
Quoted 9 lines · Rene Rebe

Let's link a normal object and a shared obeject of the ALSAHelper:

rene@idefix:~/develop/trunk/lowlevel/src$ g++ -g -Wall -I. -I../include
-I../../dam/include -I../../utility/include -c -o ALSAHelper.o
ALSAHelper.cc
rene@idefix:~/develop/trunk/lowlevel/src$ g++ --shared -g -Wall -I.
-I../include -I../../dam/include -I../../utility/include -o
ALSAHelper.so ALSAHelper.cc

I tried that and it seems that you MUST link also this shared module against the asound library:

g++ --shared -g -Wall -I. -I../include -I../../dam/include -I../../utility/include -lasound -o ALSAHelper.so ALSAHelper.cc

                        ^^^^^^^^

Otherwise the versioned symbol are not applied. Here is the correct nm output:

perex@pnote:~/src/1/svn.rocklinux-consulting.de/gsmp/trunk/lowlevel/src> nm ALSAHelper.so | grep snd_pcm_hw_params_get_channels_max

         U snd_pcm_hw_params_get_channels_max@@ALSA_0.9.0rc4

					Have fun,
						Jaroslav

-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, SuSE Labs

Quoted 9 lines

-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004 Premiere Conference on Open Tools Development and Integration See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
Alsa-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel

-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004 Premiere Conference on Open Tools Development and Integration See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn