diff options
author | Sam Protsenko <semen.protsenko@linaro.org> | 2017-11-09 19:44:53 +0200 |
---|---|---|
committer | Sam Protsenko <semen.protsenko@linaro.org> | 2018-07-04 17:32:24 +0300 |
commit | c976b782201514779dd67013d6c57f2a219023c6 (patch) | |
tree | fba5513f6f6d10f4bb454be98c59c95b09ee7a37 | |
parent | 0c9566a278b70101a6f2a6c209d3bd7435b672a5 (diff) | |
download | ppp-c976b782201514779dd67013d6c57f2a219023c6.tar.gz |
pppd: Enable plugin support in pppd
This patch makes it possible for pppd to load plugins in Android. Next
changes were made:
1. Link pppd with libdl library, which allows dynamic loading of shared
libraries.
2. Use -rdynamic to export all pppd symbols in dynamic symbol table,
so that plugins can link their undefined symbols against pppd.
3. Change plugins search path in pppd to:
- /system/lib/ (on 32-bit systems)
- /system/lib64/ (on 64-bit systems)
Last change was done for two reasons:
1. Fix plugin loading on 64-bit architectures
On ARM64 pppd will try to load 32-bit plugins (.so) files from /lib,
which leads to this kind of errors:
E pppd : dlopen failed:
"/system/lib/pppd/2.4.7/pppol2tp-android.so"
is 32-bit instead of 64 bit
E pppd : Couldn't load plugin pppol2tp-android.so
To overcome this issue let's make pppd look for plugins in lib/ or
in lib64/ directory based on __LP64__ definition.
2. Search for plugins in /system/${LIB}
Bionic loader allows us to dlopen() libraries only from
/system/${LIB} root directory (as specified in ld.config.txt, see
"default" linker namespace). When using upstream pppd location, which
is /system/${LIB}/pppd/2.4.7/, next error occurs in logcat, when pppd
is trying to load some plugin:
pppd : dlopen failed: library
"/system/lib64/pppd/2.4.7/pppol2tp-android.so"
needed or dlopened by "/system/bin/pppd" is not accessible for the
namespace "(default)"
Make pppd look only in /system/${LIB} root directory to fix this
issue.
Change-Id: I13c8c30337b1307911bdafa711afa1c3c34e99a6
Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
-rw-r--r-- | pppd/Android.mk | 4 | ||||
-rw-r--r-- | pppd/pathnames.h | 16 |
2 files changed, 20 insertions, 0 deletions
diff --git a/pppd/Android.mk b/pppd/Android.mk index 88cfe35..ba06198 100644 --- a/pppd/Android.mk +++ b/pppd/Android.mk @@ -41,6 +41,10 @@ LOCAL_CFLAGS := -DCHAPMS=1 -DMPPE=1 -DINET6=1 -DUSE_OPENSSL=1 -Wno-unused-parame # Turn off warnings for now until this is fixed upstream. b/18632512 LOCAL_CFLAGS += -Wno-unused-variable +# Enable plugin support +LOCAL_CFLAGS += -DPLUGIN +LOCAL_LDFLAGS := -ldl -rdynamic + LOCAL_MODULE:= pppd include $(BUILD_EXECUTABLE) diff --git a/pppd/pathnames.h b/pppd/pathnames.h index a33f046..ea74736 100644 --- a/pppd/pathnames.h +++ b/pppd/pathnames.h @@ -56,10 +56,26 @@ #endif /* __STDC__ */ #ifdef PLUGIN +#ifdef __ANDROID__ + +/* + * In Android we can't load plugins from /system/lib{64}/pppd/, because + * Bionic loader only allows us to dlopen() libraries from /system/lib{64} root + * directory (as specified in ld.config.txt, see "default" linker namespace). + */ +#ifdef __LP64__ +#define _PATH_PLUGIN "/system/lib64" +#else /* __LP64__ */ +#define _PATH_PLUGIN "/system/lib" +#endif /* __LP64__ */ + +#else /* __ANDROID__ */ + #ifdef __STDC__ #define _PATH_PLUGIN DESTDIR "/lib/pppd/" VERSION #else /* __STDC__ */ #define _PATH_PLUGIN "/usr/lib/pppd" #endif /* __STDC__ */ +#endif /* __ANDROID__ */ #endif /* PLUGIN */ |