Skip to content

Commit

Permalink
add -ld_classic only if Apple clang version 15.0.0 or higher is detected
Browse files Browse the repository at this point in the history
  • Loading branch information
yeggor committed Sep 29, 2023
1 parent e0052b7 commit 78711ec
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions cmake/FindIdaSdk.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@
include(CMakeParseArguments)
include(FindPackageHandleStandardArgs)

option(USE_LD_CLASSIC "Use -ld_classic option" OFF)
if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "15.0.0")
set(USE_LD_CLASSIC ON)
endif()
endif()

find_path(
IdaSdk_DIR
NAMES include/pro.h
Expand Down Expand Up @@ -121,9 +128,15 @@ function(_ida_plugin name ea64 link_script) # ARGN contains sources
if(UNIX)
target_compile_options(${t} PUBLIC ${_ida_compile_options})
if(APPLE)
target_link_libraries(
${t} ${_ida_compile_options} -Wl,-ld_classic -Wl,-flat_namespace
-Wl,-undefined,warning -Wl,-exported_symbol,_PLUGIN)
if(USE_LD_CLASSIC)
target_link_libraries(
${t} ${_ida_compile_options} -Wl,-ld_classic -Wl,-flat_namespace
-Wl,-undefined,warning -Wl,-exported_symbol,_PLUGIN)
else()
target_link_libraries(
${t} ${_ida_compile_options} -Wl,-flat_namespace
-Wl,-undefined,warning -Wl,-exported_symbol,_PLUGIN)
endif()
else()
# Always use the linker script needed for IDA.
target_link_libraries(${t} ${_ida_compile_options} -Wl,--version-script
Expand Down Expand Up @@ -157,9 +170,14 @@ function(_ida_loader name ea64 link_script)
if(UNIX)
target_compile_options(${t} PUBLIC ${_ida_compile_options})
if(APPLE)
target_link_libraries(
${t} ${_ida_compile_options} -Wl,-ld_classic -Wl,-flat_namespace
-Wl,-undefined,warning -Wl,-exported_symbol,_LDSC)
if(USE_LD_CLASSIC)
target_link_libraries(
${t} ${_ida_compile_options} -Wl,-ld_classic -Wl,-flat_namespace
-Wl,-undefined,warning -Wl,-exported_symbol,_LDSC)
else()
target_link_libraries(${t} ${_ida_compile_options} -Wl,-flat_namespace
-Wl,-undefined,warning -Wl,-exported_symbol,_LDSC)
endif()
else()
# Always use the linker script needed for IDA.
target_link_libraries(${t} ${_ida_compile_options} -Wl,--version-script
Expand Down

0 comments on commit 78711ec

Please sign in to comment.