Move writable data to a higher block of memory.
This means we can map the text and rodata sections read-only, and enable
WXN. The data section must be copied from its (now readonly) load
address to the writable block.
Bug: 223166344
Test: Ran unprotected VM under crosvm.
Change-Id: I9105f200c8bd937f6e3a504fed7d0fb5e38ff366
diff --git a/pvmfw/image.ld b/pvmfw/image.ld
index e08fbe2..4655f68 100644
--- a/pvmfw/image.ld
+++ b/pvmfw/image.ld
@@ -18,6 +18,7 @@
{
dtb_region : ORIGIN = 0x80000000, LENGTH = 2M
image : ORIGIN = 0x80200000, LENGTH = 2M
+ writable_data : ORIGIN = 0x80400000, LENGTH = 2M
}
/*
@@ -82,7 +83,9 @@
*/
. = ALIGN(32);
data_end = .;
- } >image
+ } >writable_data AT>image
+ data_lma = LOADADDR(.data);
+
/* Everything beyond this point will not be included in the binary. */
bin_end = .;
@@ -93,14 +96,14 @@
*(COMMON)
. = ALIGN(16);
bss_end = .;
- } >image
+ } >writable_data
.stack (NOLOAD) : ALIGN(4096) {
boot_stack_begin = .;
. += 40 * 4096;
. = ALIGN(4096);
boot_stack_end = .;
- } >image
+ } >writable_data
/*
* Remove unused sections from the image.