Add cc_defaults for hugepage alignment of shared libraries
Introduces a cc_defaults category hugepage_aligned that passes the
requisite linker flags to produce shared object files with 2MB-aligned
sections. This enables supporting platforms to back the text segments of
these libraries with hugepages.
Bug: 158135888
Test: Built and confirmed ELF layout
Change-Id: I5c8ce35d8f8bf6647ec19d58398740bd494cc89c
diff --git a/linker/Android.bp b/linker/Android.bp
index 3370f28..d6a3d71 100644
--- a/linker/Android.bp
+++ b/linker/Android.bp
@@ -413,6 +413,19 @@
bazel_module: { bp2build_available: true },
}
+// Used to generate binaries that can be backed by transparent hugepages.
+cc_defaults {
+ name: "linker_hugepage_aligned",
+ arch: {
+ arm64: {
+ ldflags: ["-z max-page-size=0x200000"],
+ },
+ x86_64: {
+ ldflags: ["-z max-page-size=0x200000"],
+ },
+ },
+}
+
cc_library {
// NOTE: --exclude-libs=libgcc.a makes sure that any symbols ld-android.so pulls from
// libgcc.a are made static to ld-android.so. This in turn ensures that libraries that