Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -2688,6 +2688,8 @@ def MakeGenericLinuxEnv(platform=None):
LINK = '$CXX',
)

linux_env.SetDefault(MAX_PAGE_SIZE='0x1000')

# Prepend so we can disable warnings via Append
linux_env.Prepend(
CPPDEFINES = [['_POSIX_C_SOURCE', '199506'],
Expand All @@ -2710,6 +2712,7 @@ def MakeGenericLinuxEnv(platform=None):
LINKFLAGS = ['-m64'] + sysroot_flags,
)
elif linux_env.Bit('build_arm'):
linux_env.Replace(MAX_PAGE_SIZE='0x10000')
SetUpLinuxEnvArm(linux_env)
elif linux_env.Bit('build_mips32'):
SetUpLinuxEnvMips(linux_env)
Expand All @@ -2735,7 +2738,8 @@ def MakeGenericLinuxEnv(platform=None):
linux_env.Prepend(SHLINKFLAGS=['$COMMON_LINKFLAGS'])
linux_env.Prepend(COMMON_LINKFLAGS=['-Wl,-z,relro',
'-Wl,-z,now',
'-Wl,-z,noexecstack'])
'-Wl,-z,noexecstack',
'-Wl,-z,max-page-size=${MAX_PAGE_SIZE}'])
linux_env.Prepend(LINKFLAGS=['-pie'])
# The ARM toolchain has a linker that doesn't handle the code its
# compiler generates under -fPIE.
Expand Down
13 changes: 13 additions & 0 deletions cmake/NaClFlags.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
option(USE_WERROR "Tell the compiler to make the build fail when warnings are present." OFF)

if (DAEMON_ARCH_armhf)
option(USE_ARMHF_LARGE_PAGESIZE "Build armhf binaries with large page size." ON)
list(APPEND INHERITED_OPTIONS "USE_ARMHF_LARGE_PAGESIZE")
endif()

macro(set_ASM_flag FLAG)
set(lang ASM)
if (${ARGC} GREATER 1)
Expand Down Expand Up @@ -84,6 +89,14 @@ macro(set_linker_flag FLAG)
endforeach()
endmacro()

if (USE_ARMHF_LARGE_PAGESIZE)
set(MAX_PAGE_SIZE 0x10000)
else()
set(MAX_PAGE_SIZE 0x1000)
endif()

set_linker_flag("-Wl,-z,max-page-size=${MAX_PAGE_SIZE}")

#TODO: Import from SetUpClang() from (root)/SConstruct.
#TODO: This is mostly ASAN configurations.

Expand Down
2 changes: 1 addition & 1 deletion src/trusted/service_runtime/build.scons
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ if (env.Bit('linux') and not env.Bit('built_elsewhere')):
'nacl_bootstrap_raw',
[bootstrap_obj],
("env CXX='${CXX}' ${PYTHON} %s %s " +
'-m %s --build-id -static -z max-page-size=0x1000 ' +
'-m %s --build-id -static -z max-page-size=${MAX_PAGE_SIZE} ' +
'--orphan-handling=discard ' +
'--defsym RESERVE_TOP=%s --script %s -o ${TARGET} ${SOURCES}') %
(bootstrap_env.File('linux/ld_bfd.py'), compiler_override, ld_emul,
Expand Down
2 changes: 1 addition & 1 deletion src/trusted/service_runtime/linux/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ add_custom_target(nacl_bootstrap_raw
-m "${LD_EMUL}"
--build-id
-static
-z "max-page-size=0x1000"
-z "max-page-size=${MAX_PAGE_SIZE}"
--defsym RESERVE_TOP="${RESERVE_TOP}"
--orphan-handling=discard
--script "${CMAKE_CURRENT_LIST_DIR}/nacl_bootstrap.x"
Expand Down
4 changes: 2 additions & 2 deletions src/trusted/service_runtime/linux/nacl_bootstrap.x
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ SECTIONS {
* It just maps it from the file, i.e. way off the end of the file,
* which is perfect for reserving the address space.
*/
. = ALIGN(CONSTANT(COMMONPAGESIZE));
. = ALIGN(CONSTANT(MAXPAGESIZE));
RESERVE_START = .;
.reserve : {
.reserve : ALIGN(CONSTANT(MAXPAGESIZE)) {
. += (RESERVE_TOP > RESERVE_START) ? (RESERVE_TOP - RESERVE_START) : 0;
} :reserve

Expand Down