Ghidra is a software reverse engineering (SRE) framework
GP-4235: Adding the means to build and find native components on FreeBSD
Ryan Kurtzd16747cf6ccb
diff --git a/GPL/DemanglerGnu/build.gradle b/GPL/DemanglerGnu/build.gradleindex 255fd56a5c..174747549f 100644--- a/GPL/DemanglerGnu/build.gradle+++ b/GPL/DemanglerGnu/build.gradle@@ -81,6 +81,7 @@ model {targetPlatform "linux_arm_64"targetPlatform "mac_x86_64"targetPlatform "mac_arm_64"+ targetPlatform "freebsd_x86_64"sources {c {source {@@ -102,6 +103,7 @@ model {targetPlatform "linux_arm_64"targetPlatform "mac_x86_64"targetPlatform "mac_arm_64"+ targetPlatform "freebsd_x86_64"sources {c {source {diff --git a/GPL/nativeBuildProperties.gradle b/GPL/nativeBuildProperties.gradleindex 5e9c33f4eb..6ba0409b6a 100644--- a/GPL/nativeBuildProperties.gradle+++ b/GPL/nativeBuildProperties.gradle@@ -52,6 +52,11 @@ model {}}}+ if (isCurrentFreeBSD()) {+ gcc(Gcc) {+ target("freebsd_x86_64")+ }+ }if (isCurrentWindows() && VISUAL_STUDIO_INSTALL_DIR) {// specify installDir because Gradle doesn't find VS Build Tools.// See https://github.com/gradle/gradle-native/issues/617#issuecomment-575735288diff --git a/GPL/nativePlatforms.gradle b/GPL/nativePlatforms.gradleindex a75cf48a5d..24d540f10a 100644--- a/GPL/nativePlatforms.gradle+++ b/GPL/nativePlatforms.gradle@@ -24,7 +24,8 @@ project.ext.PLATFORMS = [[name: "linux_x86_64", os: "linux", arch: "x86_64"],[name: "linux_arm_64", os: "linux", arch: "arm64"],[name: "mac_x86_64", os: "osx", arch: "x86_64"],- [name: "mac_arm_64", os: "osx", arch: "arm64"]+ [name: "mac_arm_64", os: "osx", arch: "arm64"],+ [name: "freebsd_x86_64", os: "freebsd", arch: "x86_64"]]/*********************************************************************************@@ -51,6 +52,9 @@ ext.getCurrentPlatformName = {case ~/Mac OS X.*/:os = "mac"break+ case ~/FreeBSD.*/:+ os = "freebsd"+ breakdefault:throw new GradleException("Unrecognized platform operating system: $os")}@@ -112,6 +116,20 @@ ext.isCurrentMac = {return isMac(getCurrentPlatformName())}+/*********************************************************************************+ * Returns true if the given platform is FreeBSD.+ *********************************************************************************/+ext.isFreeBSD = { platform_name ->+ return platform_name.startsWith("freebsd")+}++/*********************************************************************************+ * Returns true if the current platform is FreeBSD.+ *********************************************************************************/+ext.isCurrentFreeBSD = {+ return isFreeBSD(getCurrentPlatformName())+}+/********************************************************************************** Returns true if the given platform is Windows.*********************************************************************************/diff --git a/Ghidra/Features/Decompiler/buildNatives.gradle b/Ghidra/Features/Decompiler/buildNatives.gradleindex 9cf660e915..25a90a11e9 100644--- a/Ghidra/Features/Decompiler/buildNatives.gradle+++ b/Ghidra/Features/Decompiler/buildNatives.gradle@@ -43,6 +43,7 @@ model {targetPlatform "linux_arm_64"targetPlatform "mac_x86_64"targetPlatform "mac_arm_64"+ targetPlatform "freebsd_x86_64"sources {cpp {// NOTE: The bison/flex generated files are assumed to be up-to-date.@@ -148,6 +149,7 @@ model {targetPlatform "linux_arm_64"targetPlatform "mac_x86_64"targetPlatform "mac_arm_64"+ targetPlatform "freebsd_x86_64"sources {cpp {// NOTE: The bison/flex generated files are assumed to be up-to-date.diff --git a/Ghidra/Framework/Generic/src/main/java/ghidra/framework/Platform.java b/Ghidra/Framework/Generic/src/main/java/ghidra/framework/Platform.javaindex 562ca606af..68f5d476fb 100644--- a/Ghidra/Framework/Generic/src/main/java/ghidra/framework/Platform.java+++ b/Ghidra/Framework/Generic/src/main/java/ghidra/framework/Platform.java@@ -65,6 +65,11 @@ public enum Platform {*/MAC_ARM_64(OperatingSystem.MAC_OS_X, Architecture.ARM_64, "mac_arm_64", ".dylib", ""),+ /**+ * Identifies a FreeBSD x86 64-bit OS.+ */+ FREEBSD_X86_64(OperatingSystem.FREE_BSD, Architecture.X86_64, "freebsd_x86_64", ".so", ""),+/*** Identifies an unsupported OS.*/@@ -199,7 +204,8 @@ public enum Platform {*/public List<String> getAdditionalLibraryPaths() {List<String> paths = new ArrayList<String>();- if (operatingSystem == OperatingSystem.LINUX) {+ if (operatingSystem == OperatingSystem.LINUX ||+ operatingSystem == OperatingSystem.FREE_BSD) {paths.add("/bin");paths.add("/lib");paths.add("/lib64");diff --git a/Ghidra/Framework/Utility/src/main/java/ghidra/framework/OperatingSystem.java b/Ghidra/Framework/Utility/src/main/java/ghidra/framework/OperatingSystem.javaindex 1abe4d34b2..e803f338a1 100644--- a/Ghidra/Framework/Utility/src/main/java/ghidra/framework/OperatingSystem.java+++ b/Ghidra/Framework/Utility/src/main/java/ghidra/framework/OperatingSystem.java@@ -1,6 +1,5 @@/* ###* IP: GHIDRA- * REVIEWED: YES** Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.@@ -20,6 +19,7 @@ public enum OperatingSystem {WINDOWS("Windows"),LINUX("Linux"),MAC_OS_X("Mac OS X"),+ FREE_BSD("FreeBSD"),UNSUPPORTED("Unsupported Operating System");/**diff --git a/Ghidra/Framework/Utility/src/main/java/utility/application/ApplicationUtilities.java b/Ghidra/Framework/Utility/src/main/java/utility/application/ApplicationUtilities.javaindex 261b0ddcd3..16d354cc64 100644--- a/Ghidra/Framework/Utility/src/main/java/utility/application/ApplicationUtilities.java+++ b/Ghidra/Framework/Utility/src/main/java/utility/application/ApplicationUtilities.java@@ -225,6 +225,7 @@ public class ApplicationUtilities {return createDir(switch (OperatingSystem.CURRENT_OPERATING_SYSTEM) {case WINDOWS -> new File(getEnvFile("LOCALAPPDATA", true), appName);case LINUX -> new File("/var/tmp/" + userDirName);+ case FREE_BSD -> new File("/var/tmp/" + userDirName);case MAC_OS_X -> new File("/var/tmp/" + userDirName);default -> throw new FileNotFoundException("Failed to find the user cache directory: Unsupported operating system.");@@ -281,6 +282,7 @@ public class ApplicationUtilities {return createDir(switch (OperatingSystem.CURRENT_OPERATING_SYSTEM) {case WINDOWS -> new File(getEnvFile("APPDATA", true), versionedSubdir);case LINUX -> new File(userHomeDir, ".config/" + versionedSubdir);+ case FREE_BSD -> new File(userHomeDir, ".config/" + versionedSubdir);case MAC_OS_X -> new File(userHomeDir, "Library/" + versionedSubdir);default -> throw new FileNotFoundException("Failed to find the user settings directory: Unsupported operating system.");diff --git a/GhidraDocs/InstallationGuide.html b/GhidraDocs/InstallationGuide.htmlindex 9dffdc2c23..3c47400b84 100644--- a/GhidraDocs/InstallationGuide.html+++ b/GhidraDocs/InstallationGuide.html@@ -18,7 +18,7 @@<h1>Ghidra Installation Guide</h1><p>-The installation information provided is effective as of Ghidra 10.2 and is subject to change with+The installation information provided is effective as of Ghidra 11.1 and is subject to change withfuture releases.</p>@@ -310,20 +310,20 @@ Ghidra release includes native binaries for the following platforms:</p><li>Windows x86 64-bit</li><li>Linux x86 64-bit</li><li>macOS x86 64-bit</li>- <li>macOS ARM 64-bit (x86 using Rosetta translation)</li>+ <li>macOS ARM 64-bit</li></ul><p>Ghidra supports running on the following additional platforms with user-built native binaries:</p><ul><li>Linux ARM 64-bit</li>- <li>macOS ARM 64-bit (Apple silicon)</li>+ <li>FreeBSD x86 64-bit (no debugger support)</li></ul><p>In order to build native binaries for your platform, you will need the following installed on yoursystem:</p><ul><li>A <a href="#Requirements">supported</a> version of a Java Development Kit</li><li><a href="https://gradle.org/releases/">Gradle 7.3+</a></li>- <li>make, gcc, and g++ (Linux/macOS-only)</li>+ <li>make, gcc, and g++ (Linux/macOS/FreeBSD-only)</li><li><a href="https://visualstudio.microsoft.com/vs/community/">Microsoft Visual Studio</a>2017 or later, or <a href="https://visualstudio.microsoft.com/visual-cpp-build-tools/">