[vlc-devel] [PATCH 1/2] bank: enable static modules for mach-o binaries

Alexandre Janniaux ajanni at videolabs.io
Fri Mar 6 15:10:17 CET 2020


Hi,

It seems this patch is quite incorrect too, weak symbols in
the tools using mach-o seems to have a default semantic of
allowing the symbol to be absent during runtime but require
it to be present in compile time, meaning that what is above
cannot work as vlc_static_modules won't have definition and
with static libraries, only the first symbol seen in the
first object will be found.

In other words, it is much different from ELF, which tells
the linker that "it shouldn't care if the symbol is missing".

Would it make sense to allow a mechanism like dlopen on
ourselves and dlsym to achieve the same mechanism?

Regards,
--
Alexandre Janniaux
Videolabs

On Thu, Mar 05, 2020 at 07:25:25PM +0100, Alexandre Janniaux wrote:
> Static modules are available by overriding the vlc_static_modules
> symbol in the executable. To avoid exposing this feature by forcing the
> user to declare this symbol regardless of whether it was needed or not,
> it was only defined on ELF binaries which supports the weak attributes
> or when dynamic plugins are disabled as it becomes the only (thus
> mandatory) way to define plugins.
>
> Mach-O objects are also capable to define weak symbols, like defined
> for the VLC_WEAK symbol in the vlc_common.h file so also allow this
> mechanism when producing Mach-O objects.
>
> It is particularly useful to ship battery-included LibVLC builds and
> still allow external plugins in paths controlled by the application
> using the library.
> ---
>  src/modules/bank.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/modules/bank.c b/src/modules/bank.c
> index 36c4b30cdd..e8c956ebe6 100644
> --- a/src/modules/bank.c
> +++ b/src/modules/bank.c
> @@ -172,7 +172,7 @@ static vlc_plugin_t *module_InitStatic(vlc_plugin_cb entry)
>      return lib;
>  }
>
> -#if defined(__ELF__) || !HAVE_DYNAMIC_PLUGINS
> +#if defined(__ELF__) || defined(__MACH__) || !HAVE_DYNAMIC_PLUGINS
>  VLC_WEAK
>  extern vlc_plugin_cb vlc_static_modules[];
>
> --
> 2.25.1
>


More information about the vlc-devel mailing list