Is there an ld(1)
option that provides the equivalent of --exclude-libs ALL
on ARM platforms?
I'm trying to reduce the size of a shared object on Android, but --exclude-libs ALL
is only available on x86.
EDIT: here's the reason I ask. Sorry about this extra detail. I was trying to keep the question short. My shared object does not export any Crypto++ symbols, yet 88 are showing up with and without --exclude-libs ALL
.
Here are the envars of interest:
$ 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, build 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 number of Crypto++ exports:
$ arm-linux-androideabi-nm --defined-only libprng.so | grep -i cryptopp | wc -l
88
Second, 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 number of Crypto++ exports:
$ arm-linux-androideabi-nm --defined-only libprng.so | grep -i cryptopp | wc -l
88
In both cases, 88 Crypto++ symbols are being exported. The source file is below, an it does not export any 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)
{
}