Remove alloca from osabi.c

I noticed that the call to alloca in osabi.c can be replaced with a
statically-sized buffer, because some code just before the declaration
ensures that the length is bounded.

Reviewed-by: John Baldwin <jhb@FreeBSD.org>
This commit is contained in:
Tom Tromey 2023-08-13 10:37:00 -06:00
parent e72b937ddd
commit dad9ed2f25

View File

@ -463,7 +463,6 @@ generic_elf_osabi_sniff_abi_tag_sections (bfd *abfd, asection *sect,
{
const char *name;
unsigned int sectsize;
char *note;
name = bfd_section_name (sect);
sectsize = bfd_section_size (sect);
@ -477,7 +476,7 @@ generic_elf_osabi_sniff_abi_tag_sections (bfd *abfd, asection *sect,
compressed section. But, since note sections are not compressed,
deferring the reading until we recognize the section avoids any
error. */
note = (char *) alloca (sectsize);
char note[MAX_NOTESZ];
/* .note.ABI-tag notes, used by GNU/Linux and FreeBSD. */
if (strcmp (name, ".note.ABI-tag") == 0)