Merge "vmbase: Move stack guard page to own section" into main am: f287851bf2 am: 59a4464165

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Virtualization/+/3383328

Change-Id: I4e6486a8e1217b4b2086f778c18f1c8e1cbd118c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/libs/libvmbase/sections.ld b/libs/libvmbase/sections.ld
index 7d464bc..5ca5ff4 100644
--- a/libs/libvmbase/sections.ld
+++ b/libs/libvmbase/sections.ld
@@ -96,11 +96,16 @@
 		bss_end = .;
 	} >writable_data
 
-	init_stack_pointer = ORIGIN(writable_data) + LENGTH(writable_data);
+	/* Left unmapped, to catch overflows of the stack. */
+	.stack_guard_page (NOLOAD) : ALIGN(4096) {
+		. += 4096;
+	} >writable_data
+
+	/* Stack, mapped read-write (possibly partially). */
 	.stack (NOLOAD) : ALIGN(4096) {
-		. += 4096; /* Ensure we have one guard page for overflow. */
 		stack_limit = .;
-		. = init_stack_pointer;
+		. = ALIGN(LENGTH(writable_data));
+		init_stack_pointer = .;
 	} >writable_data
 
 	/* Make our Bionic stack protector compatible with mainline LLVM */