Date: Sun, 27 Apr 2025 10:26:13 -0400 From: Mark Johnston <markj@freebsd.org> To: Andriy Gapon <avg@freebsd.org> Cc: Konstantin Belousov <kostikbel@gmail.com>, FreeBSD Current <current@freebsd.org> Subject: Re: RTLD_DEEPBIND question Message-ID: <aA4-hQ6xrF2dD-sJ@nuc> In-Reply-To: <59db8ace-770f-4f73-976f-411f6de0885a@FreeBSD.org> References: <0b3dda4e-53e4-40e5-9484-8b5ffb84e658@FreeBSD.org> <aALjHwFnFKChuAdR@kib.kiev.ua> <900c8521-559a-47b5-acaa-ae941f6852c4@freebsd.org> <fd12cce4-7e6b-4ab6-bced-b36e98c995ba@FreeBSD.org> <7c4e1682-d797-493c-8326-08d51dde3359@FreeBSD.org> <aAN69URjEJFuOLxR@kib.kiev.ua> <aAN9NH1IR-gZceP4@kib.kiev.ua> <e528f630-9d6e-4ec6-b7e6-30b5a978f5c8@freebsd.org> <59db8ace-770f-4f73-976f-411f6de0885a@FreeBSD.org>
index | next in thread | previous in thread | raw e-mail
On Thu, Apr 24, 2025 at 08:56:44AM +0300, Andriy Gapon wrote: > On 23/04/2025 21:56, Andriy Gapon wrote: > > BTW, I've been wondering how illumos avoids the problem even though they > > do not use any special dlopen flags. > > It turns out that they link almost all system shared libraries with > > -Bdirect option (which is Solaris/illumos specific). > > It's somewhat similar to, but different from, -Bsymbolic. > > https://docs.oracle.com/cd/E23824_01/html/819-0690/aehzq.html#scrolltoc > > https://docs.oracle.com/cd/E36784_01/html/E36857/gejfe.html > > Oh, and it looks like there is an even better explanation for illumos. > There is a version map file for libdtrace which explicitly lists API > functions and makes everything else local. > https://github.com/illumos/illumos-gate/blob/master/usr/src/lib/libdtrace/common/mapfile-vers > > I wonder why we didn't do the same when porting. > Maybe we should do that now? I don't have any objection, but I believe adding a version map after the fact doesn't accomplish much, assuming that we care deeply about ABI stability in libdtrace.so (I'm not sure we do though). > > I think that on FreeBSD we should use symbol visibility attributes or a > > symbol map to hide (make local) symbols that are not expected to be > > interposed or have a high chance to be interposed by accident. > > > > IMO, yyparse should definitely get that treatment. > > > > I think that approach would be better than magic rtld tricks. > > Especially because the tricks do not work with the current rtld. > > I'd rather make a change to libdtrace.so than to rtld. > > This, while not as nice as the illumos solution, fixes my specific issue: > diff --git a/cddl/lib/libdtrace/Makefile b/cddl/lib/libdtrace/Makefile > index d086fffb07bc..58054d129b49 100644 > --- a/cddl/lib/libdtrace/Makefile > +++ b/cddl/lib/libdtrace/Makefile > @@ -146,7 +146,8 @@ CFLAGS+= -fsanitize=address -fsanitize=undefined > LDFLAGS+= -fsanitize=address -fsanitize=undefined > .endif > > -LIBADD= ctf elf proc pthread rtld_db xo > +VERSION_MAP= ${.CURDIR}/Symbol.map > +LIBADD= ctf elf proc pthread rtld_db xo > > CLEANFILES= dt_errtags.c dt_names.c > > diff --git a/cddl/lib/libdtrace/Symbol.map b/cddl/lib/libdtrace/Symbol.map > new file mode 100644 > index 000000000000..89ee9de65209 > --- /dev/null > +++ b/cddl/lib/libdtrace/Symbol.map > @@ -0,0 +1,4 @@ > +{ > + local: > + yy*; > +}; This just gives the lexer/parser symbols in libdtrace.so local visibility? I think that's fine.help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?aA4-hQ6xrF2dD-sJ>
