Skip to content

Commit

Permalink
Merge pull request binarly-io#83 from binarly-io/bugfix/build
Browse files Browse the repository at this point in the history
Fix build with Apple clang v15.0.0
  • Loading branch information
yeggor authored Sep 29, 2023
2 parents e2ca660 + 78711ec commit 2bdd97b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
1 change: 0 additions & 1 deletion build.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ def build_plugin(idasdk: str, hexrays_sdk: str, batch: bool):
if hexrays_sdk:
print("[INFO] HexRays analysis will be enabled")
command.append(f"-DHexRaysSdk_ROOT_DIR={hexrays_sdk}")
print(command)
subprocess.call(command)
subprocess.call(["cmake", "--build", ".", "--config", "Release", "--parallel"])

Expand Down
28 changes: 24 additions & 4 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,8 +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,-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 @@ -156,8 +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,-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 2bdd97b

Please sign in to comment.