bionic: Adapt segment gap test for various page sizes
This makes the segment gap test compatible with systems having different
page sizes.
- The linker script now uses `ALIGN(CONSTANT (MAXPAGESIZE))`.
- The C++ code now uses `sysconf(_SC_PAGESIZE)` to get the actual page
size ensuring correct memory alignment of 'start_of_gap' at runtime.
Bug: 315509500
Test: (16k testing)
lunch aosp_cf_x86_64_phone_pgagnostic-trunk_staging-userdebug
m && launch_cvd
atest dlfcn#segment_gap
(4k testing)
lunch aosp_cf_x86_64_phone-trunk_staging-userdebug
m && launch_cvd
atest dlfcn#segment_gap
Change-Id: I31d45d1d22a237ef7d5ea487a64ef20e5e984ec0
diff --git a/tests/libs/segment_gap_outer.lds b/tests/libs/segment_gap_outer.lds
index 527f29e..758b6bc 100644
--- a/tests/libs/segment_gap_outer.lds
+++ b/tests/libs/segment_gap_outer.lds
@@ -3,17 +3,17 @@
# appropriate alignment between them.
. = SIZEOF_HEADERS;
.rodata : {*(.rodata .rodata.*)}
- . = ALIGN(0x1000);
+ . = ALIGN(CONSTANT (MAXPAGESIZE));
.text : {*(.text .text.*)}
- . = ALIGN(0x1000);
+ . = ALIGN(CONSTANT (MAXPAGESIZE));
.dynamic : {*(.dynamic)}
- . = ALIGN(0x1000);
+ . = ALIGN(CONSTANT (MAXPAGESIZE));
.data : {*(.data .data.*)}
.bss : {*(.bss .bss.*)}
# Now create the gap. We need a text segment first to prevent the linker from
# merging .bss with .custom_bss.
- . = ALIGN(0x1000);
+ . = ALIGN(CONSTANT (MAXPAGESIZE));
.custom_text : {
*(.custom_text);
}