From 9a73315161bc07d958060847ae01996312e1b30f Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Tue, 15 Oct 2019 15:57:35 +1030 Subject: remove more xmalloc in bfd Also fixes m68hc1x printf arguments which would have bombed when compiling on a 32-bit host with --enable-64-bit-bfd. bfd/ PR 24955 * elf32-arm.c (set_cmse_veneer_addr_from_implib): Use bfd_malloc rather than xmalloc. * elf32-m68hc1x.c (reloc_warning): New function. (elf32_m68hc11_relocate_section): Use it here. Cast bfd_vma values corresponding to %lx in format strings. * elf32-nds32.c (nds32_insertion_sort): Use a stack temporary. gas/ * config/tc-nds32.c (nds32_set_section_relocs): Use relocs and n parameters rather than equivalent sec->orelocation and sec->reloc_count. Don't sort for n <= 1. Tidy. --- bfd/elf32-nds32.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'bfd/elf32-nds32.c') diff --git a/bfd/elf32-nds32.c b/bfd/elf32-nds32.c index 013355a..482fb29 100644 --- a/bfd/elf32-nds32.c +++ b/bfd/elf32-nds32.c @@ -2526,7 +2526,9 @@ nds32_insertion_sort (void *base, size_t nmemb, size_t size, { char *ptr = (char *) base; int i, j; - char *tmp = xmalloc (size); + char tmp[sizeof (Elf_Internal_Rela)]; + + BFD_ASSERT (size <= sizeof (tmp)); /* If i is less than j, i is inserted before j. @@ -2550,7 +2552,6 @@ nds32_insertion_sort (void *base, size_t nmemb, size_t size, memmove (ptr + (j + 1) * size, ptr + j * size, (i - j) * size); memcpy (ptr + j * size, tmp, size); } - free (tmp); } /* Sort relocation by r_offset. -- cgit v1.1