From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1062) id 405AD3858436; Mon, 9 Jan 2023 23:40:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 405AD3858436 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Alan Modra To: bfd-cvs@sourceware.org Subject: [binutils-gdb] Move mips_refhi_list to bfd tdata X-Act-Checkin: binutils-gdb X-Git-Author: Alan Modra X-Git-Refname: refs/heads/master X-Git-Oldrev: b1c95bc4dd737d3d0a6c9a1b6e022e3ef85110bc X-Git-Newrev: 5a671d7a854b4e4cf31837e423419654139a482d Message-Id: <20230109234025.405AD3858436@sourceware.org> Date: Mon, 9 Jan 2023 23:40:25 +0000 (GMT) X-BeenThere: binutils-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Jan 2023 23:40:25 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D5a671d7a854b= 4e4cf31837e423419654139a482d commit 5a671d7a854b4e4cf31837e423419654139a482d Author: Alan Modra Date: Fri Jan 6 22:38:33 2023 +1030 Move mips_refhi_list to bfd tdata =20 Similar to commit c799eddb3512, but for mips-ecoff. mips-ecoff is marked obsolete, but we still allow reading of these object files in a number of mips targets. =20 * coff-mips.c (struct mips_hi, mips_refhi_list): Delete. (mips_refhi_reloc, mips_reflo_reloc): Access mips_refhi_list in ecoff_data. * ecoff.c (_bfd_ecoff_close_and_cleanup): New function. * libecoff.h (struct mips_hi): Moved from coff-mips.c. (struct ecoff_tdata): Add mips_refhi_list. (_bfd_ecoff_close_and_cleanup): Declare. Diff: --- bfd/coff-mips.c | 23 ++++++----------------- bfd/ecoff.c | 15 +++++++++++++++ bfd/libecoff.h | 11 ++++++++++- 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/bfd/coff-mips.c b/bfd/coff-mips.c index 79cbc20a03d..fdc0771979d 100644 --- a/bfd/coff-mips.c +++ b/bfd/coff-mips.c @@ -423,19 +423,8 @@ mips_generic_reloc (bfd *abfd ATTRIBUTE_UNUSED, reloc. This extension permits gcc to output the HI and LO relocs itself. */ =20 -struct mips_hi -{ - struct mips_hi *next; - bfd_byte *addr; - bfd_vma addend; -}; - -/* FIXME: This should not be a static variable. */ - -static struct mips_hi *mips_refhi_list; - static bfd_reloc_status_type -mips_refhi_reloc (bfd *abfd ATTRIBUTE_UNUSED, +mips_refhi_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol, void * data, @@ -480,8 +469,8 @@ mips_refhi_reloc (bfd *abfd ATTRIBUTE_UNUSED, return bfd_reloc_outofrange; n->addr =3D (bfd_byte *) data + reloc_entry->address; n->addend =3D relocation; - n->next =3D mips_refhi_list; - mips_refhi_list =3D n; + n->next =3D ecoff_data (abfd)->mips_refhi_list; + ecoff_data (abfd)->mips_refhi_list =3D n; =20 if (output_bfd !=3D (bfd *) NULL) reloc_entry->address +=3D input_section->output_offset; @@ -502,11 +491,11 @@ mips_reflo_reloc (bfd *abfd, bfd *output_bfd, char **error_message) { - if (mips_refhi_list !=3D NULL) + if (ecoff_data (abfd)->mips_refhi_list !=3D NULL) { struct mips_hi *l; =20 - l =3D mips_refhi_list; + l =3D ecoff_data (abfd)->mips_refhi_list; while (l !=3D NULL) { unsigned long insn; @@ -549,7 +538,7 @@ mips_reflo_reloc (bfd *abfd, l =3D next; } =20 - mips_refhi_list =3D NULL; + ecoff_data (abfd)->mips_refhi_list =3D NULL; } =20 /* Now do the REFLO reloc in the usual way. */ diff --git a/bfd/ecoff.c b/bfd/ecoff.c index 228394a5046..717d2fa2c75 100644 --- a/bfd/ecoff.c +++ b/bfd/ecoff.c @@ -109,6 +109,21 @@ _bfd_ecoff_mkobject_hook (bfd *abfd, void * filehdr, v= oid * aouthdr) return (void *) ecoff; } =20 +bool +_bfd_ecoff_close_and_cleanup (bfd *abfd) +{ + struct ecoff_tdata *tdata =3D ecoff_data (abfd); + + if (tdata !=3D NULL && bfd_get_format (abfd) =3D=3D bfd_object) + while (tdata->mips_refhi_list !=3D NULL) + { + struct mips_hi *ref =3D tdata->mips_refhi_list; + tdata->mips_refhi_list =3D ref->next; + free (ref); + } + return _bfd_generic_close_and_cleanup (abfd); +} + /* Initialize a new section. */ =20 bool diff --git a/bfd/libecoff.h b/bfd/libecoff.h index 9db5012292b..12664b890c4 100644 --- a/bfd/libecoff.h +++ b/bfd/libecoff.h @@ -80,6 +80,13 @@ struct ecoff_backend_data members of the embedded bfd_coff_backend_data struct. */ #define ECOFF_NO_LONG_SECTION_NAMES (false), _bfd_ecoff_no_long_sections =20 +struct mips_hi +{ + struct mips_hi *next; + bfd_byte *addr; + bfd_vma addend; +}; + /* This is the target specific information kept for ECOFF files. */ =20 #define ecoff_data(abfd) ((abfd)->tdata.ecoff_obj_data) @@ -148,6 +155,8 @@ typedef struct ecoff_tdata ecoff_compute_section_file_positions is called. */ bool rdata_in_text; =20 + /* Used by coff-mips.c to track REFHI relocs for pairing with REFLO. */ + struct mips_hi *mips_refhi_list; } ecoff_data_type; =20 /* Each canonical asymbol really looks like this. */ @@ -234,7 +243,7 @@ extern bool _bfd_ecoff_slurp_symbolic_info =20 extern bool _bfd_ecoff_write_object_contents (bfd *); =20 -#define _bfd_ecoff_close_and_cleanup _bfd_generic_close_and_cleanup +extern bool _bfd_ecoff_close_and_cleanup (bfd *); #define _bfd_ecoff_bfd_free_cached_info _bfd_generic_bfd_free_cached_info extern bool _bfd_ecoff_new_section_hook (bfd *, asection *);