|
|
Message-ID: <Pine.BSM.4.64L.2511121844070.3777@herc.mirbsd.org>
Date: Wed, 12 Nov 2025 18:50:24 +0000 (UTC)
From: Thorsten Glaser <tg@...bsd.de>
To: musl@...ts.openwall.com
Subject: Re: Safe to load musl shared lib into glibc executable?
Fredrik Orderud dixit:
>My background is mostly from Windows where it's always been simple to
>link statically to the C library when building a shared library. The
>glibc and musl limitations in this area therefore came as a surprise
As a Unix user it’s less surprising. I can only assume that on
Windows, the “libc” does much less and that the various Win32
DLLs you’re also implicitly linking against do the shared state
parts.
There exist projects that embed a musl subset running on the
host libc (though for the one I have in mind that’s also a musl),
you’d have to do lots of work for that though. First, identify
what actual functions you need…
Other projects get around this problem by expecting the caller
to provide all necessary functions (and link with -Bsymbolic)
and not using any libc headers themselves. This would work like:
/* yourlib/extapi.h */
int yourlib_printf(const char *, ...);
/* yourlib/impl.c */
void foo() {
yourlib_printf("Hi!\n");
}
/* user/yourlib_glue.c */
#include <stdarg.h>
#include <stdio.h>
#include <yourlib/extapi.h>
int yourlib_printf(const char *msg, ...) {
int rv;
va_list ap;
va_start(ap, msg);
rv = vfprintf(stdout, msg, ap);
va_end(ap);
return (rv);
}
So basically, you put the binding of the libc functions
into the user’s responsibility.
You could even ship such a file.
Or just ship your library as source and expect users to
build it for their local systems, if that’s possible.
Good luck,
//mirabilos
--
Yay for having to rewrite other people's Bash scripts because bash
suddenly stopped supporting the bash extensions they make use of
-- Tonnerre Lombard in #nosec
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.