Merge "Add syscalls that aren't currently used to the seccomp whitelist."
diff --git a/libc/arch-x86_64/include/machine/elf_machdep.h b/libc/arch-x86_64/include/machine/elf_machdep.h
deleted file mode 100644
index dedbd41..0000000
--- a/libc/arch-x86_64/include/machine/elf_machdep.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/* $NetBSD: elf_machdep.h,v 1.4 2010/03/18 08:28:33 cegger Exp $ */
-
-#ifndef _X86_64_ELF_MACHDEP_H_
-#define _X86_64_ELF_MACHDEP_H_
-
-/* x86-64 relocations */
-
-#define R_X86_64_NONE 0
-#define R_X86_64_64 1
-#define R_X86_64_PC32 2
-#define R_X86_64_GOT32 3
-#define R_X86_64_PLT32 4
-#define R_X86_64_COPY 5
-#define R_X86_64_GLOB_DAT 6
-#define R_X86_64_JUMP_SLOT 7
-#define R_X86_64_RELATIVE 8
-#define R_X86_64_GOTPCREL 9
-#define R_X86_64_32 10
-#define R_X86_64_32S 11
-#define R_X86_64_16 12
-#define R_X86_64_PC16 13
-#define R_X86_64_8 14
-#define R_X86_64_PC8 15
-
-/* TLS relocations */
-#define R_X86_64_DTPMOD64 16
-#define R_X86_64_DTPOFF64 17
-#define R_X86_64_TPOFF64 18
-#define R_X86_64_TLSGD 19
-#define R_X86_64_TLSLD 20
-#define R_X86_64_DTPOFF32 21
-#define R_X86_64_GOTTPOFF 22
-#define R_X86_64_TPOFF32 23
-
-#define R_X86_64_IRELATIVE 37
-
-#define R_TYPE(name) __CONCAT(R_X86_64_,name)
-
-#endif
diff --git a/libc/include/bits/auxvec.h b/libc/include/bits/auxvec.h
new file mode 100644
index 0000000..de3cfbb
--- /dev/null
+++ b/libc/include/bits/auxvec.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _BITS_AUXVEC_H_
+#define _BITS_AUXVEC_H_
+
+#include <sys/cdefs.h>
+
+#include <linux/auxvec.h>
+
+/* Historical arch-specific cruft. */
+#define AT_FPUCW 18 /* SuperH */
+#define AT_DCACHEBSIZE 19 /* PowerPC */
+#define AT_ICACHEBSIZE 20 /* PowerPC */
+#define AT_UCACHEBSIZE 21 /* PowerPC */
+#define AT_IGNOREPPC 22 /* PowerPC */
+
+#endif
diff --git a/libc/arch-arm/include/machine/elf_machdep.h b/libc/include/bits/elf_arm.h
similarity index 80%
rename from libc/arch-arm/include/machine/elf_machdep.h
rename to libc/include/bits/elf_arm.h
index f7ee43f..320feaf 100644
--- a/libc/arch-arm/include/machine/elf_machdep.h
+++ b/libc/include/bits/elf_arm.h
@@ -1,8 +1,11 @@
-/* $NetBSD: elf_machdep.h,v 1.10 2012/08/05 04:12:46 matt Exp $ */
+/* $NetBSD: elf_machdep.h,v 1.17 2014/02/25 19:20:09 matt Exp $ */
#ifndef _ARM_ELF_MACHDEP_H_
#define _ARM_ELF_MACHDEP_H_
+/* Android-added. */
+#define R_ARM_IRELATIVE 160
+
/* Processor specific flags for the ELF header e_flags field. */
#define EF_ARM_RELEXEC 0x00000001
#define EF_ARM_HASENTRY 0x00000002
@@ -17,6 +20,7 @@
#define EF_ARM_NEW_ABI 0x00000080
#define EF_ARM_OLD_ABI 0x00000100
#define EF_ARM_SOFT_FLOAT 0x00000200
+#define EF_ARM_BE8 0x00800000
#define EF_ARM_EABIMASK 0xff000000
#define EF_ARM_EABI_VER1 0x01000000
#define EF_ARM_EABI_VER2 0x02000000
@@ -58,13 +62,29 @@
#define R_ARM_GOTPC 25
#define R_ARM_GOT32 26
#define R_ARM_PLT32 27
-
+#define R_ARM_CALL 28
+#define R_ARM_JUMP24 29
+#define R_ARM_THM_JUMP24 30
+#define R_ARM_BASE_ABS 31
#define R_ARM_ALU_PCREL_7_0 32
#define R_ARM_ALU_PCREL_15_8 33
#define R_ARM_ALU_PCREL_23_15 34
#define R_ARM_ALU_SBREL_11_0 35
#define R_ARM_ALU_SBREL_19_12 36
-#define R_ARM_ALU_SBREL_27_20 37
+#define R_ARM_ALU_SBREL_27_20 37 // depcreated
+#define R_ARM_TARGET1 38
+#define R_ARM_SBREL31 39 // deprecated
+#define R_ARM_V4BX 40
+#define R_ARM_TARGET2 41
+#define R_ARM_PREL31 42
+#define R_ARM_MOVW_ABS_NC 43
+#define R_ARM_MOVT_ABS 44
+#define R_ARM_MOVW_PREL_NC 45
+#define R_ARM_MOVT_PREL 46
+#define R_ARM_THM_MOVW_ABS_NC 47
+#define R_ARM_THM_MOVT_ABS 48
+#define R_ARM_THM_MOVW_PREL_NC 49
+#define R_ARM_THM_MOVT_PREL 50
/* 96-111 are reserved to G++. */
#define R_ARM_GNU_VTENTRY 100
@@ -84,8 +104,6 @@
/* 112-127 are reserved for private experiments. */
-#define R_ARM_IRELATIVE 160
-
#define R_ARM_RXPC25 249
#define R_ARM_RSBREL32 250
#define R_ARM_THM_RPC22 251
@@ -94,13 +112,14 @@
#define R_ARM_RPC24 254
#define R_ARM_RBASE 255
-#define R_TYPE(name) __CONCAT(R_ARM_,name)
-
/* Processor specific program header flags */
#define PF_ARM_SB 0x10000000
#define PF_ARM_PI 0x20000000
#define PF_ARM_ENTRY 0x80000000
+/* Processor specific program header types */
+#define PT_ARM_EXIDX (PT_LOPROC + 1)
+
/* Processor specific section header flags */
#define SHF_ENTRYSECT 0x10000000
#define SHF_COMDEF 0x80000000
diff --git a/libc/arch-arm64/include/machine/elf_machdep.h b/libc/include/bits/elf_arm64.h
similarity index 97%
rename from libc/arch-arm64/include/machine/elf_machdep.h
rename to libc/include/bits/elf_arm64.h
index 9f10b99..acd9c70 100644
--- a/libc/arch-arm64/include/machine/elf_machdep.h
+++ b/libc/include/bits/elf_arm64.h
@@ -87,6 +87,4 @@
#define R_AARCH64_TLS_DTPREL32 1031
#define R_AARCH64_IRELATIVE 1032
-#define R_TYPE(name) __CONCAT(R_AARCH64_,name)
-
#endif /* _AARCH64_ELF_MACHDEP_H_ */
diff --git a/libc/arch-mips/include/machine/elf_machdep.h b/libc/include/bits/elf_mips.h
similarity index 98%
rename from libc/arch-mips/include/machine/elf_machdep.h
rename to libc/include/bits/elf_mips.h
index 59e0974..e29c481 100644
--- a/libc/arch-mips/include/machine/elf_machdep.h
+++ b/libc/include/bits/elf_mips.h
@@ -71,8 +71,6 @@
#define R_MIPS_max 51
-#define R_TYPE(name) __CONCAT(R_MIPS_,name)
-
#define R_MIPS16_min 100
#define R_MIPS16_26 100
#define R_MIPS16_GPREL 101
diff --git a/libc/arch-x86/include/machine/elf_machdep.h b/libc/include/bits/elf_x86.h
similarity index 84%
rename from libc/arch-x86/include/machine/elf_machdep.h
rename to libc/include/bits/elf_x86.h
index 5324ebc..dfbaba0 100644
--- a/libc/arch-x86/include/machine/elf_machdep.h
+++ b/libc/include/bits/elf_x86.h
@@ -1,4 +1,4 @@
-/* $NetBSD: elf_machdep.h,v 1.10 2009/05/30 05:56:52 skrll Exp $ */
+/* $NetBSD: elf_machdep.h,v 1.12 2016/02/02 20:16:59 christos Exp $ */
#ifndef _X86_ELF_MACHDEP_H_
#define _X86_ELF_MACHDEP_H_
@@ -15,6 +15,7 @@
#define R_386_RELATIVE 8
#define R_386_GOTOFF 9
#define R_386_GOTPC 10
+#define R_386_32PLT 11
/* TLS relocations */
#define R_386_TLS_TPOFF 14
@@ -45,11 +46,15 @@
#define R_386_TLS_DTPMOD32 35
#define R_386_TLS_DTPOFF32 36
#define R_386_TLS_TPOFF32 37
+
+#define R_386_SIZE32 38
+
+/* More TLS relocations */
#define R_386_TLS_GOTDESC 39
#define R_386_TLS_DESC_CALL 40
#define R_386_TLS_DESC 41
-#define R_386_IRELATIVE 42
-#define R_TYPE(name) __CONCAT(R_386_,name)
+#define R_386_IRELATIVE 42
+#define R_386_GOT32X 43
#endif
diff --git a/libc/include/bits/elf_x86_64.h b/libc/include/bits/elf_x86_64.h
new file mode 100644
index 0000000..30062af
--- /dev/null
+++ b/libc/include/bits/elf_x86_64.h
@@ -0,0 +1,55 @@
+/* $NetBSD: elf_machdep.h,v 1.5 2016/02/02 20:13:59 christos Exp $ */
+
+#ifndef _X86_64_ELF_MACHDEP_H_
+#define _X86_64_ELF_MACHDEP_H_
+
+/* x86-64 relocations */
+
+#define R_X86_64_NONE 0
+#define R_X86_64_64 1
+#define R_X86_64_PC32 2
+#define R_X86_64_GOT32 3
+#define R_X86_64_PLT32 4
+#define R_X86_64_COPY 5
+#define R_X86_64_GLOB_DAT 6
+#define R_X86_64_JUMP_SLOT 7
+#define R_X86_64_RELATIVE 8
+#define R_X86_64_GOTPCREL 9
+#define R_X86_64_32 10
+#define R_X86_64_32S 11
+#define R_X86_64_16 12
+#define R_X86_64_PC16 13
+#define R_X86_64_8 14
+#define R_X86_64_PC8 15
+
+/* TLS relocations */
+#define R_X86_64_DTPMOD64 16
+#define R_X86_64_DTPOFF64 17
+#define R_X86_64_TPOFF64 18
+#define R_X86_64_TLSGD 19
+#define R_X86_64_TLSLD 20
+#define R_X86_64_DTPOFF32 21
+#define R_X86_64_GOTTPOFF 22
+#define R_X86_64_TPOFF32 23
+
+#define R_X86_64_PC64 24
+#define R_X86_64_GOTOFF64 25
+#define R_X86_64_GOTPC32 26
+#define R_X86_64_GOT64 27
+#define R_X86_64_GOTPCREL64 28
+#define R_X86_64_GOTPC64 29
+#define R_X86_64_GOTPLT64 30
+#define R_X86_64_PLTOFF64 31
+#define R_X86_64_SIZE32 32
+#define R_X86_64_SIZE64 33
+#define R_X86_64_GOTPC32_TLSDESC 34
+#define R_X86_64_TLSDESC_CALL 35
+#define R_X86_64_TLSDESC 36
+#define R_X86_64_IRELATIVE 37
+#define R_X86_64_RELATIVE64 38
+#define R_X86_64_PC32_BND 39
+#define R_X86_64_PLT32_BND 40
+#define R_X86_64_GOTPCRELX 41
+#define R_X86_64_REX_GOTPCRELX 42
+
+#endif
diff --git a/libc/include/elf.h b/libc/include/elf.h
index ae05d3d..c36bc8d 100644
--- a/libc/include/elf.h
+++ b/libc/include/elf.h
@@ -31,10 +31,14 @@
#include <sys/cdefs.h>
-#include <linux/auxvec.h>
+#include <bits/auxvec.h>
+#include <bits/elf_arm.h>
+#include <bits/elf_arm64.h>
+#include <bits/elf_mips.h>
+#include <bits/elf_x86.h>
+#include <bits/elf_x86_64.h>
#include <linux/elf.h>
#include <linux/elf-em.h>
-#include <machine/elf_machdep.h>
#define ELF32_R_INFO(sym, type) ((((Elf32_Word)sym) << 8) | ((type) & 0xff))
#define ELF64_R_INFO(sym, type) ((((Elf64_Xword)sym) << 32) | ((type) & 0xffffffff))
diff --git a/libc/include/string.h b/libc/include/string.h
index 6520996..c178a3c 100644
--- a/libc/include/string.h
+++ b/libc/include/string.h
@@ -412,7 +412,7 @@
#undef __error_zero_size
#undef __error_if_overflows_dst
#else // defined(__clang__)
-extern char* __strncpy_real(char* __restrict, const char*, size_t) __RENAME(strcpy);
+extern char* __strncpy_real(char* __restrict, const char*, size_t) __RENAME(strncpy);
extern void* __memrchr_real(const void*, int, size_t) __RENAME(memrchr);
extern size_t __strlcpy_real(char* __restrict, const char* __restrict, size_t)
__RENAME(strlcpy);
diff --git a/libc/include/sys/auxv.h b/libc/include/sys/auxv.h
index 2fa637e..ab5a39d 100644
--- a/libc/include/sys/auxv.h
+++ b/libc/include/sys/auxv.h
@@ -25,12 +25,14 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
+
#ifndef _SYS_AUXV_H_
#define _SYS_AUXV_H_
-#include <linux/auxvec.h>
#include <sys/cdefs.h>
+#include <bits/auxvec.h>
+
__BEGIN_DECLS
unsigned long int getauxval(unsigned long int type) __INTRODUCED_IN(18);
diff --git a/linker/linker_phdr.cpp b/linker/linker_phdr.cpp
index 72549cc..42c29c8 100644
--- a/linker/linker_phdr.cpp
+++ b/linker/linker_phdr.cpp
@@ -199,6 +199,15 @@
return true;
}
+static const char* EM_to_string(int em) {
+ if (em == EM_386) return "EM_386";
+ if (em == EM_AARCH64) return "EM_AARCH64";
+ if (em == EM_ARM) return "EM_ARM";
+ if (em == EM_MIPS) return "EM_MIPS";
+ if (em == EM_X86_64) return "EM_X86_64";
+ return "EM_???";
+}
+
bool ElfReader::VerifyElfHeader() {
if (memcmp(header_.e_ident, ELFMAG, SELFMAG) != 0) {
DL_ERR("\"%s\" has bad ELF magic", name_.c_str());
@@ -244,7 +253,8 @@
}
if (header_.e_machine != GetTargetElfMachine()) {
- DL_ERR("\"%s\" has unexpected e_machine: %d", name_.c_str(), header_.e_machine);
+ DL_ERR("\"%s\" has unexpected e_machine: %d (%s)", name_.c_str(), header_.e_machine,
+ EM_to_string(header_.e_machine));
return false;
}
diff --git a/tests/Android.bp b/tests/Android.bp
index 519c28c..ae8d7fc 100644
--- a/tests/Android.bp
+++ b/tests/Android.bp
@@ -405,6 +405,7 @@
"libdl_preempt_test_1",
"libdl_preempt_test_2",
"libdl_test_df_1_global",
+ "libgnu-hash-table-library",
"libsysv-hash-table-library",
"libtest_atexit",
"libtest_check_order_dlsym_1_left",
@@ -440,6 +441,7 @@
"libtest_dlsym_weak_func",
"libtest_dt_runpath_d",
"libtest_empty",
+ "libtest_ifunc",
"libtest_init_fini_order_child",
"libtest_init_fini_order_grand_child",
"libtest_init_fini_order_root2",