Merge "linker: fix off-by-one error in GNU_RELRO handling"
diff --git a/libc/kernel/common/linux/if_alg.h b/libc/kernel/common/linux/if_alg.h
new file mode 100644
index 0000000..35f161c
--- /dev/null
+++ b/libc/kernel/common/linux/if_alg.h
@@ -0,0 +1,43 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ ***   This header was automatically generated from a Linux kernel header
+ ***   of the same name, to make information necessary for userspace to
+ ***   call into the kernel available to libc.  It contains only constants,
+ ***   structures, and macros generated from the original header, and thus,
+ ***   contains no copyrightable information.
+ ***
+ ***   To edit the content of this header, modify the corresponding
+ ***   source file (e.g. under external/kernel-headers/original/) then
+ ***   run bionic/libc/kernel/tools/update_all.py
+ ***
+ ***   Any manual change here will be lost the next time this script will
+ ***   be run. You've been warned!
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _LINUX_IF_ALG_H
+#define _LINUX_IF_ALG_H
+#include <linux/types.h>
+struct sockaddr_alg {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+ __u16 salg_family;
+ __u8 salg_type[14];
+ __u32 salg_feat;
+ __u32 salg_mask;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+ __u8 salg_name[64];
+};
+struct af_alg_iv {
+ __u32 ivlen;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+ __u8 iv[0];
+};
+#define ALG_SET_KEY 1
+#define ALG_SET_IV 2
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ALG_SET_OP 3
+#define ALG_OP_DECRYPT 0
+#define ALG_OP_ENCRYPT 1
+#endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/linker/linker.c b/linker/linker.c
index 17d8555..3a923c1 100644
--- a/linker/linker.c
+++ b/linker/linker.c
@@ -815,16 +815,15 @@
     return (unsigned)req_base;
 }
 
-/* alloc_mem_region
+/* reserve_mem_region
  *
  *     This function reserves a chunk of memory to be used for mapping in
- *     the shared library. We reserve the entire memory region here, and
+ *     a prelinked shared library. We reserve the entire memory region here, and
  *     then the rest of the linker will relocate the individual loadable
  *     segments into the correct locations within this memory range.
  *
  * Args:
- *     si->base: The requested base of the allocation. If 0, a sane one will be
- *               chosen in the range LIBBASE <= base < LIBLAST.
+ *     si->base: The requested base of the allocation.
  *     si->size: The size of the allocation.
  *
  * Returns:
@@ -834,7 +833,7 @@
 
 static int reserve_mem_region(soinfo *si)
 {
-    void *base = mmap((void *)si->base, si->size, PROT_READ | PROT_EXEC,
+    void *base = mmap((void *)si->base, si->size, PROT_NONE,
                       MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
     if (base == MAP_FAILED) {
         DL_ERR("%5d can NOT map (%sprelinked) library '%s' at 0x%08x "
@@ -852,8 +851,7 @@
     return 0;
 }
 
-static int
-alloc_mem_region(soinfo *si)
+static int alloc_mem_region(soinfo *si)
 {
     if (si->base) {
         /* Attempt to mmap a prelinked library. */
@@ -864,7 +862,7 @@
        allocator.
     */
 
-    void *base = mmap(NULL, si->size, PROT_READ | PROT_EXEC,
+    void *base = mmap(NULL, si->size, PROT_NONE,
                       MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
     if (base == MAP_FAILED) {
         DL_ERR("%5d mmap of library '%s' failed: %d (%s)\n",