On 4/16/21 11:12 AM, Thomas Klausner wrote:
> Hi Ryan!
>
> Thanks for the reply.
>
> Bob's reply was quite helpful already with his hint that nothing
> should link against softokn3 or freebl. This was a bug in pkgsrc
> previously, but I fixed it after his message. Nothing in pkgsrc now
> links against either of the two directly. I think I followed all of
> his advice.
>
> nss seems to take great care to be interoperable with openssl. But I
> still don't understand how this works in detail. Perhaps you can shed
> some more light on this to help me debug this problem.
>
> Bob wrote that NSS hides the conflicting symbols through a dynamically
> loaded object and a function table. I assume this means using
> dlopen(). I'm not sure about the function table.
NSS hides the symbols with shared libraries that only export a curated
set of public symbols. Each nss shared library has it's own symbol list
found in {sharedlibname}.def so lib/nss/nss.def lib/util/nssutil.def
lib/ssl/ssl.def etc.
The NSS build system massages this file to whatever system the OS uses
to create an use an explicit export list for your shared library.
When you link with NSS, you need to link with the NSS shared library,
namley libnss3.so libnssutil3.so libssl3.so and libsmime3.so (depending
on how much of NSS you need). libsoftken3 will be automatically loaded
by libnss3.so and it in term will automatically load libfreebl* as
needed. So only the last two are dlopened. You should not link with any
libnss*.a files, or all bets are off on working with something like openssl.
If you are doing all this and still running into issues, it's likely the
build system (either your own or the NSS build system) isn't correctly
processing the .def file for your platform. The command to process the
.def file is set with the symbol PROCESS_MAP_FILE and is set in your
{OS}.mk file in nss/coreconf.
Linux, for instance, sets the command as follows:
PROCESS_MAP_FILE = grep -v ';-' $< | \
sed -e 's,;+,,' -e 's; DATA ;;' -e 's,;;,,' -e 's,;.*,;,' > $@
This removes all the lines with ;- , then removes all occurrences of
';+',' DATA ',';;', and then all commands '; to the end of the line'
Linux later adds the directive -Wl,-c,$(MAPFILE) to it's shared library
linking command.
It looks like openBSD has the same processing line as linux, and adds
-Wl,--version-script,$(MAPFILE) which sounds right to me.
(Some unsupported OSs ignore the MAPFILE, and they could be subject to
symbol collisions).
bob