diff options
author | Alan Modra <amodra@gmail.com> | 2023-01-06 18:59:20 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2023-01-06 21:06:15 +1030 |
commit | 22a95e1a37aff28238e9d40bbe4441aa554a14c6 (patch) | |
tree | 1f23719284f052d698cc11a3ed971d0d2ae8ec29 /bfd/libcoff.h | |
parent | bb391cb24d8f92ecad10bb6a60abdf0b880de0dd (diff) | |
download | gdb-22a95e1a37aff28238e9d40bbe4441aa554a14c6.zip gdb-22a95e1a37aff28238e9d40bbe4441aa554a14c6.tar.gz gdb-22a95e1a37aff28238e9d40bbe4441aa554a14c6.tar.bz2 |
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.
Diffstat (limited to 'bfd/libcoff.h')
-rw-r--r-- | bfd/libcoff.h | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/bfd/libcoff.h b/bfd/libcoff.h index 9d51cef..f03330f 100644 --- a/bfd/libcoff.h +++ b/bfd/libcoff.h @@ -83,21 +83,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; @@ -115,13 +128,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. */ @@ -841,7 +847,7 @@ typedef struct } bfd_coff_backend_data; #define coff_backend_info(abfd) \ - ((bfd_coff_backend_data *) (abfd)->xvec->backend_data) + ((const bfd_coff_backend_data *) (abfd)->xvec->backend_data) #define bfd_coff_swap_aux_in(a,e,t,c,ind,num,i) \ ((coff_backend_info (a)->_bfd_coff_swap_aux_in) (a,e,t,c,ind,num,i)) @@ -884,7 +890,7 @@ typedef struct #define bfd_coff_long_filenames(abfd) \ (coff_backend_info (abfd)->_bfd_coff_long_filenames) #define bfd_coff_long_section_names(abfd) \ - (coff_backend_info (abfd)->_bfd_coff_long_section_names) + (coff_data (abfd)->long_section_names) #define bfd_coff_set_long_section_names(abfd, enable) \ ((coff_backend_info (abfd)->_bfd_coff_set_long_section_names) (abfd, enable)) #define bfd_coff_default_section_alignment_power(abfd) \ |