diff --git a/librz/bin/bobj_process.c b/librz/bin/bobj_process.c index 9054ad3d946..a4e6a886de5 100644 --- a/librz/bin/bobj_process.c +++ b/librz/bin/bobj_process.c @@ -159,12 +159,20 @@ RZ_API bool rz_bin_object_process_plugin_data(RZ_NONNULL RzBinFile *bf, RZ_NONNU // we need to detect the language of the binary // one way can be based on the compiler. - if (o->info && RZ_STR_ISEMPTY(o->info->compiler)) { - free(o->info->compiler); - o->info->compiler = rz_bin_file_golang_compiler(bf); - if (o->info->compiler) { + if (o->info) { + char *go_compiler = rz_bin_file_golang_compiler(bf); + if (go_compiler) { o->info->lang = "go"; o->lang = RZ_BIN_LANGUAGE_GO; + if (RZ_STR_ISNOTEMPTY(o->info->compiler)) { + char *merge = rz_str_newf("%s %s", go_compiler, o->info->compiler); + free(o->info->compiler); + free(go_compiler); + o->info->compiler = merge; + } else { + free(o->info->compiler); + o->info->compiler = go_compiler; + } } } diff --git a/librz/bin/format/pe/pe.h b/librz/bin/format/pe/pe.h index 43a1c7d26ce..247f0dc45e6 100644 --- a/librz/bin/format/pe/pe.h +++ b/librz/bin/format/pe/pe.h @@ -210,6 +210,7 @@ struct rz_bin_pe_import_t *PE_(rz_bin_pe_get_imports)(RzBinPEObj *bin); // pe_info.c char *PE_(rz_bin_pe_get_arch)(RzBinPEObj *bin); char *PE_(rz_bin_pe_get_cc)(RzBinPEObj *bin); +char *PE_(rz_bin_pe_get_compiler)(RzBinPEObj *bin); char *PE_(rz_bin_pe_get_machine)(RzBinPEObj *bin); char *PE_(rz_bin_pe_get_os)(RzBinPEObj *bin); char *PE_(rz_bin_pe_get_class)(RzBinPEObj *bin); diff --git a/librz/bin/format/pe/pe_info.c b/librz/bin/format/pe/pe_info.c index e57ccd67eda..a670605ac34 100644 --- a/librz/bin/format/pe/pe_info.c +++ b/librz/bin/format/pe/pe_info.c @@ -221,6 +221,18 @@ char *PE_(rz_bin_pe_get_cc)(RzBinPEObj *bin) { return NULL; } +char *PE_(rz_bin_pe_get_compiler)(RzBinPEObj *bin) { + if (!bin || !bin->nt_headers) { + return NULL; + } + int major = (int)bin->nt_headers->optional_header.MajorLinkerVersion; + int minor = (int)bin->nt_headers->optional_header.MinorLinkerVersion; + if (major || minor) { + return rz_str_newf("Linker %02d.%02d", major, minor); + } + return NULL; +} + int PE_(bin_pe_get_claimed_checksum)(RzBinPEObj *bin) { if (!bin || !bin->optional_header) { return 0; diff --git a/librz/bin/p/bin_pe.inc b/librz/bin/p/bin_pe.inc index 1bf0db5dbda..e5259f15ea2 100644 --- a/librz/bin/p/bin_pe.inc +++ b/librz/bin/p/bin_pe.inc @@ -610,6 +610,7 @@ static RzBinInfo *info(RzBinFile *bf) { ret->machine = PE_(rz_bin_pe_get_machine)(bf->o->bin_obj); ret->subsystem = PE_(rz_bin_pe_get_subsystem)(bf->o->bin_obj); ret->default_cc = PE_(rz_bin_pe_get_cc)(bf->o->bin_obj); + ret->compiler = PE_(rz_bin_pe_get_compiler)(bf->o->bin_obj); RzPVector *libs = PE_(rz_bin_pe_get_libs)(bf->o->bin_obj); if (libs && rz_pvector_find(libs, "mscoree.dll", compare_strings, NULL)) { diff --git a/test/db/analysis/golang b/test/db/analysis/golang index 6bcf1703165..fae84f8de65 100644 --- a/test/db/analysis/golang +++ b/test/db/analysis/golang @@ -708,7 +708,7 @@ EXPECT=<