]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
objcopy: bfd_alloc orelocation
authorAlan Modra <amodra@gmail.com>
Mon, 4 Jul 2022 01:54:22 +0000 (11:24 +0930)
committerAlan Modra <amodra@gmail.com>
Mon, 4 Jul 2022 13:21:56 +0000 (22:51 +0930)
commit0772daccb3ebaf513badf4266e1948454b4455c1
tree23032d204a77ac8f9c8cec3a0c48e0ee8b826548
parentd8efadbdd94772562fed8fba9ce553587a62550f
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.
binutils/bucomm.c
binutils/bucomm.h
binutils/objcopy.c