From eae85ad1557f4b2537e9de37ae4fd117ed66e19f Mon Sep 17 00:00:00 2001 From: Zijun Date: Mon, 10 Jun 2024 19:45:33 +0000 Subject: [PATCH 1/3] Fix anonymous class error Fail to compile bionic/tests/complex_test.cpp when updating compiler due to the conflict. Bug: b/346349678 Test: change the clang version and then run mm to build Change-Id: Ic22b7325b6e52006e620e13944f3f1d76030d782 --- tests/complex_test.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/complex_test.cpp b/tests/complex_test.cpp index 6a1831f78..8fdb2b2e1 100644 --- a/tests/complex_test.cpp +++ b/tests/complex_test.cpp @@ -32,7 +32,11 @@ #include // For M_PI_2/M_PI_2l. // Prettify gtest Complex printing. +// Macro 'complex' defined in complex.h conflicts with iostream. +#pragma push_macro("complex") +#undef complex #include +#pragma pop_macro("complex") namespace testing { namespace internal { inline void PrintTo(const double _Complex& c, std::ostream* os) { From d8328a931bb60b382268386912119f1d0ac2cf7c Mon Sep 17 00:00:00 2001 From: Florian Mayer Date: Mon, 10 Jun 2024 17:35:25 -0700 Subject: [PATCH 2/3] [HWASan] [16k] do not instrument getauxval To support page agnostic systems, we call getauxval before HWASan is fully set up. Bug: 315511637 Change-Id: I0b760943a23bd3a4d83bcc2182696a827dcbd446 --- libc/bionic/getauxval.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libc/bionic/getauxval.cpp b/libc/bionic/getauxval.cpp index a3c6b1932..e188d73ff 100644 --- a/libc/bionic/getauxval.cpp +++ b/libc/bionic/getauxval.cpp @@ -37,7 +37,9 @@ // This function needs to be safe to call before TLS is set up, so it can't // access errno or the stack protector. -__LIBC_HIDDEN__ unsigned long __bionic_getauxval(unsigned long type, bool* exists) { +// Cannot use HWASan, as this is called during setup of the HWASan runtime to +// determine the page size. +__LIBC_HIDDEN__ unsigned long __bionic_getauxval(unsigned long type, bool* exists) __attribute__((no_sanitize("hwaddress"))) { for (ElfW(auxv_t)* v = __libc_shared_globals()->auxv; v->a_type != AT_NULL; ++v) { if (v->a_type == type) { *exists = true; @@ -48,7 +50,9 @@ __LIBC_HIDDEN__ unsigned long __bionic_getauxval(unsigned long type, bool* exist return 0; } -extern "C" unsigned long getauxval(unsigned long type) { +// Cannot use HWASan, as this is called during setup of the HWASan runtime to +// determine the page size. +extern "C" unsigned long getauxval(unsigned long type) __attribute__((no_sanitize("hwaddress"))) { bool exists; unsigned long result = __bionic_getauxval(type, &exists); if (!exists) errno = ENOENT; From c221beccc17368aba2fe354ac4aa595b32787d4b Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Tue, 11 Jun 2024 12:59:38 +0000 Subject: [PATCH 3/3] Add a missing riscv64 psabi constant. Also group all the RELR/arm64/riscv64 bits together rather than mixing them up slightly as we'd done so far. Change-Id: Iff1ea2cfca9ff702b88aa2e7d09db46e2f34f965 --- libc/include/elf.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libc/include/elf.h b/libc/include/elf.h index 1275f2ede..374d5bb0e 100644 --- a/libc/include/elf.h +++ b/libc/include/elf.h @@ -223,8 +223,6 @@ typedef Elf64_Xword Elf64_Relr; #undef SHT_NUM #define SHT_NUM 20 -#define SHT_RISCV_ATTRIBUTES 0x70000003 - /* * Experimental support for SHT_RELR sections. For details, see proposal * at https://groups.google.com/forum/#!topic/generic-abi/bX460iggiKg. @@ -254,6 +252,8 @@ typedef Elf64_Xword Elf64_Relr; #define DT_ANDROID_RELA 0x60000011 // DT_LOOS + 4 #define DT_ANDROID_RELASZ 0x60000012 // DT_LOOS + 5 +/* arm64 psabi. */ + /* TODO: upstreamed to FreeBSD as https://github.com/freebsd/freebsd-src/pull/1141/. */ #define DT_AARCH64_MEMTAG_MODE 0x70000009 #define DT_AARCH64_MEMTAG_HEAP 0x7000000b @@ -270,6 +270,8 @@ typedef Elf64_Xword Elf64_Relr; #define R_ARM_TLS_DESC 13 #define R_ARM_IRELATIVE 160 +/* riscv64 psabi. */ + /* FreeBSD is missing these, found in * https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc#relocations * so I've sent https://github.com/freebsd/freebsd-src/pull/1141 upstream. @@ -283,6 +285,12 @@ typedef Elf64_Xword Elf64_Relr; #define R_RISCV_TLSDESC_ADD_LO12 64 #define R_RISCV_TLSDESC_CALL 65 +/* https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc#program-header-table */ +#define PT_RISCV_ATTRIBUTES 0x70000003 + +/* https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc#section-types */ +#define SHT_RISCV_ATTRIBUTES 0x70000003 + /* FreeBSD spells this slightly differently to Linux. Linux is correct according to * https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc#file-header * so I've sent https://github.com/freebsd/freebsd-src/pull/1148 upstream.