Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-1040: Fixing GnuDisassembler build

Ryan Kurtz8473259d0653
diff --git a/GPL/GnuDisassembler/.gitignore b/GPL/GnuDisassembler/.gitignore
new file mode 100644
index 0000000000..e5452ab8aa
--- /dev/null
+++ b/GPL/GnuDisassembler/.gitignore
@@ -0,0 +1 @@
+binutils-*
diff --git a/GPL/GnuDisassembler/README.txt b/GPL/GnuDisassembler/README.txt
index 1ffd524a36..3af72f4239 100644
--- a/GPL/GnuDisassembler/README.txt
+++ b/GPL/GnuDisassembler/README.txt
@@ -14,6 +14,12 @@ To build this extension for Linux or Mac OS X:
If a different binutils distribution is used the build.gradle and/or buildGdis.gradle
may require modification.
+ The build requires the following packages to be installed:
+ * flex
+ * bison
+ * texinfo
+ * zlib1g-dev
+
2. Run gradle from the module's root directory (see top of build.gradle file for
specific instructions).
diff --git a/GPL/GnuDisassembler/build.gradle b/GPL/GnuDisassembler/build.gradle
index 0fd000d05e..2d51c81c4a 100644
--- a/GPL/GnuDisassembler/build.gradle
+++ b/GPL/GnuDisassembler/build.gradle
@@ -28,55 +28,56 @@
// directory once the extension has been installed/unpacked by Ghidra. The binutils referenced
// by the script below may be downloaded from the following URL:
//
-// https://ftp.gnu.org/pub/gnu/binutils/binutils-2.34.tar.bz2
+// https://ftp.gnu.org/pub/gnu/binutils/binutils-2.36.tar.bz2
//
-ext.binutils = "binutils-2.34"
+ext.binutils = "binutils-2.36"
ext.binutilsDistro = "${binutils}.tar.bz2"
-ext.ghidraInstallDir = null;
-
-if (file("../gpl.gradle").exists()) {
- // Module is located within the Ghidra GPL directory
- ext.ghidraInstallDir = file("../..").getCanonicalPath()
- ext.binutilsLocation = file("${ghidraInstallDir}/../ghidra.bin/GPL/${name}").getCanonicalPath()
- apply from: file("../gpl.gradle").getCanonicalPath()
+// Find the GPL dir
+def gplDir = null;
+if (file("../gpl.gradle").exists()) {
+ gplDir = file("..").getCanonicalPath()
}
else {
- // various module placements for Ghidra installations
- ext.binutilsLocation = projectDir
- if (file("../../../GPL/gpl.gradle").exists()) {
- // Handle GPL extension install within Ghidra Extensions directory
- ext.ghidraInstallDir = file("../../..").getCanonicalPath()
+ // 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()) {
+ // Module is installed within a Ghidra installation (i.e, ghidra/Ghidra/Extensions)
+ gplDir = file("../../../GPL").getCanonicalPath()
}
else {
- // Handle extension install outside of Ghidra installation - must specify Ghidra install path
+ // Module is in an unknown location (likely outside of Ghidra).
+ // Rely on the GHIDRA_INSTALL_DIR property being set.
+ def ghidraInstallDir = null;
if (System.env.GHIDRA_INSTALL_DIR) {
- ext.ghidraInstallDir = System.env.GHIDRA_INSTALL_DIR
+ ghidraInstallDir = System.env.GHIDRA_INSTALL_DIR
}
else if (project.hasProperty("GHIDRA_INSTALL_DIR")) {
- ext.ghidraInstallDir = project.getProperty("GHIDRA_INSTALL_DIR")
+ ghidraInstallDir = project.getProperty("GHIDRA_INSTALL_DIR")
}
- }
- if (ghidraInstallDir) {
+ else {
+ throw new GradleException("GHIDRA_INSTALL_DIR is not defined!")
+ }
+
if (ghidraInstallDir.replace("\\","/").endsWith("/")) {
- ext.ghidraInstallDir = ghidraInstallDir.substring(0, ghidraInstallDir.length()-1)
+ ghidraInstallDir = ghidraInstallDir.substring(0, ghidraInstallDir.length()-1)
}
+ gplDir = file("${ghidraInstallDir}/GPL")
println "Building with Ghidra installation at $ghidraInstallDir"
- apply from: new File(ghidraInstallDir).getCanonicalPath() + "/GPL/gpl.gradle"
- }
- else {
- throw new GradleException("GHIDRA_INSTALL_DIR is not defined!")
}
}
+// If we see other projects, we are packaging this extension for distribution
if (findProject(':Generic') != null) {
- // Handle integrated Ghidra build - do not build gdis native
+ // Package extension
apply from: "$rootProject.projectDir/gradle/distributableGPLExtension.gradle"
delete file("build/os"); // remove any prior build of gdis
}
else {
- apply from: "${ghidraInstallDir}/GPL/nativeBuildProperties.gradle"
+ // Build GPL extension (gdis)
+ apply from: "${gplDir}/gpl.gradle"
+ apply from: "${gplDir}/nativeBuildProperties.gradle"
apply from: "buildGdis.gradle"
}
diff --git a/GPL/GnuDisassembler/buildGdis.gradle b/GPL/GnuDisassembler/buildGdis.gradle
index d145467092..9be9c9459c 100644
--- a/GPL/GnuDisassembler/buildGdis.gradle
+++ b/GPL/GnuDisassembler/buildGdis.gradle
@@ -1,17 +1,12 @@
/* ###
* IP: Public Domain
*/
-/*******************************************************************************************
- * build.gradle file that applies this script must define two properties
- * 1) binutilsLocation - the folder where the original binutils.zip lives
- * 2) binutilsPrebuiltPath - the folder where the custom prebuilt binutils lives or will be built to
- *******************************************************************************************/
defaultTasks 'assemble'
ext.supportedPlatforms = ['osx64', 'linux64']
-ext.binutilsResource = new File("${binutilsLocation}/${binutils}.tar.bz2")
+ext.binutilsResource = new File("${projectDir}/${binutils}.tar.bz2")
def binutilsUnpackDir = file("${project.buildDir}/${binutils}/")
@@ -19,8 +14,6 @@ def binutilsUnpackDir = file("${project.buildDir}/${binutils}/")
*
* For each supported platform build the following tasks:
* buildBinutils_<platform> builds binutils for the platform
- * packageBinutilsDev_<platform> creates the built bundle of stuf we need to build gdis
- * unpackBinutilsPrebuilt_<platform> unpacks the built bundle to be used to build gdis
*
******************************************************************************************/
diff --git a/GPL/GnuDisassembler/certification.manifest b/GPL/GnuDisassembler/certification.manifest
index 1692c70354..ffbc546607 100644
--- a/GPL/GnuDisassembler/certification.manifest
+++ b/GPL/GnuDisassembler/certification.manifest
@@ -1,6 +1,7 @@
##VERSION: 2.0
##MODULE IP: GPL 2
##MODULE IP: Public Domain
+.gitignore||Public Domain||||END|
Module.manifest||Public Domain||||END|
README.txt||Public Domain||||END|
data/arm_test1.s||Public Domain||||END|
diff --git a/GPL/GnuDisassembler/extension.properties b/GPL/GnuDisassembler/extension.properties
index 5624d5632b..5b7d35b134 100644
--- a/GPL/GnuDisassembler/extension.properties
+++ b/GPL/GnuDisassembler/extension.properties
@@ -1,5 +1,5 @@
name=GnuDisassembler
-description=GNU Disassembler. Extension is delivered unbuilt. See module README.txt for build instructions.
+description=GNU Disassembler. Extension is delivered unbuilt. See module README.txt for build instructions. Depends on SleighDevTools.
author=Ghidra Team
createdOn=6/18/2019
version=@extversion@
diff --git a/GPL/gpl.gradle b/GPL/gpl.gradle
index 4dafd461f7..8ca3271e77 100644
--- a/GPL/gpl.gradle
+++ b/GPL/gpl.gradle
@@ -14,7 +14,7 @@ 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: "../vsconfig.gradle"
+apply from: buildscript.sourceFile.getParent() + "/vsconfig.gradle"
/*********************************************************************************
* Returns the local platform name.