GP-3833: Updated binutils to version 2.41

This commit is contained in:
ghidorahrex 2023-11-14 09:10:56 -05:00
parent 180b09041c
commit bdae8f73d8
3 changed files with 24 additions and 9 deletions

View File

@ -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()

View File

@ -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"
}
}

View File

@ -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);