Skip to content

Commit

Permalink
Added linkerversion to rz-bin -I
Browse files Browse the repository at this point in the history
  • Loading branch information
tushar3q34 committed Sep 13, 2024
1 parent a29c2c3 commit 6d8d21c
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions librz/bin/bin.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ RZ_API void rz_bin_info_free(RZ_NULLABLE RzBinInfo *rb) {
free(rb->claimed_checksum);
free(rb->compiler);
free(rb->head_flag);
free(rb->linker);
free(rb);
}

Expand Down
1 change: 1 addition & 0 deletions librz/bin/format/pe/pe.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_linker)(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);
Expand Down
13 changes: 13 additions & 0 deletions librz/bin/format/pe/pe_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,19 @@ char *PE_(rz_bin_pe_get_cc)(RzBinPEObj *bin) {
return NULL;
}

char *PE_(rz_bin_pe_get_linker)(RzBinPEObj *bin) {
if (!bin || !bin->nt_headers) {
return NULL;
} else {
int major = (int)bin->nt_headers->optional_header.MajorLinkerVersion;
int minor = (int)bin->nt_headers->optional_header.MinorLinkerVersion;
if (major != 0 || minor != 0) {
return rz_str_newf("%02d.%02d", major, minor);
} else
return NULL;
}
}

int PE_(bin_pe_get_claimed_checksum)(RzBinPEObj *bin) {
if (!bin || !bin->optional_header) {
return 0;
Expand Down
1 change: 1 addition & 0 deletions librz/bin/p/bin_pe.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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->linker = PE_(rz_bin_pe_get_linker)(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)) {
Expand Down
6 changes: 6 additions & 0 deletions librz/core/cbin.c
Original file line number Diff line number Diff line change
Expand Up @@ -3236,6 +3236,9 @@ RZ_API bool rz_core_bin_info_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzBinFile
free(buf);
pj_end(pj);
}
if (info->linker) {
pj_ks(pj, "lnkrver", info->linker);
}
pj_end(pj);

break;
Expand Down Expand Up @@ -3335,6 +3338,9 @@ RZ_API bool rz_core_bin_info_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzBinFile
rz_table_add_rowf(t, "ss", h->type, buf);
free(buf);
}
if (info->linker) {
rz_table_add_rowf(t, "ss", "lnkrver", info->linker);
}
break;
default:
rz_warn_if_reached();
Expand Down
1 change: 1 addition & 0 deletions librz/include/rz_bin.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ typedef struct rz_bin_info_t {
ut64 baddr;
char *intrp;
char *compiler;
char *linker;
} RzBinInfo;

typedef struct rz_bin_file_load_options_t {
Expand Down
1 change: 1 addition & 0 deletions test/db/formats/pe/arm
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ canary false
PIE true
RELROCS false
NX true
lnkrver 14.29
vaddr paddr hvaddr haddr type
----------------------------------------------------
0x004011d4 0x000005d4 ---------- 0x00000108 program
Expand Down

0 comments on commit 6d8d21c

Please sign in to comment.