I have chrooted Debian in android marshmallow (snapdragon 650 [64bit]).

I installed iceweasel in chrooted debian. But it showed this error ::

(firefox:16210): Gdk-WARNING **: shmget failed: error 38 (Function not implemented)   Segmentation fault

So, I compiled libandroid-shmem.so from this repo using android-ndk and copied from armv8-a folder to /lib directory of chrooted debian. It then asked for liblog.so.

iceweasel: error while loading shared libraries: liblog.so: cannot open shared object file: No such file or directory

So I copied liblog.so from android-ndk to chrooted debian /lib directory.

Now when I run env LD_PRELOAD="/lib/libandroid-shmem.so" iceweasel . It displays this error :

iceweasel: error while loading shared libraries: /usr/lib/aarch64-linux-gnu/libc.so: invalid ELF header

Here are some details :: file /lib/libandroid-shmem.so

/lib/libandroid-shmem.so: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, BuildID[sha1]=5ad4582c76effbe27a6688369ad979fea5dfac2a, stripped

$ cat /usr/lib/aarch64-linux-gnu/libc.so

/* GNU ld script
   Use the shared library, but some functions are only in
   the static library, so try that secondarily.  */
GROUP ( /lib/aarch64-linux-gnu/libc.so.6 /usr/lib/aarch64-linux-gnu/libc_nonshared.a  AS_NEEDED ( /lib/aarch64-linux-gnu/ld-linux-aarch64.so.1 ) )

How did you compile it ? I compiled and not facing any wrong elf error Here is my steps to compile libandroid-shmem

  1. Enter into chroot

  2. Clone this repository git clone https://github.com/pelya/android-shmem

  3. Get submodules git submodule update --init libancillary
  4. Now, to compile it for aarch64 or arm64 you will have to make some changes in build.sh script so goto cloned repository cd android-shmem and delete build.sh and create new one with any text editor I am using vi here vi build.sh
  5. Copy and paste this into build.sh and save

        gcc -shared -fpic -std=gnu99 -Wall *.c -I . -I libancillary \
                    -o libandroid-shmem.so -Wl,--version-script=exports.txt -lc -lpthread && \
    strip libandroid-shmem.so
  6. Run build script ./build.sh now you can see compiled binary in your current directory

  7. Now export it export LD_PRELOAD=/path/to/your/binary
|improve this answer|||||

The problem seems to be, that you compiled the library using the android-ndk. This way it is linked against the android version of libc.so.

On some linux distributions libc.so seems to be a linker script and not an actual library, while the android-ndk apparently expects it to be a library.

However even if you replace libc.so with a symbolic link to the actual library, your compiled libandroid-shmem.so will still not work, because then it complains, that the libc version doesn't match. (I got /lib/aarch64-linux-gnu/libc.so.6: version `LIBC' not found (required by /data/data/com.termux/files/usr/lib/libandroid-shmem.so))

Instead, compile the library directly within the chroot environment, as described in Auxs answer. Note: I didn't need to change the build.sh script - the one provided upstream worked just fine.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.