Load library using file handle.

 * This patch enables dlopen by file descriptor
   instead of path/name.

Bug: 15984217
Change-Id: Ib39051e00567fb97070bf96d8ce63993877c0a01
diff --git a/libc/include/android/dlext.h b/libc/include/android/dlext.h
index 90962fa..616e08e 100644
--- a/libc/include/android/dlext.h
+++ b/libc/include/android/dlext.h
@@ -49,11 +49,17 @@
    */
   ANDROID_DLEXT_USE_RELRO             = 0x8,
 
+  /* Instruct dlopen to use library_fd instead of opening file by name.
+   * The filename parameter is still used to identify the library.
+   */
+  ANDROID_DLEXT_USE_LIBRARY_FD        = 0x10,
+
   /* Mask of valid bits */
   ANDROID_DLEXT_VALID_FLAG_BITS       = ANDROID_DLEXT_RESERVED_ADDRESS |
                                         ANDROID_DLEXT_RESERVED_ADDRESS_HINT |
                                         ANDROID_DLEXT_WRITE_RELRO |
-                                        ANDROID_DLEXT_USE_RELRO,
+                                        ANDROID_DLEXT_USE_RELRO |
+                                        ANDROID_DLEXT_USE_LIBRARY_FD,
 };
 
 typedef struct {
@@ -61,6 +67,7 @@
   void*   reserved_addr;
   size_t  reserved_size;
   int     relro_fd;
+  int     library_fd;
 } android_dlextinfo;
 
 extern void* android_dlopen_ext(const char* filename, int flag, const android_dlextinfo* extinfo);