相关文章推荐
活泼的松鼠  ·  informix ...·  2 年前    · 
眉毛粗的毛衣  ·  error C2504: ...·  2 年前    · 

Stack Exchange Network

Stack Exchange network consists of 183 Q&A communities including Stack Overflow , the largest, most trusted online community for developers to learn, share their knowledge, and build their careers. Visit Stack Exchange

Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.

Sign up to join this community

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

Emulating an AARCH64 Binary calling libgps on x86_64 Ubuntu using QEMU gives "Error relocating: symbol not found" Errors

Ask Question

This is similar to the issue posted here and here . I want to reverse engineer a binary called gpslogger but before debugging it using GDB, I wish to simply emulate it using QEMU (qemu-aarch64) since when I run file gpslogger I get gpslogger: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-musl-aarch64.so.1, not stripped . I start by downloading the exact interpreter file and pasting it in my Ubuntu 16.04 x86_64 /lib folder and then other errors show up asking for other .so files, e.g., libgps.so . I then download those .so files for the AARCH64 architecture and paste them in the /lib folder of my Ubuntu. Once all the .so errors, i.e., no such file or directory are gone, I'm left with

Error relocating /lib/libgps.so: __strdup: symbol not found
Error relocating /lib/libgps.so: __fdelt_chk: symbol not found
Error relocating /lib/libgps.so: __fprintf_chk: symbol not found
Error relocating /lib/libgps.so: __snprintf_chk: symbol not found
Error relocating /lib/libgps.so: __isnan: symbol not found
Error relocating /lib/libgps.so: __syslog_chk: symbol not found
Error relocating /lib/libgps.so: __vsnprintf_chk: symbol not found
Error relocating /lib/libdbus-1.so.3: __snprintf_chk: symbol not found
Error relocating /lib/libdbus-1.so.3: __vsnprintf_chk: symbol not found
Error relocating /lib/libdbus-1.so.3: __strncpy_chk: symbol not found
Error relocating /lib/libdbus-1.so.3: __vfprintf_chk: symbol not found
Error relocating /lib/libdbus-1.so.3: __fprintf_chk: symbol not found
Error relocating /lib/libdbus-1.so.3: __vsprintf_chk: symbol not found
Error relocating /lib/libsystemd.so.0: __sprintf_chk: symbol not found
Error relocating /lib/libsystemd.so.0: reallocarray: symbol not found
Error relocating /lib/libsystemd.so.0: __register_atfork: symbol not found
Error relocating /lib/libsystemd.so.0: __memcpy_chk: symbol not found
Error relocating /lib/libsystemd.so.0: __snprintf_chk: symbol not found
Error relocating /lib/libsystemd.so.0: __vsnprintf_chk: symbol not found
Error relocating /lib/libsystemd.so.0: __strncpy_chk: symbol not found
Error relocating /lib/libsystemd.so.0: __vasprintf_chk: symbol not found
Error relocating /lib/libsystemd.so.0: __open64_2: symbol not found
Error relocating /lib/libsystemd.so.0: __asprintf_chk: symbol not found
Error relocating /lib/libsystemd.so.0: __fprintf_chk: symbol not found
Error relocating /lib/libsystemd.so.0: __ppoll_chk: symbol not found
Error relocating /lib/libsystemd.so.0: fcntl64: symbol not found
Error relocating /lib/libsystemd.so.0: __explicit_bzero_chk: symbol not found
Error relocating /lib/libsystemd.so.0: parse_printf_format: symbol not found
Error relocating /lib/libsystemd.so.0: __openat64_2: symbol not found
Error relocating /lib/libgcrypt.so.20: __memcpy_chk: symbol not found
Error relocating /lib/libgcrypt.so.20: __snprintf_chk: symbol not found
Error relocating /lib/libgcrypt.so.20: __fdelt_chk: symbol not found
Error relocating /lib/libgcrypt.so.20: __vfprintf_chk: symbol not found
Error relocating /lib/libgcrypt.so.20: __memset_chk: symbol not found
Error relocating /lib/libgcrypt.so.20: __fprintf_chk: symbol not found
Error relocating /lib/libgcrypt.so.20: __read_chk: symbol not found
Error relocating /lib/libgcrypt.so.20: __syslog_chk: symbol not found
Error relocating /lib/libgpg-error.so.0: __sprintf_chk: symbol not found
Error relocating /lib/libgpg-error.so.0: __fdelt_chk: symbol not found
Error relocating /lib/libgpg-error.so.0: __vfprintf_chk: symbol not found
Error relocating /lib/libgpg-error.so.0: __memset_chk: symbol not found
Error relocating /lib/libgpg-error.so.0: __fprintf_chk: symbol not found
Error relocating gpslogger: GPSNMEA: symbol not found

Except for the last relocation error, I believe all the other functions should be implemented in glibc. Therefore, I simply downloaded the libc-2.32.so file from here for the AARCH64 architecture and pasted it in the /lib folder of my Ubuntu. However, the errors didn't go away. Please let me know if more information is needed. I appreciate any help on the issue.

Edit:

readelf -d gpslogger | grep 'NEEDED' returns:

0x0000000000000001 (NEEDED) Shared library: [libgps.so]

0x0000000000000001 (NEEDED) Shared library: [libc.musl-aarch64.so.1]

Does this mean that the libc is coming from musl and is not glibc?

“interpreter /lib/ld-musl-aarch64.so.1” in file’s output indicates that gpslogger was built with musl. This means that you need not only the musl dynamic linker (ld-musl-aarch64.so.1), but you also need musl variants of every single library used by gpslogger.

The missing symbols you list indicate that the libraries you’ve installed were built for glibc.

Is there any place I can download these shared library files already built using musl? Otherwise I have to build them using a machine with aarch64 architecture running musl, correct? – Newbie Nov 27, 2020 at 15:27