Skip to content

Commit a53e13b

Browse files
committed
cmake,bootstrap: Make possible to build sel_ldr and nacl_helper_bootstrap with 16K page size
1 parent 3eba6d5 commit a53e13b

File tree

3 files changed

+25
-10
lines changed

3 files changed

+25
-10
lines changed

cmake/NaClFlags.cmake

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
option(USE_WERROR "Tell the compiler to make the build fail when warnings are present." OFF)
22

3+
if (ARCH_armhf)
4+
option(USE_ARMHF_16K_PAGESIZE "Build armhf binaries with 16K PageSize." OFF)
5+
list(APPEND INHERITED_OPTIONS "USE_ARMHF_16K_PAGESIZE")
6+
endif()
7+
38
macro(set_ASM_flag FLAG)
49
set(lang ASM)
510
if (${ARGC} GREATER 1)
@@ -84,6 +89,10 @@ macro(set_linker_flag FLAG)
8489
endforeach()
8590
endmacro()
8691

92+
if (USE_ARMHF_16K_PAGESIZE)
93+
set_linker_flag("-Wl,-z,max-page-size=16384")
94+
endif()
95+
8796
#TODO: Import from SetUpClang() from (root)/SConstruct.
8897
#TODO: This is mostly ASAN configurations.
8998

src/trusted/service_runtime/linux/CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,20 @@ string(REPLACE ";" " " BOOTSTRAP_FLAGS_STRING "${BOOTSTRAP_FLAGS}")
106106
add_library(nacl_bootstrap OBJECT "nacl_bootstrap.c")
107107
set_target_properties(nacl_bootstrap PROPERTIES COMPILE_FLAGS ${BOOTSTRAP_FLAGS_STRING})
108108

109+
if (USE_ARMHF_16K_PAGESIZE)
110+
set(MAX_PAGE_SIZE 0x4000)
111+
else()
112+
set(MAX_PAGE_SIZE 0x1000)
113+
endif()
114+
109115
add_custom_target(nacl_bootstrap_raw
110116
COMMAND env "${PYTHON}"
111117
"${CMAKE_CURRENT_LIST_DIR}/ld_bfd.py"
112118
--compiler "${COMPILER_OVERRIDE}"
113119
-m "${LD_EMUL}"
114120
--build-id
115121
-static
116-
-z "max-page-size=0x1000"
122+
-z "max-page-size=${MAX_PAGE_SIZE}"
117123
--defsym RESERVE_TOP="${RESERVE_TOP}"
118124
--script "${CMAKE_CURRENT_LIST_DIR}/nacl_bootstrap.x"
119125
-o "${CMAKE_CURRENT_BINARY_DIR}/nacl_bootstrap_raw"

src/trusted/service_runtime/linux/nacl_bootstrap.x

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,35 +65,35 @@ SECTIONS {
6565
* It's both part of the text PT_LOAD segment (like other rodata) and
6666
* it's what the PT_NOTE header points to.
6767
*/
68-
.note.gnu.build-id : {
68+
.note.gnu.build-id : ALIGN(CONSTANT(MAXPAGESIZE)) {
6969
*(.note.gnu.build-id)
7070
} :text :note
7171

7272
/*
7373
* Here is the program itself.
7474
*/
75-
.text : {
75+
.text : ALIGN(CONSTANT(MAXPAGESIZE)) {
7676
*(.text*)
7777
} :text
78-
.rodata : {
78+
.rodata : ALIGN(CONSTANT(MAXPAGESIZE)) {
7979
*(.rodata*)
8080
*(.eh_frame*)
8181
}
8282

8383
etext = .;
8484

8585
/*
86-
* Adjust the address for the data segment. We want to adjust up to
86+
* Adjust the address for the data segment. We want to adjust up to
8787
* the same address within the page on the next page up.
8888
*/
8989
. = (ALIGN(CONSTANT(MAXPAGESIZE)) -
9090
((CONSTANT(MAXPAGESIZE) - .) & (CONSTANT(MAXPAGESIZE) - 1)));
9191
. = DATA_SEGMENT_ALIGN(CONSTANT(MAXPAGESIZE), CONSTANT(COMMONPAGESIZE));
9292

93-
.data : {
93+
.data : ALIGN(CONSTANT(MAXPAGESIZE)) {
9494
*(.data*)
9595
} :data
96-
.bss : {
96+
.bss : ALIGN(CONSTANT(MAXPAGESIZE)) {
9797
*(.bss*)
9898
}
9999

@@ -107,9 +107,9 @@ SECTIONS {
107107
* It just maps it from the file, i.e. way off the end of the file,
108108
* which is perfect for reserving the address space.
109109
*/
110-
. = ALIGN(CONSTANT(COMMONPAGESIZE));
110+
. = ALIGN(CONSTANT(MAXPAGESIZE));
111111
RESERVE_START = .;
112-
.reserve : {
112+
.reserve : ALIGN(CONSTANT(MAXPAGESIZE)) {
113113
. += (RESERVE_TOP > RESERVE_START) ? (RESERVE_TOP - RESERVE_START) : 0;
114114
} :reserve
115115

@@ -118,7 +118,7 @@ SECTIONS {
118118
* be clobbered by NaCl. We want this to be visible at its fixed address
119119
* in the memory image so the debugger can make sense of things.
120120
*/
121-
.r_debug : {
121+
.r_debug : ALIGN(CONSTANT(MAXPAGESIZE)) {
122122
*(.r_debug)
123123
} :r_debug
124124

0 commit comments

Comments
 (0)