WSL: ELF section .note.ABI-tag breaks shared libraries
Your Windows build number: (Type ver at a Windows Command Prompt)
10.0.16299.192
Linux ananke 4.4.0-43-Microsoft #1-Microsoft Wed Dec 31 14:42:53 PST 2014 x86_64 GNU/Linux
Debian sid
What you’re doing and what’s happening: (Copy&paste specific commands and their output, or include screen shots)
Executing lupdate from Qt5 tools, LD_DEBUG=all ldd /usr/lib/libQt5Xml.so, etc.
Doesn’t treat libQt5Core.so.5 as a suitable library, as per
lupdate: error while loading shared libraries: libQt5Core.so.5: cannot open shared object file: No such file or directory
What’s wrong / what should be happening instead:
As long as ELF section called .note.ABI-tag exists, the library can’t be linked to by other shared objects. It can be executed directly by the ld-linux linker however.
The workaround is to strip --remove-section=.note.ABI-tag /usr/lib/libQt5Core.so.5.10.1.
See how the section’s presence influences file(1) output:
/usr/lib/libQt5Core.so.5.10.1: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=147dcf3333ff6b490dabb4028a217effa08013e3, for GNU/Linux 3.17.0, stripped
Finally, without the section:
/usr/lib/libQt5Core.so.5.10.1: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=147dcf3333ff6b490dabb4028a217effa08013e3, stripped
Strace of the failing command, if applicable[…]
openat of the library, read, lseek, close, barf out error message on the standard error file descriptor and exit_group.
Similarly LD_DEBUG=all shows opening the ELF without further information other than an error message.
3954: file=libQt5Core.so.5 [0]; needed by lupdate [0]
3954: find library=libQt5Core.so.5 [0]; searching
3954: search path=/usr/lib (system search path)
3954: trying file=/usr/lib/libQt5Core.so.5
3954: search cache=/etc/ld.so.cache
3954: search path=/usr/lib (system search path)
3954: trying file=/usr/lib/libQt5Core.so.5
3954:
lupdate: error while loading shared libraries: libQt5Core.so.5: cannot open shared object file: No such file or directory
After removing the tag, the runtime linking process proceeds normally.
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 32
- Comments: 45 (2 by maintainers)
Links to this issue
Commits related to this issue
- chroot-fixups/qt5-core-abi.sh: make libQt5Core.so.5 load on el7 kernel ... by stripping an incompatible ABI note as suggested here: https://github.com/Microsoft/WSL/issues/3023 — committed to csutils/csmock by kdudka 8 years ago
- Update Jenkinsfile Put several commands together and try to make libQt5Core.so work on Docker [1][2] [1] = https://github.com/dnschneid/crouton/wiki/Fix-error-while-loading-shared-libraries:-libQt5C... — committed to lirios/settings by plfiorini 7 years ago
- chore: fix wkhtmltoimage not work in docker centos host Fix: https://makingsense.atlassian.net/browse/DD-396 See (https://github.com/wkhtmltopdf/wkhtmltopdf/issues/4497#issuecomment-621004138 and ht... — committed to FromDoppler/conversion-tool by RodrigoPereyraDiaz 6 years ago
Okay, I’ve debugged this a bit, there’s actually another issue at hand here. Since I’ve got this on Arch with a requirement of 4.11.0 I thought it was just the fact that the kernel version is too low. However that’s not quite the case, and that’s why people with the older 3.17.0 version see this too.
This needs a bit of explanation how
glibcworks, so bear with me. The version check we ultimately run into can be found in theglibcsource file/sysdeps/unix/sysv/linux/dl-sysdep.cin theglibcsources. The responsible function there is_dl_discover_osversion. If the output of that function is too low in comparison to what.note.ABI-tagrequires,glibcrefuses to load the binary at all, see/elf/dl-load.cfor the respective code segment.Now,
_dl_discover_osversiontries discovering the kernel version by the following three methods:.notesection that identifies the kernel.uname(2)/proc/sys/kernel/osreleaseThe problem for us is going to be 1), the other two identify as kernel 4.4.0. To see what 1 gives, we need to dump the kernel vDSO ourselves. The easy way to do this is by opening
gdbon any arbitrary process, usinginfo proc mapto see the mapping of[vdso]and then dump it using thedumpcommand. For example, it looked like this for me:Now with
vdso.dumpon disk, we can analyze the sectionglibcparses, namely:The relevant part is the last 4 bytes, it is to be read as kernel version
0x03.0x0d.0x0b, i.e. kernel 3.14.11. This is not correct however, since WSL wants to identify as kernel 4.4.0, and this has to matchuname(2). This precisely is why people have been seeing the error with requirements of kernel 3.17.0.@therealkenc can you forward this to whoever is responsible for the vDSO?
For ArchLinux users, it’s possible to utilize pacman hooks to automatize the stripping of the
libQt5Core.soduring the installation or upgrade of Qt. Simply create a.hookfile in/etc/pacman.d/hookswith the following contents:Upon every Qt5 upgrade after that, the offending section will be stripped automatically. If
qt5-basewas already installed, simply force a reinstallation.This “atomic bomb” workaround helps too:
Will barf out a few errors where libraries are actually linker scripts. No ill effects.
This issue has been automatically closed since it has not had any activity for the past year. If you’re still experiencing this issue please re-file this as a new issue or feature request.
Thank you!
I had an error with libQt5Core on WSL and I fixed it by using this workaround: https://github.com/YosysHQ/nextpnr/issues/444#issuecomment-631558250 I hope WSL can fix this issue.
I haven’t read this but see fakeroot-tcp on AUR if it’s an issue for any of you.
I have reservations toward a Hyper-V basis for WSL2. Ballooning doesn’t solve memory pressure issues as it can result in OOM. Hyper-V is also inferior in several aspects (USB redirection, running X11 as server, lack of OSX support) to VMware and can’t be installed alongside it.
I can confirm that stripping the tag resolves the problem with Arch. Afterwards Qt5 works fine.
this also happens for octave install in WSL1 Ubuntu focal (20.04LTS) from store on Windows 10.0.18363.1556:
FYI, Debian ‘Buster’ release, which will be released within a few months, will be affected by this bug.
See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=927940 for the discussion in Debian.
Right, I’ll see if I can generate a simple example. It’s easily reproduced by using a similar trick to what Qt5 itself does. They explicitly add an assembly file with the section information and have a header that differentiates between the available kernel features it was configured with. Qt5 can use
renameat(2),getentropy(2)andstatx(2), which were introduced in 3.16, 3.17, and 4.11 accordingly. It should be noted that WSL (as of 1809 at least) supports all three syscalls despite identifying as 4.4. I suspect the original reason people blamedrenameat(2)is related to this, too - if you configured Qt5 with it, it requires kernel 3.16, but to glibc it appears as if 3.14.11 was in use, making the binary invalid.Aside from the mismatch, which can be easily reproduced and argued why it’s an issue - LSB also demands that LSB compliant binaries require the proper kernel version, and if
renameat(2)is used, it should be 3.16 - the second problem at hand here is that the kernel version of 4.4 is too low. It makes little sense to retain an older kernel identifier other than for kernel modules, which WSL obviously does not have.That aside, I don’t understand why Qt5 would be entirely out of scope. Qt is not a GUI library in itself, and there’s a lot of features in the library that have nothing to do with GUI or hardware abstractions, like XML parsers, an SQL abstraction layer, networking, concurrency extensions, and these are also common place in the C++ world, even on servers. The problem also has nothing to do with the combination of Qt and certain distros, but rather depends on what syscalls are exposed in the glibc of the system the binary is being built on. If you were to compile Qt5 yourself on Ubuntu, you’d still run into this problem, albeit not in the
statx(2)case, since it took until glibc 2.28 for that to be implemented in the C library. On the upcoming Ubuntu 19.04, this is going to be the case, though.@therealkenc Actually, the glibc dynamic linker looks at the ABI notes and refuses to load incompatible DSOs. To determine the kernel version, it prefers the version reported in the vDSO, followed by uname, followed by the contents of
/proc/sys/kernel/osrelease. I wonder if the version in the vDSO isn’t 4.4.Hi, I found a workaround by leverage ld.so to load ELF so WSL won’t need to parse the problematic ELF file.
Here is my shim script: https://github.com/Inndy/dotfiles/blob/73c86b582d5c8404ab7e0f5a6f40ca6a9078f4c1/bin/fix-wsl-v1-elf-shim
As detailed in nextpnr #444 post-close comments, I am seeing this error in a fresh WSL1 Ubuntu 20.04 install:
edit: version info WSL on
Microsoft Windows [Version 10.0.18362.836]Reproducible on Gentoo with Qt-5.11.1, Glibc-2.27 and gcc-8.1.0
@sthalik : Thanks for your “atomic bomb”, this one saved my day! 👍
Yes, it would certainly be interesting to see the output of
objdump -s -j .note.ABI-tag /usr/lib/libQt5Core.so.5.10.1. So far, we only know that the object requires kernel version 3.17.If the Windows kernel self-identifies itself as something earlier than kernel version 3.17, then the dynamic linker is completely right to ignore the object.