Align ELF sections to 16K boundaries (-Wl,-z,max-page-size=16384)

Even though the initial request was about Android, it is not only about
it, but it could be the case for Linux as well (so as Apple M1/...
chips)

And this should not affect anything, since this is just ELFs

Fixes: https://github.com/libevent/libevent/issues/1708
This commit is contained in:
Azat Khuzhin 2024-10-21 09:58:26 +02:00 committed by Azat Khuzhin
parent f84896d37f
commit f01879d5a6
3 changed files with 20 additions and 0 deletions

View File

@ -72,6 +72,7 @@ include(CheckPrototypeDefinition)
include(CheckFunctionKeywords)
include(CheckConstExists)
include(AddCompilerFlags)
include(AddLinkerFlags)
include(VersionViaGit)
event_fuzzy_version_from_git()
@ -213,6 +214,8 @@ if (EVENT__ENABLE_VERBOSE_DEBUG)
add_definitions(-DUSE_DEBUG=1)
endif()
add_linker_flags(-Wl,-z,max-page-size=16384)
# make it colorful under ninja-build
if ("${CMAKE_GENERATOR}" STREQUAL "Ninja")
add_compiler_flags(-fdiagnostics-color=always)
@ -1751,6 +1754,8 @@ message(STATUS "CMAKE_VERBOSE_MAKEFILE: ${CMAKE_VERBOSE_MAKEFILE}")
message(STATUS "CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}")
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
message(STATUS "CMAKE_C_COMPILER: ${CMAKE_C_COMPILER} (id ${CMAKE_C_COMPILER_ID}, clang ${CLANG}, GNUC ${GNUC}, version ${CMAKE_C_COMPILER_VERSION})")
message(STATUS "CMAKE_SHARED_LINKER_FLAGS:${CMAKE_SHARED_LINKER_FLAGS}")
message(STATUS "CMAKE_EXE_LINKER_FLAGS: ${CMAKE_EXE_LINKER_FLAGS}")
message(STATUS "CMAKE_AR: ${CMAKE_AR}")
message(STATUS "CMAKE_RANLIB: ${CMAKE_RANLIB}")
message(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")

View File

@ -108,6 +108,7 @@ PLATFORM_DEPENDENT_SRC = \
CMAKE_FILES = \
cmake/AddCompilerFlags.cmake \
cmake/AddLinkerFlags.cmake \
cmake/AddEventLibrary.cmake \
cmake/CheckConstExists.cmake \
cmake/CheckFileOffsetBits.c \

View File

@ -0,0 +1,14 @@
include(CheckLinkerFlag)
macro(add_linker_flags)
foreach(flag ${ARGN})
string(REGEX REPLACE "[-.+/:= ]" "_" _flag_esc "${flag}")
check_linker_flag(C "${flag}" check_c_linker_flag_${_flag_esc})
if (check_c_linker_flag_${_flag_esc})
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${flag}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${flag}")
endif()
endforeach()
endmacro()