Skip to contentSkip to conversation

snd_dlsym: only do versioning checks if built --with-versioning

PATCH Applied John Spencer 2 participants 2 messages Nov 15, 2014 – Nov 16, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 snd_dlsym: only do versioning checks if built --with-versioning

From 291553a0132936611d48f41e924601dff8941537 Mon Sep 17 00:00:00 2001
From: John Spencer <[email protected]>
Date: Sat, 15 Nov 2014 13:41:00 +0100
Subject: [PATCH] snd_dlsym: only do versioning checks if built --with-versioning

a combination of some of the following garbage collecting LD/CFLAGS -Os -g0 -fdata-sections -ffunction-sections -s -Wl,--gc-sections -fno-unwind-tables -fno-asynchronous-unwind-tables causes the symbol versioning marker symbols to be removed from BSS since they're otherwise unreferenced. this causes dlsym failing to find them which results in runtime breakage:

$ alsamixer
ALSA lib dlmisc.c:142:(snd_dlsym_verify) unable to verify version for symbol snd_config_hook_load
ALSA lib conf.c:3328:(snd_config_hooks_call) symbol snd_config_hook_load is not defined inside (null)
ALSA lib conf.c:3788:(snd_config_update_r) hooks failed, removing configuration
cannot open mixer: No such device or address

correct DSO:

$ objdump -T libasound.so.2.strip | grep _snd_config_hook_load_dlsym_config_hook_001
001196bc g    DO .bss   00000001 _snd_config_hook_load_dlsym_config_hook_001

incorrect DSO:

$ objdump -T libs/libasound.so.2 | grep _snd_config_hook_load_dlsym_config_hook_001
00000000 g    DO *ABS*  00000001 _snd_config_hook_load_dlsym_config_hook_001

since alsa was built with --without-versioning, doing those versioning checks at all is unnecessary and harmful and thus now disabled in this case.

---
 src/dlmisc.c | 2 ++
 1 file changed, 2 insertions(+)

From 291553a0132936611d48f41e924601dff8941537 Mon Sep 17 00:00:00 2001
From: John Spencer <[email protected]>
Date: Sat, 15 Nov 2014 13:41:00 +0100
Subject: [PATCH] snd_dlsym: only do versioning checks if built --with-versioning

a combination of some of the following garbage collecting LD/CFLAGS -Os -g0 -fdata-sections -ffunction-sections -s -Wl,--gc-sections -fno-unwind-tables -fno-asynchronous-unwind-tables causes the symbol versioning marker symbols to be removed from BSS since they're otherwise unreferenced. this causes dlsym failing to find them which results in runtime breakage:

$ alsamixer
ALSA lib dlmisc.c:142:(snd_dlsym_verify) unable to verify version for symbol snd_config_hook_load
ALSA lib conf.c:3328:(snd_config_hooks_call) symbol snd_config_hook_load is not defined inside (null)
ALSA lib conf.c:3788:(snd_config_update_r) hooks failed, removing configuration
cannot open mixer: No such device or address

correct DSO:

$ objdump -T libasound.so.2.strip | grep _snd_config_hook_load_dlsym_config_hook_001
001196bc g    DO .bss   00000001 _snd_config_hook_load_dlsym_config_hook_001

incorrect DSO:

$ objdump -T libs/libasound.so.2 | grep _snd_config_hook_load_dlsym_config_hook_001
00000000 g    DO *ABS*  00000001 _snd_config_hook_load_dlsym_config_hook_001

since alsa was built with --without-versioning, doing those versioning checks at all is unnecessary and harmful and thus now disabled in this case.

---
 src/dlmisc.c | 2 ++
 1 file changed, 2 insertions(+)
src/dlmisc.c +2 -0
index 4b8a02c..62f7047 100644
@@ -177,11 +177,13 @@ void *snd_dlsym(void *handle, const char *name, const char *version)
 	}
 #endif
 #ifdef HAVE_LIBDL
+#ifdef VERSIONED_SYMBOLS
 	if (version) {
 		err = snd_dlsym_verify(handle, name, version);
 		if (err < 0)
 			return NULL;
 	}
+#endif
 	return dlsym(handle, name);
 #else
 	return NULL;
Signature · 1 line
1.8.4
Applied
#1 lore raw

At Sat, 15 Nov 2014 13:55:54 +0100,

Quoted 29 lines · John Spencer

From 291553a0132936611d48f41e924601dff8941537 Mon Sep 17 00:00:00 2001
From: John Spencer <[email protected]>
Date: Sat, 15 Nov 2014 13:41:00 +0100
Subject: [PATCH] snd_dlsym: only do versioning checks if built --with-versioning

a combination of some of the following garbage collecting LD/CFLAGS

(quoted diff) +0 -2
-Os -g0 -fdata-sections -ffunction-sections -s -Wl,--gc-sections
-fno-unwind-tables -fno-asynchronous-unwind-tables

causes the symbol versioning marker symbols to be removed from BSS since they're otherwise unreferenced. this causes dlsym failing to find them which results in runtime breakage:

$ alsamixer
ALSA lib dlmisc.c:142:(snd_dlsym_verify) unable to verify version for 
symbol snd_config_hook_load
ALSA lib conf.c:3328:(snd_config_hooks_call) symbol snd_config_hook_load 
is not defined inside (null)
ALSA lib conf.c:3788:(snd_config_update_r) hooks failed, removing 
configuration
cannot open mixer: No such device or address

correct DSO:

$ objdump -T libasound.so.2.strip | grep 
_snd_config_hook_load_dlsym_config_hook_001
001196bc g    DO .bss   00000001 _snd_config_hook_load_dlsym_config_hook_001

incorrect DSO:

Quoted 8 lines
$ objdump -T libs/libasound.so.2 | grep 
_snd_config_hook_load_dlsym_config_hook_001
00000000 g    DO *ABS*  00000001 _snd_config_hook_load_dlsym_config_hook_001

since alsa was built with --without-versioning, doing those versioning checks at all is unnecessary and harmful and thus now disabled in this case.

Thanks, applied.

Takashi