asm: reader: implement reading ident and atom constpool values

This commit is contained in:
2025-05-15 12:06:04 +01:00
parent 9229e90723
commit 95f58615e0

View File

@@ -333,6 +333,8 @@ enum ivy_status ivy_asm_constpool_reader_read_value(
break;
case IVY_CONSTPOOL_TABLE_ATOM:
value->v_type = IVY_ASM_CONSTPOOL_TYPE_ATOM;
handle = b_i32_btoh(entry.e_ex_handle);
status = read_string_xdata(reader, handle, &value->v_str);
break;
case IVY_CONSTPOOL_TABLE_SELECTOR: {
value->v_type = IVY_ASM_CONSTPOOL_TYPE_SELECTOR;
@@ -395,6 +397,8 @@ enum ivy_status ivy_asm_constpool_reader_read_value(
ivy_selector_add_arg(sel, arg_name, NULL);
free(arg_name);
handle += sizeof arg;
}
if (status != IVY_OK) {
@@ -405,14 +409,72 @@ enum ivy_status ivy_asm_constpool_reader_read_value(
value->v_sel = sel;
break;
}
case IVY_CONSTPOOL_TABLE_IDENT:
case IVY_CONSTPOOL_TABLE_IDENT: {
value->v_type = IVY_ASM_CONSTPOOL_TYPE_IDENT;
handle = b_i32_btoh(entry.e_ex_handle);
struct ivy_bin_ident id_entry;
status = ivy_asm_section_reader_read(
reader->r_xdat, handle, sizeof id_entry, &id_entry, &r);
if (status != IVY_OK) {
break;
default:
}
if (r != sizeof id_entry) {
status = IVY_ERR_BAD_FORMAT;
break;
}
struct ivy_ident *id;
id = ivy_ident_create();
if (!id) {
status = IVY_ERR_NO_MEMORY;
break;
}
handle += sizeof id_entry;
size_t nr_parts = id_entry.id_nr_parts;
for (size_t i = 0; i < nr_parts; i++) {
b_i32 part;
status = ivy_asm_section_reader_read(
reader->r_xdat, handle, sizeof part, &part, &r);
if (status != IVY_OK) {
break;
}
if (r != sizeof part) {
status = IVY_ERR_BAD_FORMAT;
break;
}
size_t part_key = b_i32_btoh(part);
char *part_name = NULL;
status = read_string_xdata(reader, part_key, &part_name);
if (status != IVY_OK) {
break;
}
ivy_ident_add_part(id, part_name);
free(part_name);
handle += sizeof part;
}
if (status != IVY_OK) {
ivy_ident_destroy(id);
break;
}
value->v_ident = id;
break;
}
default:
value->v_type = IVY_ASM_CONSTPOOL_TYPE_NONE;
break;
}
if (status != IVY_OK) {
free(value);
value = NULL;