[06/13] gdb: remove a use of alloca from elfread.c

Message ID c76b6d9d60a1369325cb24c3263e3bda4f09d0fd.1677533215.git.aburgess@redhat.com
State New
Headers
Series Remove a bunch of alloca uses |

Commit Message

Andrew Burgess Feb. 27, 2023, 9:29 p.m. UTC
  This removes one of the uses of alloca from elfread.c and replaces it
with gdb::byte_vector.  There are other uses of alloca in this file,
but they all deal with types other than gdb_byte and so will require
replacing with something other than gdb::byte_vector.

There should be no user visible changes in this commit.
---
 gdb/elfread.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
  

Patch

diff --git a/gdb/elfread.c b/gdb/elfread.c
index ca684aab57e..05a7f753843 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -839,7 +839,6 @@  elf_gnu_ifunc_resolve_by_got (const char *name, CORE_ADDR *addr_p)
 	 size_t ptr_size = ptr_type->length ();
 	 CORE_ADDR pointer_address, addr;
 	 asection *plt;
-	 gdb_byte *buf = (gdb_byte *) alloca (ptr_size);
 	 bound_minimal_symbol msym;
 
 	 msym = lookup_minimal_symbol (name_got_plt, NULL, objfile);
@@ -855,9 +854,11 @@  elf_gnu_ifunc_resolve_by_got (const char *name, CORE_ADDR *addr_p)
 
 	 if (msym.minsym->size () != ptr_size)
 	   return 0;
-	 if (target_read_memory (pointer_address, buf, ptr_size) != 0)
+
+	 gdb::byte_vector buf (ptr_size);
+	 if (target_read_memory (pointer_address, buf.data (), ptr_size) != 0)
 	   return 0;
-	 addr = extract_typed_address (buf, ptr_type);
+	 addr = extract_typed_address (buf.data (), ptr_type);
 	 addr = gdbarch_convert_from_func_ptr_addr
 	   (gdbarch, addr, current_inferior ()->top_target ());
 	 addr = gdbarch_addr_bits_remove (gdbarch, addr);