Merge "Update to v6.5 kernel headers." into main
diff --git a/android-changes-for-ndk-developers.md b/android-changes-for-ndk-developers.md
index c78528d..ab3b247 100644
--- a/android-changes-for-ndk-developers.md
+++ b/android-changes-for-ndk-developers.md
@@ -479,3 +479,20 @@
 You can read more about relative relocations
 and their long and complicated history at
 https://maskray.me/blog/2021-10-31-relative-relocations-and-relr.
+
+## No more sentinels in .preinit_array/.init_array/.fini_array sections of executables (in All API levels)
+
+In Android <= U and NDK <= 26, Android used sentinels in these sections of
+executables to locate the start and end of arrays. However, when building with
+LTO, the function pointers in the arrays can be reordered, making sentinels no
+longer work. This prevents constructors for global C++ variables from being
+called in static executables when using LTO.
+
+To fix this, in Android >= V and NDK >= 27, we removed sentinels and switched
+to using symbols inserted by LLD (like `__init_array_start`,
+`__init_array_end`) to locate the arrays. This also avoids keeping a section
+when there are no corresponding functions.
+
+For dynamic executables, we kept sentinel support in crtbegin_dynamic.o and
+libc.so. This ensures that executables built with newer crtbegin_dynamic.o
+(in NDK >= 27) work with older libc.so (in Android <= U), and vice versa.
diff --git a/benchmarks/malloc_map_benchmark.cpp b/benchmarks/malloc_map_benchmark.cpp
index 5757325..04c9a07 100644
--- a/benchmarks/malloc_map_benchmark.cpp
+++ b/benchmarks/malloc_map_benchmark.cpp
@@ -52,7 +52,7 @@
         android::base::StartsWith(vma.name, "[anon:GWP-ASan")) {
       android::meminfo::Vma update_vma(vma);
       if (!proc_mem.FillInVmaStats(update_vma)) {
-        err(1, "FillInVmaStats failed\n");
+        err(1, "FillInVmaStats failed");
       }
       *rss_bytes += update_vma.usage.rss;
     }