mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-03 09:01:50 -05:00
fix implementation of bind now ltdl loader for libtool 2.2
This commit is contained in:
parent
e4aa5f2115
commit
b8fe1b683e
1 changed files with 31 additions and 26 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
/***
|
/***
|
||||||
This file is part of PulseAudio.
|
This file is part of PulseAudio.
|
||||||
|
|
||||||
Copyright 2004-2006 Lennart Poettering
|
Copyright 2004-2008 Lennart Poettering
|
||||||
Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
|
Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
|
||||||
|
|
||||||
PulseAudio is free software; you can redistribute it and/or modify
|
PulseAudio is free software; you can redistribute it and/or modify
|
||||||
|
|
@ -39,8 +39,6 @@
|
||||||
#include <pulse/i18n.h>
|
#include <pulse/i18n.h>
|
||||||
|
|
||||||
#include <pulsecore/macro.h>
|
#include <pulsecore/macro.h>
|
||||||
#include <pulsecore/mutex.h>
|
|
||||||
#include <pulsecore/thread.h>
|
|
||||||
#include <pulsecore/log.h>
|
#include <pulsecore/log.h>
|
||||||
|
|
||||||
#include "ltdl-bind-now.h"
|
#include "ltdl-bind-now.h"
|
||||||
|
|
@ -67,16 +65,13 @@
|
||||||
to set $LT_BIND_NOW before starting the pulsaudio binary.
|
to set $LT_BIND_NOW before starting the pulsaudio binary.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static lt_module bind_now_open(lt_user_data d, const char *fname, lt_dladvise advise)
|
static lt_module bind_now_open(lt_user_data d, const char *fname, lt_dladvise advise) {
|
||||||
{
|
|
||||||
lt_module m;
|
lt_module m;
|
||||||
|
|
||||||
pa_assert(fname);
|
pa_assert(fname);
|
||||||
|
|
||||||
if (!(m = dlopen(fname, PA_BIND_NOW))) {
|
if (!(m = dlopen(fname, PA_BIND_NOW))) {
|
||||||
#ifdef HAVE_LT_DLMUTEX_REGISTER
|
lt_dlseterror(LT_ERROR_CANNOT_OPEN);
|
||||||
libtool_set_error(dlerror());
|
|
||||||
#endif
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -88,9 +83,7 @@ static int bind_now_close(lt_user_data d, lt_module m) {
|
||||||
pa_assert(m);
|
pa_assert(m);
|
||||||
|
|
||||||
if (dlclose(m) != 0){
|
if (dlclose(m) != 0){
|
||||||
#ifdef HAVE_LT_DLMUTEX_REGISTER
|
lt_dlseterror(LT_ERROR_CANNOT_CLOSE);
|
||||||
libtool_set_error(dlerror());
|
|
||||||
#endif
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -104,49 +97,61 @@ static lt_ptr bind_now_find_sym(lt_user_data d, lt_module m, const char *symbol)
|
||||||
pa_assert(symbol);
|
pa_assert(symbol);
|
||||||
|
|
||||||
if (!(ptr = dlsym(m, symbol))) {
|
if (!(ptr = dlsym(m, symbol))) {
|
||||||
#ifdef HAVE_LT_DLMUTEX_REGISTER
|
lt_dlseterror(LT_ERROR_SYMBOL_NOT_FOUND);
|
||||||
libtool_set_error(dlerror());
|
|
||||||
#endif
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static lt_dlvtable *bindnow_loader = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void pa_ltdl_init(void) {
|
void pa_ltdl_init(void) {
|
||||||
|
|
||||||
#ifdef PA_BIND_NOW
|
#ifdef PA_BIND_NOW
|
||||||
static const lt_dlvtable *dlopen_loader;
|
const lt_dlvtable *dlopen_loader;
|
||||||
static lt_dlvtable bindnow_loader;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pa_assert_se(lt_dlinit() == 0);
|
pa_assert_se(lt_dlinit() == 0);
|
||||||
|
|
||||||
#ifdef PA_BIND_NOW
|
#ifdef PA_BIND_NOW
|
||||||
/* Already initialised */
|
/* Already initialised */
|
||||||
if (dlopen_loader)
|
if (bindnow_loader)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!(dlopen_loader = lt_dlloader_find("dlopen"))) {
|
if (!(dlopen_loader = lt_dlloader_find((char*) "lt_dlopen"))) {
|
||||||
pa_log_warn(_("Failed to find original dlopen loader."));
|
pa_log_warn(_("Failed to find original lt_dlopen loader."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(&bindnow_loader, dlopen_loader, sizeof(bindnow_loader));
|
if (!(bindnow_loader = malloc(sizeof(lt_dlvtable)))) {
|
||||||
bindnow_loader.name = "bind-now-loader";
|
pa_log_error(_("Failed to allocate new dl loader."));
|
||||||
bindnow_loader.module_open = bind_now_open;
|
return;
|
||||||
bindnow_loader.module_close = bind_now_close;
|
}
|
||||||
bindnow_loader.find_sym = bind_now_find_sym;
|
|
||||||
bindnow_loader.priority = LT_DLLOADER_PREPEND;
|
memcpy(bindnow_loader, dlopen_loader, sizeof(*bindnow_loader));
|
||||||
|
bindnow_loader->name = "bind-now-loader";
|
||||||
|
bindnow_loader->module_open = bind_now_open;
|
||||||
|
bindnow_loader->module_close = bind_now_close;
|
||||||
|
bindnow_loader->find_sym = bind_now_find_sym;
|
||||||
|
bindnow_loader->priority = LT_DLLOADER_PREPEND;
|
||||||
|
|
||||||
/* Add our BIND_NOW loader as the default module loader. */
|
/* Add our BIND_NOW loader as the default module loader. */
|
||||||
if (lt_dlloader_add(&bindnow_loader) != 0)
|
if (lt_dlloader_add(bindnow_loader) != 0) {
|
||||||
pa_log_warn(_("Failed to add bind-now-loader."));
|
pa_log_warn(_("Failed to add bind-now-loader."));
|
||||||
|
free(bindnow_loader);
|
||||||
|
bindnow_loader = NULL;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void pa_ltdl_done(void) {
|
void pa_ltdl_done(void) {
|
||||||
pa_assert_se(lt_dlexit() == 0);
|
pa_assert_se(lt_dlexit() == 0);
|
||||||
|
|
||||||
|
#ifdef PA_BIND_NOW
|
||||||
|
/* lt_dlexit() will free our loader vtable, hence reset our
|
||||||
|
* pointer to it here */
|
||||||
|
bindnow_loader = NULL;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue