ARM equivalent "--exclude-libs ALL"
Is there an option ld(1)
that provides an equivalent --exclude-libs ALL
on ARM platforms?
I'm trying to reduce the size of a shared object on Android, but --exclude-libs ALL
only available on x86.
EDIT : this is why I am asking. Sorry for this additional information. I tried to keep the question short. My shared object does not export Crypto ++ symbols, but 88 displays with and without --exclude-libs ALL
.
Here are the envars we are interested in:
$ echo $CXX
arm-linux-androideabi-g++
$ echo $ANDROID_STL_INC
/opt/android-ndk-r9/sources/cxx-stl/stlport/stlport/
$ echo $ANDROID_SYSROOT
/opt/android-ndk-r9/platforms/android-9/arch-arm
First create my shared object without --exclude-libs ALL
:
$ $CXX -fPIC -Os -I/usr/local/cryptopp-android-9/include -I$ANDROID_STL_INC
--sysroot=$ANDROID_SYSROOT com_deltoid_androidprng_PRNG.cpp
-o libprng.so -shared
And then count the Crypto ++ exports:
$ arm-linux-androideabi-nm --defined-only libprng.so | grep -i cryptopp | wc -l
88
Second, the same experiment with --exclude-libs ALL
:
$ $CXX -fPIC -Os -I/usr/local/cryptopp-android-9/include -I$ANDROID_STL_INC
--sysroot=$ANDROID_SYSROOT com_deltoid_androidprng_PRNG.cpp
-o libprng.so -shared -Wl,--exclude-libs,ALL
And then count the Crypto ++ exports:
$ arm-linux-androideabi-nm --defined-only libprng.so | grep -i cryptopp | wc -l
88
In both cases, 88 Crypto ++ symbols are exported. Source file below, it doesn't export Crypto ++ symbols.
#include <string.h>
#include <jni.h>
#include <cryptopp/osrng.h>
using CryptoPP::AutoSeededRandomPool;
#include "com_deltoid_androidprng_PRNG.h"
static AutoSeededRandomPool& GetPRNG()
{
static AutoSeededRandomPool prng;
return prng;
}
static int IncorporateSensors()
{
return 0;
}
/*
* Class: com_deltoid_androidprng_PRNG
* Method: CryptoPP_Reseed
* Signature: ([B)I
*/
jint JNICALL Java_com_deltoid_androidprng_PRNG_CryptoPP_1Reseed
(JNIEnv* env, jclass, jbyteArray seed)
{
int ret, consumed = 0;
try
{
AutoSeededRandomPool& prng = GetPRNG();
if(env)
{
jbyte* bytes = env->GetByteArrayElements(seed, 0);
jint length = env->GetArrayLength(seed);
if(bytes)
{
if(length >= 0)
{
prng.IncorporateEntropy((const byte*)bytes, (size_t)length);
consumed += length;
}
env->ReleaseByteArrayElements(seed, bytes, JNI_ABORT);
}
}
}
catch(const CryptoPP::Exception& ex)
{
}
return consumed;
}
/*
* Class: com_deltoid_androidprng_PRNG
* Method: CryptoPP_GetBytes
* Signature: ([B)I
*/
JNIEXPORT jint JNICALL Java_com_deltoid_androidprng_PRNG_CryptoPP_1GetBytes
(JNIEnv *, jclass, jbyteArray)
{
}
source to share