Skip to content

ELF section .note.ABI-tag breaks shared libraries #3023

Description

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.

Activity

  1. sthalik commented on Mar 14, 2018

    @sthalik
    Author

    This "atomic bomb" workaround helps too:

    find /lib /usr/lib /usr/libexec -name '*.so' | xargs strip --remove-section=.note.ABI-tag
    

    Will barf out a few errors where libraries are actually linker scripts. No ill effects.

  2. jkj commented on Apr 17, 2018

    @jkj

    Just came across this in a Google search. Not sure if it is relevant or not but just FYI glibc creates an ABI-invalid .note section for that exact section. I have just filed a bug against glibc about that.
    https://sourceware.org/bugzilla/show_bug.cgi?id=23072
    I don't know exactly what lupdate is, but if it is a strictly conforming gABI ELF processor it will get wrong values from that section. Just in case that helps.

  3. sthalik commented on May 17, 2018

    @sthalik
    Author

    Works for me on Linux in a VM. The ELF standard notwithstanding, having the runtime linker not work due to a quirk in WSL is an issue.

    Interestingly enough, the newer shared objects added the option to call them directly, having them say more or less "I'm a library". Calling that .so directly works, it's only linking to it that's broken.

  4. fweimer commented on May 19, 2018

    @fweimer

    What, exactly, is causing this? The ELF note in a shared object is only parsed by the glibc dynamic linker during program loading, not the kernel, so it is unclear to me why there would be a difference between Linux and Windows in this context.

    Perhaps the auxiliary vector contains some data which tells glibc not to load the shared object with this kind of ABI note?

  5. therealkenc commented on May 19, 2018

    @therealkenc

    What, exactly, is causing this? The ELF note in a shared object is only parsed by the glibc dynamic linker during program loading, not the kernel

    I've been also curious for my own edification: What, exactly, is special about the libQt5Core.so build process that generates the (let's call it) unusual binary? I understand the bug cited by jkj. I am just not clear on why libQt5Core trips it in this scenario. How would one go about creating a helloworld.so library that exhibits the fail? And why does libQt5Core generate the binary that way? I could do a deep dive but I suspect someone in this thread (or Ben) already takes the reason as obvious.

  6. fweimer commented on May 19, 2018

    @fweimer

    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.

  7. therealkenc commented on May 19, 2018

    @therealkenc

    If the Windows kernel self-identifies itself as something earlier than kernel version 3.17

    WSL self identifies as 4.4. But I'd be real real surprised if the linker looks. [I have been surprised before though.]

  8. fweimer commented on May 19, 2018

    @fweimer

    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.

  9. sthalik commented on May 19, 2018

    @sthalik
    Author

    I can't remember the Linux distribution that had the binary. It was either Debian sid or Arch testing. Sorry guys. You can list sections for your own binaries though.

  10. therealkenc commented on May 19, 2018

    @therealkenc

    I can't remember the Linux distribution that had the binary.

    Ah. That was kinda relevant to mention in the the OP (grumble). This is possibly related to #2820, which was on Arch. In that issue libQt5Core.so.5 exists but could not be opened. The discussion there subsequently went downhill to what was almost certainly a rename2() blind alley, and was ultimately closed for lack of a repro. Something this issue is in need of as well; and is likely a contributing factor to the chirping crickets.

  11. sthalik commented on May 28, 2018

    @sthalik
    Author

    Noah Baxter (@noahbaxter) it's somewhere in site-packages.

    therealkenc the issue's reproducible on Debian sid. You can install it into a chroot via debootstrap into the default Ubuntu environment, or some other distro on MSFT Store. When debootstrap doesn't work, download cdebootstrap-static and manually unpack the .deb archive. That one works even on Android.

    No idea what causes it to begin with, binutils, gcc, GNU libc or something else...?

  12. Yamakuzure commented on Jun 22, 2018

    @Yamakuzure

    Reproducible on Gentoo with Qt-5.11.1, Glibc-2.27 and gcc-8.1.0

    Stanislaw Halik (@sthalik) : Thanks for your "atomic bomb", this one saved my day! 👍

  13. ChrisTX commented on Aug 8, 2018

    @ChrisTX

    Ah. That was kinda relevant to mention in the the OP (grumble). This is possibly related to #2820, which was on Arch.

    I can confirm that stripping the tag resolves the problem with Arch. Afterwards Qt5 works fine.

  14. FrankHB commented on Sep 27, 2018

    @FrankHB

    This "atomic bomb" workaround helps too:

    find /lib /usr/lib /usr/libexec -name '*.so' | xargs strip --remove-section=.note.ABI-tag
    

    Will barf out a few errors where libraries are actually linker scripts. No ill effects.

    This would break programs relying on stripped information in the binary files. For example, modified /usr/lib/ld-2.28.so (linked as /usr/lib/ld-linux-x86-64.so.2) would not work with valgrind on my Arch Linux instance. This would be fixed by reinstalling the corresponding package which provides the unmodified binary files, which would also void the effect of strip command.

  15. 22 remaining items

  16. py563 commented on May 10, 2019

    @py563

    My bad, I did not have binutils in WSL. as it was not throwing any error I didn't realize what was wrong.

    i got same issue when installing anaconda3, i found the .so file and trying to run xargs command. i think it is not responding. the shell prompt just blinks indefinitely.

  17. sthalik commented on Jun 21, 2019

    @sthalik
    Author

    The author of that ArchWSL known issues Wiki page just picked their personal pet peeves (Qt and, utterly at random, fakeroot)

    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.

  18. ericLemanissier commented on Dec 4, 2019

    @ericLemanissier

    For those trying to build qt on WSL (like me), the workaround is to use configure arguments : -no-feature-statx -no-feature-getentropy -no-feature-renameat2 (I did not try to reduce to the minimum arguments, so maybe only one of those is actually needed)
    EDIT: setting only -no-feature-getentropy fixes the failure

  19. gojimmypi commented on May 19, 2020

    @gojimmypi

    As detailed in nextpnr #444 post-close comments, I am seeing this error in a fresh WSL1 Ubuntu 20.04 install:

    error while loading shared libraries: libQt5Core.so.5: cannot open shared object file: No such file or directory
    
    $ ls /lib/x86_64-linux-gnu/libQt5Core.so.5 -al
    lrwxrwxrwx 1 root root 20 Apr  9 00:57 /lib/x86_64-linux-gnu/libQt5Core.so.5 -> libQt5Core.so.5.12.8
    
    $ file /lib/x86_64-linux-gnu/libQt5Core.so.5.12.8
    /lib/x86_64-linux-gnu/libQt5Core.so.5.12.8: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=e54a6cea97c3942fbcec1973574545fb3ad74015, for GNU/Linux 3.17.0, stripped
    
    $ uname -a
    Linux DESKTOP-AHQNIJN 4.4.0-18362-Microsoft #836-Microsoft Mon May 05 16:04:00 PST 2020 x86_64 x86_64 x86_64 GNU/Linux
    
    

    edit: version info WSL on Microsoft Windows [Version 10.0.18362.836]

    No LSB modules are available.
    Distributor ID: Ubuntu
    Description:    Ubuntu 20.04 LTS
    Release:        20.04
    Codename:       focal
    Python 2.7.18rc1
    Python 3.8.2
    cmake version 3.16.3
    
    CMake suite maintained and supported by Kitware (kitware.com/cmake).
    clang version 10.0.0-4ubuntu1
    Target: x86_64-pc-linux-gnu
    Thread model: posix
    InstalledDir: /usr/bin
    qtf_default Version: 5.12.8+dfsg-0ubuntu1
    libboost-all-dev Version: 1.71.0.0ubuntu2
    build-essential Version: 12.8ubuntu1
    clang Version: 1:10.0-50~exp1
    bison Version: 2:3.5.1+dfsg-1
    flex Version: 2.6.4-6.2
    libreadline-dev Version: 8.0-4
    gawk Version: 1:5.0.1+dfsg-1
    tcl-dev Version: 8.6.9+1
    libffi-dev Version: 3.3-4
    git Version: 1:2.25.1-1ubuntu3
    mercurial Version: 5.3.1-1ubuntu1
    graphviz Version: 2.42.2-3build2
    xdot Version: 1.1-2
    pkg-config Version: 0.29.1-0ubuntu4
    python
    python3 Version: 3.8.2-0ubuntu2
    libftdi-dev Version: 0.20-4build8
    qt5-default Version: 5.12.8+dfsg-0ubuntu1
    python3-dev Version: 3.8.2-0ubuntu2
    libboost-dev Version: 1.71.0.0ubuntu2
    nextpnr-ecp5: error while loading shared libraries: libQt5Core.so.5: cannot open shared object file: No such file or directory
    
    binutils is already the newest version (2.34-6ubuntu1).
    binutils set to manually installed.
    The following package was automatically installed and is no longer required:
      guile-2.0-libs
    
  20. 1337bowen commented on Jun 26, 2020

    @1337bowen

    I had an error with libQt5Core on WSL and I fixed it by using this workaround: YosysHQ/nextpnr#444 (comment)
    I hope WSL can fix this issue.

  21. mikofski commented on May 19, 2021

    @mikofski

    this also happens for octave install in WSL1 Ubuntu focal (20.04LTS) from store on Windows 10.0.18363.1556:

    $ sudo apt install octave
    
    $ octave  # doesn't work
    octave: error while loading shared libraries: libQt5Core.so.5: cannot open shared object file: No such file or directory
    
    $ sudo strip --remove-section=.note.ABI-tag /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 
    
    $ octave  # works fine
    
  22. thisisnotmyrealname commented on Jun 26, 2022

    @thisisnotmyrealname

    Considering running GUI linux apps in win11 is supposed to be a feature, you'd think this 4+ year old bug would have been looked at

  23. fweimer commented on Jul 10, 2022

    @fweimer

    glibc 2.36 will remove the kernel version check. From the NEWS file:

    • The Linux kernel version check has been removed along with the
      LD_ASSUME_KERNEL environment variable. The minimum kernel used to built
      glibc is still provided through NT_GNU_ABI_TAG ELF note and also printed
      when libc.so is issued directly.
  24. afidegnum commented on Nov 28, 2022

    @afidegnum

    I'm also facing a similar situation, applying the patch strip --remove-section=.note.ABI-tag at anywhere Qt5Core.so is located didn't help. What else can i do ?

  25. microsoft-github-policy-service commented on Feb 1, 2024

    @microsoft-github-policy-service
    Contributor

    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!

  26. Inndy commented on Dec 7, 2024

    @Inndy

    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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions