forked from monero-project/monero
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request monero-project#2993
776b44f Add misc hardening flags to the cmake machinery (moneromooo-monero)
- Loading branch information
Showing
9 changed files
with
153 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#ifdef __CLASSIC_C__ | ||
int main() | ||
{ | ||
int ac; | ||
char* av[]; | ||
#else | ||
int main(int ac, char* av[]) | ||
{ | ||
#endif | ||
if (ac > 1000) { | ||
return *av[0]; | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
include(CheckCCompilerFlag) | ||
|
||
macro(CHECK_LINKER_FLAG flag VARIABLE) | ||
if(NOT DEFINED "${VARIABLE}") | ||
if(NOT CMAKE_REQUIRED_QUIET) | ||
message(STATUS "Looking for ${flag} linker flag") | ||
endif() | ||
|
||
set(_cle_source ${CMAKE_SOURCE_DIR}/cmake/CheckLinkerFlag.c) | ||
|
||
set(saved_CMAKE_C_FLAGS ${CMAKE_C_FLAGS}) | ||
set(CMAKE_C_FLAGS "${flag}") | ||
try_compile(${VARIABLE} | ||
${CMAKE_BINARY_DIR} | ||
${_cle_source} | ||
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} ${flag} | ||
CMAKE_FLAGS | ||
OUTPUT_VARIABLE OUTPUT) | ||
unset(_cle_source) | ||
set(CMAKE_C_FLAGS ${saved_CMAKE_C_FLAGS}) | ||
unset(saved_CMAKE_C_FLAGS) | ||
|
||
if ("${OUTPUT}" MATCHES "warning.*ignored") | ||
set(${VARIABLE} 0) | ||
endif() | ||
|
||
if(${VARIABLE}) | ||
if(NOT CMAKE_REQUIRED_QUIET) | ||
message(STATUS "Looking for ${flag} linker flag - found") | ||
endif() | ||
set(${VARIABLE} 1 CACHE INTERNAL "Have linker flag ${flag}") | ||
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log | ||
"Determining if the ${flag} linker flag is supported " | ||
"passed with the following output:\n" | ||
"${OUTPUT}\n\n") | ||
else() | ||
if(NOT CMAKE_REQUIRED_QUIET) | ||
message(STATUS "Looking for ${flag} linker flag - not found") | ||
endif() | ||
set(${VARIABLE} "" CACHE INTERNAL "Have linker flag ${flag}") | ||
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log | ||
"Determining if the ${flag} linker flag is suppored " | ||
"failed with the following output:\n" | ||
"${OUTPUT}\n\n") | ||
endif() | ||
endif() | ||
endmacro() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters