Merge "Update visibility according to the change AVF directories layout" into main
diff --git a/libm/Android.bp b/libm/Android.bp
index c6e44fc..fa43a16 100644
--- a/libm/Android.bp
+++ b/libm/Android.bp
@@ -161,8 +161,6 @@
"upstream-freebsd/lib/msun/src/s_nextafterf.c",
"upstream-freebsd/lib/msun/src/s_remquo.c",
"upstream-freebsd/lib/msun/src/s_remquof.c",
- "upstream-freebsd/lib/msun/src/s_rint.c",
- "upstream-freebsd/lib/msun/src/s_rintf.c",
"upstream-freebsd/lib/msun/src/s_round.c",
"upstream-freebsd/lib/msun/src/s_roundf.c",
"upstream-freebsd/lib/msun/src/s_scalbln.c",
@@ -179,8 +177,6 @@
"upstream-freebsd/lib/msun/src/s_tanh.c",
"upstream-freebsd/lib/msun/src/s_tanhf.c",
"upstream-freebsd/lib/msun/src/s_tgammaf.c",
- "upstream-freebsd/lib/msun/src/s_trunc.c",
- "upstream-freebsd/lib/msun/src/s_truncf.c",
"upstream-freebsd/lib/msun/src/w_cabs.c",
"upstream-freebsd/lib/msun/src/w_cabsf.c",
"upstream-freebsd/lib/msun/src/w_cabsl.c",
@@ -275,10 +271,23 @@
arch: {
arm: {
srcs: [
- "arm/fenv.c",
- "upstream-freebsd/lib/msun/src/s_ceil.c",
- "upstream-freebsd/lib/msun/src/s_ceilf.c",
+ "fenv-arm.c",
],
+ armv7_a_neon: {
+ // armv7 arm32 has no instructions to implement these as
+ // builtins, so we build the portable implementations for armv7,
+ // because the NDK still supports armv7.
+ srcs: [
+ "upstream-freebsd/lib/msun/src/s_ceil.c",
+ "upstream-freebsd/lib/msun/src/s_ceilf.c",
+ "upstream-freebsd/lib/msun/src/s_floor.c",
+ "upstream-freebsd/lib/msun/src/s_floorf.c",
+ "upstream-freebsd/lib/msun/src/s_rint.c",
+ "upstream-freebsd/lib/msun/src/s_rintf.c",
+ "upstream-freebsd/lib/msun/src/s_trunc.c",
+ "upstream-freebsd/lib/msun/src/s_truncf.c",
+ ],
+ },
instruction_set: "arm",
version_script: ":libm.arm.map",
no_libcrt: true,
@@ -292,7 +301,7 @@
arm64: {
srcs: [
- "arm64/fenv.c",
+ "fenv-arm64.c",
],
exclude_srcs: [
"upstream-freebsd/lib/msun/src/s_fma.c",
@@ -309,19 +318,15 @@
"upstream-freebsd/lib/msun/src/s_lrintf.c",
"upstream-freebsd/lib/msun/src/s_lround.c",
"upstream-freebsd/lib/msun/src/s_lroundf.c",
- "upstream-freebsd/lib/msun/src/s_rint.c",
- "upstream-freebsd/lib/msun/src/s_rintf.c",
"upstream-freebsd/lib/msun/src/s_round.c",
"upstream-freebsd/lib/msun/src/s_roundf.c",
- "upstream-freebsd/lib/msun/src/s_trunc.c",
- "upstream-freebsd/lib/msun/src/s_truncf.c",
],
version_script: ":libm.arm64.map",
},
riscv64: {
srcs: [
- "riscv64/fenv.c",
+ "fenv-riscv64.c",
],
exclude_srcs: [
@@ -339,31 +344,22 @@
"upstream-freebsd/lib/msun/src/s_lrintf.c",
"upstream-freebsd/lib/msun/src/s_lround.c",
"upstream-freebsd/lib/msun/src/s_lroundf.c",
- "upstream-freebsd/lib/msun/src/s_rint.c",
- "upstream-freebsd/lib/msun/src/s_rintf.c",
"upstream-freebsd/lib/msun/src/s_round.c",
"upstream-freebsd/lib/msun/src/s_roundf.c",
- "upstream-freebsd/lib/msun/src/s_trunc.c",
- "upstream-freebsd/lib/msun/src/s_truncf.c",
],
version_script: ":libm.riscv64.map",
},
x86: {
srcs: [
- "i387/fenv.c",
+ "fenv-x86.c",
"x86/lrint.S",
"x86/lrintf.S",
],
exclude_srcs: [
"upstream-freebsd/lib/msun/src/s_lrint.c",
"upstream-freebsd/lib/msun/src/s_lrintf.c",
- "upstream-freebsd/lib/msun/src/s_rint.c",
- "upstream-freebsd/lib/msun/src/s_rintf.c",
- "upstream-freebsd/lib/msun/src/s_trunc.c",
- "upstream-freebsd/lib/msun/src/s_truncf.c",
],
- local_include_dirs: ["i387"],
// The x86 ABI doesn't include this, which is needed for the
// roundss/roundsd instructions that we've used since Android M.
cflags: ["-msse4.1"],
@@ -372,7 +368,7 @@
x86_64: {
srcs: [
- "amd64/fenv.c",
+ "fenv-x86_64.c",
"x86_64/lrint.S",
"x86_64/lrintf.S",
],
@@ -381,10 +377,6 @@
"upstream-freebsd/lib/msun/src/s_llrintf.c",
"upstream-freebsd/lib/msun/src/s_lrint.c",
"upstream-freebsd/lib/msun/src/s_lrintf.c",
- "upstream-freebsd/lib/msun/src/s_rint.c",
- "upstream-freebsd/lib/msun/src/s_rintf.c",
- "upstream-freebsd/lib/msun/src/s_trunc.c",
- "upstream-freebsd/lib/msun/src/s_truncf.c",
],
version_script: ":libm.x86_64.map",
},
diff --git a/libm/builtins.cpp b/libm/builtins.cpp
index 41e145b..22a0191 100644
--- a/libm/builtins.cpp
+++ b/libm/builtins.cpp
@@ -18,13 +18,12 @@
#include "fpmath.h"
-double fabs(double x) { return __builtin_fabs(x); }
-float fabsf(float x) { return __builtin_fabsf(x); }
-long double fabsl(long double x) { return __builtin_fabsl(x); }
-
-#if defined(__aarch64__) || defined(__riscv) || defined(__i386__) || defined(__x86_64__)
-float ceilf(float x) { return __builtin_ceilf(x); }
+#if defined(__arm__) && (__ARM_ARCH <= 7)
+// armv7 arm32 has no instructions to implement these builtins,
+// so we include the msun source in the .bp file instead.
+#else
double ceil(double x) { return __builtin_ceil(x); }
+float ceilf(float x) { return __builtin_ceilf(x); }
#if defined(__ILP32__)
__weak_reference(ceil, ceill);
#endif
@@ -34,21 +33,16 @@
float copysignf(float x, float y) { return __builtin_copysignf(x, y); }
long double copysignl(long double x, long double y) { return __builtin_copysignl(x, y); }
-#if defined(__arm__) && (__ARM_ARCH < 8)
-// armv8 arm32 has a single-instruction implementation for these, but
-// armv7 arm32 doesn't, so __builtin_ doesn't work for arm32.
-#include "math_private.h"
-namespace s_floor {
-#include "upstream-freebsd/lib/msun/src/s_floor.c"
-}
-namespace s_floorf {
-#include "upstream-freebsd/lib/msun/src/s_floorf.c"
-}
-float floorf(float x) { return s_floorf::floorf(x); }
-double floor(double x) { return s_floor::floor(x); }
+double fabs(double x) { return __builtin_fabs(x); }
+float fabsf(float x) { return __builtin_fabsf(x); }
+long double fabsl(long double x) { return __builtin_fabsl(x); }
+
+#if defined(__arm__) && (__ARM_ARCH <= 7)
+// armv7 arm32 has no instructions to implement these builtins,
+// so we include the msun source in the .bp file instead.
#else
-float floorf(float x) { return __builtin_floorf(x); }
double floor(double x) { return __builtin_floor(x); }
+float floorf(float x) { return __builtin_floorf(x); }
#if defined(__ILP32__)
__weak_reference(floor, floorl);
#endif
@@ -79,28 +73,34 @@
long long llroundf(float x) { return __builtin_llroundf(x); }
#endif
-#if defined(__aarch64__) || defined(__riscv) || defined(__i386__) || defined(__x86_64__)
-float rintf(float x) { return __builtin_rintf(x); }
+#if defined(__arm__) && (__ARM_ARCH <= 7)
+// armv7 arm32 has no instructions to implement these builtins,
+// so we include the msun source in the .bp file instead.
+#else
double rint(double x) { return __builtin_rint(x); }
+float rintf(float x) { return __builtin_rintf(x); }
#if defined(__ILP32__)
__weak_reference(rint, rintl);
#endif
#endif
#if defined(__aarch64__) || defined(__riscv)
-float roundf(float x) { return __builtin_roundf(x); }
double round(double x) { return __builtin_round(x); }
+float roundf(float x) { return __builtin_roundf(x); }
#endif
-float sqrtf(float x) { return __builtin_sqrtf(x); }
double sqrt(double x) { return __builtin_sqrt(x); }
+float sqrtf(float x) { return __builtin_sqrtf(x); }
#if defined(__ILP32__)
__weak_reference(sqrt, sqrtl);
#endif
-#if defined(__aarch64__) || defined(__riscv) || defined(__i386__) || defined(__x86_64__)
-float truncf(float x) { return __builtin_truncf(x); }
+#if defined(__arm__) && (__ARM_ARCH <= 7)
+// armv7 arm32 has no instructions to implement these builtins,
+// so we include the msun source in the .bp file instead.
+#else
double trunc(double x) { return __builtin_trunc(x); }
+float truncf(float x) { return __builtin_truncf(x); }
#if defined(__ILP32__)
__weak_reference(trunc, truncl);
#endif
diff --git a/libm/arm/fenv.c b/libm/fenv-arm.c
similarity index 100%
rename from libm/arm/fenv.c
rename to libm/fenv-arm.c
diff --git a/libm/arm64/fenv.c b/libm/fenv-arm64.c
similarity index 100%
rename from libm/arm64/fenv.c
rename to libm/fenv-arm64.c
diff --git a/libm/riscv64/fenv.c b/libm/fenv-riscv64.c
similarity index 100%
rename from libm/riscv64/fenv.c
rename to libm/fenv-riscv64.c
diff --git a/libm/i387/fenv.c b/libm/fenv-x86.c
similarity index 100%
rename from libm/i387/fenv.c
rename to libm/fenv-x86.c
diff --git a/libm/amd64/fenv.c b/libm/fenv-x86_64.c
similarity index 100%
rename from libm/amd64/fenv.c
rename to libm/fenv-x86_64.c
diff --git a/linker/linker.cpp b/linker/linker.cpp
index e13d37d..2eb3cae 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -3370,7 +3370,7 @@
}
#endif
- if (!relocate(lookup_list)) {
+ if (this != solist_get_vdso() && !relocate(lookup_list)) {
return false;
}
diff --git a/linker/linker_main.cpp b/linker/linker_main.cpp
index a625af7..cdc4b86 100644
--- a/linker/linker_main.cpp
+++ b/linker/linker_main.cpp
@@ -73,6 +73,25 @@
void __libc_init_mte(const memtag_dynamic_entries_t* memtag_dynamic_entries, const void* phdr_start,
size_t phdr_count, uintptr_t load_bias, void* stack_top);
+__printflike(1, 2) static void __linker_error(const char* fmt, ...) {
+ va_list ap;
+
+ va_start(ap, fmt);
+ async_safe_format_fd_va_list(STDERR_FILENO, fmt, ap);
+ write(STDERR_FILENO, "\n", 1);
+ va_end(ap);
+
+ va_start(ap, fmt);
+ async_safe_format_log_va_list(ANDROID_LOG_FATAL, "linker", fmt, ap);
+ va_end(ap);
+
+ _exit(EXIT_FAILURE);
+}
+
+static void __linker_cannot_link(const char* argv0) {
+ __linker_error("CANNOT LINK EXECUTABLE \"%s\": %s", argv0, linker_get_error_buffer());
+}
+
// These should be preserved static to avoid emitting
// RELATIVE relocations for the part of the code running
// before linker links itself.
@@ -167,22 +186,21 @@
return;
}
- soinfo* si = soinfo_alloc(&g_default_namespace, "[vdso]", nullptr, 0, 0);
+ vdso = soinfo_alloc(&g_default_namespace, "[vdso]", nullptr, 0, 0);
- si->phdr = reinterpret_cast<ElfW(Phdr)*>(reinterpret_cast<char*>(ehdr_vdso) + ehdr_vdso->e_phoff);
- si->phnum = ehdr_vdso->e_phnum;
- si->base = reinterpret_cast<ElfW(Addr)>(ehdr_vdso);
- si->size = phdr_table_get_load_size(si->phdr, si->phnum);
- si->load_bias = get_elf_exec_load_bias(ehdr_vdso);
+ vdso->phdr = reinterpret_cast<ElfW(Phdr)*>(reinterpret_cast<char*>(ehdr_vdso) + ehdr_vdso->e_phoff);
+ vdso->phnum = ehdr_vdso->e_phnum;
+ vdso->base = reinterpret_cast<ElfW(Addr)>(ehdr_vdso);
+ vdso->size = phdr_table_get_load_size(vdso->phdr, vdso->phnum);
+ vdso->load_bias = get_elf_exec_load_bias(ehdr_vdso);
- si->prelink_image();
- si->link_image(SymbolLookupList(si), si, nullptr, nullptr);
- // prevents accidental unloads...
- si->set_dt_flags_1(si->get_dt_flags_1() | DF_1_NODELETE);
- si->set_linked();
- si->call_constructors();
+ if (!vdso->prelink_image() || !vdso->link_image(SymbolLookupList(vdso), vdso, nullptr, nullptr)) {
+ __linker_cannot_link(g_argv[0]);
+ }
- vdso = si;
+ // Prevent accidental unloads...
+ vdso->set_dt_flags_1(vdso->get_dt_flags_1() | DF_1_NODELETE);
+ vdso->set_linked();
}
// Initializes an soinfo's link_map_head field using other fields from the
@@ -239,28 +257,6 @@
static char kFallbackLinkerPath[] = "/system/bin/linker";
#endif
-__printflike(1, 2)
-static void __linker_error(const char* fmt, ...) {
- va_list ap;
-
- va_start(ap, fmt);
- async_safe_format_fd_va_list(STDERR_FILENO, fmt, ap);
- write(STDERR_FILENO, "\n", 1);
- va_end(ap);
-
- va_start(ap, fmt);
- async_safe_format_log_va_list(ANDROID_LOG_FATAL, "linker", fmt, ap);
- va_end(ap);
-
- _exit(EXIT_FAILURE);
-}
-
-static void __linker_cannot_link(const char* argv0) {
- __linker_error("CANNOT LINK EXECUTABLE \"%s\": %s",
- argv0,
- linker_get_error_buffer());
-}
-
// Load an executable. Normally the kernel has already loaded the executable when the linker
// starts. The linker can be invoked directly on an executable, though, and then the linker must
// load it. This function doesn't load dependencies or resolve relocations.
diff --git a/linker/linker_soinfo.cpp b/linker/linker_soinfo.cpp
index d915503..b2170d8 100644
--- a/linker/linker_soinfo.cpp
+++ b/linker/linker_soinfo.cpp
@@ -159,11 +159,6 @@
break;
}
}
-
- if (IsGeneral) {
- TRACE_TYPE(LOOKUP, "NOT FOUND %s in %s@%p",
- name, lib->si_->get_realpath(), reinterpret_cast<void*>(lib->si_->base));
- }
}
// Search the library's hash table chain.
@@ -186,21 +181,11 @@
memcmp(lib->strtab_ + sym->st_name, name, name_len + 1) == 0 &&
is_symbol_global_and_defined(lib->si_, sym)) {
*si_found_in = lib->si_;
- if (IsGeneral) {
- TRACE_TYPE(LOOKUP, "FOUND %s in %s (%p) %zd",
- name, lib->si_->get_realpath(), reinterpret_cast<void*>(sym->st_value),
- static_cast<size_t>(sym->st_size));
- }
return sym;
}
}
++sym_idx;
} while ((chain_value & 1) == 0);
-
- if (IsGeneral) {
- TRACE_TYPE(LOOKUP, "NOT FOUND %s in %s@%p",
- name, lib->si_->get_realpath(), reinterpret_cast<void*>(lib->si_->base));
- }
}
}
@@ -338,9 +323,6 @@
// test against bloom filter
if ((1 & (bloom_word >> h1) & (bloom_word >> h2)) == 0) {
- TRACE_TYPE(LOOKUP, "NOT FOUND %s in %s@%p",
- symbol_name.get_name(), get_realpath(), reinterpret_cast<void*>(base));
-
return nullptr;
}
@@ -348,9 +330,6 @@
uint32_t n = gnu_bucket_[hash % gnu_nbucket_];
if (n == 0) {
- TRACE_TYPE(LOOKUP, "NOT FOUND %s in %s@%p",
- symbol_name.get_name(), get_realpath(), reinterpret_cast<void*>(base));
-
return nullptr;
}
@@ -363,16 +342,10 @@
check_symbol_version(versym, n, verneed) &&
strcmp(get_string(s->st_name), symbol_name.get_name()) == 0 &&
is_symbol_global_and_defined(this, s)) {
- TRACE_TYPE(LOOKUP, "FOUND %s in %s (%p) %zd",
- symbol_name.get_name(), get_realpath(), reinterpret_cast<void*>(s->st_value),
- static_cast<size_t>(s->st_size));
return symtab_ + n;
}
} while ((gnu_chain_[n++] & 1) == 0);
- TRACE_TYPE(LOOKUP, "NOT FOUND %s in %s@%p",
- symbol_name.get_name(), get_realpath(), reinterpret_cast<void*>(base));
-
return nullptr;
}
@@ -392,18 +365,10 @@
if (check_symbol_version(versym, n, verneed) &&
strcmp(get_string(s->st_name), symbol_name.get_name()) == 0 &&
is_symbol_global_and_defined(this, s)) {
- TRACE_TYPE(LOOKUP, "FOUND %s in %s (%p) %zd",
- symbol_name.get_name(), get_realpath(),
- reinterpret_cast<void*>(s->st_value),
- static_cast<size_t>(s->st_size));
return symtab_ + n;
}
}
- TRACE_TYPE(LOOKUP, "NOT FOUND %s in %s@%p %x %zd",
- symbol_name.get_name(), get_realpath(),
- reinterpret_cast<void*>(base), hash, hash % nbucket_);
-
return nullptr;
}
diff --git a/tests/float_test.cpp b/tests/float_test.cpp
index 3ef4593..a2b7ecb 100644
--- a/tests/float_test.cpp
+++ b/tests/float_test.cpp
@@ -122,3 +122,7 @@
#error LDBL_HAS_SUBNORM
#endif
}
+
+TEST(float_h, FLT_EVAL_METHOD_exact) {
+ ASSERT_EQ(0, FLT_EVAL_METHOD);
+}