diff options
author | Alan Modra <amodra@gmail.com> | 2024-12-10 16:02:53 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2024-12-12 16:04:51 +1030 |
commit | 6f0ab551876087d8bcce55beb55e58d72ae78d98 (patch) | |
tree | 56b3d2b22b0d5f6cdea812cccdcbbf55a746b8dc /bfd/xsym.c | |
parent | eda87e58d12bfb73ff3e93b7e822488e578f7015 (diff) | |
download | gdb-6f0ab551876087d8bcce55beb55e58d72ae78d98.zip gdb-6f0ab551876087d8bcce55beb55e58d72ae78d98.tar.gz gdb-6f0ab551876087d8bcce55beb55e58d72ae78d98.tar.bz2 |
tdata related object_p tidy for various formats
The aout object_p function copies any existing tdata. Apparently this
was done for hp300, an old target that is no longer supported. See
commit ebd241352942. This isn't useful for current sources, nor is it
necessary or useful any more to preserve tdata in object_p functions
when a target doesn't match. When I was fixing this, I noticed some
object_p functions rudely didn't release memory on failures, and
others had nits in the bfd_error returns.
* aoutx.h (some_aout_object_p): Don't restore previous tdata
on failure. Don't copy any existing tdata.
* archive.c (bfd_generic_archive_p): Don't restore previous
tdata on failure.
* pdp11.c (some_aout_object_p): Likewise.
* coff-rs6000.c (_bfd_xcoff_archive_p): Allocate both artdata
and extension in one call. Don't restore previous tdata on
failure.
* coff64-rs6000.c (xcoff64_archive_p): Likewise.
* coffgen.c (coff_real_object_p): Don't restore previous
tdata on failure.
* ihex.c (ihex_object_p): Likewise. Simplify release of tdata
on scan failure.
* mach-o.c (bfd_mach_o_scan): Don't set tdata here. Do set
error on read_command failure.
(bfd_mach_o_header_p): Set tdata here, release on failure.
Tidy bfd_error return values.
(bfd_mach_o_fat_archive_p): Tidy error return values.
* mmo.c (mmo_mkobject): Do not test current tdata.
* pef.c (bfd_pef_scan_start_address): Set bfd_error on
failure.
(bfd_pef_scan): Don't set tdata here.
(bfd_pef_object_p): Set tdata here, release on failure. Tidy
bfd_error return values.
(bfd_pef_xlib_object_p): Tidy bfd_error return values.
* srec.c (srec_object_p): Don't restore previous tdata on
failure. Do release tdata on failure.
(symbolsrec_object_p): Likewise.
* tekhex.c (tekhex_object_p): Don't ignore tekhex_mkobject
failure. Release tdata on failure.
* vms-alpha.c (alpha_vms_object_p): Don't restore previous
tdata on failure. Simplify release of tdata.
* xsym.c (bfd_sym_scan): Don't set tdata here.
(bfd_sym_object_p): Set tdata here. Release on failure.
Diffstat (limited to 'bfd/xsym.c')
-rw-r--r-- | bfd/xsym.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -2224,8 +2224,6 @@ bfd_sym_scan (bfd *abfd, bfd_sym_version version, bfd_sym_data_struct *mdata) bfdsec->filepos = 0; bfdsec->alignment_power = 0; - abfd->tdata.sym_data = mdata; - return 0; } @@ -2233,7 +2231,7 @@ bfd_cleanup bfd_sym_object_p (bfd *abfd) { bfd_sym_version version = -1; - bfd_sym_data_struct *mdata; + bfd_sym_data_struct *mdata = NULL; if (bfd_seek (abfd, 0, SEEK_SET) != 0 || bfd_sym_read_version (abfd, &version) != 0) @@ -2246,12 +2244,15 @@ bfd_sym_object_p (bfd *abfd) if (bfd_sym_scan (abfd, version, mdata) != 0) goto wrong; + abfd->tdata.sym_data = mdata; return _bfd_no_cleanup; wrong: bfd_set_error (bfd_error_wrong_format); fail: + if (mdata) + bfd_release (abfd, mdata); return NULL; } |