wireapp/cryptobox-jni

New 64bit-ready version references wrong libraries

marcoconti83 opened this issue · 0 comments

We used to have a libcryptobox-jni.so library built for 32 bit. We now changed the toolchain to build also for 64 bit.

The version built with the new toolchain is now referencing some other libraries that were not there before. We can live with that, I guess we need to add those to the package too, but it's also referencing one using the wrong path. Therefore at runtime it crashes because it can't load them.

Here is what we found out: this is the comparison of the two version (working vs. non working), from this you can see which libraries are referenced.

Working, old lib:

[nix-shell:~/Projects/wire/cryptobox-jni/output/dist/lib/armeabi-v7a]$ readelf -d libcryptobox.so

Dynamic section at offset 0x57d48 contains 28 entries:
  Tag        Type                         Name/Value
 0x00000003 (PLTGOT)                     0x58ed0
 0x00000002 (PLTRELSZ)                   584 (bytes)
 0x00000017 (JMPREL)                     0x3608
 0x00000014 (PLTREL)                     REL
 0x00000011 (REL)                        0x2640
 0x00000012 (RELSZ)                      4040 (bytes)
 0x00000013 (RELENT)                     8 (bytes)
 0x6ffffffa (RELCOUNT)                   505
 0x00000006 (SYMTAB)                     0x1cc
 0x0000000b (SYMENT)                     16 (bytes)
 0x00000005 (STRTAB)                     0xf3c
 0x0000000a (STRSZ)                      3487 (bytes)
 0x6ffffef5 (GNU_HASH)                   0x1cdc
 0x00000004 (HASH)                       0x1d9c
 0x00000001 (NEEDED)                     Shared library: [libsodium.so]
 0x00000001 (NEEDED)                     Shared library: [libdl.so]
 0x00000001 (NEEDED)                     Shared library: [libc.so]
 0x00000001 (NEEDED)                     Shared library: [libm.so]
 0x0000001a (FINI_ARRAY)                 0x57598
 0x0000001c (FINI_ARRAYSZ)               8 (bytes)
 0x0000001e (FLAGS)                      BIND_NOW
 0x6ffffffb (FLAGS_1)                    Flags: NOW
 0x6ffffff0 (VERSYM)                     0x2414
 0x6ffffffc (VERDEF)                     0x25c4
 0x6ffffffd (VERDEFNUM)                  1
 0x6ffffffe (VERNEED)                    0x25e0
 0x6fffffff (VERNEEDNUM)                 3
 0x00000000 (NULL)                       0x0

Not working, new lib:

[nix-shell:~/Projects/wire/cryptobox-jni/output/dist/lib/armeabi-v7a]$ readelf -d libcryptobox-jni.so

Dynamic section at offset 0x5d64 contains 32 entries:
  Tag        Type                         Name/Value
 0x00000003 (PLTGOT)                     0x6ed0
 0x00000002 (PLTRELSZ)                   584 (bytes)
 0x00000017 (JMPREL)                     0x1abc
 0x00000014 (PLTREL)                     REL
 0x00000011 (REL)                        0x17fc
 0x00000012 (RELSZ)                      704 (bytes)
 0x00000013 (RELENT)                     8 (bytes)
 0x6ffffffa (RELCOUNT)                   54
 0x00000006 (SYMTAB)                     0x1f0
 0x0000000b (SYMENT)                     16 (bytes)
 0x00000005 (STRTAB)                     0x8e0
 0x0000000a (STRSZ)                      2062 (bytes)
 0x6ffffef5 (GNU_HASH)                   0x10f0
 0x00000004 (HASH)                       0x1378
 0x00000001 (NEEDED)                     Shared library: [libdl.so]
 0x00000001 (NEEDED)                     Shared library: [libsodium.so]
 0x00000001 (NEEDED)                     Shared library: [./obj/local/armeabi-v7a/libcryptobox.so]
 0x00000001 (NEEDED)                     Shared library: [liblog.so]
 0x00000001 (NEEDED)                     Shared library: [libc.so]
 0x00000001 (NEEDED)                     Shared library: [libm.so]
 0x00000001 (NEEDED)                     Shared library: [libstdc++.so]
 0x0000000e (SONAME)                     Library soname: [libcryptobox-jni.so]
 0x0000001a (FINI_ARRAY)                 0x6d14
 0x0000001c (FINI_ARRAYSZ)               8 (bytes)
 0x0000001e (FLAGS)                      BIND_NOW
 0x6ffffffb (FLAGS_1)                    Flags: NOW
 0x6ffffff0 (VERSYM)                     0x16c0
 0x6ffffffc (VERDEF)                     0x17a0
 0x6ffffffd (VERDEFNUM)                  1
 0x6ffffffe (VERNEED)                    0x17bc
 0x6fffffff (VERNEEDNUM)                 2
 0x00000000 (NULL)                       0x0

You can see that one reference has the wrong path (./obj/local/armeabi-v7a/libcryptobox.so), and other references are new (e.g. libstdc++.so).

The issues that we are trying to solve:

  • how to remove that wrong path?
  • How do we include those missing libraries (if they are indeed needed)?

The build scripts are in this repo, just look at the README.

This is the changeset between the working version (before merging PR) and the broken version (after PR): https://github.com/wireapp/cryptobox-jni/pull/10/files