The string returned from riscv_arch_str is allocated by xmalloc, so once we
called it multiple times, we should keep the newest one for the output elf
architecture attribute, but free the remaining unused strings.
riscv_merge_arch_attr_info (bfd *ibfd, char *in_arch, char *out_arch)
{
riscv_subset_t *in, *out;
- char *merged_arch_str;
+ static char *merged_arch_str = NULL;
unsigned xlen_in, xlen_out;
merged_subsets.head = NULL;
return NULL;
}
+ /* Free the previous merged_arch_str which called xmalloc. */
+ free (merged_arch_str);
+
merged_arch_str = riscv_arch_str (ARCH_SIZE, &merged_subsets);
/* Release the subset lists. */