Merge "tests: Disable cpu_target_features" into main
diff --git a/libc/Android.bp b/libc/Android.bp
index 3c5c9f1..c34023c 100644
--- a/libc/Android.bp
+++ b/libc/Android.bp
@@ -1659,8 +1659,14 @@
},
native_bridge_supported: false,
// It is never correct to depend on this directly. This is only
- // needed for the runtime apex, and in base_system.mk.
- visibility: ["//bionic/apex"],
+ // needed for the runtime apex, and in base_system.mk, and system_image_defaults
+ // which is default module for soong-defined system image.
+ visibility: [
+ "//bionic/apex",
+ "//build/make/target/product/generic",
+ //TODO(b/381985636) : Remove visibility to Soong-defined GSI once resolved
+ "//build/make/target/product/gsi",
+ ],
}
genrule {
diff --git a/libc/async_safe/async_safe_log.cpp b/libc/async_safe/async_safe_log.cpp
index c24b326..07133b7 100644
--- a/libc/async_safe/async_safe_log.cpp
+++ b/libc/async_safe/async_safe_log.cpp
@@ -359,7 +359,7 @@
buffer[1] = 'x';
format_integer(buffer + 2, sizeof(buffer) - 2, value, 'x');
} else if (c == 'm') {
-#if __ANDROID_API__ >= 35 // This library is used in mainline modules.
+#if __ANDROID_API_LEVEL__ >= 35 // This library is used in mainline modules.
if (alternate) {
const char* name = strerrorname_np(errno);
if (name) {
diff --git a/libc/bionic/elf_note.cpp b/libc/bionic/elf_note.cpp
index d5cd5de..9cc6b21 100644
--- a/libc/bionic/elf_note.cpp
+++ b/libc/bionic/elf_note.cpp
@@ -38,31 +38,34 @@
return false;
}
+ size_t note_name_len = strlen(note_name) + 1;
+
ElfW(Addr) p = note_addr;
ElfW(Addr) note_end = p + phdr_note->p_memsz;
-
while (p + sizeof(ElfW(Nhdr)) <= note_end) {
+ // Parse the note and check it's structurally valid.
const ElfW(Nhdr)* note = reinterpret_cast<const ElfW(Nhdr)*>(p);
p += sizeof(ElfW(Nhdr));
const char* name = reinterpret_cast<const char*>(p);
- p += align_up(note->n_namesz, 4);
+ if (__builtin_add_overflow(p, align_up(note->n_namesz, 4), &p)) {
+ return false;
+ }
const char* desc = reinterpret_cast<const char*>(p);
- p += align_up(note->n_descsz, 4);
+ if (__builtin_add_overflow(p, align_up(note->n_descsz, 4), &p)) {
+ return false;
+ }
if (p > note_end) {
- break;
- }
- if (note->n_type != note_type) {
- continue;
- }
- size_t note_name_len = strlen(note_name) + 1;
- if (note->n_namesz != note_name_len || strncmp(note_name, name, note_name_len) != 0) {
- break;
+ return false;
}
- *note_hdr = note;
- *note_desc = desc;
-
- return true;
+ // Is this the note we're looking for?
+ if (note->n_type == note_type &&
+ note->n_namesz == note_name_len &&
+ strncmp(note_name, name, note_name_len) == 0) {
+ *note_hdr = note;
+ *note_desc = desc;
+ return true;
+ }
}
return false;
}
diff --git a/linker/linker_phdr.cpp b/linker/linker_phdr.cpp
index 14bf208..e5369ac 100644
--- a/linker/linker_phdr.cpp
+++ b/linker/linker_phdr.cpp
@@ -752,9 +752,10 @@
}
/*
- * Returns true if the kernel supports page size migration, else false.
+ * Returns true if the kernel supports page size migration for this process.
*/
bool page_size_migration_supported() {
+#if defined(__LP64__)
static bool pgsize_migration_enabled = []() {
std::string enabled;
if (!android::base::ReadFileToString("/sys/kernel/mm/pgsize_migration/enabled", &enabled)) {
@@ -763,6 +764,9 @@
return enabled.find("1") != std::string::npos;
}();
return pgsize_migration_enabled;
+#else
+ return false;
+#endif
}
// Find the ELF note of type NT_ANDROID_TYPE_PAD_SEGMENT and check that the desc value is 1.
diff --git a/tests/async_safe_test.cpp b/tests/async_safe_test.cpp
index 8692c8a..ffb8651 100644
--- a/tests/async_safe_test.cpp
+++ b/tests/async_safe_test.cpp
@@ -79,13 +79,13 @@
async_safe_format_buffer(buf, sizeof(buf), "a%mZ");
EXPECT_STREQ("aInvalid argumentZ", buf);
-#if __ANDROID_API__ >= 35
+#if __ANDROID_API_LEVEL__ >= 35
errno = EINVAL;
async_safe_format_buffer(buf, sizeof(buf), "a%#mZ");
EXPECT_STREQ("aEINVALZ", buf);
#endif
-#if __ANDROID_API__ >= 35
+#if __ANDROID_API_LEVEL__ >= 35
errno = -1;
async_safe_format_buffer(buf, sizeof(buf), "a%#mZ");
EXPECT_STREQ("a-1Z", buf);