Merge "linker: Speed up find_loaded_library_by_inode()"
diff --git a/android-changes-for-ndk-developers.md b/android-changes-for-ndk-developers.md
index 1fdb1e4..4bd97a0 100644
--- a/android-changes-for-ndk-developers.md
+++ b/android-changes-for-ndk-developers.md
@@ -66,6 +66,14 @@
intercept any symbol.
+## LD_PRELOAD and 32/64 bit
+
+LD_PRELOAD applies to both 32- and 64-bit processes. This means that you
+should avoid saying something like `/system/lib/libfoo.so` and just say
+`libfoo.so` instead, letting the dynamic linker find the correct library
+on its search path.
+
+
## RTLD_LOCAL (Available in API level >= 23)
The dlopen(3) RTLD_LOCAL flag used to be ignored but is implemented
diff --git a/libc/Android.bp b/libc/Android.bp
index 7d08365..0aa6aa0 100644
--- a/libc/Android.bp
+++ b/libc/Android.bp
@@ -754,6 +754,7 @@
arch: {
arm: {
+ asflags: libc_common_flags + ["-mno-restrict-it"],
srcs: [
"arch-arm/generic/bionic/memcmp.S",
"arch-arm/generic/bionic/memmove.S",
@@ -1716,7 +1717,6 @@
native_bridge_supported: true,
no_libcrt: true,
- no_libgcc: true,
stl: "none",
system_shared_libs: [],
diff --git a/libc/include/arpa/nameser.h b/libc/include/arpa/nameser.h
index e0b5c45..89ece1c 100644
--- a/libc/include/arpa/nameser.h
+++ b/libc/include/arpa/nameser.h
@@ -591,33 +591,29 @@
/* The names of these symbols were accidentally prefixed with __ in L. */
/* The duplication here is intentional to avoid declaring different symbols with the same
* declaration. */
-int ns_msg_getflag(ns_msg __handle, int __flag) __INTRODUCED_IN_64(23);
-uint16_t ns_get16(const u_char* __src) __INTRODUCED_IN_64(23);
-uint32_t ns_get32(const u_char* __src) __INTRODUCED_IN_64(23);
-void ns_put16(uint16_t __src, u_char* __dst) __INTRODUCED_IN_64(23);
-void ns_put32(uint32_t __src, u_char* __dst) __INTRODUCED_IN_64(23);
-int ns_initparse(const u_char* __msg, int __msg_size, ns_msg* __handle) __INTRODUCED_IN_64(23);
-int ns_skiprr(const u_char* __ptr, const u_char* __eom, ns_sect __section, int __count) __INTRODUCED_IN_64(23);
-int ns_parserr(ns_msg* __handle, ns_sect __section, int __rr_number, ns_rr* __rr) __INTRODUCED_IN_64(23);
-int ns_sprintrr(const ns_msg* __handle, const ns_rr* __rr, const char* __name_ctx, const char* __origin, char* __buf, size_t __buf_size)
- __INTRODUCED_IN_64(23);
-int ns_sprintrrf(const u_char* __msg, size_t __msg_size, const char* __name, ns_class __class, ns_type __type, u_long __ttl, const u_char* __rdata, size_t __rdata_size, const char* __name_ctx, const char* __origin, char* __buf, size_t __buf_size) __INTRODUCED_IN_64(23);
-int ns_format_ttl(u_long __ttl, char* __dst, size_t __dst_size) __INTRODUCED_IN_64(23);
-int ns_name_ntol(const u_char* __src, u_char* __dst, size_t __dst_size) __INTRODUCED_IN_64(23);
-int ns_name_ntop(const u_char* __src, char* __dst, size_t __dst_size) __INTRODUCED_IN_64(23);
-int ns_name_pton(const char* __src, u_char* __dst, size_t __dst_size) __INTRODUCED_IN_64(23);
-int ns_name_unpack(const u_char* __msg, const u_char* __eom, const u_char* __src, u_char* __dst, size_t __dst_size)
- __INTRODUCED_IN_64(23);
-int ns_name_pack(const u_char* __src, u_char* __dst, int __dst_size, const u_char** __dn_ptrs, const u_char** __last_dn_ptr) __INTRODUCED_IN_64(23);
-int ns_name_uncompress(const u_char* __msg, const u_char* __eom, const u_char* __src, char* __dst, size_t __dst_size)
- __INTRODUCED_IN_64(23);
-int ns_name_compress(const char* __src, u_char* __dst, size_t __dst_size, const u_char** __dn_ptrs, const u_char** __last_dn_ptr)
- __INTRODUCED_IN_64(23);
-int ns_name_skip(const u_char** __ptr_ptr, const u_char* __eom) __INTRODUCED_IN_64(23);
-void ns_name_rollback(const u_char* __src, const u_char** __dn_ptrs, const u_char** __last_dn_ptr) __INTRODUCED_IN_64(23);
+int ns_msg_getflag(ns_msg __handle, int __flag) __INTRODUCED_IN_64(22);
+uint16_t ns_get16(const u_char* __src) __INTRODUCED_IN_64(22);
+uint32_t ns_get32(const u_char* __src) __INTRODUCED_IN_64(22);
+void ns_put16(uint16_t __src, u_char* __dst) __INTRODUCED_IN_64(22);
+void ns_put32(uint32_t __src, u_char* __dst) __INTRODUCED_IN_64(22);
+int ns_initparse(const u_char* __msg, int __msg_size, ns_msg* __handle) __INTRODUCED_IN_64(22);
+int ns_skiprr(const u_char* __ptr, const u_char* __eom, ns_sect __section, int __count) __INTRODUCED_IN_64(22);
+int ns_parserr(ns_msg* __handle, ns_sect __section, int __rr_number, ns_rr* __rr) __INTRODUCED_IN_64(22);
+int ns_sprintrr(const ns_msg* __handle, const ns_rr* __rr, const char* __name_ctx, const char* __origin, char* __buf, size_t __buf_size) __INTRODUCED_IN_64(22);
+int ns_sprintrrf(const u_char* __msg, size_t __msg_size, const char* __name, ns_class __class, ns_type __type, u_long __ttl, const u_char* __rdata, size_t __rdata_size, const char* __name_ctx, const char* __origin, char* __buf, size_t __buf_size) __INTRODUCED_IN_64(22);
+int ns_format_ttl(u_long __ttl, char* __dst, size_t __dst_size) __INTRODUCED_IN_64(22);
+int ns_name_ntol(const u_char* __src, u_char* __dst, size_t __dst_size) __INTRODUCED_IN_64(22);
+int ns_name_ntop(const u_char* __src, char* __dst, size_t __dst_size) __INTRODUCED_IN_64(22);
+int ns_name_pton(const char* __src, u_char* __dst, size_t __dst_size) __INTRODUCED_IN_64(22);
+int ns_name_unpack(const u_char* __msg, const u_char* __eom, const u_char* __src, u_char* __dst, size_t __dst_size) __INTRODUCED_IN_64(22);
+int ns_name_pack(const u_char* __src, u_char* __dst, int __dst_size, const u_char** __dn_ptrs, const u_char** __last_dn_ptr) __INTRODUCED_IN_64(22);
+int ns_name_uncompress(const u_char* __msg, const u_char* __eom, const u_char* __src, char* __dst, size_t __dst_size) __INTRODUCED_IN_64(22);
+int ns_name_compress(const char* __src, u_char* __dst, size_t __dst_size, const u_char** __dn_ptrs, const u_char** __last_dn_ptr) __INTRODUCED_IN_64(22);
+int ns_name_skip(const u_char** __ptr_ptr, const u_char* __eom) __INTRODUCED_IN_64(22);
+void ns_name_rollback(const u_char* __src, const u_char** __dn_ptrs, const u_char** __last_dn_ptr) __INTRODUCED_IN_64(22);
-int ns_makecanon(const char* __src, char* __dst, size_t __dst_size) __INTRODUCED_IN_64(23);
-int ns_samename(const char* __lhs, const char* __rhs) __INTRODUCED_IN_64(23);
+int ns_makecanon(const char* __src, char* __dst, size_t __dst_size) __INTRODUCED_IN_64(22);
+int ns_samename(const char* __lhs, const char* __rhs) __INTRODUCED_IN_64(22);
#endif /* !defined(__LP64__) */
__END_DECLS
diff --git a/libc/libc.map.txt b/libc/libc.map.txt
index b36ee4c..424c8f3 100644
--- a/libc/libc.map.txt
+++ b/libc/libc.map.txt
@@ -690,7 +690,7 @@
ns_name_ntol; # arm64 x86_64 mips64 introduced=22
ns_name_ntop; # arm64 x86_64 mips64 introduced=22
ns_name_pack; # arm64 x86_64 mips64 introduced=22
- ns_name_pton; # arm64 x86_64 mips64 introduced=23
+ ns_name_pton; # arm64 x86_64 mips64 introduced=22
ns_name_rollback; # arm64 x86_64 mips64 introduced=22
ns_name_skip; # arm64 x86_64 mips64 introduced=22
ns_name_uncompress; # arm64 x86_64 mips64 introduced=22
diff --git a/libc/tzcode/bionic.cpp b/libc/tzcode/bionic.cpp
index 1742d79..6d84303 100644
--- a/libc/tzcode/bionic.cpp
+++ b/libc/tzcode/bionic.cpp
@@ -199,37 +199,36 @@
int __bionic_open_tzdata(const char* olson_id, int32_t* entry_length) {
int fd;
-#if defined(__ANDROID__)
- // On Android devices, try the four hard-coded locations in order.
- //
+ // Try the three locations for the tzdata file in a strict order:
// 1: The O-MR1 time zone updates via APK update mechanism. This is
- // tried first because it allows us to test that the time zone updates
- // via APK mechanism still works even on devices with the time zone
- // module.
+ // tried first because it allows us to test that the time zone updates
+ // via APK mechanism still works even on devices with the time zone
+ // module.
+ // 2: The time zone data module which contains the main copy. This is the
+ // common case.
+ // 3: The ultimate fallback: the non-updatable copy in /system.
+
+#if defined(__ANDROID__)
+ // On Android devices, bionic has to work even if exec takes place without
+ // environment variables set. So, all paths are hardcoded here.
+
fd = __bionic_open_tzdata_path("/data/misc/zoneinfo/current/tzdata",
olson_id, entry_length);
if (fd >= 0) return fd;
- // 2: The time zone data module which may contain newer data on
- // devices that support module updates.
fd = __bionic_open_tzdata_path("/apex/com.android.tzdata/etc/tz/tzdata",
olson_id, entry_length);
if (fd >= 0) return fd;
- // 3: The runtime module, which should exist even on devices that
- // do not support APEX file updates.
- fd = __bionic_open_tzdata_path("/apex/com.android.runtime/etc/tz/tzdata",
- olson_id, entry_length);
- if (fd >= 0) return fd;
-
- // 4: The ultimate fallback: the non-updatable copy in /system.
fd = __bionic_open_tzdata_path("/system/usr/share/zoneinfo/tzdata",
olson_id, entry_length);
if (fd >= 0) return fd;
#else
- // On the host, we don't expect those locations to exist, and we're not
- // worried about security so we trust $ANDROID_DATA, $ANDROID_RUNTIME_ROOT,
- // $ANDROID_TZDATA_ROOT, and $ANDROID_ROOT to point us in the right direction.
+ // On the host, we don't expect the hard-coded locations above to exist, and
+ // we're not worried about security so we trust $ANDROID_DATA,
+ // $ANDROID_TZDATA_ROOT, and $ANDROID_ROOT to point us in the right direction
+ // instead.
+
char* path = make_path("ANDROID_DATA", "/misc/zoneinfo/current/tzdata");
fd = __bionic_open_tzdata_path(path, olson_id, entry_length);
free(path);
@@ -240,11 +239,6 @@
free(path);
if (fd >= 0) return fd;
- path = make_path("ANDROID_RUNTIME_ROOT", "/etc/tz/tzdata");
- fd = __bionic_open_tzdata_path(path, olson_id, entry_length);
- free(path);
- if (fd >= 0) return fd;
-
path = make_path("ANDROID_ROOT", "/usr/share/zoneinfo/tzdata");
fd = __bionic_open_tzdata_path(path, olson_id, entry_length);
free(path);