aboutsummaryrefslogtreecommitdiff
path: root/gas/config
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2023-06-08 19:55:55 +0930
committerAlan Modra <amodra@gmail.com>2023-06-09 12:56:12 +0930
commitce3ab55fa72dd8778f5fd5fea7d6389af16d141e (patch)
tree72712c30fe65f06cd6b365231e3596f95db4013e /gas/config
parent8fd82abda0f367f89db50040d519e1464a84c3a0 (diff)
downloadgdb-ce3ab55fa72dd8778f5fd5fea7d6389af16d141e.zip
gdb-ce3ab55fa72dd8778f5fd5fea7d6389af16d141e.tar.gz
gdb-ce3ab55fa72dd8778f5fd5fea7d6389af16d141e.tar.bz2
ecoff find_nearest_line and final link leaks
Freeing ecoff_debug_info "pointers to the unswapped symbolic info" isn't a simple matter, due to differing allocation strategies. In _bfd_ecoff_slurp_symbolic_info the pointers are to objalloc memory. In the ecoff linker they are to separately malloc'd memory. In gas we have most (obj-elf) or all (obj-ecoff) into a single malloc'd buffer. This patch fixes the leaks for binutils and ld, leaving the gas leaks for another day. The mips elf backend already had this covered, and the ecoff backend had a pointer, raw_syments used as a flag, so most of the patch is moving these around a little so they are accessible for both ecoff and elf. include/ * coff/ecoff.h (struct ecoff_debug_info): Add alloc_syments. bfd/ * libecoff.h (struct ecoff_tdata): Delete raw_syments. * elfxx-mips.c (free_ecoff_debug): Delete. Replace uses with _bfd_ecoff_free_ecoff_debug_info. (_bfd_mips_elf_final_link): Init debug.alloc_syments. * ecofflink.c (_bfd_ecoff_free_ecoff_debug_info): New function. * ecoff.c (_bfd_ecoff_bfd_free_cached_info): Call _bfd_ecoff_free_ecoff_debug_info. (_bfd_ecoff_slurp_symbolic_info): Replace uses of raw_syments with alloc_syments. (ecoff_final_link_debug_accumulate): Likewise. Use _bfd_ecoff_free_ecoff_debug_info. (_bfd_ecoff_bfd_copy_private_bfd_data): Set alloc_syments for copied output. * elf64-alpha.c (elf64_alpha_read_ecoff_info): Use _bfd_ecoff_free_ecoff_debug_info. * libbfd-in.h (_bfd_ecoff_free_ecoff_debug_info): Declare. * libbfd.h: Regenerate. gas/ * config/obj-ecoff.c (ecoff_frob_file): Set alloc_syments. * config/obj-elf.c (elf_frob_file_after_relocs): Likewise.
Diffstat (limited to 'gas/config')
-rw-r--r--gas/config/obj-ecoff.c1
-rw-r--r--gas/config/obj-elf.c1
2 files changed, 2 insertions, 0 deletions
diff --git a/gas/config/obj-ecoff.c b/gas/config/obj-ecoff.c
index 092f6f2..26da2af 100644
--- a/gas/config/obj-ecoff.c
+++ b/gas/config/obj-ecoff.c
@@ -151,6 +151,7 @@ ecoff_frob_file (void)
ecoff_build_debug (hdr, &buf, debug_swap);
/* Finish up the ecoff_tdata structure. */
+ ecoff_data (stdoutput)->debug_info.alloc_syments = true;
set = buf;
#define SET(ptr, count, type, size) \
if (hdr->count == 0) \
diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c
index bf3ef54..753a929 100644
--- a/gas/config/obj-elf.c
+++ b/gas/config/obj-elf.c
@@ -3008,6 +3008,7 @@ elf_frob_file_after_relocs (void)
ecoff_build_debug (&debug.symbolic_header, &buf, debug_swap);
/* Set up the pointers in debug. */
+ debug.alloc_syments = true;
#define SET(ptr, offset, type) \
debug.ptr = (type) (buf + debug.symbolic_header.offset)