{
riscv_subset_t *in, *out;
static char *merged_arch_str = NULL;
+ char *result = NULL;
unsigned xlen_in, xlen_out;
- merged_subsets.head = NULL;
- merged_subsets.tail = NULL;
riscv_parse_subset_t riscv_rps_ld_in =
{&in_subsets, _bfd_error_handler, &xlen_in, NULL, false};
/* Parse subset from ISA string. */
if (!riscv_parse_subset (&riscv_rps_ld_in, in_arch))
- return NULL;
+ goto cleanup;
if (!riscv_parse_subset (&riscv_rps_ld_out, out_arch))
- return NULL;
+ goto cleanup;
/* Checking XLEN. */
if (xlen_out != xlen_in)
_bfd_error_handler
(_("error: %pB: ISA string of input (%s) doesn't match "
"output (%s)"), ibfd, in_arch, out_arch);
- return NULL;
+ goto cleanup;
}
/* Merge subset list. */
/* Merge standard extension. */
if (!riscv_merge_std_ext (ibfd, in_arch, out_arch, &in, &out))
- return NULL;
+ goto cleanup;
/* Merge all non-single letter extensions with single call. */
if (!riscv_merge_multi_letter_ext (&in, &out))
- return NULL;
+ goto cleanup;
if (xlen_in != xlen_out)
{
_bfd_error_handler
(_("error: %pB: XLEN of input (%u) doesn't match "
"output (%u)"), ibfd, xlen_in, xlen_out);
- return NULL;
+ goto cleanup;
}
if (xlen_in != arch_size)
_bfd_error_handler
(_("error: %pB: unsupported XLEN (%u), you might be "
"using wrong emulation"), ibfd, xlen_in);
- return NULL;
+ goto cleanup;
}
/* Free the previous merged_arch_str which called xmalloc. */
merged_arch_str = riscv_arch_str (arch_size, &merged_subsets,
false/* update */);
+ result = merged_arch_str;
+ cleanup:
/* Release the subset lists. */
riscv_release_subset_list (&in_subsets);
riscv_release_subset_list (&out_subsets);
riscv_release_subset_list (&merged_subsets);
- return merged_arch_str;
+ return result;
}
/* Merge object attributes from IBFD into output_bfd of INFO.