Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolving UnsatisfiedLinkError for Missing Symbols in libfio.so on Android #1838

Closed
hschenzhimin opened this issue Nov 20, 2024 · 2 comments
Closed

Comments

@hschenzhimin
Copy link

On Ubuntu, I used NDK version 27 to compile fio version 3.38 and generated libfio.so. However, when using System.load("fio") in the app, it crashes with the following error:

java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "device_is_mounted" referenced by "/data/app/com.example.performance_check-HXHM-fAkeyw52mI75oDcVw==/lib/x86_64/libfio.so"...
at java.lang.Runtime.loadLibrary0(Runtime.java:1041)
at java.lang.System.loadLibrary(System.java:1675)

The build script is as follows:

NDK_PATH="/home/work/work-space/android-ndk-r27c"
CC="${NDK_PATH}/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android24-clang"
AR="${NDK_PATH}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar"

export CC
export AR

CFLAGS="-fPIC -DANDROID -fvisibility=hidden"
LDFLAGS="-shared -Wl"

make clean

make CFLAGS="$CFLAGS"

$CC $CFLAGS $LDFLAGS *.o -o libfio.so

When analyzing the exported methods of libfio.so, I found that some methods are marked as NOTYPE. The command and its output are as follows:

readelf -s libfio.so | grep NOTYPE

Output:

 0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
13: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND device_is_mounted
14: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND buf_output_init
15: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND buf_output_free
32: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND __fio_memfree
35: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND fio_getrusage
45: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND __fio_memalign
55: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND logf
61: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND blktrace_lookup_[...]
64: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND unpack754
66: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND pack754
86: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND inflateInit_
87: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND inflate
88: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND inflateEnd
@vincentkfu
Copy link
Collaborator

I am not familiar with building/running fio on Android but I asked my colleague Jinyoung Choi to look at this and this is his assessment:

The reason why it appears as "NOTYPE" is that, of course, the device_is_mounted function is included in the lib/mountcheck.o object.
When doing CC, it was performed on "*.o", so the objects of the sub-folders were not included together.

$CC $CFLAGS $LDFLAGS *.o -o libfio.so --> $CC $CFLAGS $LDFLAGS *.o lib/*.o -o libfio.so (This is not enough....)

(the additional amount of objects will be reduced only when you build by giving disable hints about unnecessary contents in configuration.)
(I think to make fio a library, you need to modify header exposure (extern "c"{}) and Makefile well ...)

Anyway, in the case of fio, I have not seen the case of making it into a library and using it.
I want to know what it is for.

functions called in libfio.c do not expose functions in the form of below, so they must be added manually.

@vincentkfu
Copy link
Collaborator

Closing due to lack of response.

@vincentkfu vincentkfu closed this as not planned Won't fix, can't repro, duplicate, stale Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants