From bdae8f73d8aa5f362600848665f661ac2a124872 Mon Sep 17 00:00:00 2001 From: ghidorahrex Date: Tue, 14 Nov 2023 09:10:56 -0500 Subject: [PATCH] GP-3833: Updated binutils to version 2.41 --- GPL/GnuDisassembler/build.gradle | 7 +++++-- GPL/GnuDisassembler/buildGdis.gradle | 9 +++++---- GPL/GnuDisassembler/src/gdis/c/disasm_1.c | 17 ++++++++++++++--- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/GPL/GnuDisassembler/build.gradle b/GPL/GnuDisassembler/build.gradle index c2340ce183..2b7de82476 100644 --- a/GPL/GnuDisassembler/build.gradle +++ b/GPL/GnuDisassembler/build.gradle @@ -28,20 +28,23 @@ // 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.36.tar.bz2 +// https://ftp.gnu.org/pub/gnu/binutils/binutils-2.41.tar.bz2 // -ext.binutils = "binutils-2.36" +ext.binutils = "binutils-2.41" ext.binutilsDistro = "${binutils}.tar.bz2" // Find the GPL dir def gplDir = null; if (file("../utils.gradle").exists()) { gplDir = file("..").getCanonicalPath() + ext.ghidraInstallDir = file("../..").getCanonicalPath() + ext.binutilsLocation = file("${ghidraInstallDir}/../ghidra.bin/GPL/${name}").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. + ext.binutilsLocation = projectDir 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() diff --git a/GPL/GnuDisassembler/buildGdis.gradle b/GPL/GnuDisassembler/buildGdis.gradle index a8a0f3eada..5ae37406b4 100644 --- a/GPL/GnuDisassembler/buildGdis.gradle +++ b/GPL/GnuDisassembler/buildGdis.gradle @@ -6,7 +6,7 @@ defaultTasks 'assemble' ext.supportedPlatforms = ['mac_x86_64', 'mac_arm_64', 'linux_x86_64', 'linux_arm_64'] -ext.binutilsResource = new File("${projectDir}/${binutils}.tar.bz2") +ext.binutilsResource = new File("${binutilsLocation}/${binutils}.tar.bz2") def binutilsUnpackDir = file("${project.buildDir}/${binutils}/") @@ -37,8 +37,8 @@ model { all { def binutilsArtifactsDir = file("build/binutils/${targetPlatform.name}") if ((toolChain in Gcc) || (toolChain in Clang)) { - cCompiler.args "-I${binutilsArtifactsDir}/include", "-I${binutilsArtifactsDir}/bfd" - linker.args "-L${binutilsArtifactsDir}/lib", "-lopcodes", "-lbfd", "-liberty", "-lz", "-ldl" + cCompiler.args "-I${binutilsArtifactsDir}/include", "-I${binutilsArtifactsDir}/bfd", "-I${binutilsArtifactsDir}/libsframe" + linker.args "-L${binutilsArtifactsDir}/lib", "-lopcodes", "-lbfd", "-lsframe", "-liberty", "-lz", "-ldl" } } } @@ -151,9 +151,10 @@ supportedPlatforms.each { platform -> include "**/*.h" } into("/lib") { - from "${configDir}/bfd/libbfd.a" + from "${configDir}/bfd/.libs/libbfd.a" from "${configDir}/libiberty/libiberty.a" from "${configDir}/opcodes/libopcodes.a" + from "${configDir}/libsframe/.libs/libsframe.a" } } diff --git a/GPL/GnuDisassembler/src/gdis/c/disasm_1.c b/GPL/GnuDisassembler/src/gdis/c/disasm_1.c index 5274062917..0eeba4a2a2 100644 --- a/GPL/GnuDisassembler/src/gdis/c/disasm_1.c +++ b/GPL/GnuDisassembler/src/gdis/c/disasm_1.c @@ -45,8 +45,7 @@ void listSupportedArchMachTargets(void) int objdump_sprintf (SFILE *f, const char *format, ...) { - int i; - size_t n; + int n; va_list args; va_start (args, format); @@ -57,6 +56,18 @@ int objdump_sprintf (SFILE *f, const char *format, ...) return n; } +/* Compatibility fix for binutils v 2.39 change to INIT_DISASSEMLE_INFO signature */ +int objdump_sprintf_styled(SFILE *f, enum disassembler_style style, const char *format, ...) { + int n; + va_list args; + + va_start (args, format); + n = vsnprintf (f->buffer + f->pos, BUFF_SIZE, format, args); + strncat(disassembled_buffer, f->buffer, n); + va_end (args); + + return n; +} void configureDisassembleInfo(bfd* abfd, disassemble_info* info, @@ -67,7 +78,7 @@ void configureDisassembleInfo(bfd* abfd, memset(sfile.buffer, 0x00, BUFF_SIZE); - INIT_DISASSEMBLE_INFO(*info, stdout, objdump_sprintf); + INIT_DISASSEMBLE_INFO(*info, stdout, objdump_sprintf, objdump_sprintf_styled); info->arch = (enum bfd_architecture) arch; info->mach = mach; info->flavour = bfd_get_flavour(abfd);