From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1062) id C20FC3858C00; Fri, 6 Jan 2023 10:45:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C20FC3858C00 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] Tidy pe flag in coff_data X-Act-Checkin: binutils-gdb X-Git-Author: Alan Modra X-Git-Refname: refs/heads/master X-Git-Oldrev: 22a95e1a37aff28238e9d40bbe4441aa554a14c6 X-Git-Newrev: 10df41b188b2692b6bc8c36d4003e0f8790d1f1b Message-Id: <20230106104507.C20FC3858C00@sourceware.org> Date: Fri, 6 Jan 2023 10:45:07 +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: Fri, 06 Jan 2023 10:45:07 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D10df41b188b2= 692b6bc8c36d4003e0f8790d1f1b commit 10df41b188b2692b6bc8c36d4003e0f8790d1f1b Author: Alan Modra Date: Fri Jan 6 19:34:15 2023 +1030 Tidy pe flag in coff_data =20 Make it a bool, use obj_pe accessor everywhere. Diff: --- bfd/coff-arm.c | 2 +- bfd/coff-mcore.c | 2 +- bfd/coffgen.c | 5 ++--- bfd/cofflink.c | 6 +++--- bfd/coffswap.h | 2 +- bfd/libcoff-in.h | 2 +- bfd/libcoff.h | 2 +- bfd/peicode.h | 2 +- ld/emultempl/beos.em | 2 +- ld/emultempl/pe.em | 2 +- ld/emultempl/pep.em | 2 +- 11 files changed, 14 insertions(+), 15 deletions(-) diff --git a/bfd/coff-arm.c b/bfd/coff-arm.c index c0b2b04b26a..694ae8daa08 100644 --- a/bfd/coff-arm.c +++ b/bfd/coff-arm.c @@ -953,7 +953,7 @@ arm_emit_base_file_entry (struct bfd_link_info *info, + input_section->output_offset + input_section->output_section->vma); =20 - if (coff_data (output_bfd)->pe) + if (obj_pe (output_bfd)) addr -=3D pe_data (output_bfd)->pe_opthdr.ImageBase; if (fwrite (&addr, sizeof (addr), 1, (FILE *) info->base_file) =3D=3D 1) return true; diff --git a/bfd/coff-mcore.c b/bfd/coff-mcore.c index 561333d596b..e360d5efe14 100644 --- a/bfd/coff-mcore.c +++ b/bfd/coff-mcore.c @@ -220,7 +220,7 @@ mcore_emit_base_file_entry (struct bfd_link_info *info, + input_section->output_offset + input_section->output_section->vma; =20 - if (coff_data (output_bfd)->pe) + if (obj_pe (output_bfd)) addr -=3D pe_data (output_bfd)->pe_opthdr.ImageBase; =20 if (fwrite (&addr, sizeof (addr), 1, (FILE *) info->base_file) =3D=3D 1) diff --git a/bfd/coffgen.c b/bfd/coffgen.c index 74636a9e305..f21cf2ca523 100644 --- a/bfd/coffgen.c +++ b/bfd/coffgen.c @@ -1826,8 +1826,7 @@ coff_get_normalized_symtab (bfd *abfd) /* Ordinary short filename, put into memory anyway. The Microsoft PE tools sometimes store a filename in multiple AUX entries. */ - if (internal_ptr->u.syment.n_numaux > 1 - && coff_data (abfd)->pe) + if (internal_ptr->u.syment.n_numaux > 1 && obj_pe (abfd)) internal_ptr->u.syment._n._n_n._n_offset =3D ((uintptr_t) copy_name (abfd, @@ -1842,7 +1841,7 @@ coff_get_normalized_symtab (bfd *abfd) } =20 /* Normalize other strings available in C_FILE aux entries. */ - if (!coff_data (abfd)->pe) + if (!obj_pe (abfd)) for (int numaux =3D 1; numaux < internal_ptr->u.syment.n_numaux; numa= ux++) { aux =3D internal_ptr + numaux + 1; diff --git a/bfd/cofflink.c b/bfd/cofflink.c index d6ccae4ffe2..07226882e0d 100644 --- a/bfd/cofflink.c +++ b/bfd/cofflink.c @@ -1168,7 +1168,7 @@ _bfd_coff_final_link (bfd *abfd, static char * dores_com (char *ptr, bfd *output_bfd, int heap) { - if (coff_data(output_bfd)->pe) + if (obj_pe (output_bfd)) { int val =3D strtoul (ptr, &ptr, 0); =20 @@ -1400,7 +1400,7 @@ _bfd_coff_link_input_bfd (struct coff_final_link_info= *flaginfo, bfd *input_bfd) output_index =3D syment_base; outsym =3D flaginfo->outsyms; =20 - if (coff_data (output_bfd)->pe + if (obj_pe (output_bfd) && ! process_embedded_commands (output_bfd, flaginfo->info, input_bf= d)) return false; =20 @@ -3057,7 +3057,7 @@ _bfd_coff_generic_relocate_section (bfd *output_bfd, - input_section->vma + input_section->output_offset + input_section->output_section->vma); - if (coff_data (output_bfd)->pe) + if (obj_pe (output_bfd)) addr -=3D pe_data(output_bfd)->pe_opthdr.ImageBase; if (fwrite (&addr, 1, sizeof (bfd_vma), (FILE *) info->base_file) !=3D sizeof (bfd_vma)) diff --git a/bfd/coffswap.h b/bfd/coffswap.h index e809deaf0ef..03f52bd0486 100644 --- a/bfd/coffswap.h +++ b/bfd/coffswap.h @@ -426,7 +426,7 @@ coff_swap_aux_in (bfd *abfd, #if FILNMLEN !=3D E_FILNMLEN #error we need to cope with truncating or extending FILNMLEN #else - if (numaux > 1 && coff_data (abfd)->pe) + if (numaux > 1 && obj_pe (abfd)) { if (indx =3D=3D 0) memcpy (in->x_file.x_n.x_fname, ext->x_file.x_fname, diff --git a/bfd/libcoff-in.h b/bfd/libcoff-in.h index d27e5d4394f..a0d286d37f4 100644 --- a/bfd/libcoff-in.h +++ b/bfd/libcoff-in.h @@ -101,7 +101,7 @@ typedef struct coff_tdata bool go32; =20 /* Is this a PE format coff file? */ - int pe; + bool pe; =20 /* Copy of some of the f_flags bits in the COFF filehdr structure, used by ARM code. */ diff --git a/bfd/libcoff.h b/bfd/libcoff.h index f03330fcfa0..c2c1f4add3a 100644 --- a/bfd/libcoff.h +++ b/bfd/libcoff.h @@ -105,7 +105,7 @@ typedef struct coff_tdata bool go32; =20 /* Is this a PE format coff file? */ - int pe; + bool pe; =20 /* Copy of some of the f_flags bits in the COFF filehdr structure, used by ARM code. */ diff --git a/bfd/peicode.h b/bfd/peicode.h index cc5a54e1843..06642c3db5a 100644 --- a/bfd/peicode.h +++ b/bfd/peicode.h @@ -1090,7 +1090,7 @@ pe_ILF_build_a_bfd (bfd * abfd, if (bfd_coff_mkobject_hook (abfd, (void *) & internal_f, NULL) =3D=3D NU= LL) goto error_return; =20 - coff_data (abfd)->pe =3D 1; + obj_pe (abfd) =3D true; #ifdef THUMBPEMAGIC if (vars.magic =3D=3D THUMBPEMAGIC) /* Stop some linker warnings about thumb code not supporting interwork= ing. */ diff --git a/ld/emultempl/beos.em b/ld/emultempl/beos.em index 1f3b67b6372..521d92797ec 100644 --- a/ld/emultempl/beos.em +++ b/ld/emultempl/beos.em @@ -379,7 +379,7 @@ gld${EMULATION_NAME}_after_open (void) /* Pass the wacky PE command line options into the output bfd. FIXME: This should be done via a function, rather than by including an internal BFD header. */ - if (!coff_data(link_info.output_bfd)->pe) + if (!obj_pe (link_info.output_bfd)) { einfo (_("%F%P: PE operations on non PE file\n")); } diff --git a/ld/emultempl/pe.em b/ld/emultempl/pe.em index d201a97dac1..bce1d1b9052 100644 --- a/ld/emultempl/pe.em +++ b/ld/emultempl/pe.em @@ -1515,7 +1515,7 @@ gld${EMULATION_NAME}_after_open (void) =20 if (bfd_get_flavour (link_info.output_bfd) !=3D bfd_target_coff_flavour || coff_data (link_info.output_bfd) =3D=3D NULL - || coff_data (link_info.output_bfd)->pe =3D=3D 0) + || !obj_pe (link_info.output_bfd)) einfo (_("%F%P: cannot perform PE operations on non PE output file '%p= B'\n"), link_info.output_bfd); =20 diff --git a/ld/emultempl/pep.em b/ld/emultempl/pep.em index d61cab86d75..69b1c3ec79b 100644 --- a/ld/emultempl/pep.em +++ b/ld/emultempl/pep.em @@ -1519,7 +1519,7 @@ gld${EMULATION_NAME}_after_open (void) =20 if (bfd_get_flavour (link_info.output_bfd) !=3D bfd_target_coff_flavour || coff_data (link_info.output_bfd) =3D=3D NULL - || coff_data (link_info.output_bfd)->pe =3D=3D 0) + || !obj_pe (link_info.output_bfd)) einfo (_("%F%P: cannot perform PE operations on non PE output file '%p= B'\n"), link_info.output_bfd);