Merge "bionic: fix pthread_mutex_timedlock for PI mutexes" into main
diff --git a/benchmarks/stdlib_benchmark.cpp b/benchmarks/stdlib_benchmark.cpp
index 9be72e7..7680b40 100644
--- a/benchmarks/stdlib_benchmark.cpp
+++ b/benchmarks/stdlib_benchmark.cpp
@@ -235,3 +235,6 @@
BIONIC_TRIVIAL_BENCHMARK(BM_stdlib_strtoll, strtoll(" -123", nullptr, 0));
BIONIC_TRIVIAL_BENCHMARK(BM_stdlib_strtoul, strtoul(" -123", nullptr, 0));
BIONIC_TRIVIAL_BENCHMARK(BM_stdlib_strtoull, strtoull(" -123", nullptr, 0));
+
+BIONIC_TRIVIAL_BENCHMARK(BM_stdlib_strtol_hex, strtol("0xdeadbeef", nullptr, 0));
+BIONIC_TRIVIAL_BENCHMARK(BM_stdlib_strtoul_hex, strtoul("0xdeadbeef", nullptr, 0));
diff --git a/libc/Android.bp b/libc/Android.bp
index 6f36aad..fdf34eb 100644
--- a/libc/Android.bp
+++ b/libc/Android.bp
@@ -67,9 +67,6 @@
// __dso_handle needs to have default visibility on ARM32. See b/73485611.
"-Wexit-time-destructors",
- // GWP-ASan requires platform TLS.
- "-fno-emulated-tls",
-
// We know clang does a lot of harm by rewriting what we've said, and sadly
// never see any good it does, so let's just ask it to do what we say...
// (The specific motivating example was clang turning a loop that would only
diff --git a/libc/bionic/vdso.cpp b/libc/bionic/vdso.cpp
index d0f01d0..0a9a9e5 100644
--- a/libc/bionic/vdso.cpp
+++ b/libc/bionic/vdso.cpp
@@ -131,6 +131,7 @@
for (size_t i = 0; i < vdso_ehdr->e_shnum; ++i) {
if (vdso_shdr[i].sh_type == SHT_DYNSYM) {
symbol_count = vdso_shdr[i].sh_size / sizeof(ElfW(Sym));
+ break;
}
}
if (symbol_count == 0) {
@@ -147,6 +148,7 @@
} else if (vdso_phdr[i].p_type == PT_LOAD) {
vdso_addr = vdso_ehdr_addr + vdso_phdr[i].p_offset - vdso_phdr[i].p_vaddr;
}
+ if (vdso_addr && vdso_dyn) break;
}
if (vdso_addr == 0 || vdso_dyn == nullptr) {
return;
@@ -161,16 +163,18 @@
} else if (d->d_tag == DT_SYMTAB) {
symtab = reinterpret_cast<ElfW(Sym)*>(vdso_addr + d->d_un.d_ptr);
}
+ if (strtab && symtab) break;
}
if (strtab == nullptr || symtab == nullptr) {
return;
}
// Are there any symbols we want?
- for (size_t i = 0; i < symbol_count; ++i) {
- for (size_t j = 0; j < VDSO_END; ++j) {
- if (strcmp(vdso[j].name, strtab + symtab[i].st_name) == 0) {
- vdso[j].fn = reinterpret_cast<void*>(vdso_addr + symtab[i].st_value);
+ for (size_t i = 0; i < VDSO_END; ++i) {
+ for (size_t j = 0; j < symbol_count; ++j) {
+ if (strcmp(vdso[i].name, strtab + symtab[j].st_name) == 0) {
+ vdso[i].fn = reinterpret_cast<void*>(vdso_addr + symtab[j].st_value);
+ break;
}
}
}
diff --git a/libc/dns/net/sethostent.c b/libc/dns/net/sethostent.c
index 483105a..5c4bdb5 100644
--- a/libc/dns/net/sethostent.c
+++ b/libc/dns/net/sethostent.c
@@ -157,6 +157,7 @@
if ((ptr = buf = malloc(len = info->buflen)) == NULL) {
*info->he = NETDB_INTERNAL;
+ endhostent_r(&hf);
return NULL;
}
@@ -241,6 +242,7 @@
return hp;
nospc:
*info->he = NETDB_INTERNAL;
+ endhostent_r(&hf);
free(buf);
errno = ENOSPC;
return NULL;
diff --git a/libc/platform/bionic/tls_defines.h b/libc/platform/bionic/tls_defines.h
index 3e2efa3..8fe8701 100644
--- a/libc/platform/bionic/tls_defines.h
+++ b/libc/platform/bionic/tls_defines.h
@@ -68,6 +68,11 @@
//
// - TLS_SLOT_APP: Available for use by apps in Android Q and later. (This slot
// was used for errno in P and earlier.)
+//
+// - TLS_SLOT_NATIVE_BRIDGE_GUEST_STATE: Pointer to the guest state for native
+// bridge implementations. It is (to be) used by debuggerd to access this
+// state for guest aware crash reporting of the binary translated code.
+// (Introduced in V)
#if defined(__arm__) || defined(__aarch64__)
@@ -80,7 +85,8 @@
// [1] "Addenda to, and Errata in, the ABI for the ARM Architecture". Section 3.
// http://infocenter.arm.com/help/topic/com.arm.doc.ihi0045e/IHI0045E_ABI_addenda.pdf
-#define MIN_TLS_SLOT (-1) // update this value when reserving a slot
+#define MIN_TLS_SLOT (-2) // update this value when reserving a slot
+#define TLS_SLOT_NATIVE_BRIDGE_GUEST_STATE (-2)
#define TLS_SLOT_BIONIC_TLS (-1)
#define TLS_SLOT_DTV 0
#define TLS_SLOT_THREAD_ID 1
@@ -112,7 +118,8 @@
#define TLS_SLOT_ART_THREAD_SELF 7
#define TLS_SLOT_DTV 8
#define TLS_SLOT_BIONIC_TLS 9
-#define MAX_TLS_SLOT 9 // update this value when reserving a slot
+#define TLS_SLOT_NATIVE_BRIDGE_GUEST_STATE 10
+#define MAX_TLS_SLOT 10 // update this value when reserving a slot
#elif defined(__riscv)
@@ -123,8 +130,9 @@
// [1]: RISC-V ELF Specification. Section: Thread Local Storage
// https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc#thread-local-storage
-#define MIN_TLS_SLOT (-9) // update this value when reserving a slot
+#define MIN_TLS_SLOT (-10) // update this value when reserving a slot
+#define TLS_SLOT_NATIVE_BRIDGE_GUEST_STATE (-10)
#define TLS_SLOT_BIONIC_TLS (-9)
#define TLS_SLOT_DTV (-8)
#define TLS_SLOT_THREAD_ID (-7)
diff --git a/tests/stdlib_test.cpp b/tests/stdlib_test.cpp
index 21c79c8..4793150 100644
--- a/tests/stdlib_test.cpp
+++ b/tests/stdlib_test.cpp
@@ -901,6 +901,12 @@
ASSERT_ERRNO(ERANGE);
ASSERT_EQ('\0', *end_p);
+ // Junk at the end of a valid conversion.
+ errno = 0;
+ ASSERT_EQ(static_cast<T>(123), fn("123abc", &end_p, 0));
+ ASSERT_ERRNO(0);
+ ASSERT_STREQ("abc", end_p);
+
// In case of overflow, strto* leaves us pointing past the end of the number,
// not at the digit that overflowed.
end_p = nullptr;