pppd: Enable plugin support in pppd am: c976b78220 am: 0634ee55dc
am: 109240bddd

Change-Id: Ia9b74c3324fe23466fbccb38788b5e6133b63312
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 @@
 # 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 */