On Tue, Apr 15, 2025 at 10:41:22AM +0200, Michel Dänzer wrote:
> Given that different variants of libvulkan_*.so are located in separate 
> search paths, is there any scenario other than a system misconfiguration 
> which would result in an attempt to load the wrong one?

I fear the answer to this question is not obvious and I can only
partially answer it.

For one thing, I note that the idea of separate search paths is a nice
one. We want to think of architectures and their library directories as
separate. That is not reality. The glibc dynamic loader searches every
library path referenced from /etc/ld.so.conf. On Debian multiarch
systems that happens to be every architecture for which libc6 is
installed. You can easily see this on a multiarch system by inspecting
/etc/ld.so.cache as it contains libraries for multiple architectures.

I can also tell you that running a kfreebsd-amd64 ELF executable on a
Linux amd64 kernel works "too well". The Linux kernel cannot tell these
architectures apart from the ELF header and happily runs it. As the
syscall ABI is completely different, you end up doing stuff you never
wanted such as resetting your system clock before the program quickly
fails.

Loading shared libraries is a different beast as it is done by glibc.
There the story looks different. If you attempt to load incompatible
libraries you tend to see the error "wrong ELF class: ..." from
dlerror() after having tried loading it with dlopen. Not so, if your
architectures are too similar. For instance, attempting to load an armel
library into an armhf executable, I got "cannot open shared object file:
No such file or directory" (and note that it successfully opened but not
mapped the file).

I cannot tell how this translates to the vulkan case. However, we
learned two aspects in the process:
 * On Debian systems, the loader will search all multiarch directories
   for compatible libraries.
 * The ELF class is not sufficient to tell armel and armhf apart.

Whether these are convincing arguments is up to you in the end. I
suspect further research is needed.

Helmut

Reply via email to