objcopy: bfd_alloc orelocation

This fixes an inconsequential objcopy memory leak.  I'd normally
ignore reports of leaks like this one, that are merely one block or
fewer per section processed, since objcopy soon exits and frees all
memory.  However I thought it worth providing support for allocating
memory on a bfd objalloc in objcopy and other utils.

	PR 29233
	* bucomm.c (bfd_xalloc): New function.
	* bucomm.h (bfd_xalloc): Declare.
	* objcopy.c (copy_relocations_in_section): Use it to allocate
	array of reloc pointers.  Rewrite code stripping relocs to do
	without extra memory allocation.
This commit is contained in:
Alan Modra
2022-07-04 11:24:22 +09:30
parent d8efadbdd9
commit 0772daccb3
3 changed files with 28 additions and 24 deletions

View File

@@ -39,6 +39,8 @@ void fatal (const char *, ...) ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN;
void non_fatal (const char *, ...) ATTRIBUTE_PRINTF_1;
void *bfd_xalloc (bfd *, size_t);
void set_default_bfd_target (void);
void list_matching_formats (char **);