mentebinaria / readpe

The PE file analysis toolkit
GNU General Public License v2.0
676 stars 128 forks source link

readpe: symbol lookup error: /usr/lib/libpe.so.1: undefined symbol: _ZGVdN4v_log2 #199

Closed AkechiShiro closed 10 months ago

AkechiShiro commented 1 year ago

Describe the bug Installed readpe from the AUR, ran the command

To Reproduce Please provide us with:

Expected behavior Should work

Additional context Add any other context about the problem here.

GoGoOtaku commented 1 year ago

_ZGVdN4v_log2 is part of glibc or to be more precise it it is part of glibc's vector math library (libmvec.so) To me this looks like a linking error. The compiler did properly optimize the code to AVX2 but the linker didn't get the memo. I am not sure how this would happen tbh but I look into it. I will spin up an arch VM sometime next week and try it for myself.

As an aside: Am I right to assume that you are using x86/amd64 and glibc? glibc is the default so unless you explicitly chose another C library it should be glibc. Can you run ldd on your readpe? (ldd $(which readpe) should do it) and tell me libmvec.so is in the list? Is your processor older than 2014? If it was around there could you try lscpu and check if avx2 is in the flags section?

AkechiShiro commented 12 months ago

Yes I am using glibc and x86/amd64, glibc is the default, the only thing that could impact the glibc may be that I have nix installed as well and have paths for Nix in my PATH variable, not sure if Nix comes with it's own glibc

AkechiShiro commented 12 months ago

@GoGoOtaku ldd output :

    linux-vdso.so.1 (0x00007ffca2d70000)
    libpe.so.1 => /usr/lib/libpe.so.1 (0x00007f6a68edf000)
    libc.so.6 => /usr/lib/libc.so.6 (0x00007f6a68cfd000)
    libcrypto.so.3 => /usr/lib/libcrypto.so.3 (0x00007f6a687ff000)
    /lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x00007f6a68f45000)
AkechiShiro commented 12 months ago

Processor is not older than 2014 :

Architecture:            x86_64
  CPU op-mode(s):        32-bit, 64-bit
  Address sizes:         43 bits physical, 48 bits virtual
  Byte Order:            Little Endian
CPU(s):                  8
  On-line CPU(s) list:   0-7
Vendor ID:               AuthenticAMD
  Model name:            AMD Ryzen 7 PRO 3700U w/ Radeon Vega Mobile Gfx
    CPU family:          23
    Model:               24
    Thread(s) per core:  2
    Core(s) per socket:  4
    Socket(s):           1
    Stepping:            1
    Frequency boost:     enabled
    CPU(s) scaling MHz:  72%
    CPU max MHz:         2300.0000
    CPU min MHz:         1400.0000
    BogoMIPS:            4592.34

2017 Zen+ architecture on a T495 Thinkpad Lenovo latpop. AVX2 is supported image

AkechiShiro commented 12 months ago

glibc version :

core/glibc 2.38-7 [0 B 47.33 MiB] [Installed]
    GNU C Library
core/lib32-glibc 2.38-7 [0 B 18.04 MiB] [Installed]
    GNU C Library (32-bit)

Glibc from Nix : image

GoGoOtaku commented 12 months ago

I tried building it on a fresh vm and it looks like the PKGBUILD is working.

@GoGoOtaku ldd output :

  linux-vdso.so.1 (0x00007ffca2d70000)
  libpe.so.1 => /usr/lib/libpe.so.1 (0x00007f6a68edf000)
  libc.so.6 => /usr/lib/libc.so.6 (0x00007f6a68cfd000)
  libcrypto.so.3 => /usr/lib/libcrypto.so.3 (0x00007f6a687ff000)
  /lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x00007f6a68f45000)

Seems like it didn't link against libm and libmvec on your system. libm has been explicitly added to libpes Makefile and unless you link statically you don't need to add libmvec (which is only needed due to optimizations by the compiler anyway).

I'm frankly stumped. Did you have an old libpe? I think I am mostly stumped. This commit isn't in the latest version. https://github.com/mentebinaria/readpe/commit/a4d2fb11bc611a3790c4303acbdf2f4ef5bd8077

Now afaik this shouldn't cause what you experience. (I could still run it in my VM after all) If you have a more aggressive dependency cleaning setup that might cause it.

AkechiShiro commented 12 months ago

I'm using mold as a linker, maybe that's the issue ? And not the default linker @GoGoOtaku

GoGoOtaku commented 11 months ago

I could actually reproduce this error with mold. And it is indeed the missing -lm that the commit added. I don't know what the best workaround for you is for now but I will also probably release a new version in the not so distant future.

AkechiShiro commented 11 months ago

Thanks a lot for your help ! I will be waiting and test it once it's out

AkechiShiro commented 10 months ago

Hi again @GoGoOtaku could I be of any help towards the new release ? I would just like to help fix this issue, I can work on a PR/do some tests if needed.

GoGoOtaku commented 10 months ago

I'm sorry for this taking so long. I went to a hospital and even tho I took my laptop I didn't really have much time to maintain this repo.

I did make a new release now tho.

AkechiShiro commented 10 months ago

Thanks a lot for the new release ! No worries on the time taken, it's alright !