Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit d1d4e8b

Browse files
Treehugger RobotGerrit Code Review
authored andcommitted
Merge "bionic: Adapt segment gap test for various page sizes" into main
2 parents 09e764b + 8420cf0 commit d1d4e8b

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

tests/libs/segment_gap_outer.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <android/dlext.h>
22
#include <dlfcn.h>
33
#include <stdlib.h>
4+
#include <unistd.h>
45

56
extern "C" void __attribute__((section(".custom_text"))) text_before_start_of_gap() {}
67
char __attribute__((section(".custom_bss"))) end_of_gap[0x1000];
@@ -10,8 +11,9 @@ extern "C" void* get_inner() {
1011
info.flags = ANDROID_DLEXT_RESERVED_ADDRESS;
1112

1213
char* start_of_gap =
13-
reinterpret_cast<char*>(reinterpret_cast<uintptr_t>(text_before_start_of_gap) & ~0xfffull) +
14-
0x1000;
14+
reinterpret_cast<char*>(
15+
(reinterpret_cast<uintptr_t>(text_before_start_of_gap) &
16+
~(sysconf(_SC_PAGESIZE) - 1)) + sysconf(_SC_PAGESIZE));
1517
info.reserved_addr = start_of_gap;
1618
info.reserved_size = end_of_gap - start_of_gap;
1719

tests/libs/segment_gap_outer.lds

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ SECTIONS {
33
# appropriate alignment between them.
44
. = SIZEOF_HEADERS;
55
.rodata : {*(.rodata .rodata.*)}
6-
. = ALIGN(0x1000);
6+
. = ALIGN(CONSTANT (MAXPAGESIZE));
77
.text : {*(.text .text.*)}
8-
. = ALIGN(0x1000);
8+
. = ALIGN(CONSTANT (MAXPAGESIZE));
99
.dynamic : {*(.dynamic)}
10-
. = ALIGN(0x1000);
10+
. = ALIGN(CONSTANT (MAXPAGESIZE));
1111
.data : {*(.data .data.*)}
1212
.bss : {*(.bss .bss.*)}
1313

1414
# Now create the gap. We need a text segment first to prevent the linker from
1515
# merging .bss with .custom_bss.
16-
. = ALIGN(0x1000);
16+
. = ALIGN(CONSTANT (MAXPAGESIZE));
1717
.custom_text : {
1818
*(.custom_text);
1919
}

0 commit comments

Comments
 (0)