[PATCH 4/4] gdb: remove objfile parameter from get_objfile_bfd_data
Tom Tromey
tom@tromey.com
Thu Apr 1 17:52:17 GMT 2021
>>>>> "Simon" == Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:
Simon> But if the BFD requires relocation, get_objfile_bfd_data returns a newly
Simon> allocated object that isn't kept anywhere else (and isn't shared). So
Simon> the objfile becomes the owner of the objfile_per_bfd_storage object. In
Simon> objfile::~objfile, we have this:
Simon> if (obfd)
Simon> gdb_bfd_unref (obfd);
Simon> else
Simon> delete per_bfd;
Simon> I'm thinking that obfd could be non-nullptr, and it could require
Simon> relocation. In that case, it would never be freed. Anyway, that's not
Simon> really connected to this patch.
Yes, this seems like a bug. Probably objfile should just have an
explicit "owns_per_bfd" boolean somewhere.
Simon> gdb/ChangeLog:
Simon> * objfiles.c (get_objfile_bfd_data): Remove objfile parameter,
Simon> adjust callers.
This looks good to me. Thank you.
Tom
More information about the Gdb-patches
mailing list