libc: add getauxval()

Add support for getauxval().  This method allows a program an easy way
to retrieve information from the kernel auxiliary vector, and will
hopefully replace other clumsy ways of accessing this same information.

This particular function was also added to glibc in glibc 2.16.
See the following URLs for more details.

  * http://lwn.net/Articles/519085/
  * http://www.gnu.org/software/libc/manual/html_node/Auxiliary-Vector.html

This change is a prerequisite for bug 7959813.

Bug: http://code.google.com/p/android/issues/detail?id=38441
Change-Id: Iba19d899df334bddc6f4899077ece2fc87564ea8
diff --git a/libc/bionic/libc_init_common.c b/libc/bionic/libc_init_common.c
index fb164f4..86e1eb5 100644
--- a/libc/bionic/libc_init_common.c
+++ b/libc/bionic/libc_init_common.c
@@ -38,6 +38,7 @@
 
 #include <bionic_tls.h>
 #include <errno.h>
+#include <private/bionic_auxv.h>
 
 extern unsigned __get_sp(void);
 extern pid_t gettid(void);
@@ -95,6 +96,15 @@
   __progname = argv[0] ? argv[0] : "<unknown>";
   environ = envp;
 
+  // The auxiliary vector is at the end of the environment block
+  while(*envp != NULL) {
+    envp++;
+  }
+  /* The end of the environment block is marked by two NULL pointers */
+  envp++;
+
+  __libc_auxv = (Elf32_auxv_t*) envp;
+
   __system_properties_init(); // Requires 'environ'.
 }