From 22a95e1a37aff28238e9d40bbe4441aa554a14c6 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Fri, 6 Jan 2023 18:59:20 +1030 Subject: Make coff backend data read-only The bfd_coff_backend_data struct should be read-only, the only thing preventing this is that objcopy writes to one of the fields, _bfd_coff_long_section_names. This patch creates a copy of the field in bfd coff_obj_tdata, which makes more sense anyway. When enabling long section names the intent is to do so for a particular bfd, not for all bfds that might happen to be using the target xvec. bfd/ * coffcode.h: Update coff long section name comment. (bfd_coff_set_long_section_names_allowed): Use macro accessor to set flag. (bfd_coff_set_long_section_names_disallowed): Tidy. (coff_backend_info): Return a const pointer. (bfd_coff_std_swap_table, ticoff0_swap_table, ticoff1_swap_table), (bigobj_swap_table): Make const. (bfd_coff_long_section_names): Use tdata copy. (coff_mkobject): Set long_section_names from coff_backend_info. * coff-go32.c (_bfd_go32_mkobject): Likewise. * peicode.h (pe_mkobject): Likewise. * coff-sh.c (bfd_coff_small_swap_table): Make const. * libcoff-in.h (struct coff_tdata): Add long_section_names, reorder fields. * libcoff.h: Regenerate. binutils/ * objcopy.c (set_long_section_mode): Move earlier in file. (copy_object): Call set_long_section_mode here, after setting output format. (copy_file): Don't call set_long_section_mode. --- bfd/libcoff-in.h | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'bfd/libcoff-in.h') diff --git a/bfd/libcoff-in.h b/bfd/libcoff-in.h index 8dec285..d27e5d4 100644 --- a/bfd/libcoff-in.h +++ b/bfd/libcoff-in.h @@ -79,21 +79,34 @@ typedef struct coff_tdata /* The unswapped external symbols. May be NULL. Read by _bfd_coff_get_external_symbols. */ void * external_syms; - /* If this is TRUE, the external_syms may not be freed. */ - bool keep_syms; /* The string table. May be NULL. Read by _bfd_coff_read_string_table. */ char *strings; /* The length of the strings table. For error checking. */ bfd_size_type strings_len; + + /* Set if long section names are supported. A writable copy of the COFF + backend flag _bfd_coff_long_section_names. */ + bool long_section_names; + + /* If this is TRUE, the external_syms may not be freed. */ + bool keep_syms; /* If this is TRUE, the strings may not be freed. */ bool keep_strings; /* If this is TRUE, the strings have been written out already. */ bool strings_written; + /* Is this a GO32 coff file? */ + bool go32; + /* Is this a PE format coff file? */ int pe; + + /* Copy of some of the f_flags bits in the COFF filehdr structure, + used by ARM code. */ + flagword flags; + /* Used by the COFF backend linker. */ struct coff_link_hash_entry **sym_hashes; @@ -111,13 +124,6 @@ typedef struct coff_tdata /* The timestamp from the COFF file header. */ long timestamp; - /* Copy of some of the f_flags bits in the COFF filehdr structure, - used by ARM code. */ - flagword flags; - - /* Is this a GO32 coff file? */ - bool go32; - /* A stub (extra data prepended before the COFF image) and its size. Used by coff-go32-exe, it contains executable data that loads the COFF object into memory. */ -- cgit v1.1