On Android API 26 or later, shmctl, shmdt and shmget are defined
in libc.so but are disallowed by SELinux. When a main executable
links against a shared library linking against libandroid-shmem.so
which the main executable itself does not link against, then the
definitions in libandroid-shmem.so are bypassed but instead the ones
in libc.so are used. As a result, when the program calls one of
these three functions, then it fails with "Bad system call".
To avoid this situation, the public header should not directly declare
these symbols. Instead it should declare symbols that are prefixed by
libandroid_ and #define the original symbols as aliases.
On Android API 26 or later,
shmctl
,shmdt
andshmget
are defined inlibc.so
but are disallowed by SELinux. When a main executable links against a shared library linking againstlibandroid-shmem.so
which the main executable itself does not link against, then the definitions inlibandroid-shmem.so
are bypassed but instead the ones inlibc.so
are used. As a result, when the program calls one of these three functions, then it fails with "Bad system call".To avoid this situation, the public header should not directly declare these symbols. Instead it should declare symbols that are prefixed by
libandroid_
and#define
the original symbols as aliases.Related issue: https://github.com/termux/termux-packages/issues/9560.