Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for 32-bit addressing on posix platforms #24

Open
arizvisa opened this issue Nov 25, 2023 · 2 comments
Open

support for 32-bit addressing on posix platforms #24

arizvisa opened this issue Nov 25, 2023 · 2 comments

Comments

@arizvisa
Copy link

diff --git a/cmake/FindIdaSdk.cmake b/cmake/FindIdaSdk.cmake
index 4d3d9d7..4377020 100644
--- a/cmake/FindIdaSdk.cmake
+++ b/cmake/FindIdaSdk.cmake
@@ -52,6 +52,8 @@ find_path(IdaSdk_DIR NAMES include/pro.h
 set(IdaSdk_INCLUDE_DIRS ${IdaSdk_DIR}/include)
 set(IdaSdk_MODULE_DIRS ${IdaSdk_DIR}/module)
 
+set(EA64 ON CACHE BOOL "64-bits addressing")
+
 find_package_handle_standard_args(
         IdaSdk FOUND_VAR IdaSdk_FOUND
         REQUIRED_VARS IdaSdk_DIR
@@ -71,7 +73,12 @@ else ()
 endif ()
 
 if (UNIX)
-    set(IdaLib ${IdaSdk_DIR}/lib/x64_linux_gcc_64/libida64.so)
+    if (${EA64})
+        set(IdaLib ${IdaSdk_DIR}/lib/x64_linux_gcc_64/libida64.so)
+    else ()
+        set(IdaLib ${IdaSdk_DIR}/lib/x64_linux_gcc_32/libida.so)
+    endif ()
+
     if (APPLE)
         set(IdaSdk_PLATFORM __MAC__)
     else ()
@@ -108,10 +115,15 @@ endif ()
 function(ida_common_target_settings t)
     # Add the necessary __IDP__ define and allow to use "dangerous" and standard
     # file functions.
-    target_compile_definitions(${t} PUBLIC
-            ${IdaSdk_PLATFORM} __X64__ __IDP__ USE_DANGEROUS_FUNCTIONS
-            USE_STANDARD_FILE_FUNCTIONS __EA64__)
-
+    if (${EA64})
+        target_compile_definitions(${t} PUBLIC
+                ${IdaSdk_PLATFORM} __X64__ __IDP__ USE_DANGEROUS_FUNCTIONS
+                USE_STANDARD_FILE_FUNCTIONS __EA64__)
+    else ()
+        target_compile_definitions(${t} PUBLIC
+                ${IdaSdk_PLATFORM} __X64__ __IDP__ USE_DANGEROUS_FUNCTIONS
+                USE_STANDARD_FILE_FUNCTIONS)
+    endif ()
     target_include_directories(${t} PUBLIC ${IdaSdk_INCLUDE_DIRS})
 endfunction()
 
@@ -121,9 +133,15 @@ function(_ida_plugin name link_script)  # ARGN contains sources
     ida_common_target_settings(${name})
 
     # Rename the plugin to have the proper naming scheme for IDA
-    set_target_properties(${name} PROPERTIES
-            PREFIX ""
-            OUTPUT_NAME ${name}${PROJECT_VERSION_MAJOR}${PROJECT_VERSION_MINOR}64)
+    if (${EA64})
+        set_target_properties(${name} PROPERTIES
+                PREFIX ""
+                OUTPUT_NAME ${name}${PROJECT_VERSION_MAJOR}${PROJECT_VERSION_MINOR}64)
+    else ()
+        set_target_properties(${name} PROPERTIES
+                PREFIX ""
+                OUTPUT_NAME ${name}${PROJECT_VERSION_MAJOR}${PROJECT_VERSION_MINOR}32)
+    endif ()
 
     if (UNIX)
         if (APPLE)
@arizvisa arizvisa changed the title support for 32-bit addressing support for 32-bit addressing on posix platforms Nov 25, 2023
@DarkaMaul
Copy link
Collaborator

Hi,
Thanks a lot for your contribution.
Let us review it before merging it.

(As a side note, if it is possible for you, could you create a Pull Requests with the changes?)

@arizvisa
Copy link
Author

arizvisa commented Dec 3, 2023

Hi, Thanks a lot for your contribution. Let us review it before merging it.

Yep, no problem. The core of it is defining the __EA64__ preprocessor macro when building for 64-bit addressing, and ensuring it's not defined for 32-bit addressing. I exposed it as a CMake knob, but I srsly hate CMake and so there's likely a better way.

(As a side note, if it is possible for you, could you create a Pull Requests with the changes?)

Sorry, I have to go through a legal process and all that jazz to contribute to opensource projects. As I don't plan on doing any major development for quokka (and this being literally <20 liens of code), I'd prefer to avoid that process entirely and also avoid my username being retained inside the repository history.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants