[PATCH v2 09/16] BFD: Unset the format on releasing a BFD's objalloc memory
Maciej W. Rozycki
macro@orcam.me.uk
Thu Nov 6 21:19:39 GMT 2025
From: Maciej W. Rozycki <macro@redhat.com>
Make a BFD reusable after a `_bfd_free_cached_info' call to release its
objalloc memory, by unsetting the format so that a subsequent call to
`bfd_check_format_matches' will re-retrieve data previously discarded.
Otherwise accesses to discarded data will be attempted where the BFD
continues being used. Found with a crash in `bfd_set_gp_size' when
building archive symbol maps on the fly in a subsequent change.
---
No change from v1 (6/8),
<https://inbox.sourceware.org/binutils/alpine.DEB.2.21.2509262051431.63399@angie.orcam.me.uk/>.
---
bfd/opncls.c | 1 +
1 file changed, 1 insertion(+)
binutils-bfd-free-cached-info-format.diff
Index: binutils-gdb/bfd/opncls.c
===================================================================
--- binutils-gdb.orig/bfd/opncls.c
+++ binutils-gdb/bfd/opncls.c
@@ -195,6 +195,7 @@ _bfd_free_cached_info (bfd *abfd)
abfd->outsymbols = NULL;
abfd->tdata.any = NULL;
abfd->usrdata = NULL;
+ abfd->format = bfd_unknown;
return true;
}
More information about the Binutils
mailing list