Skip to content

Commit

Permalink
Added RzTypeScope
Browse files Browse the repository at this point in the history
  • Loading branch information
rockrid3r committed Apr 27, 2024
1 parent b5898d0 commit 0fb1009
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
9 changes: 9 additions & 0 deletions librz/arch/dwarf_process.c
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,10 @@ static bool RzBaseType_eq(const RzBaseType *a, const RzBaseType *b) {
if (a == NULL || b == NULL) {
return a == NULL && b == NULL;
}
if (a->scope.cu_name && b->scope.cu_name && RZ_STR_NE(a->scope.cu_name, b->scope.cu_name)) {
printf("types '%s' and '%s' are not equal\n", a->name, b->name);
return false;
}
return a->kind == b->kind && a->attrs == b->attrs && RZ_STR_EQ(a->name, b->name);
}

Expand Down Expand Up @@ -708,6 +712,11 @@ static RzBaseType *RzBaseType_from_die(DwContext *ctx, const RzBinDwarfDie *die)
return NULL;
}

if (ctx->unit->name) {
printf("storing cu_name: '%s'\n", ctx->unit->name);
btype->scope.cu_name = rz_str_dup(ctx->unit->name);
}

RzBinDwarfAttr *attr = NULL;
rz_vector_foreach (&die->attrs, attr) {
switch (attr->at) {
Expand Down
2 changes: 1 addition & 1 deletion librz/include/rz_analysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ typedef struct {
HtUP /*<ut64, RzCallable *>*/ *callable_by_offset; ///< Store all callables parsed from DWARF by DIE offset
HtUP /*<ut64, RzType *>*/ *type_by_offset; ///< Store all RzType parsed from DWARF by DIE offset
HtUP /*<ut64, RzBaseType *>*/ *base_type_by_offset; ///< Store all RzBaseType parsed from DWARF by DIE offset
HtSP /*<const char*, RzPVector<const RzBaseType *>>*/ *base_types_by_name; ///< Store all RzBaseType parsed from DWARF by DIE offset
HtSP /*<const char*, RzPVector<const RzBaseType *>>*/ *base_types_by_name; ///< Store all RzBaseType parsed from DWARF by DIE name
DWARF_RegisterMapping dwarf_register_mapping; ///< Store the mapping function between DWARF registers number and register name in current architecture
RzBinDWARF *dw; ///< Holds ownership of RzBinDwarf, avoid releasing it prematurely
SetU *visited;
Expand Down
6 changes: 6 additions & 0 deletions librz/include/rz_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ typedef struct rz_type_db_t {
RzIOBind iob; // for RzIO in formats
} RzTypeDB;


typedef struct rz_type_scope_t {
char *cu_name;
} RzTypeScope;

// All types in RzTypeDB module are either concrete,
// "base" types that are types already having the
// concrete size and memory layout
Expand Down Expand Up @@ -114,6 +119,7 @@ typedef struct rz_base_type_t {
ut64 size; // size of the whole type in bits
RzBaseTypeKind kind;
RzTypeAttribute attrs;
RzTypeScope scope;
union {
RzBaseTypeStruct struct_data;
RzBaseTypeEnum enum_data;
Expand Down

0 comments on commit 0fb1009

Please sign in to comment.