Skip to content

Commit

Permalink
Fix incorrect compile flags
Browse files Browse the repository at this point in the history
  • Loading branch information
tishion committed Dec 13, 2021
1 parent 119f516 commit f564c35
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
7 changes: 2 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,8 @@ set(CMAKE_CONFIGURATION_TYPES Debug Release)

# Default compile flags
# Thanks for the PR https://github.com/microsoft/vcpkg/pull/15151/files from https://github.com/BillyONeal
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GS-"
CACHE STRING "default C++ compile flags" FORCE)
set(CMAKE_C_FLAGS
"${CMAKE_C_FLAGS} /GS-"
CACHE STRING "default C++ compile flags" FORCE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GS-")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /GS-")

message(STATUS "CMAKE_CXX_FLAGS=" ${CMAKE_CXX_FLAGS})
message(STATUS "CMAKE_CXX_FLAGS_DEBUG=" ${CMAKE_CXX_FLAGS_DEBUG})
Expand Down
17 changes: 17 additions & 0 deletions tools/shellcode-generator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,23 @@ target_link_libraries(${PROJECT_NAME} PRIVATE
Shlwapi
)

# remove /RTC* from compile flags
foreach(flag_var
CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_RELEASE
CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_RELEASE
)
STRING (REGEX REPLACE "/RTC[^ ]*" "" ${flag_var} "${${flag_var}}")
endforeach(flag_var)

# enable function ordering
target_compile_options(${PROJECT_NAME} PRIVATE
/Gy
)

target_link_options(${PROJECT_NAME} PRIVATE
/OPT:NOREF
/OPT:NOICF
Expand Down
2 changes: 1 addition & 1 deletion tools/shellcode-generator/functionorder
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ MapMemModuleSections
RelocateModuleBase
ResolveImportTable
SetMemProtectStatus
ExecuteTLSCallback
HandleTlsData
CallModuleEntry
GetExportedProcAddress
UnmapMemModule
Expand Down

0 comments on commit f564c35

Please sign in to comment.