Skip to content

Commit

Permalink
Fix endianess for RzTypes
Browse files Browse the repository at this point in the history
  • Loading branch information
XVilka committed Mar 31, 2021
1 parent e9cfd3a commit bd687bb
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions librz/analysis/analysis.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ RZ_API int rz_analysis_set_big_endian(RzAnalysis *analysis, int bigend) {
if (analysis->reg) {
analysis->reg->big_endian = bigend;
}
rz_type_db_set_endian(analysis->typedb, bigend);
return true;
}

Expand Down
2 changes: 2 additions & 0 deletions librz/core/cconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,8 @@ static bool cb_asmarch(void *user, void *data) {
if (!core->analysis || !core->analysis->typedb) {
rz_core_analysis_type_init(core);
}
// set endian of RzAnalysis to match binary
rz_analysis_set_big_endian(core->analysis, bigbin);
rz_core_analysis_cc_init(core);

return true;
Expand Down
1 change: 1 addition & 0 deletions librz/include/rz_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ RZ_API void rz_type_db_purge(RzTypeDB *typedb);
RZ_API void rz_type_db_set_bits(RzTypeDB *typedb, int bits);
RZ_API void rz_type_db_set_os(RzTypeDB *typedb, const char *os);
RZ_API void rz_type_db_set_cpu(RzTypeDB *typedb, const char *cpu);
RZ_API void rz_type_db_set_endian(RzTypeDB *typedb, bool big_endian);
RZ_API char *rz_type_db_kuery(RzTypeDB *typedb, const char *query);

RZ_API const char *rz_type_db_get(RzTypeDB *typedb, const char *name);
Expand Down
4 changes: 4 additions & 0 deletions librz/type/type.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ RZ_API void rz_type_db_set_cpu(RzTypeDB *typedb, const char *cpu) {
typedb->target->cpu = cpu;
}

RZ_API void rz_type_db_set_endian(RzTypeDB *typedb, bool big_endian) {
typedb->target->big_endian = big_endian;
}

RZ_API char *rz_type_db_kuery(RzTypeDB *typedb, const char *query) {
char *output = NULL;
if (query) {
Expand Down

0 comments on commit bd687bb

Please sign in to comment.