Merge "Add a zip package containing the crt*.o objects"
diff --git a/libc/Android.bp b/libc/Android.bp
index 9321633..6042929 100644
--- a/libc/Android.bp
+++ b/libc/Android.bp
@@ -2516,13 +2516,8 @@
cmd: "grep -v '^int[ \t]*setresgid' $(in) > $(out)",
}
-cc_genrule {
- name: "libseccomp_policy_app_zygote_sources",
- recovery_available: true,
- cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app_zygote $(in)",
-
- tools: [ "genseccomp" ],
-
+filegroup {
+ name: "seccomp_syscalls_sources_zygote",
srcs: [
"SYSCALLS.TXT",
"SECCOMP_ALLOWLIST_COMMON.TXT",
@@ -2531,62 +2526,10 @@
"SECCOMP_PRIORITY.TXT",
":generate_app_zygote_blocklist",
],
-
- arch: {
- arm: {
- srcs: [
- ":libseccomp_gen_syscall_nrs_arm",
- ":libseccomp_gen_syscall_nrs_arm64",
- ],
- out: [
- "arm_app_zygote_policy.cpp",
- "arm64_app_zygote_policy.cpp",
- ],
- },
- arm64: {
- srcs: [
- ":libseccomp_gen_syscall_nrs_arm",
- ":libseccomp_gen_syscall_nrs_arm64",
- ],
- out: [
- "arm_app_zygote_policy.cpp",
- "arm64_app_zygote_policy.cpp",
- ],
- },
- riscv64: {
- srcs: [":libseccomp_gen_syscall_nrs_riscv64"],
- out: ["riscv64_app_zygote_policy.cpp"],
- },
- x86: {
- srcs: [
- ":libseccomp_gen_syscall_nrs_x86",
- ":libseccomp_gen_syscall_nrs_x86_64",
- ],
- out: [
- "x86_app_zygote_policy.cpp",
- "x86_64_app_zygote_policy.cpp",
- ],
- },
- x86_64: {
- srcs: [
- ":libseccomp_gen_syscall_nrs_x86",
- ":libseccomp_gen_syscall_nrs_x86_64",
- ],
- out: [
- "x86_app_zygote_policy.cpp",
- "x86_64_app_zygote_policy.cpp",
- ],
- },
- },
}
-cc_genrule {
- name: "libseccomp_policy_app_sources",
- recovery_available: true,
- cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app $(in)",
-
- tools: [ "genseccomp" ],
-
+filegroup {
+ name: "seccomp_syscalls_sources_app",
srcs: [
"SYSCALLS.TXT",
"SECCOMP_ALLOWLIST_COMMON.TXT",
@@ -2595,62 +2538,10 @@
"SECCOMP_BLOCKLIST_APP.TXT",
"SECCOMP_PRIORITY.TXT",
],
-
- arch: {
- arm: {
- srcs: [
- ":libseccomp_gen_syscall_nrs_arm",
- ":libseccomp_gen_syscall_nrs_arm64",
- ],
- out: [
- "arm_app_policy.cpp",
- "arm64_app_policy.cpp",
- ],
- },
- arm64: {
- srcs: [
- ":libseccomp_gen_syscall_nrs_arm",
- ":libseccomp_gen_syscall_nrs_arm64",
- ],
- out: [
- "arm_app_policy.cpp",
- "arm64_app_policy.cpp",
- ],
- },
- riscv64: {
- srcs: [":libseccomp_gen_syscall_nrs_riscv64"],
- out: ["riscv64_app_policy.cpp"],
- },
- x86: {
- srcs: [
- ":libseccomp_gen_syscall_nrs_x86",
- ":libseccomp_gen_syscall_nrs_x86_64",
- ],
- out: [
- "x86_app_policy.cpp",
- "x86_64_app_policy.cpp",
- ],
- },
- x86_64: {
- srcs: [
- ":libseccomp_gen_syscall_nrs_x86",
- ":libseccomp_gen_syscall_nrs_x86_64",
- ],
- out: [
- "x86_app_policy.cpp",
- "x86_64_app_policy.cpp",
- ],
- },
- },
}
-cc_genrule {
- name: "libseccomp_policy_system_sources",
- recovery_available: true,
- cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=system $(in)",
-
- tools: [ "genseccomp" ],
-
+filegroup {
+ name: "seccomp_syscalls_sources_system",
srcs: [
"SYSCALLS.TXT",
"SECCOMP_ALLOWLIST_COMMON.TXT",
@@ -2658,52 +2549,185 @@
"SECCOMP_BLOCKLIST_COMMON.TXT",
"SECCOMP_PRIORITY.TXT",
],
+}
+cc_genrule {
+ name: "libseccomp_policy_app_zygote_sources_x86",
+ recovery_available: true,
+ cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app_zygote $(in)",
+ tools: [ "genseccomp" ],
+ srcs: [
+ ":seccomp_syscalls_sources_zygote",
+ ":libseccomp_gen_syscall_nrs_x86",
+ ":libseccomp_gen_syscall_nrs_x86_64",
+ ],
+ out: [
+ "x86_app_zygote_policy.cpp",
+ "x86_64_app_zygote_policy.cpp",
+ ],
+ enabled: false,
arch: {
- arm: {
- srcs: [
- ":libseccomp_gen_syscall_nrs_arm",
- ":libseccomp_gen_syscall_nrs_arm64",
- ],
- out: [
- "arm_system_policy.cpp",
- "arm64_system_policy.cpp",
- ],
- },
- arm64: {
- srcs: [
- ":libseccomp_gen_syscall_nrs_arm",
- ":libseccomp_gen_syscall_nrs_arm64",
- ],
- out: [
- "arm_system_policy.cpp",
- "arm64_system_policy.cpp",
- ],
- },
- riscv64: {
- srcs: [":libseccomp_gen_syscall_nrs_riscv64"],
- out: ["riscv64_system_policy.cpp"],
- },
- x86: {
- srcs: [
- ":libseccomp_gen_syscall_nrs_x86",
- ":libseccomp_gen_syscall_nrs_x86_64",
- ],
- out: [
- "x86_system_policy.cpp",
- "x86_64_system_policy.cpp",
- ],
- },
- x86_64: {
- srcs: [
- ":libseccomp_gen_syscall_nrs_x86",
- ":libseccomp_gen_syscall_nrs_x86_64",
- ],
- out: [
- "x86_system_policy.cpp",
- "x86_64_system_policy.cpp",
- ],
- },
+ x86: { enabled: true },
+ x86_64: { enabled: true },
+ },
+}
+
+cc_genrule {
+ name: "libseccomp_policy_app_zygote_sources_arm",
+ recovery_available: true,
+ cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app_zygote $(in)",
+ tools: [ "genseccomp" ],
+ srcs: [
+ ":seccomp_syscalls_sources_zygote",
+ ":libseccomp_gen_syscall_nrs_arm",
+ ":libseccomp_gen_syscall_nrs_arm64",
+ ],
+ out: [
+ "arm_app_zygote_policy.cpp",
+ "arm64_app_zygote_policy.cpp",
+ ],
+ enabled: false,
+ arch: {
+ arm: { enabled: true },
+ arm64: { enabled: true },
+ },
+}
+
+cc_genrule {
+ name: "libseccomp_policy_app_zygote_sources_riscv64",
+ recovery_available: true,
+ cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app_zygote $(in)",
+ tools: [ "genseccomp" ],
+ srcs: [
+ ":seccomp_syscalls_sources_zygote",
+ ":libseccomp_gen_syscall_nrs_riscv64",
+ ],
+ out: [
+ "riscv64_app_zygote_policy.cpp",
+ ],
+ enabled: false,
+ arch: {
+ riscv64: { enabled: true },
+ },
+}
+
+cc_genrule {
+ name: "libseccomp_policy_app_sources_x86",
+ recovery_available: true,
+ cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app $(in)",
+ tools: [ "genseccomp" ],
+ srcs: [
+ ":seccomp_syscalls_sources_app",
+ ":libseccomp_gen_syscall_nrs_x86",
+ ":libseccomp_gen_syscall_nrs_x86_64",
+ ],
+ out: [
+ "x86_app_policy.cpp",
+ "x86_64_app_policy.cpp",
+ ],
+ enabled: false,
+ arch: {
+ x86: { enabled: true },
+ x86_64: { enabled: true },
+ },
+}
+
+cc_genrule {
+ name: "libseccomp_policy_app_sources_arm",
+ recovery_available: true,
+ cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app $(in)",
+ tools: [ "genseccomp" ],
+ srcs: [
+ ":seccomp_syscalls_sources_app",
+ ":libseccomp_gen_syscall_nrs_arm",
+ ":libseccomp_gen_syscall_nrs_arm64",
+ ],
+ out: [
+ "arm_app_policy.cpp",
+ "arm64_app_policy.cpp",
+ ],
+ enabled: false,
+ arch: {
+ arm: { enabled: true },
+ arm64: { enabled: true },
+ },
+}
+
+cc_genrule {
+ name: "libseccomp_policy_app_sources_riscv64",
+ recovery_available: true,
+ cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app $(in)",
+ tools: [ "genseccomp" ],
+ srcs: [
+ ":seccomp_syscalls_sources_app",
+ ":libseccomp_gen_syscall_nrs_riscv64",
+ ],
+ out: [
+ "riscv64_app_policy.cpp",
+ ],
+ enabled: false,
+ arch: {
+ riscv64: { enabled: true },
+ },
+}
+
+cc_genrule {
+ name: "libseccomp_policy_system_sources_x86",
+ recovery_available: true,
+ cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=system $(in)",
+ tools: [ "genseccomp" ],
+ srcs: [
+ ":seccomp_syscalls_sources_system",
+ ":libseccomp_gen_syscall_nrs_x86",
+ ":libseccomp_gen_syscall_nrs_x86_64",
+ ],
+ out: [
+ "x86_system_policy.cpp",
+ "x86_64_system_policy.cpp",
+ ],
+ enabled: false,
+ arch: {
+ x86: { enabled: true },
+ x86_64: { enabled: true },
+ },
+}
+
+cc_genrule {
+ name: "libseccomp_policy_system_sources_arm",
+ recovery_available: true,
+ cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=system $(in)",
+ tools: [ "genseccomp" ],
+ srcs: [
+ ":seccomp_syscalls_sources_system",
+ ":libseccomp_gen_syscall_nrs_arm",
+ ":libseccomp_gen_syscall_nrs_arm64",
+ ],
+ out: [
+ "arm_system_policy.cpp",
+ "arm64_system_policy.cpp",
+ ],
+ enabled: false,
+ arch: {
+ arm: { enabled: true },
+ arm64: { enabled: true },
+ },
+}
+
+cc_genrule {
+ name: "libseccomp_policy_system_sources_riscv64",
+ recovery_available: true,
+ cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=system $(in)",
+ tools: [ "genseccomp" ],
+ srcs: [
+ ":seccomp_syscalls_sources_system",
+ ":libseccomp_gen_syscall_nrs_riscv64",
+ ],
+ out: [
+ "riscv64_system_policy.cpp",
+ ],
+ enabled: false,
+ arch: {
+ riscv64: { enabled: true },
},
}
@@ -2711,11 +2735,44 @@
name: "libseccomp_policy",
recovery_available: true,
generated_headers: ["func_to_syscall_nrs"],
- generated_sources: [
- "libseccomp_policy_app_sources",
- "libseccomp_policy_app_zygote_sources",
- "libseccomp_policy_system_sources",
- ],
+
+ arch: {
+ arm: {
+ generated_sources: [
+ "libseccomp_policy_app_sources_arm",
+ "libseccomp_policy_app_zygote_sources_arm",
+ "libseccomp_policy_system_sources_arm",
+ ],
+ },
+ arm64: {
+ generated_sources: [
+ "libseccomp_policy_app_sources_arm",
+ "libseccomp_policy_app_zygote_sources_arm",
+ "libseccomp_policy_system_sources_arm",
+ ],
+ },
+ riscv64: {
+ generated_sources: [
+ "libseccomp_policy_app_sources_riscv64",
+ "libseccomp_policy_app_zygote_sources_riscv64",
+ "libseccomp_policy_system_sources_riscv64",
+ ],
+ },
+ x86: {
+ generated_sources: [
+ "libseccomp_policy_app_sources_x86",
+ "libseccomp_policy_app_zygote_sources_x86",
+ "libseccomp_policy_system_sources_x86",
+ ],
+ },
+ x86_64: {
+ generated_sources: [
+ "libseccomp_policy_app_sources_x86",
+ "libseccomp_policy_app_zygote_sources_x86",
+ "libseccomp_policy_system_sources_x86",
+ ],
+ },
+ },
srcs: [
"seccomp/seccomp_policy.cpp",
diff --git a/libc/BUILD b/libc/BUILD
index e26c026..1777ae9 100644
--- a/libc/BUILD
+++ b/libc/BUILD
@@ -27,16 +27,16 @@
load("//build/bazel/rules/apis:cc_api_contribution.bzl", "cc_api_contribution")
cc_api_contribution(
- name="libc_contributions",
- library_name="libc",
- api=":libc.map.txt",
- hdrs=[
- "//bionic/libc/kernel/android:libc_kernel_android_uapi_headers",
- "//bionic/libc/kernel/android:libc_kernel_android_scsi_headers",
- "//bionic/libc/kernel/uapi:libc_kernel_uapi_headers",
- "//bionic/libc/kernel/uapi:libc_kernal_uapi_asm_arm_headers", #arm
- "//bionic/libc/kernel/uapi:libc_kernal_uapi_asm_arm64_headers", #arm64
- "//bionic/libc/kernel/uapi:libc_kernal_uapi_asm_x86_headers", #x86
- "//bionic/libc/kernel/uapi:libc_kernal_uapi_asm_x86_64_headers", #x86_64
- ],
+ name = "libc_contributions",
+ hdrs = [
+ "//bionic/libc/kernel/android:libc_kernel_android_scsi_headers",
+ "//bionic/libc/kernel/android:libc_kernel_android_uapi_headers",
+ "//bionic/libc/kernel/uapi:libc_kernel_uapi_asm_arm64_headers", #arm64
+ "//bionic/libc/kernel/uapi:libc_kernel_uapi_asm_arm_headers", #arm
+ "//bionic/libc/kernel/uapi:libc_kernel_uapi_asm_x86_64_headers", #x86_64
+ "//bionic/libc/kernel/uapi:libc_kernel_uapi_asm_x86_headers", #x86
+ "//bionic/libc/kernel/uapi:libc_kernel_uapi_headers",
+ ],
+ api = ":libc.map.txt",
+ library_name = "libc",
)
diff --git a/libc/arch-riscv64/bionic/__bionic_clone.S b/libc/arch-riscv64/bionic/__bionic_clone.S
index aeb2da6..d535095 100644
--- a/libc/arch-riscv64/bionic/__bionic_clone.S
+++ b/libc/arch-riscv64/bionic/__bionic_clone.S
@@ -34,7 +34,7 @@
# Push 'fn' and 'arg' onto the child stack.
addi a1, a1, -16
sd a5, 0(a1)
- sd a6, 0(a1)
+ sd a6, 8(a1)
# Make the system call.
li a7, __NR_clone
diff --git a/libc/arch-riscv64/bionic/setjmp.S b/libc/arch-riscv64/bionic/setjmp.S
index 812cfd1..2811bbe 100644
--- a/libc/arch-riscv64/bionic/setjmp.S
+++ b/libc/arch-riscv64/bionic/setjmp.S
@@ -141,16 +141,14 @@
addi a2, a0, _JB_SIGMASK // old_mask.
call PIC_PLT(sigprocmask)
- ld a1, 8(sp)
-
1:
- // Restore original a0/a1/ra.
+ // Restore original a0/ra.
ld a0, 0(sp)
- ld a1, 8(sp)
ld ra, 16(sp)
addi sp, sp, 24
- // Mask off the signal flag bit.
+ // Get the cookie.
+ ld a1, _JB_SIGFLAG(a0)
andi a1, a1, -2
// Save core registers.
@@ -169,7 +167,7 @@
sd s9, _JB_S9(a0)
sd s10, _JB_S10(a0)
sd s11, _JB_S11(a0)
- sd sp, _JB_SP(a0)
+ sd a2, _JB_SP(a0)
m_unmangle_registers a1, sp_reg=a2
// Save floating point registers.
diff --git a/libc/kernel/uapi/BUILD b/libc/kernel/uapi/BUILD
index 2f92464..3c9bb69 100644
--- a/libc/kernel/uapi/BUILD
+++ b/libc/kernel/uapi/BUILD
@@ -29,39 +29,39 @@
package(default_visibility = ["//bionic/libc:__pkg__"])
cc_api_headers(
- name="libc_kernel_uapi_headers",
- hdrs=glob(["**/*.h"]),
- system=True,
+ name = "libc_kernel_uapi_headers",
+ hdrs = glob(["**/*.h"]),
+ system = True,
)
cc_api_headers(
- name="libc_kernal_uapi_asm_arm_headers",
- include_dir="asm-arm",
- hdrs=glob(["asm-arm/**/*.h"]),
- system=True,
- arch="arm",
+ name = "libc_kernel_uapi_asm_arm_headers",
+ hdrs = glob(["asm-arm/**/*.h"]),
+ arch = "arm",
+ include_dir = "asm-arm",
+ system = True,
)
cc_api_headers(
- name="libc_kernal_uapi_asm_arm64_headers",
- include_dir="asm-arm64",
- hdrs=glob(["asm-arm64/**/*.h"]),
- system=True,
- arch="arm64",
+ name = "libc_kernel_uapi_asm_arm64_headers",
+ hdrs = glob(["asm-arm64/**/*.h"]),
+ arch = "arm64",
+ include_dir = "asm-arm64",
+ system = True,
)
cc_api_headers(
- name="libc_kernal_uapi_asm_x86_headers",
- include_dir="asm-x86",
- hdrs=glob(["asm-x86/**/*.h"]),
- system=True,
- arch="x86",
+ name = "libc_kernel_uapi_asm_x86_headers",
+ hdrs = glob(["asm-x86/**/*.h"]),
+ arch = "x86",
+ include_dir = "asm-x86",
+ system = True,
)
cc_api_headers(
- name="libc_kernal_uapi_asm_x86_64_headers",
- include_dir="asm-x86_64",
- hdrs=glob(["asm-x86_64/**/*.h"]),
- system=True,
- arch="x86_64",
+ name = "libc_kernel_uapi_asm_x86_64_headers",
+ hdrs = glob(["asm-x86_64/**/*.h"]),
+ arch = "x86_64",
+ include_dir = "asm-x86_64",
+ system = True,
)
diff --git a/libm/arm64/fenv.c b/libm/arm64/fenv.c
index a99288b..0f28d0c 100644
--- a/libm/arm64/fenv.c
+++ b/libm/arm64/fenv.c
@@ -59,7 +59,6 @@
int fesetenv(const fenv_t* envp) {
fpu_control_t fpcr;
-
__get_fpcr(fpcr);
if (envp->__control != fpcr) {
__set_fpcr(envp->__control);
@@ -70,27 +69,22 @@
int feclearexcept(int excepts) {
fpu_status_t fpsr;
-
- excepts &= FE_ALL_EXCEPT;
__get_fpsr(fpsr);
- fpsr &= ~excepts;
+ fpsr &= ~(excepts & FE_ALL_EXCEPT);
__set_fpsr(fpsr);
return 0;
}
int fegetexceptflag(fexcept_t* flagp, int excepts) {
fpu_status_t fpsr;
-
- excepts &= FE_ALL_EXCEPT;
__get_fpsr(fpsr);
- *flagp = fpsr & excepts;
+ *flagp = fpsr & (excepts & FE_ALL_EXCEPT);
return 0;
}
int fesetexceptflag(const fexcept_t* flagp, int excepts) {
- fpu_status_t fpsr;
-
excepts &= FE_ALL_EXCEPT;
+ fpu_status_t fpsr;
__get_fpsr(fpsr);
fpsr &= ~excepts;
fpsr |= *flagp & excepts;
@@ -100,32 +94,27 @@
int feraiseexcept(int excepts) {
fexcept_t ex = excepts;
-
fesetexceptflag(&ex, excepts);
return 0;
}
int fetestexcept(int excepts) {
fpu_status_t fpsr;
-
- excepts &= FE_ALL_EXCEPT;
__get_fpsr(fpsr);
- return (fpsr & excepts);
+ return (fpsr & (excepts & FE_ALL_EXCEPT));
}
int fegetround(void) {
fpu_control_t fpcr;
-
__get_fpcr(fpcr);
return ((fpcr >> FPCR_RMODE_SHIFT) & FE_TOWARDZERO);
}
int fesetround(int round) {
- fpu_control_t fpcr, new_fpcr;
-
- round &= FE_TOWARDZERO;
+ if (round < FE_TONEAREST || round > FE_TOWARDZERO) return -1;
+ fpu_control_t fpcr;
__get_fpcr(fpcr);
- new_fpcr = fpcr & ~(FE_TOWARDZERO << FPCR_RMODE_SHIFT);
+ fpu_control_t new_fpcr = fpcr & ~(FE_TOWARDZERO << FPCR_RMODE_SHIFT);
new_fpcr |= (round << FPCR_RMODE_SHIFT);
if (new_fpcr != fpcr) {
__set_fpcr(new_fpcr);
@@ -134,33 +123,15 @@
}
int feholdexcept(fenv_t* envp) {
- fpu_status_t fpsr;
- __get_fpsr(fpsr);
- fpu_control_t fpcr;
- __get_fpcr(fpcr);
- fenv_t env = { .__status = fpsr, .__control = fpcr };
- *envp = env;
-
- // Clear all exceptions.
- fpsr &= ~FE_ALL_EXCEPT;
- __set_fpsr(fpsr);
+ fegetenv(envp);
+ feclearexcept(FE_ALL_EXCEPT);
return 0;
}
int feupdateenv(const fenv_t* envp) {
- fpu_status_t fpsr;
- fpu_control_t fpcr;
-
- // Set FPU Control register.
- __get_fpcr(fpcr);
- if (envp->__control != fpcr) {
- __set_fpcr(envp->__control);
- }
-
- // Set FPU Status register to status | currently raised exceptions.
- __get_fpsr(fpsr);
- fpsr = envp->__status | (fpsr & FE_ALL_EXCEPT);
- __set_fpsr(fpsr);
+ int excepts = fetestexcept(FE_ALL_EXCEPT);
+ fesetenv(envp);
+ feraiseexcept(excepts);
return 0;
}
diff --git a/tests/dl_test.cpp b/tests/dl_test.cpp
index a61586b..2f3e905 100644
--- a/tests/dl_test.cpp
+++ b/tests/dl_test.cpp
@@ -32,9 +32,10 @@
#include <regex>
#include <string>
-#include "gtest_globals.h"
#include <android-base/file.h>
+#include <android-base/macros.h>
#include <android-base/test_utils.h>
+#include "gtest_globals.h"
#include "utils.h"
extern "C" int main_global_default_serial() {
@@ -84,22 +85,13 @@
#if defined(__BIONIC__)
#if defined(__LP64__)
- static constexpr const char* kPathToLinker = "/system/bin/linker64";
+#define LINKER_NAME "linker64"
#else
- static constexpr const char* kPathToLinker = "/system/bin/linker";
+#define LINKER_NAME "linker"
#endif
-
-#if defined (__aarch64__)
- static constexpr const char* kAlternatePathToLinker = "/system/bin/arm64/linker64";
-#elif defined (__arm__)
- static constexpr const char* kAlternatePathToLinker = "/system/bin/arm/linker";
-#elif defined (__x86_64__)
- static constexpr const char* kAlternatePathToLinker = "/system/bin/x86_64/linker64";
-#elif defined (__i386__)
- static constexpr const char* kAlternatePathToLinker = "/system/bin/x86/linker";
-#else
-#error "Unknown architecture"
-#endif
+static constexpr const char* kPathToLinker = "/system/bin/" LINKER_NAME;
+static constexpr const char* kAlternatePathToLinker = "/system/bin/" ABI_STRING "/" LINKER_NAME;
+#undef LINKER_NAME
const char* PathToLinker() {
// On the systems with emulated architecture linker would be of different
diff --git a/tests/dlfcn_test.cpp b/tests/dlfcn_test.cpp
index 940e726..c5d1218 100644
--- a/tests/dlfcn_test.cpp
+++ b/tests/dlfcn_test.cpp
@@ -33,6 +33,7 @@
#include <thread>
#include <android-base/file.h>
+#include <android-base/macros.h>
#include <android-base/scopeguard.h>
#include "gtest_globals.h"
@@ -966,17 +967,7 @@
#endif
}
-#if defined (__aarch64__)
-#define ALTERNATE_PATH_TO_SYSTEM_LIB "/system/lib64/arm64/"
-#elif defined (__arm__)
-#define ALTERNATE_PATH_TO_SYSTEM_LIB "/system/lib/arm/"
-#elif defined (__i386__)
-#define ALTERNATE_PATH_TO_SYSTEM_LIB "/system/lib/x86/"
-#elif defined (__x86_64__)
-#define ALTERNATE_PATH_TO_SYSTEM_LIB "/system/lib64/x86_64/"
-#else
-#error "Unknown architecture"
-#endif
+#define ALTERNATE_PATH_TO_SYSTEM_LIB "/system/lib64/" ABI_STRING "/"
#define PATH_TO_LIBC PATH_TO_SYSTEM_LIB "libc.so"
#define PATH_TO_BOOTSTRAP_LIBC PATH_TO_SYSTEM_LIB "bootstrap/libc.so"
#define ALTERNATE_PATH_TO_LIBC ALTERNATE_PATH_TO_SYSTEM_LIB "libc.so"
diff --git a/tests/fenv_test.cpp b/tests/fenv_test.cpp
index ad34caa..9cf9d98 100644
--- a/tests/fenv_test.cpp
+++ b/tests/fenv_test.cpp
@@ -202,9 +202,10 @@
TEST(fenv, feenableexcept_fegetexcept) {
#if !defined(ANDROID_HOST_MUSL)
-#if defined(__aarch64__) || defined(__arm__)
- // ARM doesn't support this. They used to if you go back far enough, but it was removed in
- // the Cortex-A8 between r3p1 and r3p2.
+#if defined(__aarch64__) || defined(__arm__) || defined(__riscv)
+ // ARM and RISC-V don't support hardware trapping of floating point
+ // exceptions. ARM used to if you go back far enough, but it was
+ // removed in the Cortex-A8 between r3p1 and r3p2. RISC-V never has.
ASSERT_EQ(-1, feenableexcept(FE_INVALID));
ASSERT_EQ(0, fegetexcept());
ASSERT_EQ(-1, feenableexcept(FE_DIVBYZERO));
@@ -215,8 +216,10 @@
ASSERT_EQ(0, fegetexcept());
ASSERT_EQ(-1, feenableexcept(FE_INEXACT));
ASSERT_EQ(0, fegetexcept());
+#if defined(_FE_DENORMAL) // riscv64 doesn't support this.
ASSERT_EQ(-1, feenableexcept(FE_DENORMAL));
ASSERT_EQ(0, fegetexcept());
+#endif
#else
// We can't recover from SIGFPE, so sacrifice a child...
pid_t pid = fork();
diff --git a/tests/setjmp_test.cpp b/tests/setjmp_test.cpp
index c9e9a0c..2f891ec 100644
--- a/tests/setjmp_test.cpp
+++ b/tests/setjmp_test.cpp
@@ -81,8 +81,10 @@
sigset64_t ss;
sigemptyset64(&ss);
sigaddset64(&ss, SIGUSR1 + offset);
+#if defined(__BIONIC__)
// TIMER_SIGNAL.
sigaddset64(&ss, __SIGRTMIN);
+#endif
sigaddset64(&ss, SIGRTMIN + offset);
return ss;
}
diff --git a/tests/signal_test.cpp b/tests/signal_test.cpp
index 5bda8b3..7f7f3db 100644
--- a/tests/signal_test.cpp
+++ b/tests/signal_test.cpp
@@ -34,6 +34,13 @@
using namespace std::chrono_literals;
+#if defined(ANDROID_HOST_MUSL)
+// Musl doesn't export __SIGRTMIN and __SIGRTMAX, #define
+// them here.
+#define __SIGRTMIN 32
+#define __SIGRTMAX 64
+#endif
+
static int SIGNAL_MIN() {
return 1; // Signals start at 1 (SIGHUP), not 0.
}
diff --git a/tests/string_test.cpp b/tests/string_test.cpp
index 30c87dc..38957e2 100644
--- a/tests/string_test.cpp
+++ b/tests/string_test.cpp
@@ -136,7 +136,7 @@
// A real-time signal.
ASSERT_STREQ("Real-time signal 14", strsignal(SIGRTMIN + 14));
// One of the signals the C library keeps to itself.
- ASSERT_STREQ("Unknown signal 32", strsignal(__SIGRTMIN));
+ ASSERT_STREQ("Unknown signal 32", strsignal(32)); // __SIGRTMIN
// Errors.
ASSERT_STREQ("Unknown signal -1", strsignal(-1)); // Too small.