[PATCH 5/8] gdb/xcoffread: allocate symbol table using vector in scan_xcoff_symtab

Simon Marchi
2026-01-08T19:36:09Z

The symbol table content is only needed for the duration of
scan_xcoff_symtab, so it's not necessary to allocate it on the objfile
obstack. Switch to using a vector that is freed at the end of the
function.

Change-Id: Ib5acdea460969300a92816a3e71b7d82c80faebf
---
gdb/xcoffread.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 0f3470cae45d..7dd0f29cb107 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -166,14 +166,14 @@ scan_xcoff_symtab (struct objfile *objfile)

unsigned int num_symbols = bfd_get_symcount (abfd);
size_t size = coff_data (abfd)->local_symesz * num_symbols;
- char *symtbl = (char *) obstack_alloc (&objfile->objfile_obstack, size);
+ gdb::char_vector symtbl (size);

/* Read in symbol table. */
- if (int ret = bfd_read (symtbl, size, abfd);
+ if (int ret = bfd_read (symtbl.data (), size, abfd);
ret != size)
error (_("reading symbol table: %s"), bfd_errmsg (bfd_get_error ()));

- char *sraw_symbol = symtbl;
+ char *sraw_symbol = symtbl.data ();
ssymnum = 0;
while (ssymnum < num_symbols)
{
--
2.52.0