Ghidra is a software reverse engineering (SRE) framework
GP-1106: Platform naming convention now supports different architectures. Support for building on ARM.
Ryan Kurtz00533b2869db
diff --git a/DevGuide.md b/DevGuide.mdindex addc98bdcd..f2cd01265f 100644--- a/DevGuide.md+++ b/DevGuide.md@@ -270,23 +270,25 @@ Now build using Gradle:On Linux:```bash-gradle buildNatives_linux64+gradle buildNatives_linux_x86_64```On macOS:```bash-gradle buildNatives_osx64+gradle buildNatives_mac_x86_64```On Windows:```bash-gradle buildNatives_win64+gradle buildNatives_win_x86_64```This will build the decompiler, the demangler for GNU toolchains, the sleigh compiler, and (on Windows only) the PDB parser.+**NOTE:** `buildNatives_linux_arm_64` and `buildNatives_mac_arm_64` are also supported.+### Pre-compile Language Modules (optional)Optionally, to pre-compile all the language modules, you may also execute:diff --git a/GPL/DMG/build.gradle b/GPL/DMG/build.gradleindex 6211ef390a..f06f6926b9 100644--- a/GPL/DMG/build.gradle+++ b/GPL/DMG/build.gradle@@ -1,7 +1,6 @@/* ###* IP: Public Domain*/-apply from: file("../gpl.gradle").getCanonicalPath()if (findProject(':Generic') != null) {apply from: "$rootProject.projectDir/gradle/javaProject.gradle"diff --git a/GPL/DMG/certification.manifest b/GPL/DMG/certification.manifestindex f2127813c2..ebc6cd3f2f 100644--- a/GPL/DMG/certification.manifest+++ b/GPL/DMG/certification.manifest@@ -8,10 +8,10 @@ data/lib/hfsexplorer-0_21-src.zip||GPL 3||||END|data/lib/hfsx.jar||GPL 3||||END|data/lib/hfsx_dmglib.jar||GPL 3||||END|data/lib/iharder-base64.jar||GPL 3||||END|-data/os/win32/llio_amd64.dll||GPL 3||||END|-data/os/win32/llio_i386.dll||GPL 3||||END|-data/os/win32/llio_ia64.dll||GPL 3||||END|-data/os/win64/llio_amd64.dll||GPL 3||||END|-data/os/win64/llio_i386.dll||GPL 3||||END|-data/os/win64/llio_ia64.dll||GPL 3||||END|+data/os/win_x86_32/llio_amd64.dll||GPL 3||||END|+data/os/win_x86_32/llio_i386.dll||GPL 3||||END|+data/os/win_x86_32/llio_ia64.dll||GPL 3||||END|+data/os/win_x86_64/llio_amd64.dll||GPL 3||||END|+data/os/win_x86_64/llio_i386.dll||GPL 3||||END|+data/os/win_x86_64/llio_ia64.dll||GPL 3||||END|data/server_memory.cfg||Public Domain||||END|diff --git a/GPL/DMG/data/os/win32/llio_amd64.dll b/GPL/DMG/data/os/win_x86_32/llio_amd64.dllsimilarity index 100%rename from GPL/DMG/data/os/win32/llio_amd64.dllrename to GPL/DMG/data/os/win_x86_32/llio_amd64.dlldiff --git a/GPL/DMG/data/os/win32/llio_i386.dll b/GPL/DMG/data/os/win_x86_32/llio_i386.dllsimilarity index 100%rename from GPL/DMG/data/os/win32/llio_i386.dllrename to GPL/DMG/data/os/win_x86_32/llio_i386.dlldiff --git a/GPL/DMG/data/os/win32/llio_ia64.dll b/GPL/DMG/data/os/win_x86_32/llio_ia64.dllsimilarity index 100%rename from GPL/DMG/data/os/win32/llio_ia64.dllrename to GPL/DMG/data/os/win_x86_32/llio_ia64.dlldiff --git a/GPL/DMG/data/os/win64/llio_amd64.dll b/GPL/DMG/data/os/win_x86_64/llio_amd64.dllsimilarity index 100%rename from GPL/DMG/data/os/win64/llio_amd64.dllrename to GPL/DMG/data/os/win_x86_64/llio_amd64.dlldiff --git a/GPL/DMG/data/os/win64/llio_i386.dll b/GPL/DMG/data/os/win_x86_64/llio_i386.dllsimilarity index 100%rename from GPL/DMG/data/os/win64/llio_i386.dllrename to GPL/DMG/data/os/win_x86_64/llio_i386.dlldiff --git a/GPL/DMG/data/os/win64/llio_ia64.dll b/GPL/DMG/data/os/win_x86_64/llio_ia64.dllsimilarity index 100%rename from GPL/DMG/data/os/win64/llio_ia64.dllrename to GPL/DMG/data/os/win_x86_64/llio_ia64.dlldiff --git a/GPL/DemanglerGnu/build.gradle b/GPL/DemanglerGnu/build.gradleindex bf413418c8..0e50950bdf 100644--- a/GPL/DemanglerGnu/build.gradle+++ b/GPL/DemanglerGnu/build.gradle@@ -1,13 +1,14 @@/* ###* IP: Public Domain*/-apply from: file("../gpl.gradle").getCanonicalPath()if (findProject(':Generic') != null) {apply from: "$rootProject.projectDir/gradle/nativeProject.gradle"apply from: "$rootProject.projectDir/gradle/distributableGPLModule.gradle"}else {+ apply from: "../utils.gradle"+ apply from: "../nativePlatforms.gradle"apply from: "../nativeBuildProperties.gradle"}@@ -21,30 +22,6 @@ def v24 = "demangler_gnu_v2_24"def srcVersion33_1 = "src/demangler_gnu_v2_33_1"def srcVersion24 = "src/demangler_gnu_v2_24"-/****************************************************************************- * Defines the platforms we have to support in Ghidra. This model is used- * for all native builds and should be extended by each module as-needed.- ****************************************************************************/-model {-- // define the platforms that we support in ghidra- platforms {- win64 {- architecture 'x86_64'- operatingSystem 'windows'- }- linux64 {- architecture 'x86_64'- operatingSystem 'linux'- }- osx64 {- architecture 'x86_64'- operatingSystem 'osx'- }- }-}--/*** This project has some native 'c' code we need to include in the zip for licensing* and build reasons. So include them here, but we have to do something special: the@@ -100,9 +77,11 @@ model {//components {demangler_gnu_v2_33_1(NativeExecutableSpec) {- targetPlatform "win64"- targetPlatform "linux64"- targetPlatform "osx64"+ targetPlatform "win_x86_64"+ targetPlatform "linux_x86_64"+ targetPlatform "linux_arm_64"+ targetPlatform "mac_x86_64"+ targetPlatform "mac_arm_64"sources {c {source {@@ -119,9 +98,11 @@ model {// Version 2.24//demangler_gnu_v2_24(NativeExecutableSpec) {- targetPlatform "win64"- targetPlatform "linux64"- targetPlatform "osx64"+ targetPlatform "win_x86_64"+ targetPlatform "linux_x86_64"+ targetPlatform "linux_arm_64"+ targetPlatform "mac_x86_64"+ targetPlatform "mac_arm_64"sources {c {source {diff --git a/GPL/GnuDisassembler/build.gradle b/GPL/GnuDisassembler/build.gradleindex 2d51c81c4a..c2340ce183 100644--- a/GPL/GnuDisassembler/build.gradle+++ b/GPL/GnuDisassembler/build.gradle@@ -36,13 +36,13 @@ ext.binutilsDistro = "${binutils}.tar.bz2"// Find the GPL dirdef gplDir = null;-if (file("../gpl.gradle").exists()) {+if (file("../utils.gradle").exists()) {gplDir = file("..").getCanonicalPath()}else {// Module lives disconnected from the GPL directory, which it will need to build.// Find a Ghidra installation directory and use its GPL directory.- if (file("../../Extensions").exists() && file("../../../GPL/gpl.gradle").exists()) {+ if (file("../../Extensions").exists() && file("../../../GPL/utils.gradle").exists()) {// Module is installed within a Ghidra installation (i.e, ghidra/Ghidra/Extensions)gplDir = file("../../../GPL").getCanonicalPath()}@@ -76,7 +76,8 @@ if (findProject(':Generic') != null) {}else {// Build GPL extension (gdis)- apply from: "${gplDir}/gpl.gradle"+ apply from: "${gplDir}/utils.gradle"+ apply from: "${gplDir}/nativePlatforms.gradle"apply from: "${gplDir}/nativeBuildProperties.gradle"apply from: "buildGdis.gradle"}diff --git a/GPL/GnuDisassembler/buildGdis.gradle b/GPL/GnuDisassembler/buildGdis.gradleindex 9be9c9459c..a8a0f3eada 100644--- a/GPL/GnuDisassembler/buildGdis.gradle+++ b/GPL/GnuDisassembler/buildGdis.gradle@@ -4,7 +4,7 @@defaultTasks 'assemble'-ext.supportedPlatforms = ['osx64', 'linux64']+ext.supportedPlatforms = ['mac_x86_64', 'mac_arm_64', 'linux_x86_64', 'linux_arm_64']ext.binutilsResource = new File("${projectDir}/${binutils}.tar.bz2")@@ -18,17 +18,6 @@ def binutilsUnpackDir = file("${project.buildDir}/${binutils}/")******************************************************************************************/model {- platforms {- linux64 {- architecture 'x86_64'- operatingSystem 'linux'- }- osx64 {- architecture 'x86_64'- operatingSystem 'osx'- }- }-components {gdis(NativeExecutableSpec) {@@ -56,11 +45,17 @@ model {}}- tasks.compileGdisOsx64ExecutableGdisC {- dependsOn 'copyBinutilsArtifcats_osx64'+ tasks.compileGdisMac_x86_64ExecutableGdisC {+ dependsOn 'copyBinutilsArtifcats_mac_x86_64'+ }+ tasks.compileGdisLinux_x86_64ExecutableGdisC {+ dependsOn 'copyBinutilsArtifcats_linux_x86_64'+ }+ tasks.compileGdisMac_arm_64ExecutableGdisC {+ dependsOn 'copyBinutilsArtifcats_mac_arm_64'}- tasks.compileGdisLinux64ExecutableGdisC {- dependsOn 'copyBinutilsArtifcats_linux64'+ tasks.compileGdisLinux_arm_64ExecutableGdisC {+ dependsOn 'copyBinutilsArtifcats_linux_arm_64'}}diff --git a/GPL/gpl.gradle b/GPL/gpl.gradledeleted file mode 100644index 8ca3271e77..0000000000--- a/GPL/gpl.gradle+++ /dev/null@@ -1,90 +0,0 @@-/* ###- * IP: Public Domain- */-// BIN_REPO only useable in full Ghidra source configuration-project.ext.BIN_REPO = file("../../../ghidra.bin").absolutePath--/****************************************************************************- * Create a set containing all the platforms we need when building native- * artifacts.- ****************************************************************************/-project.ext.set("OS_NAMES", ["osx64", "win32", "win64", "linux64"])--/****************************************************************************- * Establish Visual Studio configuration environment for Windows native builds- * NOTE: vsconfig.gradle path is relative to each GPL project module- ****************************************************************************/-apply from: buildscript.sourceFile.getParent() + "/vsconfig.gradle"--/*********************************************************************************- * Returns the local platform name.- *********************************************************************************/-ext.getCurrentPlatformName = {-- String osName = System.getProperty("os.name")- String archName = System.getProperty("os.arch")-- boolean isX86_32 = archName.equals("x86") || archName.equals("i386");- boolean isX86_64 = archName.equals("x86_64") || archName.equals("amd64");-- if (osName.startsWith("Windows")) {- if (isX86_32) {- return 'win32'- }- else if (isX86_64) {- return 'win64'- }- }- else if (osName.startsWith("Linux")) {- if (isX86_64) {- return 'linux64'- }- }- else if (osName.startsWith("Mac OS X")) {- if (isX86_64) {- return 'osx64'- }- }- throw new GradleException("Unrecognized current platform -> osName = $osName, archName = $archName")-}-/******************************************************************************************- * Helper method that returns a file that is the same relative location in the bin repo- * as the given project is in its repo.- ******************************************************************************************/-ext.getProjectLocationInBinRepo = {- String relativePath = getGhidraRelativePath(this.project)- println("RELATIVE: $relativePath")- File binRepoRootProject = new File("${BIN_REPO}")- if (!binRepoRootProject.isDirectory()) {- throw new GradleException("Task requires Ghidra source and ghidra.bin")- }- return new File(binRepoRootProject, relativePath)-}-/****************************************************************************************- * Returns the "effective" relative path (Path starting with Ghidra)- * Normally, for files in the ghidra repo this is just the relative path from- * the root project (ghidra) to the given project.- *- * For example <...>/ghidra/Ghidra/Features/Base will return Ghidra/Features/Base- *- * If the project is in a sibling repo (ghidra.<other> that lives in the same directory- * as ghidra), then this method returns a relative path as though the project lived- * in ghidra.- *- * for example <...>/ghidra.foo/Ghidra/Features/OtherProject will return Ghidra/Features/OtherProject- ****************************************************************************************/-String getGhidraRelativePath(Project p) {- String path = rootProject.relativePath(p.projectDir)-- // If the project lives outside the ghidra repo, then its relative path will- // start with "../". In this case, we want to remove the "../" and the next path element- // so that the path will appear as though the project lived under the ghidra repo.- // example: "../ghidra/Ghidra/Features/Foo" will get changed to "Ghidra/Features/Foo"- String prefix = ".."+File.separator- if (path.startsWith(prefix)) {- int index = path.indexOf(File.separator,3)- path = path.substring(index+1)- }-- return path-}diff --git a/GPL/nativeBuildProperties.gradle b/GPL/nativeBuildProperties.gradleindex 6ddc826059..494e2be7f8 100644--- a/GPL/nativeBuildProperties.gradle+++ b/GPL/nativeBuildProperties.gradle@@ -24,25 +24,35 @@ apply plugin: 'c'****************************************************************************/model {- // define the platforms that we support in ghidra+ // Use the PLATFORMS list to create the platforms that Ghidra supports.platforms {- win32 {- architecture 'x86'- operatingSystem 'windows'- }- win64 {- architecture 'x86_64'- operatingSystem 'windows'+ project.PLATFORMS.each { platform ->+ "${platform.name}" {+ architecture platform.arch+ operatingSystem platform.os+ }}- linux64 {- architecture 'x86_64'- operatingSystem 'linux'+ }++ // The toolChains block is needed because Gradle doesn't find gcc/clang on ARM-based Linux+ // and macOS platforms without explicitly declaring their targets. Might be a bug in the+ // native Gradle plugin.+ toolChains {+ if (isCurrentLinux()) {+ gcc(Gcc) {+ if (isCurrentArm_64()) {+ target("linux_arm_64")+ }+ }}- osx64 {- architecture 'x86_64'- operatingSystem 'osx'+ if (isCurrentMac()) {+ clang(Clang) {+ if (isCurrentArm_64()) {+ target("mac_arm_64")+ }+ }}- }+ }}/*******************************************************************************************@@ -51,7 +61,7 @@ model {task CheckToolChain {// Native C/Cpp plugins will trigger failure if no tool chain founddoFirst {- if (org.gradle.internal.os.OperatingSystem.current().isWindows()) {+ if (isCurrentWindows()) {// ensure that required MS Visual Studio is installedif (!VISUAL_STUDIO_INSTALL_DIR) {throw new GradleException("Visual Studio not found!");@@ -100,7 +110,7 @@ def shouldSkipNative(task) {/******************************************************************************************** Task Rule : builds all the natives in this module for a given platform.*- * Example : gradle buildNatives_win64 will build all win64 native executables and shared libraries.+ * Example : gradle buildNatives_win_x86_64 will build all win_x86_64 native executables and shared libraries.** NOTE: you must be on the appropriate platform for this to work.*@@ -151,7 +161,7 @@ tasks.addRule("Pattern: buildNatives_<platform name>]: build all natives for giv* Task Rule : builds all the natives in this module for a given platform and copies the* results to the bin repo.*- * Example : gradle prebuildNatives_win64 will build all win64 native executables and shared+ * Example : gradle prebuildNatives_win_x86_64 will build all win_x86_64 native executables and shared* libraries and copy the results to the appropriate project/os directory in the bin* repo.*diff --git a/GPL/nativePlatforms.gradle b/GPL/nativePlatforms.gradlenew file mode 100644index 0000000000..7b1ea948a8--- /dev/null+++ b/GPL/nativePlatforms.gradle@@ -0,0 +1,159 @@+/* ###+ * IP: Public Domain+ */+/****************************************************************************+ * nativePlatforms.gradle+ *+ * This script defines the various platforms that Ghidra supports being built+ * on. Utility methods are provided for determining the current platform, as+ * well as querying and extracting information about the platform, such as+ * operating system and architecture.+ ****************************************************************************/++/****************************************************************************+ * Create a list containing all the platforms we support for building native+ * artifacts. Each platform has the following fields:+ * name: Ghidra's naming convention for the platform. This is used in the+ native build tasks, and is the name of the os/ subdirectories.+ * os: Gradle's NativePlatform operatingSystem property naming convention.+ * arch: Gradle's NativePlatform architecture property naming convention.+ ****************************************************************************/+project.ext.PLATFORMS = [+ [name: "win_x86_32", os: "windows", arch: "x86"],+ [name: "win_x86_64", os: "windows", arch: "x86_64"],+ [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"]+]++/*********************************************************************************+ * Returns the local platform name.+ *********************************************************************************/+import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform+ext.currentPlatformName = null+ext.getCurrentPlatformName = {++ if (currentPlatformName) {+ return currentPlatformName+ }++ def osGradle = DefaultNativePlatform.currentOperatingSystem.getName()+ def osJvm = System.getProperty("os.name");+ def os = osJvm+ switch (osJvm) {+ case ~/Windows.*/:+ os = "win"+ break+ case ~/Linux.*/:+ os = "linux"+ break+ case ~/Mac OS X.*/:+ os = "mac"+ break+ default:+ throw new GradleException("Unrecognized platform operating system: $os")+ }++ def archGradle = DefaultNativePlatform.currentArchitecture.getName()+ def archJvm = System.getProperty("os.arch");+ def arch = archJvm+ switch (arch) {+ case "x86":+ case "i386":+ arch = "x86_32"+ break+ case "x86_64":+ case "amd64":+ arch = "x86_64"+ break+ case "aarch64":+ case "arm64":+ arch = "arm_64"+ break+ default:+ throw new GradleException("Unrecognized platform architecture: $arch" )+ }++ currentPlatformName = "${os}_${arch}"++ println "OS: " + osJvm + (osJvm != osGradle ? " (gradle: " + osGradle + ")" : "")+ println "Arch: " + archJvm + (archJvm != archGradle ? " (gradle: " + archGradle + ")" : "")+ println "Using platform: " + currentPlatformName++ return currentPlatformName+}+++/*********************************************************************************+ * Returns true if the given platform is linux.+ *********************************************************************************/+ext.isLinux = { platform_name ->+ return platform_name.startsWith("linux")+}+/*********************************************************************************+ * Returns true if the current platform is linux.+ *********************************************************************************/+ext.isCurrentLinux = {+ return isLinux(getCurrentPlatformName())+}++/*********************************************************************************+ * Returns true if the given platform is macOS.+ *********************************************************************************/+ext.isMac = { platform_name ->+ return platform_name.startsWith("mac")+}++/*********************************************************************************+ * Returns true if the current platform is macOS.+ *********************************************************************************/+ext.isCurrentMac = {+ return isMac(getCurrentPlatformName())+}++/*********************************************************************************+ * Returns true if the given platform is Windows.+ *********************************************************************************/+ext.isWindows = { platform_name ->+ return platform_name.startsWith("win")+}++/*********************************************************************************+ * Returns true if the current platform is Windows.+ *********************************************************************************/+ext.isCurrentWindows = {+ return isWindows(getCurrentPlatformName())+}++/*********************************************************************************+ * Returns true if the given platform is x86.+ *********************************************************************************/+ext.isX86_64 = { platform_name ->+ return platform_name.contains("x86")+}+/*********************************************************************************+ * Returns true if the current platform is x86.+ *********************************************************************************/+ext.isCurrentX86_64 = {+ return isX86_64(getCurrentPlatformName())+}++/*********************************************************************************+ * Returns true if the given platform is ARM.+ *********************************************************************************/+ext.isArm_64 = { platform_name ->+ return platform_name.contains("arm")+}+/*********************************************************************************+ * Returns true if the current platform is ARM.+ *********************************************************************************/+ext.isCurrentArm_64 = {+ return isArm_64(getCurrentPlatformName())+}++/****************************************************************************+ * Establish Visual Studio configuration environment for Windows native builds+ * NOTE: vsconfig.gradle path is relative to each GPL project module+ ****************************************************************************/+apply from: buildscript.sourceFile.getParent() + "/vsconfig.gradle"diff --git a/GPL/utils.gradle b/GPL/utils.gradlenew file mode 100644index 0000000000..a510e921c5--- /dev/null+++ b/GPL/utils.gradle@@ -0,0 +1,41 @@+/* ###+ * IP: Public Domain+ */++/******************************************************************************************+ * Helper method that returns a file that is the same relative location in the bin repo+ * as the given project is in its repo.+ ******************************************************************************************/+ext.getProjectLocationInBinRepo = { p ->+ String relativePath = getGhidraRelativePath(p)+ File binRepoRootProject = new File("${BIN_REPO}")+ return new File(binRepoRootProject, relativePath)+}+/****************************************************************************************+ * Returns the "effective" relative path (Path starting with Ghidra)+ * Normally, for files in the ghidra repo this is just the relative path from+ * the root project (ghidra) to the given project.+ *+ * For example <...>/ghidra/Ghidra/Features/Base will return Ghidra/Features/Base+ *+ * If the project is in a sibling repo (ghidra.<other> that lives in the same directory+ * as ghidra), then this method returns a relative path as though the project lived+ * in ghidra.+ *+ * for example <...>/ghidra.foo/Ghidra/Features/OtherProject will return Ghidra/Features/OtherProject+ ****************************************************************************************/+ext.getGhidraRelativePath = { p ->+ String path = rootProject.relativePath(p.projectDir)++ // If the project lives outside the ghidra repo, then its relative path will+ // start with "../". In this case, we want to remove the "../" and the next path element+ // so that the path will appear as though the project lived under the ghidra repo.+ // example: "../ghidra/Ghidra/Features/Foo" will get changed to "Ghidra/Features/Foo"+ String prefix = ".."+File.separator+ if (path.startsWith(prefix)) {+ int index = path.indexOf(File.separator,3)+ path = path.substring(index+1)+ }++ return path+}diff --git a/GPL/vsconfig.gradle b/GPL/vsconfig.gradleindex a57b7eb54a..a21190cb0b 100644--- a/GPL/vsconfig.gradle+++ b/GPL/vsconfig.gradle@@ -27,7 +27,7 @@ if (!hasProperty("VISUAL_STUDIO_INSTALL_DIR")) {def configureVisualStudio() {- if (org.gradle.internal.os.OperatingSystem.current().isWindows()) {+ if (isCurrentWindows()) {// Initialize variablesrootProject.ext.VISUAL_STUDIO_INSTALL_DIR = ""diff --git a/Ghidra/Debug/Debugger-agent-dbgeng/build.gradle b/Ghidra/Debug/Debugger-agent-dbgeng/build.gradleindex 836b3ef00b..bd89485188 100644--- a/Ghidra/Debug/Debugger-agent-dbgeng/build.gradle+++ b/Ghidra/Debug/Debugger-agent-dbgeng/build.gradle@@ -84,7 +84,7 @@ task nodepJar(type: Jar) {test {jvmArgs('-Xrs') // TODO: Is this needed, or left over from trial-and-error- if ("win64".equals(getCurrentPlatformName())) {- dependsOn(":Framework-Debugging:testSpecimenWin64")+ if ("win_x86_64".equals(getCurrentPlatformName())) {+ dependsOn(":Framework-Debugging:testSpecimenWin_x86_64")}}diff --git a/Ghidra/Debug/Debugger-agent-dbgmodel/build.gradle b/Ghidra/Debug/Debugger-agent-dbgmodel/build.gradleindex 5fe088d111..350a6e743b 100644--- a/Ghidra/Debug/Debugger-agent-dbgmodel/build.gradle+++ b/Ghidra/Debug/Debugger-agent-dbgmodel/build.gradle@@ -79,7 +79,7 @@ task nodepJar(type: Jar) {test {jvmArgs('-Xrs') // TODO: Is this needed, or left over from trial-and-error- if ("win64".equals(getCurrentPlatformName())) {- dependsOn(":Framework-Debugging:testSpecimenWin64")+ if ("win_x86_64".equals(getCurrentPlatformName())) {+ dependsOn(":Framework-Debugging:testSpecimenWin_x86_64")}}diff --git a/Ghidra/Debug/Debugger-agent-gdb/build.gradle b/Ghidra/Debug/Debugger-agent-gdb/build.gradleindex b69137869c..ec929fbb42 100644--- a/Ghidra/Debug/Debugger-agent-gdb/build.gradle+++ b/Ghidra/Debug/Debugger-agent-gdb/build.gradle@@ -104,7 +104,7 @@ task executableJar {}test {- if ("linux64".equals(getCurrentPlatformName())) {- dependsOn(":Framework-Debugging:testSpecimenLinux64")+ if ("linux_x86_64".equals(getCurrentPlatformName())) {+ dependsOn(":Framework-Debugging:testSpecimenLinux_x86_64")}}diff --git a/Ghidra/Debug/Debugger-gadp/Module.manifest b/Ghidra/Debug/Debugger-gadp/Module.manifestindex 35e983519d..964f9ff330 100644--- a/Ghidra/Debug/Debugger-gadp/Module.manifest+++ b/Ghidra/Debug/Debugger-gadp/Module.manifest@@ -1 +1 @@-MODULE FILE LICENSE: lib/protobuf-java-3.11.1.jar BSD+MODULE FILE LICENSE: lib/protobuf-java-3.17.3.jar BSDdiff --git a/Ghidra/Debug/Debugger-gadp/build.gradle b/Ghidra/Debug/Debugger-gadp/build.gradleindex 86185f5b42..1b4922f663 100644--- a/Ghidra/Debug/Debugger-gadp/build.gradle+++ b/Ghidra/Debug/Debugger-gadp/build.gradle@@ -30,24 +30,36 @@ configurations {protocArtifact}-def os = org.gradle.internal.os.OperatingSystem.current()+def platform = getCurrentPlatformName()dependencies {- allProtocArtifacts 'com.google.protobuf:protoc:3.11.1:windows-x86_64@exe'- allProtocArtifacts 'com.google.protobuf:protoc:3.11.1:linux-x86_64@exe'- allProtocArtifacts 'com.google.protobuf:protoc:3.11.1:osx-x86_64@exe'+ allProtocArtifacts 'com.google.protobuf:protoc:3.17.3:windows-x86_64@exe'+ allProtocArtifacts 'com.google.protobuf:protoc:3.17.3:linux-x86_64@exe'+ allProtocArtifacts 'com.google.protobuf:protoc:3.17.3:linux-aarch_64@exe'+ allProtocArtifacts 'com.google.protobuf:protoc:3.17.3:osx-x86_64@exe'+ allProtocArtifacts 'com.google.protobuf:protoc:3.17.3:osx-aarch_64@exe'- if (os.isWindows()) {- protocArtifact 'com.google.protobuf:protoc:3.11.1:windows-x86_64@exe'+ if (isCurrentWindows()) {+ protocArtifact 'com.google.protobuf:protoc:3.17.3:windows-x86_64@exe'}- if (os.isLinux()) {- protocArtifact 'com.google.protobuf:protoc:3.11.1:linux-x86_64@exe'+ if (isCurrentLinux()) {+ if (platform.endsWith("x86_64")) {+ protocArtifact 'com.google.protobuf:protoc:3.17.3:linux-x86_64@exe'+ }+ else {+ protocArtifact 'com.google.protobuf:protoc:3.17.3:linux-aarch_64@exe'+ }+ }+ if (isCurrentMac()) {+ if (platform.endsWith("x86_64")) {+ protocArtifact 'com.google.protobuf:protoc:3.17.3:osx-x86_64@exe'+ }+ else {+ protocArtifact 'com.google.protobuf:protoc:3.17.3:osx-aarch_64@exe'+ }}- if (os.isMacOsX()) {- protocArtifact 'com.google.protobuf:protoc:3.11.1:osx-x86_64@exe'- }- api 'com.google.protobuf:protobuf-java:3.11.1'+ api 'com.google.protobuf:protobuf-java:3.17.3'api project(':Framework-AsyncComm')api project(':Framework-Debugging')api project(':ProposedUtils')@@ -58,7 +70,7 @@ dependencies {/*protobuf {protoc {- artifact = 'com.google.protobuf:protoc:3.11.1'+ artifact = 'com.google.protobuf:protoc:3.17.3'}}*/@@ -73,7 +85,7 @@ task generateProto {dependsOn(configurations.protocArtifact)doLast {def exe = configurations.protocArtifact.first()- if (!os.isWindows()) {+ if (!isCurrentWindows()) {exe.setExecutable(true)}exec {diff --git a/Ghidra/Debug/Framework-Debugging/build.gradle b/Ghidra/Debug/Framework-Debugging/build.gradleindex 841b955a24..75ba6e34cd 100644--- a/Ghidra/Debug/Framework-Debugging/build.gradle+++ b/Ghidra/Debug/Framework-Debugging/build.gradle@@ -34,77 +34,70 @@ dependencies {// Ensure the below native test binaries don't get built for a distributionext.nativesTestOnly = true-task testSpecimenWin64 {- dependsOn 'expCreateProcessWin64Executable'- dependsOn 'expCreateThreadExitWin64Executable'- //dependsOn 'expCreateThreadSpinWin64Executable'- dependsOn 'expPrintWin64Executable'- //dependsOn 'expSpinWin64Executable'- dependsOn 'expRegistersWin64Executable'- dependsOn 'expStackWin64Executable'+task testSpecimenWin_x86_64 {+ dependsOn 'expCreateProcessWin_x86_64Executable'+ dependsOn 'expCreateThreadExitWin_x86_64Executable'+ //dependsOn 'expCreateThreadSpinWin_x86_64Executable'+ dependsOn 'expPrintWin_x86_64Executable'+ //dependsOn 'expSpinWin_x86_64Executable'+ dependsOn 'expRegistersWin_x86_64Executable'+ dependsOn 'expStackWin_x86_64Executable'}-task testSpecimenLinux64 {- dependsOn 'expCloneExecExecutable'//Linux64Executable'- dependsOn 'expCloneExitExecutable'//Linux64Executable'- //dependsOn 'expCloneSpinExecutable'//Linux64Executable'- dependsOn 'expForkExecutable'//Linux64Executable'- dependsOn 'expPrintLinux64Executable'- //dependsOn 'expTypesExecutable'//Linux64Executable'- dependsOn 'expRegistersLinux64Executable'- dependsOn 'expStackLinux64Executable'+task testSpecimenLinux_x86_64 {+ dependsOn 'expCloneExecExecutable'//Linux_x86_64Executable'+ dependsOn 'expCloneExitExecutable'//Linux_x86_64Executable'+ //dependsOn 'expCloneSpinExecutable'//Linux_x86_64Executable'+ dependsOn 'expForkExecutable'//Linux_x86_64Executable'+ dependsOn 'expPrintLinux_x86_64Executable'+ //dependsOn 'expTypesExecutable'//Linux_x86_64Executable'+ dependsOn 'expRegistersLinux_x86_64Executable'+ dependsOn 'expStackLinux_x86_64Executable'}model {- platforms {- /*linux32 {- architecture "x86"- operatingSystem "linux"- }*/- }-components {expCreateProcess(NativeExecutableSpec) {- targetPlatform "win64"- targetPlatform "win32" // TODO: Test on these+ targetPlatform "win_x86_64"+ targetPlatform "win_x86_32" // TODO: Test on these}expCreateThreadExit(NativeExecutableSpec) {- targetPlatform "win64"- targetPlatform "win32" // TODO: Test on these+ targetPlatform "win_x86_64"+ targetPlatform "win_x86_32" // TODO: Test on these}expCreateThreadSpin(NativeExecutableSpec) {- targetPlatform "win64"- targetPlatform "win32" // TODO: Test on these+ targetPlatform "win_x86_64"+ targetPlatform "win_x86_32" // TODO: Test on these}expCloneExec(NativeExecutableSpec) {- targetPlatform "linux64"- //targetPlatform "linux32" // TODO: Test on these+ targetPlatform "linux_x86_64"+ //targetPlatform "linux_x86_32" // TODO: Test on these}expCloneExit(NativeExecutableSpec) {- targetPlatform "linux64"- //targetPlatform "linux32" // TODO: Test on these+ targetPlatform "linux_x86_64"+ //targetPlatform "linux_x86_32" // TODO: Test on these}expCloneSpin(NativeExecutableSpec) {- targetPlatform "linux64"- //targetPlatform "linux32" // TODO: Test on these+ targetPlatform "linux_x86_64"+ //targetPlatform "linux_x86_32" // TODO: Test on these}expFork(NativeExecutableSpec) {- targetPlatform "linux64"- //targetPlatform "linux32" // TODO: Test on these+ targetPlatform "linux_x86_64"+ //targetPlatform "linux_x86_32" // TODO: Test on these}expPrint(NativeExecutableSpec) {- targetPlatform "linux64"- //targetPlatform "linux32" // TODO: Test on these- targetPlatform "win64"- targetPlatform "win32" // TODO: Test on these+ targetPlatform "linux_x86_64"+ //targetPlatform "linux_x86_32" // TODO: Test on these+ targetPlatform "win_x86_64"+ targetPlatform "win_x86_32" // TODO: Test on these}expSpin(NativeExecutableSpec) {- targetPlatform "win64"- targetPlatform "win32" // TODO: Test on these+ targetPlatform "win_x86_64"+ targetPlatform "win_x86_32" // TODO: Test on these}expTypes(NativeExecutableSpec) {- targetPlatform "linux64"- //targetPlatform "linux32" // TODO: Test on these+ targetPlatform "linux_x86_64"+ //targetPlatform "linux_x86_32" // TODO: Test on thesebinaries {withType(NativeExecutableBinarySpec) {if (toolChain in Gcc) {@@ -114,16 +107,16 @@ model {}}expRegisters(NativeExecutableSpec) {- targetPlatform "linux64"- //targetPlatform "linux32" // TODO: Test on these- targetPlatform "win64"- targetPlatform "win32" // TODO: Test on these+ targetPlatform "linux_x86_64"+ //targetPlatform "linux_x86_32" // TODO: Test on these+ targetPlatform "win_x86_64"+ targetPlatform "win_x86_32" // TODO: Test on these}expStack(NativeExecutableSpec) {- targetPlatform "linux64"- //targetPlatform "linux32" // TODO: Test on these- targetPlatform "win64"- targetPlatform "win32" // TODO: Test on these+ targetPlatform "linux_x86_64"+ //targetPlatform "linux_x86_32" // TODO: Test on these+ targetPlatform "win_x86_64"+ targetPlatform "win_x86_32" // TODO: Test on these}}@@ -141,7 +134,7 @@ model {linker.args("/SUBSYSTEM:windows", "/DYNAMICBASE", "/NXCOMPAT")linker.args("shell32.lib");}- if (targetPlatform.name.startsWith("win")) {+ if (isWindows(targetPlatform.name)) {cppCompiler.define("WIN32")cCompiler.define("WIN32")diff --git a/Ghidra/Features/Decompiler/build.gradle b/Ghidra/Features/Decompiler/build.gradleindex 6f46538159..e5f9069112 100644--- a/Ghidra/Features/Decompiler/build.gradle+++ b/Ghidra/Features/Decompiler/build.gradle@@ -221,9 +221,8 @@ task buildDecompilerHelpPdf(type: Exec) {*/task buildDecompilerDocumentationPdfs(type: Exec) {// Check the OS before enabling task.- if (!(org.gradle.internal.os.OperatingSystem.current().isLinux()- || org.gradle.internal.os.OperatingSystem.current().isMacOsX())) {- it.enabled = false+ if (!(isCurrentLinux() || isCurrentMac())) {+ it.enabled = false}workingDir 'src/main/doc'@@ -388,9 +387,11 @@ model {baseName "decompile"// these tell gradle for which platforms to build a decompiler executable.- targetPlatform "win64"- targetPlatform "linux64"- targetPlatform "osx64"+ targetPlatform "win_x86_64"+ targetPlatform "linux_x86_64"+ targetPlatform "linux_arm_64"+ targetPlatform "mac_x86_64"+ targetPlatform "mac_arm_64"sources {cpp {// NOTE: The bison/flex generated files are assumed to be up-to-date.@@ -486,9 +487,11 @@ model {} // end decompilesleigh(NativeExecutableSpec) {- targetPlatform "win64"- targetPlatform "linux64"- targetPlatform "osx64"+ targetPlatform "win_x86_64"+ targetPlatform "linux_x86_64"+ targetPlatform "linux_arm_64"+ targetPlatform "mac_x86_64"+ targetPlatform "mac_arm_64"sources {cpp {// NOTE: The bison/flex generated files are assumed to be up-to-date.@@ -557,7 +560,7 @@ model {b.cppCompiler.define "_WINDOWS"b.cppCompiler.define "WIN32"b.cppCompiler.define "_WIN32"- if (b.targetPlatform.name == "win64") {+ if (b.targetPlatform.name == "win_x86_64") {b.cppCompiler.define "WIN64"b.cppCompiler.define "_WIN64"}diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/types.h b/Ghidra/Features/Decompiler/src/decompile/cpp/types.hindex d109066370..f07b14b8dd 100644--- a/Ghidra/Features/Decompiler/src/decompile/cpp/types.h+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/types.h@@ -101,6 +101,21 @@ typedef char int1;typedef uint8 uintp;#endif+#if defined (__linux__) && defined (__aarch64__)+#define HOST_ENDIAN 0+typedef unsigned int uintm;+typedef int intm;+typedef unsigned long uint8;+typedef long int8;+typedef unsigned int uint4;+typedef int int4;+typedef unsigned short uint2;+typedef short int2;+typedef unsigned char uint1;+typedef char int1;+typedef uint8 uintp;+#endif+#if defined(_WINDOWS)#if defined(_WIN64)diff --git a/Ghidra/Features/FileFormats/src/main/java/ghidra/file/jad/JadProcessWrapper.java b/Ghidra/Features/FileFormats/src/main/java/ghidra/file/jad/JadProcessWrapper.javaindex de81d6029d..4428adeccd 100644--- a/Ghidra/Features/FileFormats/src/main/java/ghidra/file/jad/JadProcessWrapper.java+++ b/Ghidra/Features/FileFormats/src/main/java/ghidra/file/jad/JadProcessWrapper.java@@ -114,8 +114,8 @@ public class JadProcessWrapper {private static String getJadPath() throws IOException {File jadExecutableFile =- Application.getOSFile((Platform.CURRENT_PLATFORM == Platform.WIN_32 ||- Platform.CURRENT_PLATFORM == Platform.WIN_64) ? "jad.exe" : "jad");+ Application.getOSFile((Platform.CURRENT_PLATFORM == Platform.WIN_X86_32 ||+ Platform.CURRENT_PLATFORM == Platform.WIN_X86_64) ? "jad.exe" : "jad");String jadPath = jadExecutableFile.getAbsolutePath();return jadPath;diff --git a/Ghidra/Features/FileFormats/src/main/java/ghidra/file/jad/OldJad.java b/Ghidra/Features/FileFormats/src/main/java/ghidra/file/jad/OldJad.javaindex c89e7ec01d..de059f0a27 100644--- a/Ghidra/Features/FileFormats/src/main/java/ghidra/file/jad/OldJad.java+++ b/Ghidra/Features/FileFormats/src/main/java/ghidra/file/jad/OldJad.java@@ -15,15 +15,15 @@*/package ghidra.file.jad;+import java.io.*;+import java.util.ArrayList;+import java.util.List;+import ghidra.framework.Application;import ghidra.framework.Platform;import ghidra.util.SystemUtilities;import ghidra.util.task.TaskMonitor;-import java.io.*;-import java.util.ArrayList;-import java.util.List;-/**** Wrapper class for JAD, a java decompiler.@@ -136,8 +136,8 @@ class OldJad {}private String getJadPath() throws FileNotFoundException {- if (Platform.CURRENT_PLATFORM == Platform.WIN_32 ||- Platform.CURRENT_PLATFORM == Platform.WIN_64) {+ if (Platform.CURRENT_PLATFORM == Platform.WIN_X86_32 ||+ Platform.CURRENT_PLATFORM == Platform.WIN_X86_64) {File jadExecutableFile = Application.getOSFile("jad.exe");String jadPath = jadExecutableFile.getAbsolutePath();return jadPath;diff --git a/Ghidra/Features/PDB/build.gradle b/Ghidra/Features/PDB/build.gradleindex 0ea23828b9..43fe526337 100644--- a/Ghidra/Features/PDB/build.gradle+++ b/Ghidra/Features/PDB/build.gradle@@ -54,9 +54,9 @@ rootProject.assembleDistribution {}}-if ("win64".equals(getCurrentPlatformName())) {+if ("win_x86_64".equals(getCurrentPlatformName())) {- String makeName = "win64PDBMake"+ String makeName = "win_x86_64PDBMake"task(type: Exec, makeName) {def projectPath = projectDir.toString()@@ -65,7 +65,7 @@ if ("win64".equals(getCurrentPlatformName())) {def solutionPathWindows = "\"${projectPathWindows}\\src\\pdb\\pdb.sln\""doFirst {- file("build/os/win64").mkdirs()+ file("build/os/win_x86_64").mkdirs()def platformToolset = 'v' + VISUAL_STUDIO_TOOLS_VERSION_DEFAULT.substring(0, 4).replace('.', '');def windowsTargetPlatformVersion = VISUAL_STUDIO_SDK_VERSION_OVERRIDE ?: VISUAL_STUDIO_SDK_VERSION_DEFAULT@@ -80,7 +80,7 @@ if ("win64".equals(getCurrentPlatformName())) {}doLast {- assert file("build/os/win64/pdb.exe").exists() : "Failed to build pdb.exe"+ assert file("build/os/win_x86_64/pdb.exe").exists() : "Failed to build pdb.exe"}executable "cmd"diff --git a/Ghidra/Features/PDB/src/pdb/pdb.vcxproj b/Ghidra/Features/PDB/src/pdb/pdb.vcxprojindex 8c20e06fe2..cf7d709341 100644--- a/Ghidra/Features/PDB/src/pdb/pdb.vcxproj+++ b/Ghidra/Features/PDB/src/pdb/pdb.vcxproj@@ -44,7 +44,7 @@<ReferencePath>$(VCInstallDir)lib\amd64;</ReferencePath><SourcePath /><ExcludePath>$(VCInstallDir)include;$(VCInstallDir)lib\amd64</ExcludePath>- <OutDir>$(SolutionDir)..\..\build\os\win64\</OutDir>+ <OutDir>$(SolutionDir)..\..\build\os\win_x86_64\</OutDir><IntDir>$(SolutionDir)..\..\build\tmp\pdb\$(Platform)\$(Configuration)\</IntDir></PropertyGroup><PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">@@ -53,7 +53,7 @@<ReferencePath>$(VCInstallDir)lib\amd64</ReferencePath><SourcePath /><ExcludePath>$(VCInstallDir)include;$(WindowsSDK_IncludePath);$(MSBuildToolsPath);$(MSBuildToolsPath32);$(VCInstallDir)lib\amd64;</ExcludePath>- <OutDir>$(SolutionDir)..\..\build\os\win64\</OutDir>+ <OutDir>$(SolutionDir)..\..\build\os\win_x86_64\</OutDir><IntDir>$(SolutionDir)..\..\build\tmp\pdb\$(Platform)\$(Configuration)\</IntDir></PropertyGroup><ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">@@ -74,9 +74,9 @@<Command>rem copy /y /v /b "$(VSInstallDir)DIA SDK\bin\amd64\msdia*.dll" "$(OutDir)"set OS_DIR=$(SolutionDir)..\..\os-if exist "%OS_DIR%\win64" (+if exist "%OS_DIR%\win_x86_64" (mkdir "%OS_DIR%"- mkdir "%OS_DIR%\win64"+ mkdir "%OS_DIR%\win_x86_64"xcopy /Y /S "$(OutDir)" "%OS_DIR%")</Command>@@ -107,9 +107,9 @@ if exist "%OS_DIR%\win64" (<Command>rem copy /y /v /b "$(VSInstallDir)DIA SDK\bin\amd64\msdia*.dll" "$(OutDir)"set OS_DIR=$(SolutionDir)..\..\os-if exist "%OS_DIR%\win64" (+if exist "%OS_DIR%\win_x86_64" (mkdir "%OS_DIR%"- mkdir "%OS_DIR%\win64"+ mkdir "%OS_DIR%\win_x86_64"xcopy /Y /S "$(OutDir)" "%OS_DIR%")</Command>diff --git a/Ghidra/Framework/Generic/src/main/java/ghidra/framework/Application.java b/Ghidra/Framework/Generic/src/main/java/ghidra/framework/Application.javaindex ab6b083c73..01b583bc12 100644--- a/Ghidra/Framework/Generic/src/main/java/ghidra/framework/Application.java+++ b/Ghidra/Framework/Generic/src/main/java/ghidra/framework/Application.java@@ -470,12 +470,13 @@ public class Application {}// Allow win32 to be used for win64 as fallback- if (file == null && Platform.CURRENT_PLATFORM == Platform.WIN_64) {- file = getModuleFile(module, "build/os/" + Platform.WIN_32.getDirectoryName(),+ if (file == null && Platform.CURRENT_PLATFORM == Platform.WIN_X86_64) {+ file = getModuleFile(module, "build/os/" + Platform.WIN_X86_32.getDirectoryName(),exactFilename);}- if (file == null && Platform.CURRENT_PLATFORM == Platform.WIN_64) {- file = getModuleFile(module, "os/" + Platform.WIN_32.getDirectoryName(), exactFilename);+ if (file == null && Platform.CURRENT_PLATFORM == Platform.WIN_X86_64) {+ file = getModuleFile(module, "os/" + Platform.WIN_X86_32.getDirectoryName(),+ exactFilename);}return file;@@ -501,11 +502,11 @@ public class Application {}// Allow win32 to be used for win64 as fallback- if (file == null && Platform.CURRENT_PLATFORM == Platform.WIN_64) {- file = findModuleFile("build/os/" + Platform.WIN_32.getDirectoryName(), path);+ if (file == null && Platform.CURRENT_PLATFORM == Platform.WIN_X86_64) {+ file = findModuleFile("build/os/" + Platform.WIN_X86_32.getDirectoryName(), path);}- if (file == null && Platform.CURRENT_PLATFORM == Platform.WIN_64) {- file = findModuleFile("os/" + Platform.WIN_32.getDirectoryName(), path);+ if (file == null && Platform.CURRENT_PLATFORM == Platform.WIN_X86_64) {+ file = findModuleFile("os/" + Platform.WIN_X86_32.getDirectoryName(), path);}if (file == null) {diff --git a/Ghidra/Framework/Generic/src/main/java/ghidra/framework/Architecture.java b/Ghidra/Framework/Generic/src/main/java/ghidra/framework/Architecture.javaindex 1ed37ddd8a..1b0c7c37cd 100644--- a/Ghidra/Framework/Generic/src/main/java/ghidra/framework/Architecture.java+++ b/Ghidra/Framework/Generic/src/main/java/ghidra/framework/Architecture.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.@@ -21,6 +20,7 @@ public enum Architecture {X86_64("x86_64", "amd64"),POWERPC("ppc"),POWERPC_64("ppc64"),+ ARM_64("aarch64", "arm64"),UNKNOWN("Unknown Architecture");/**diff --git a/Ghidra/Framework/Generic/src/main/java/ghidra/framework/Platform.java b/Ghidra/Framework/Generic/src/main/java/ghidra/framework/Platform.javaindex 60b36878ff..9593d97fec 100644--- a/Ghidra/Framework/Generic/src/main/java/ghidra/framework/Platform.java+++ b/Ghidra/Framework/Generic/src/main/java/ghidra/framework/Platform.java@@ -26,54 +26,107 @@ import java.util.List;public enum Platform {/**- * Identifies a Windows 32-bit OS (e.g., Windows NT, 2000, XP, etc.).+ * Identifies a Windows x86 32-bit OS.*/- WIN_32(OperatingSystem.WINDOWS, Architecture.X86, "win32", ".dll", ".exe"),+ WIN_X86_32(OperatingSystem.WINDOWS, Architecture.X86, "win_x86_32", ".dll", ".exe"),/**- * Identifies a Windows 64-bit OS (e.g., XP-64, etc.).+ * Identifies a Windows x86 64-bit OS.*/- WIN_64(OperatingSystem.WINDOWS, Architecture.X86_64, "win64", ".dll", ".exe"),+ WIN_X86_64(OperatingSystem.WINDOWS, Architecture.X86_64, "win_x86_64", ".dll", ".exe"),/**- * Identifies a Windows OS, the architecture for which we do not know or have not encountered+ * Identifies a Windows OS, the architecture for which we do not know or have not encountered.+ * We'll treat it as {@link #WIN_X86_64} and hope for the best.*/- WIN_UNKOWN(OperatingSystem.WINDOWS, Architecture.UNKNOWN, "win64", ".dll", ".exe"),+ WIN_UNKOWN(OperatingSystem.WINDOWS, Architecture.UNKNOWN, "win_x86_64", ".dll", ".exe"),/**- * Identifies a Linux OS.+ * Identifies a Linux x86 32-bit OS.*/- LINUX(OperatingSystem.LINUX, Architecture.X86, "linux32", ".so", ""),+ LINUX_X86_32(OperatingSystem.LINUX, Architecture.X86, "linux_x86_32", ".so", ""),/**- * Identifies a Linux OS x86-64.+ * Identifies a Linux x86 64-bit OS.*/- LINUX_64(OperatingSystem.LINUX, Architecture.X86_64, "linux64", ".so", ""),+ LINUX_X86_64(OperatingSystem.LINUX, Architecture.X86_64, "linux_x86_64", ".so", ""),/**- * Identifies a Linux OS, the architecture for which we do not know or have not encountered+ * Identifies a Linux ARM 64-bit OS.*/- LINUX_UKNOWN(OperatingSystem.LINUX, Architecture.UNKNOWN, "linux64", ".so", ""),+ LINUX_ARM_64(OperatingSystem.LINUX, Architecture.ARM_64, "linux_arm_64", ".so", ""),/**- * Identifies a Mac OS X for the Intel x86 32-bit platform.+ * Identifies a Linux OS, the architecture for which we do not know or have not encountered.+ * We'll treat it as {@link #LINUX_X86_64} and hope for the best.*/- MAC_OSX_32(OperatingSystem.MAC_OS_X, Architecture.X86, "osx32", ".dylib", ""),+ LINUX_UKNOWN(OperatingSystem.LINUX, Architecture.UNKNOWN, "linux_x86_64", ".so", ""),/**- * Identifies a Mac OS X for the Intel x86 64-bit platform.+ * Identifies a macOS x86 32-bit OS.*/- MAC_OSX_64(OperatingSystem.MAC_OS_X, Architecture.X86_64, "osx64", ".dylib", ""),+ MAC_X86_32(OperatingSystem.MAC_OS_X, Architecture.X86, "mac_x86_32", ".dylib", ""),/**- * Identifies a Mac OS, the architecture for which we do not know or have not encountered+ * Identifies a macOS x86 64-bit OS.*/- MAC_UNKNOWN(OperatingSystem.MAC_OS_X, Architecture.UNKNOWN, "osx64", ".dylib", ""),+ MAC_X86_64(OperatingSystem.MAC_OS_X, Architecture.X86_64, "mac_x86_64", ".dylib", ""),++ /**+ * Identifies a macOS ARM 64-bit OS.+ */+ MAC_ARM_64(OperatingSystem.MAC_OS_X, Architecture.ARM_64, "mac_arm_64", ".so", ""),++ /**+ * Identifies a macOS OS, the architecture for which we do not know or have not encountered.+ * We'll treat it as {@link #MAC_X86_64} and hope for the best.+ */+ MAC_UNKNOWN(OperatingSystem.MAC_OS_X, Architecture.UNKNOWN, "mac_x86_64", ".dylib", ""),/*** Identifies an unsupported OS.*/- UNSUPPORTED(OperatingSystem.UNSUPPORTED, Architecture.UNKNOWN, null, null, "");+ UNSUPPORTED(OperatingSystem.UNSUPPORTED, Architecture.UNKNOWN, null, null, ""),++ /**+ * Identifies a Windows 64-bit OS.+ *+ * @deprecated Use {@link #WIN_X86_64} instead.+ */+ @Deprecated(since = "10.1", forRemoval = true)+ WIN_64(OperatingSystem.WINDOWS, Architecture.X86_64, "win_x86_64", ".dll", ".exe"),++ /**+ * Identifies a Linux X86 32-bit OS.+ *+ * @deprecated Use {@link #LINUX_X86_32} instead.+ */+ @Deprecated(since = "10.1", forRemoval = true)+ LINUX(OperatingSystem.LINUX, Architecture.X86, "linux_x86_32", ".so", ""),++ /**+ * Identifies a Linux X86 64-bit OS.+ *+ * @deprecated Use {@link #LINUX_X86_64} instead.+ */+ @Deprecated(since = "10.1", forRemoval = true)+ LINUX_64(OperatingSystem.LINUX, Architecture.X86_64, "linux_x86_64", ".so", ""),++ /**+ * Identifies a macOS X86 32-bit OS.+ *+ * @deprecated Use {@link #MAC_OSX_32} instead.+ */+ @Deprecated(since = "10.1", forRemoval = true)+ MAC_OSX_32(OperatingSystem.MAC_OS_X, Architecture.X86, "mac_x86_32", ".dylib", ""),++ /**+ * Identifies a macOS X86 64-bit OS.+ *+ * @deprecated Use {@link #MAC_X86_64} instead.+ */+ @Deprecated(since = "10.1", forRemoval = true)+ MAC_OSX_64(OperatingSystem.MAC_OS_X, Architecture.X86_64, "mac_x86_64", ".dylib", "");/*** A constant identifying the current platform.@@ -145,7 +198,7 @@ public enum Platform {paths.add("/usr/X11R6/bin");paths.add("/usr/X11R6/lib");}- else if (CURRENT_PLATFORM == WIN_64) {+ else if (CURRENT_PLATFORM == WIN_X86_64) {String windir = System.getenv("SystemRoot");if (windir != null) {File syswow64 = new File(windir, "SysWOW64");diff --git a/Ghidra/RuntimeScripts/build.gradle b/Ghidra/RuntimeScripts/build.gradleindex d497811043..f70ebaa803 100644--- a/Ghidra/RuntimeScripts/build.gradle+++ b/Ghidra/RuntimeScripts/build.gradle@@ -28,11 +28,11 @@ rootProject.assembleDistribution {}}-rootProject.OS_NAMES.each { platform ->- rootProject.tasks.findAll {it.name == "assembleDistribution_$platform"}.each { t ->+rootProject.PLATFORMS.each { platform ->+ rootProject.tasks.findAll {it.name == "assembleDistribution_${platform.name}"}.each { t ->def p = this.project- if (isLinux(platform) || isMac(platform)) {+ if (isLinux(platform.name) || isMac(platform.name)) {t.from ("${p.projectDir}/Linux/support") {into "support"}@@ -42,7 +42,7 @@ rootProject.OS_NAMES.each { platform ->t.from (p.file("Linux/ghidraRun"))}- if (isWindows(platform)) {+ if (isWindows(platform.name)) {t.from ("${p.projectDir}/Windows/support") {into "support"}diff --git a/GhidraBuild/Skeleton/certification.manifest b/GhidraBuild/Skeleton/certification.manifestindex 6c75084577..26d3f90322 100644--- a/GhidraBuild/Skeleton/certification.manifest+++ b/GhidraBuild/Skeleton/certification.manifest@@ -12,9 +12,9 @@ data/sleighArgs.txt||GHIDRA||||END|extension.properties||GHIDRA||||END|ghidra_scripts/README.txt||GHIDRA||||END|lib/README.txt||GHIDRA||||END|-os/linux64/README.txt||GHIDRA||||END|-os/osx64/README.txt||GHIDRA||||END|-os/win64/README.txt||GHIDRA||||END|+os/linux_x86_64/README.txt||GHIDRA||||END|+os/mac_x86_64/README.txt||GHIDRA||||END|+os/win_x86_64/README.txt||GHIDRA||||END|src/main/help/help/TOC_Source.xml||GHIDRA||||END|src/main/help/help/topics/skeleton/help.html||GHIDRA||||END|src/main/resources/images/README.txt||GHIDRA||||END|diff --git a/GhidraBuild/Skeleton/os/osx64/README.txt b/GhidraBuild/Skeleton/os/linux_x86_64/README.txtsimilarity index 72%rename from GhidraBuild/Skeleton/os/osx64/README.txtrename to GhidraBuild/Skeleton/os/linux_x86_64/README.txtindex 824fe27241..7dd33ce280 100644--- a/GhidraBuild/Skeleton/os/osx64/README.txt+++ b/GhidraBuild/Skeleton/os/linux_x86_64/README.txt@@ -1,3 +1,3 @@-The "os/osx64" directory is intended to hold macOS (OS X) native binaries+The "os/linux_x86_64" directory is intended to hold Linux native binarieswhich this module is dependent upon. This directory may be eliminated for a specificmodule if native binaries are not provided for the corresponding platform.diff --git a/GhidraBuild/Skeleton/os/linux64/README.txt b/GhidraBuild/Skeleton/os/mac_x86_64/README.txtsimilarity index 67%rename from GhidraBuild/Skeleton/os/linux64/README.txtrename to GhidraBuild/Skeleton/os/mac_x86_64/README.txtindex 965333c9fe..fbf2469e53 100644--- a/GhidraBuild/Skeleton/os/linux64/README.txt+++ b/GhidraBuild/Skeleton/os/mac_x86_64/README.txt@@ -1,3 +1,3 @@-The "os/linux64" directory is intended to hold Linux native binaries+The "os/mac_x86_64" directory is intended to hold macOS (OS X) native binarieswhich this module is dependent upon. This directory may be eliminated for a specificmodule if native binaries are not provided for the corresponding platform.diff --git a/GhidraBuild/Skeleton/os/win64/README.txt b/GhidraBuild/Skeleton/os/win_x86_64/README.txtsimilarity index 65%rename from GhidraBuild/Skeleton/os/win64/README.txtrename to GhidraBuild/Skeleton/os/win_x86_64/README.txtindex 924adf96f8..e0359950a9 100644--- a/GhidraBuild/Skeleton/os/win64/README.txt+++ b/GhidraBuild/Skeleton/os/win_x86_64/README.txt@@ -1,3 +1,3 @@-The "os/win64" directory is intended to hold MS Windows native binaries (.exe)+The "os/win_x86_64" directory is intended to hold MS Windows native binaries (.exe)which this module is dependent upon. This directory may be eliminated for a specificmodule if native binaries are not provided for the corresponding platform.diff --git a/README.md b/README.mdindex f8e9af3f3b..b8128a0acb 100644--- a/README.md+++ b/README.md@@ -79,12 +79,13 @@ development process has been highly customized for.* Follow the above build instructions so the build completes without errors* Install [Eclipse IDE for Java Developers][eclipse]-##### Prepare the development environment (Linux-only, see **NOTE** for Windows/macOS):+##### Prepare the development environment (Linux/x86-only, see **NOTE** for other platforms):```-$ gradle prepdev eclipse buildNatives_linux64+$ gradle prepdev eclipse buildNatives_linux_x86_64```-**NOTE:** If you are on a Windows or macOS platform, change `buildNatives_linux64` to-`buildNatives_win64` or `gradle buildNatives_osx64`.+**NOTE:** If you are on a different platform, change `buildNatives_linux_x86_64` to the gradle task+that is appropriate for your platform: `buildNatives_win_x86_64`, `buildNatives_mac_x86_64`,+`buildNatives_mac_arm_64`, or `buildNatives_linux_arm_64`##### Import Ghidra projects into Eclipse:* *File* -> *Import...*diff --git a/build.gradle b/build.gradleindex 0df62fc365..dce3a5149d 100644--- a/build.gradle+++ b/build.gradle@@ -86,21 +86,6 @@ else {}}-/****************************************************************************- * Create a set containing all the platforms we need when building native- * artifacts. This is here for convenience and can be used in a build file- * with the following syntax:- *- * project.OS_NAMES.each {...}- ****************************************************************************/--project.ext.set("OS_NAMES", ["osx64", "win32", "win64", "linux64"])--/****************************************************************************- * Establish Visual Studio configuration environment for Windows native builds- ****************************************************************************/-apply from: "GPL/vsconfig.gradle"-/********************************************************************************** Imports* For these tasks to be available on all subprojects, this MUST be placed@@ -112,12 +97,14 @@ apply from: "GPL/vsconfig.gradle"* Eventually distribution.gradle will be removed entirely, but it is included* here for the time being for those who need it.*********************************************************************************/-apply from: "gradle/root/test.gradle" // adds tasks for running tests-apply from: "gradle/root/prepDev.gradle" // adds prepDev task for each subproject-apply from: 'gradle/root/distribution.gradle' // adds zip tasks-apply from: 'gradle/root/usage.gradle' // adds task documentation-apply from: "gradle/root/svg.gradle" // adds task to process svg files-apply from: "gradle/root/jacoco.gradle" // adds tasks for java code coverage+apply from: "GPL/utils.gradle" // adds utilities used in both Ghidra and GPL projects+apply from: "GPL/nativePlatforms.gradle" // adds native platform support+apply from: "gradle/root/test.gradle" // adds tasks for running tests+apply from: "gradle/root/prepDev.gradle" // adds prepDev task for each subproject+apply from: 'gradle/root/distribution.gradle' // adds zip tasks+apply from: 'gradle/root/usage.gradle' // adds task documentation+apply from: "gradle/root/svg.gradle" // adds task to process svg files+apply from: "gradle/root/jacoco.gradle" // adds tasks for java code coverageapply plugin: 'base'@@ -130,69 +117,6 @@ clean {* Utility methods used by multiple build.gradle files******************************************************************************************/--/*********************************************************************************- * Returns true if the platform is a linux machine.- *********************************************************************************/-def isLinux(String platformName) {- return platformName.startsWith("linux")-}---/*********************************************************************************- * Returns true if the platform is a mac- *********************************************************************************/-def isMac(String platformName) {- return platformName.startsWith("osx")-}---/*********************************************************************************- * Returns true if the platform is a Windows machine.- *********************************************************************************/-def isWindows(String platformName) {- return platformName.startsWith("win")-}--/******************************************************************************************- * Helper method that returns a file that is the same relative location in the bin repo- * as the given project is in its repo.- ******************************************************************************************/-File getProjectLocationInBinRepo(Project p) {- String relativePath = getGhidraRelativePath(p)-- File binRepoRootProject = new File("${BIN_REPO}")- return new File(binRepoRootProject, relativePath)-}--/****************************************************************************************- * Returns the "effective" relative path (Path starting with Ghidra)- * Normally, for files in the ghidra repo this is just the relative path from- * the root project (ghidra) to the given project.- *- * For example <...>/ghidra/Ghidra/Features/Base will return Ghidra/Features/Base- *- * If the project is in a sibling repo (ghidra.<other> that lives in the same directory- * as ghidra), then this method returns a relative path as though the project lived- * in ghidra.- *- * for example <...>/ghidra.foo/Ghidra/Features/OtherProject will return Ghidra/Features/OtherProject- ****************************************************************************************/-String getGhidraRelativePath(Project p) {- String path = rootProject.relativePath(p.projectDir)-- // If the project lives outside the ghidra repo, then its relative path will- // start with "../". In this case, we want to remove the "../" and the next path element- // so that the path will appear as though the project lived under the ghidra repo.- // example: "../ghidra/Ghidra/Features/Foo" will get changed to "Ghidra/Features/Foo"- String prefix = ".."+File.separator- if (path.startsWith(prefix)) {- int index = path.indexOf(File.separator,3)- path = path.substring(index+1)- }-- return path-}/********************************************************************************** Returns a relative path from the root (ghidra) to the project's directory.@@ -271,42 +195,6 @@ def getCurrentDateTimeLong() {return formattedDate}-/*********************************************************************************- * Returns the local platform name.- *********************************************************************************/-String getCurrentPlatformName() {-- String osName = System.getProperty("os.name")- String archName = System.getProperty("os.arch")-- boolean isX86_32 = archName.equals("x86") || archName.equals("i386");- boolean isX86_64 = archName.equals("x86_64") || archName.equals("amd64");- boolean isAARCH_64 = archName.equals("aarch64");-- if (osName.startsWith("Windows")) {- if (isX86_32) {- return 'win32'- }- else if (isX86_64) {- return 'win64'- }- }- else if (osName.startsWith("Linux")) {- if (isX86_64) {- return 'linux64'- }- }- else if (osName.startsWith("Mac OS X")) {- if (isX86_64) {- return 'osx64'- }- if (isAARCH_64) {- return 'aarch64'- }- }- throw new GradleException("Unrecognized current platform -> osName = $osName, archName = $archName")-}-/********************************************************************************** Returns a list of all the external library paths declared as dependencies for the* given projectdiff --git a/gradle/distributableGhidraModule.gradle b/gradle/distributableGhidraModule.gradleindex c9d48fd315..b83bf52123 100644--- a/gradle/distributableGhidraModule.gradle+++ b/gradle/distributableGhidraModule.gradle@@ -98,27 +98,27 @@ rootProject.assembleDistribution {}// copy os specific files for each platform-rootProject.OS_NAMES.each { platform ->- rootProject.tasks.findAll {it.name == "assembleDistribution_$platform"}.each { t ->+rootProject.PLATFORMS.each { platform ->+ rootProject.tasks.findAll {it.name == "assembleDistribution_${platform.name}"}.each { t ->def p = this.project// the getZipPath calls here are not in closures because we are already in a taskGraph.whenReady closure- t.from (p.projectDir.toString() + "/build/os/$platform") {+ t.from (p.projectDir.toString() + "/build/os/${platform.name}") {exclude '*.lib'exclude '*.exp'- into getZipPath(p) + "/os/$platform"+ into getZipPath(p) + "/os/${platform.name}"}- t.from (p.projectDir.toString() + "/os/$platform") {- into getZipPath(p) + "/os/$platform"+ t.from (p.projectDir.toString() + "/os/${platform.name}") {+ into getZipPath(p) + "/os/${platform.name}"}}}-// For Win64 build, we have to also include any Win32 binaries in the final zip.-rootProject.assembleDistribution_win64 {- from (this.project.projectDir.toString() + "/build/os/win32") {- into getZipPath(this.project) + "/os/win32"+// For win_x86_64 build, we have to also include any win_x86_32 binaries in the final zip.+rootProject.assembleDistribution_win_x86_64 {+ from (this.project.projectDir.toString() + "/build/os/win_x86_32") {+ into getZipPath(this.project) + "/os/win_x86_32"}}@@ -204,10 +204,9 @@ plugins.withType(JavaPlugin) {// Native/////////////////////////////////////////////////////////////////////////////plugins.withType(CPlugin) {- rootProject.OS_NAMES.each { platform ->- rootProject.tasks.findAll {it.name == "assembleDistribution_$platform"}.each { t ->+ rootProject.PLATFORMS.each { platform ->+ rootProject.tasks.findAll {it.name == "assembleDistribution_${platform.name}"}.each { t ->t.dependsOn this.assemble- // t.dependsOn this.project.name+":buildNatives_$platform"}}}diff --git a/gradle/root/distribution.gradle b/gradle/root/distribution.gradleindex 867fb85ee3..a8f88b0f16 100644--- a/gradle/root/distribution.gradle+++ b/gradle/root/distribution.gradle@@ -364,8 +364,8 @@ task assembleDistribution (type: Copy) {* these have already been built and are located in the proper location.**********************************************************************************/-project.OS_NAMES.each { platform ->- task ("assembleDistribution_$platform", type: Copy ) {+project.PLATFORMS.each { platform ->+ task ("assembleDistribution_${platform.name}", type: Copy ) {// delete the gradle ziptree temp directory because of gradle bug not cleaning up its temp files.delete rootProject.file("build/tmp/expandedArchives")@@ -480,10 +480,9 @@ task createInstallationZip(type: Zip) { t ->dependsOn "assembleDistribution_$currentPlatform"if (project.hasProperty("allPlatforms")) {- dependsOn ":assembleDistribution_win32"- dependsOn ":assembleDistribution_win64"- dependsOn ":assembleDistribution_linux64"- dependsOn ":assembleDistribution_osx64"+ project.PLATFORMS.each { platform ->+ dependsOn ":assembleDistribution_${platform.name}"+ }}if (project.hasProperty("allPlatforms")) {diff --git a/gradle/root/usage.gradle b/gradle/root/usage.gradleindex 8555479114..59fba64401 100644--- a/gradle/root/usage.gradle+++ b/gradle/root/usage.gradle@@ -42,9 +42,9 @@ Primary gradle tasks for GhidraTask rules:buildNatives_[platform] builds the native executables and libraries for the- specified platform (win64, linux64, osx64, etc.) [nativeProject.gradle]+ specified platform (win_x86_64, linux_arm_64, mac_x86_64, etc.) [nativeProject.gradle]prebuildNatives_[platform] builds the native executables and libraries for the- specified platform and copies results to bin repo. [nativeProject.gradle]+ specified platform and copies results to bin repo. [nativeProject.gradle]"""}diff --git a/gradle/support/extensionCommon.gradle b/gradle/support/extensionCommon.gradleindex 0a4435391d..d1a11b101d 100644--- a/gradle/support/extensionCommon.gradle+++ b/gradle/support/extensionCommon.gradle@@ -118,9 +118,9 @@ task zipExtensions (type: Zip) {/////////////////// NATIVES/////////////////- project.OS_NAMES.each { platform ->- from (p.projectDir.toString() + "/os/$platform") {- into { getBaseProjectName(p) + "/os/$platform" }+ project.PLATFORMS.each { platform ->+ from (p.projectDir.toString() + "/os/${platform.name}") {+ into { getBaseProjectName(p) + "/os/${platform.name}" }}}}