From: Alan Modra Date: Tue, 8 Jul 2025 23:44:06 +0000 (+0930) Subject: Merge init_private_section_data with copy_private_section_data X-Git-Tag: binutils-2_45~111 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5942dd991311115f7f3454fb59e6ec0a9b912d96;p=thirdparty%2Fbinutils-gdb.git Merge init_private_section_data with copy_private_section_data init_private_section_data is used by the linker and is a special case of copy_private_section_data that copies a reduced set of section data from input to output. Merge the two functions, adding a link_info param to copy_private_section_data and remove init_private_section_data. --- diff --git a/bfd/aout-target.h b/bfd/aout-target.h index 1b711047f28..c6d9d60ca8a 100644 --- a/bfd/aout-target.h +++ b/bfd/aout-target.h @@ -214,9 +214,11 @@ static bool MY_bfd_copy_private_section_data (bfd *ibfd, asection *isec ATTRIBUTE_UNUSED, bfd *obfd, - asection *osec ATTRIBUTE_UNUSED) + asection *osec ATTRIBUTE_UNUSED, + struct bfd_link_info *link_info) { - if (bfd_get_flavour (ibfd) == bfd_target_aout_flavour + if (link_info == NULL + && bfd_get_flavour (ibfd) == bfd_target_aout_flavour && bfd_get_flavour (obfd) == bfd_target_aout_flavour) obj_aout_subformat (obfd) = obj_aout_subformat (ibfd); return true; @@ -562,9 +564,6 @@ MY_bfd_final_link (bfd *abfd, struct bfd_link_info *info) #define MY_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data #endif -#define MY_init_private_section_data \ - _bfd_generic_init_private_section_data - #ifndef MY_bfd_copy_private_symbol_data #define MY_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data #endif diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index d5d1b518bcc..b013ef954da 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -1034,11 +1034,12 @@ bool bfd_malloc_and_get_section (bfd *abfd, asection *section, bfd_byte **buf); bool bfd_copy_private_section_data - (bfd *ibfd, asection *isec, bfd *obfd, asection *osec); + (bfd *ibfd, asection *isec, bfd *obfd, asection *osec, + struct bfd_link_info *link_info); -#define bfd_copy_private_section_data(ibfd, isection, obfd, osection) \ +#define bfd_copy_private_section_data(ibfd, isec, obfd, osec, link_info) \ BFD_SEND (obfd, _bfd_copy_private_section_data, \ - (ibfd, isection, obfd, osection)) + (ibfd, isec, obfd, osec, link_info)) bool bfd_generic_is_group_section (bfd *, const asection *sec); const char *bfd_generic_group_name (bfd *, const asection *sec); @@ -7636,7 +7637,6 @@ typedef struct bfd_target #define BFD_JUMP_TABLE_COPY(NAME) \ NAME##_bfd_copy_private_bfd_data, \ NAME##_bfd_merge_private_bfd_data, \ - NAME##_init_private_section_data, \ NAME##_bfd_copy_private_section_data, \ NAME##_bfd_copy_private_symbol_data, \ NAME##_bfd_copy_private_header_data, \ @@ -7649,16 +7649,10 @@ typedef struct bfd_target /* Called to merge BFD general private data from one object file to a common output file when linking. */ bool (*_bfd_merge_private_bfd_data) (bfd *, struct bfd_link_info *); - /* Called to initialize BFD private section data from one object file - to another. */ -#define bfd_init_private_section_data(ibfd, isec, obfd, osec, link_info) \ - BFD_SEND (obfd, _bfd_init_private_section_data, \ - (ibfd, isec, obfd, osec, link_info)) - bool (*_bfd_init_private_section_data) (bfd *, sec_ptr, bfd *, sec_ptr, - struct bfd_link_info *); /* Called to copy BFD private section data from one object file to another. */ - bool (*_bfd_copy_private_section_data) (bfd *, sec_ptr, bfd *, sec_ptr); + bool (*_bfd_copy_private_section_data) (bfd *, sec_ptr, bfd *, sec_ptr, + struct bfd_link_info *); /* Called to copy BFD private symbol data from one symbol to another. */ bool (*_bfd_copy_private_symbol_data) (bfd *, asymbol *, diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c index ae9a0f613ab..3c18518b0c8 100644 --- a/bfd/coff-rs6000.c +++ b/bfd/coff-rs6000.c @@ -4456,8 +4456,6 @@ const struct xcoff_dwsect_name xcoff_dwsect_names[] = { #define _bfd_xcoff_get_section_contents _bfd_generic_get_section_contents /* For copy private data entry points. */ -#define _bfd_xcoff_init_private_section_data \ - _bfd_generic_init_private_section_data #define _bfd_xcoff_bfd_copy_private_bfd_data \ _bfd_xcoff_copy_private_bfd_data #define _bfd_xcoff_bfd_merge_private_bfd_data \ diff --git a/bfd/coff64-rs6000.c b/bfd/coff64-rs6000.c index ec7ed08d3d0..d335348c196 100644 --- a/bfd/coff64-rs6000.c +++ b/bfd/coff64-rs6000.c @@ -2621,7 +2621,6 @@ const bfd_target rs6000_xcoff64_vec = /* Copy */ _bfd_xcoff_copy_private_bfd_data, _bfd_generic_bfd_merge_private_bfd_data, - _bfd_generic_init_private_section_data, _bfd_generic_bfd_copy_private_section_data, _bfd_generic_bfd_copy_private_symbol_data, _bfd_generic_bfd_copy_private_header_data, @@ -2892,7 +2891,6 @@ const bfd_target rs6000_xcoff64_aix_vec = /* Copy */ _bfd_xcoff_copy_private_bfd_data, _bfd_generic_bfd_merge_private_bfd_data, - _bfd_generic_init_private_section_data, _bfd_generic_bfd_copy_private_section_data, _bfd_generic_bfd_copy_private_symbol_data, _bfd_generic_bfd_copy_private_header_data, diff --git a/bfd/coffcode.h b/bfd/coffcode.h index bd0374fbfdd..b81195dd2ec 100644 --- a/bfd/coffcode.h +++ b/bfd/coffcode.h @@ -5955,8 +5955,6 @@ static const bfd_coff_backend_data bigobj_swap_table = #define coff_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data #endif -#define coff_init_private_section_data _bfd_generic_init_private_section_data - #ifndef coff_bfd_copy_private_section_data #define coff_bfd_copy_private_section_data _bfd_generic_bfd_copy_private_section_data #endif diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index f62570919d5..2bd855a936c 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -2393,10 +2393,8 @@ extern bool _bfd_elf_copy_private_header_data (bfd *, bfd *); extern bool _bfd_elf_copy_private_symbol_data (bfd *, asymbol *, bfd *, asymbol *); -extern bool _bfd_elf_init_private_section_data - (bfd *, asection *, bfd *, asection *, struct bfd_link_info *); extern bool _bfd_elf_copy_private_section_data - (bfd *, asection *, bfd *, asection *); + (bfd *, asection *, bfd *, asection *, struct bfd_link_info *); extern bool _bfd_elf_write_object_contents (bfd *); extern bool _bfd_elf_write_corefile_contents diff --git a/bfd/elf.c b/bfd/elf.c index 07b2d0e5a2d..1eba14283f8 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -8375,25 +8375,34 @@ copy_private_bfd_data (bfd *ibfd, bfd *obfd) return rewrite_elf_program_header (ibfd, obfd, maxpagesize); } -/* Initialize private output section information from input section. */ +/* Copy private section information from input to output. This function + is called both by objcopy where LINK_INFO is NULL, and ld where + LINK_INFO is non-NULL in the usual case but NULL for a special case + when dealing with LTO IR or cloning output sections. */ bool -_bfd_elf_init_private_section_data (bfd *ibfd, +_bfd_elf_copy_private_section_data (bfd *ibfd, asection *isec, bfd *obfd, asection *osec, struct bfd_link_info *link_info) - { - Elf_Internal_Shdr *ihdr, *ohdr; - bool final_link = (link_info != NULL - && !bfd_link_relocatable (link_info)); - if (ibfd->xvec->flavour != bfd_target_elf_flavour || obfd->xvec->flavour != bfd_target_elf_flavour) return true; - BFD_ASSERT (elf_section_data (osec) != NULL); + Elf_Internal_Shdr *ihdr = &elf_section_data (isec)->this_hdr; + Elf_Internal_Shdr *ohdr = &elf_section_data (osec)->this_hdr; + if (link_info == NULL) + { + ohdr->sh_entsize = ihdr->sh_entsize; + + if (ihdr->sh_type == SHT_SYMTAB + || ihdr->sh_type == SHT_DYNSYM + || ihdr->sh_type == SHT_GNU_verneed + || ihdr->sh_type == SHT_GNU_verdef) + ohdr->sh_info = ihdr->sh_info; + } /* If this is a known ABI section, ELF section type and flags may have been set up when OSEC was created. For normal sections we @@ -8403,11 +8412,14 @@ _bfd_elf_init_private_section_data (bfd *ibfd, || elf_section_type (osec) == SHT_NOTE || elf_section_type (osec) == SHT_NOBITS) elf_section_type (osec) = SHT_NULL; + /* For objcopy and relocatable link, copy the ELF section type from the input file if the BFD section flags are the same. (If they are different the user may be doing something like "objcopy --set-section-flags .text=alloc,data".) For a final link allow some flags that the linker clears to differ. */ + bool final_link = (link_info != NULL + && !bfd_link_relocatable (link_info)); if (elf_section_type (osec) == SHT_NULL && (osec->flags == isec->flags || (final_link @@ -8445,14 +8457,11 @@ _bfd_elf_init_private_section_data (bfd *ibfd, elf_section_flags (osec) |= (elf_section_flags (isec) & SHF_COMPRESSED); - ihdr = &elf_section_data (isec)->this_hdr; - /* We need to handle elf_linked_to_section for SHF_LINK_ORDER. We don't use the output section of the linked-to section since it may be NULL at this point. */ if ((ihdr->sh_flags & SHF_LINK_ORDER) != 0) { - ohdr = &elf_section_data (osec)->this_hdr; ohdr->sh_flags |= SHF_LINK_ORDER; elf_linked_to_section (osec) = elf_linked_to_section (isec); } @@ -8462,36 +8471,6 @@ _bfd_elf_init_private_section_data (bfd *ibfd, return true; } -/* Copy private section information. This copies over the entsize - field, and sometimes the info field. */ - -bool -_bfd_elf_copy_private_section_data (bfd *ibfd, - asection *isec, - bfd *obfd, - asection *osec) -{ - Elf_Internal_Shdr *ihdr, *ohdr; - - if (ibfd->xvec->flavour != bfd_target_elf_flavour - || obfd->xvec->flavour != bfd_target_elf_flavour) - return true; - - ihdr = &elf_section_data (isec)->this_hdr; - ohdr = &elf_section_data (osec)->this_hdr; - - ohdr->sh_entsize = ihdr->sh_entsize; - - if (ihdr->sh_type == SHT_SYMTAB - || ihdr->sh_type == SHT_DYNSYM - || ihdr->sh_type == SHT_GNU_verneed - || ihdr->sh_type == SHT_GNU_verdef) - ohdr->sh_info = ihdr->sh_info; - - return _bfd_elf_init_private_section_data (ibfd, isec, obfd, osec, - NULL); -} - /* Look at all the SHT_GROUP sections in IBFD, making any adjustments necessary if we are removing either the SHT_GROUP section or any of the group member sections. DISCARDED is the value that a section's diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index b9b3cf831c4..c40a0c5488a 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -6136,13 +6136,14 @@ elf_x86_64_fake_sections (bfd *abfd ATTRIBUTE_UNUSED, static bool elf_x86_64_copy_private_section_data (bfd *ibfd, asection *isec, - bfd *obfd, asection *osec) + bfd *obfd, asection *osec, + struct bfd_link_info *link_info) { - if (!_bfd_elf_copy_private_section_data (ibfd, isec, obfd, osec)) + if (!_bfd_elf_copy_private_section_data (ibfd, isec, obfd, osec, link_info)) return false; /* objcopy --set-section-flags without "large" drops SHF_X86_64_LARGE. */ - if (ibfd != obfd) + if (link_info == NULL && ibfd != obfd) elf_section_flags (osec) &= ~SHF_X86_64_LARGE; return true; diff --git a/bfd/elfxx-target.h b/bfd/elfxx-target.h index 625243cac94..4cf02bbedd7 100644 --- a/bfd/elfxx-target.h +++ b/bfd/elfxx-target.h @@ -225,8 +225,6 @@ _bfd_elf_copy_private_symbol_data #endif -#define bfd_elfNN_init_private_section_data \ - _bfd_elf_init_private_section_data #ifndef bfd_elfNN_bfd_copy_private_section_data #define bfd_elfNN_bfd_copy_private_section_data \ _bfd_elf_copy_private_section_data diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h index ae6d3039017..213cc7d6759 100644 --- a/bfd/libbfd-in.h +++ b/bfd/libbfd-in.h @@ -270,17 +270,14 @@ extern bool _bfd_generic_get_section_contents #define _bfd_generic_bfd_merge_private_bfd_data \ _bfd_bool_bfd_link_true #define _bfd_generic_bfd_set_private_flags _bfd_bool_bfd_uint_true -#define _bfd_generic_bfd_copy_private_section_data \ - _bfd_bool_bfd_asection_bfd_asection_true +extern bool _bfd_generic_bfd_copy_private_section_data + (bfd *, asection *, bfd *, asection *, struct bfd_link_info *) + ATTRIBUTE_HIDDEN; #define _bfd_generic_bfd_copy_private_symbol_data \ _bfd_bool_bfd_asymbol_bfd_asymbol_true #define _bfd_generic_bfd_copy_private_header_data _bfd_bool_bfd_bfd_true #define _bfd_generic_bfd_print_private_bfd_data _bfd_bool_bfd_ptr_true -extern bool _bfd_generic_init_private_section_data - (bfd *, asection *, bfd *, asection *, struct bfd_link_info *) - ATTRIBUTE_HIDDEN; - /* Routines to use for BFD_JUMP_TABLE_CORE when there is no core file support. Use BFD_JUMP_TABLE_CORE (_bfd_nocore). */ diff --git a/bfd/libbfd.c b/bfd/libbfd.c index f2daf7977a0..6587fc195f1 100644 --- a/bfd/libbfd.c +++ b/bfd/libbfd.c @@ -1514,11 +1514,11 @@ _bfd_write_unsigned_leb128 (bfd_byte *p, bfd_byte *end, bfd_vma val) } bool -_bfd_generic_init_private_section_data (bfd *ibfd ATTRIBUTE_UNUSED, - asection *isec ATTRIBUTE_UNUSED, - bfd *obfd ATTRIBUTE_UNUSED, - asection *osec ATTRIBUTE_UNUSED, - struct bfd_link_info *link_info ATTRIBUTE_UNUSED) +_bfd_generic_bfd_copy_private_section_data (bfd *ibfd ATTRIBUTE_UNUSED, + asection *isec ATTRIBUTE_UNUSED, + bfd *obfd ATTRIBUTE_UNUSED, + asection *osec ATTRIBUTE_UNUSED, + struct bfd_link_info *link_info ATTRIBUTE_UNUSED) { return true; } diff --git a/bfd/libbfd.h b/bfd/libbfd.h index 3cb3c144228..bab1f71f7e3 100644 --- a/bfd/libbfd.h +++ b/bfd/libbfd.h @@ -276,17 +276,14 @@ extern bool _bfd_generic_get_section_contents #define _bfd_generic_bfd_merge_private_bfd_data \ _bfd_bool_bfd_link_true #define _bfd_generic_bfd_set_private_flags _bfd_bool_bfd_uint_true -#define _bfd_generic_bfd_copy_private_section_data \ - _bfd_bool_bfd_asection_bfd_asection_true +extern bool _bfd_generic_bfd_copy_private_section_data + (bfd *, asection *, bfd *, asection *, struct bfd_link_info *) + ATTRIBUTE_HIDDEN; #define _bfd_generic_bfd_copy_private_symbol_data \ _bfd_bool_bfd_asymbol_bfd_asymbol_true #define _bfd_generic_bfd_copy_private_header_data _bfd_bool_bfd_bfd_true #define _bfd_generic_bfd_print_private_bfd_data _bfd_bool_bfd_ptr_true -extern bool _bfd_generic_init_private_section_data - (bfd *, asection *, bfd *, asection *, struct bfd_link_info *) - ATTRIBUTE_HIDDEN; - /* Routines to use for BFD_JUMP_TABLE_CORE when there is no core file support. Use BFD_JUMP_TABLE_CORE (_bfd_nocore). */ diff --git a/bfd/libecoff.h b/bfd/libecoff.h index 51a00e08973..08b601d7264 100644 --- a/bfd/libecoff.h +++ b/bfd/libecoff.h @@ -250,9 +250,6 @@ extern bool _bfd_ecoff_get_section_contents #define _bfd_ecoff_bfd_link_split_section _bfd_generic_link_split_section #define _bfd_ecoff_bfd_link_check_relocs _bfd_generic_link_check_relocs -#define _bfd_ecoff_init_private_section_data \ - _bfd_generic_init_private_section_data - extern bool _bfd_ecoff_bfd_copy_private_bfd_data (bfd *, bfd *); #define _bfd_ecoff_bfd_copy_private_section_data \ diff --git a/bfd/libpei.h b/bfd/libpei.h index 4932fb1f9de..fc1ada251b6 100644 --- a/bfd/libpei.h +++ b/bfd/libpei.h @@ -473,7 +473,7 @@ CODEVIEW_INFO *_bfd_XXi_slurp_codeview_record unsigned _bfd_XX_only_swap_filehdr_out (bfd *, void *, void *); unsigned _bfd_XXi_only_swap_filehdr_out (bfd *, void *, void *); bool _bfd_XX_bfd_copy_private_section_data - (bfd *, asection *, bfd *, asection *); + (bfd *, asection *, bfd *, asection *, struct bfd_link_info *); bool _bfd_pe_print_ce_compressed_pdata (bfd *, void *); bool _bfd_pe64_print_ce_compressed_pdata (bfd *, void *); diff --git a/bfd/mach-o-target.c b/bfd/mach-o-target.c index fa1953fc4c4..e402d3a034f 100644 --- a/bfd/mach-o-target.c +++ b/bfd/mach-o-target.c @@ -74,7 +74,6 @@ #define bfd_mach_o_write_armap _bfd_noarchive_write_armap #define bfd_mach_o_get_elt_at_index _bfd_noarchive_get_elt_at_index #define bfd_mach_o_update_armap_timestamp _bfd_noarchive_update_armap_timestamp -#define bfd_mach_o_init_private_section_data _bfd_generic_init_private_section_data #define TARGET_NAME_BACKEND XCONCAT2(TARGET_NAME,_backend) diff --git a/bfd/mach-o.c b/bfd/mach-o.c index fb5bde17cdb..cc191b9ef1e 100644 --- a/bfd/mach-o.c +++ b/bfd/mach-o.c @@ -583,15 +583,17 @@ bfd_mach_o_bfd_copy_private_symbol_data (bfd *ibfd ATTRIBUTE_UNUSED, bool bfd_mach_o_bfd_copy_private_section_data (bfd *ibfd, asection *isection, - bfd *obfd, asection *osection) + bfd *obfd, asection *osection, + struct bfd_link_info *link_info) { - bfd_mach_o_section *os = bfd_mach_o_get_mach_o_section (osection); - bfd_mach_o_section *is = bfd_mach_o_get_mach_o_section (isection); - - if (ibfd->xvec->flavour != bfd_target_mach_o_flavour + if (link_info != NULL + || ibfd->xvec->flavour != bfd_target_mach_o_flavour || obfd->xvec->flavour != bfd_target_mach_o_flavour) return true; + bfd_mach_o_section *os = bfd_mach_o_get_mach_o_section (osection); + bfd_mach_o_section *is = bfd_mach_o_get_mach_o_section (isection); + BFD_ASSERT (is != NULL && os != NULL); os->flags = is->flags; diff --git a/bfd/mach-o.h b/bfd/mach-o.h index 3aaae380f2f..1cda07226e5 100644 --- a/bfd/mach-o.h +++ b/bfd/mach-o.h @@ -691,7 +691,8 @@ bool bfd_mach_o_write_contents (bfd *); bool bfd_mach_o_bfd_copy_private_symbol_data (bfd *, asymbol *, bfd *, asymbol *); bool bfd_mach_o_bfd_copy_private_section_data (bfd *, asection *, - bfd *, asection *); + bfd *, asection *, + struct bfd_link_info *); bool bfd_mach_o_bfd_copy_private_header_data (bfd *, bfd *); bool bfd_mach_o_bfd_set_private_flags (bfd *, flagword); bool bfd_mach_o_bfd_print_private_bfd_data (bfd *, void *); diff --git a/bfd/mmo.c b/bfd/mmo.c index 1b1eb87df8f..762aeffd3e0 100644 --- a/bfd/mmo.c +++ b/bfd/mmo.c @@ -3350,7 +3350,6 @@ mmo_write_object_contents (bfd *abfd) #define mmo_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data #define mmo_bfd_set_private_flags _bfd_generic_bfd_set_private_flags #define mmo_bfd_print_private_bfd_data _bfd_generic_bfd_print_private_bfd_data -#define mmo_init_private_section_data _bfd_generic_init_private_section_data const bfd_target mmix_mmo_vec = { diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c index 19f38a4ac1b..c337fc5b282 100644 --- a/bfd/peXXigen.c +++ b/bfd/peXXigen.c @@ -3115,9 +3115,11 @@ bool _bfd_XX_bfd_copy_private_section_data (bfd *ibfd, asection *isec, bfd *obfd, - asection *osec) + asection *osec, + struct bfd_link_info *link_info) { - if (bfd_get_flavour (ibfd) != bfd_target_coff_flavour + if (link_info != NULL + || bfd_get_flavour (ibfd) != bfd_target_coff_flavour || bfd_get_flavour (obfd) != bfd_target_coff_flavour) return true; diff --git a/bfd/plugin.c b/bfd/plugin.c index d57ae593e78..1c72b748a8f 100644 --- a/bfd/plugin.c +++ b/bfd/plugin.c @@ -73,8 +73,6 @@ dlerror (void) #define bfd_plugin_bfd_free_cached_info _bfd_generic_bfd_free_cached_info #define bfd_plugin_new_section_hook _bfd_generic_new_section_hook #define bfd_plugin_get_section_contents _bfd_generic_get_section_contents -#define bfd_plugin_init_private_section_data _bfd_generic_init_private_section_data -#define bfd_plugin_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data #define bfd_plugin_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data #define bfd_plugin_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data #define bfd_plugin_bfd_set_private_flags _bfd_generic_bfd_set_private_flags @@ -782,7 +780,8 @@ static bool bfd_plugin_bfd_copy_private_section_data (bfd *ibfd ATTRIBUTE_UNUSED, asection *isection ATTRIBUTE_UNUSED, bfd *obfd ATTRIBUTE_UNUSED, - asection *osection ATTRIBUTE_UNUSED) + asection *osection ATTRIBUTE_UNUSED, + struct bfd_link_info *link_info ATTRIBUTE_UNUSED) { BFD_ASSERT (0); return true; diff --git a/bfd/ppcboot.c b/bfd/ppcboot.c index b4b59c94d2f..dd70267640c 100644 --- a/bfd/ppcboot.c +++ b/bfd/ppcboot.c @@ -474,7 +474,6 @@ ppcboot_bfd_print_private_bfd_data (bfd *abfd, void * farg) #define ppcboot_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data #define ppcboot_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data -#define ppcboot_init_private_section_data _bfd_generic_init_private_section_data #define ppcboot_bfd_copy_private_section_data _bfd_generic_bfd_copy_private_section_data #define ppcboot_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data #define ppcboot_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data diff --git a/bfd/section.c b/bfd/section.c index 9460ff916b9..5f0cf6e71cb 100644 --- a/bfd/section.c +++ b/bfd/section.c @@ -1667,7 +1667,8 @@ FUNCTION SYNOPSIS bool bfd_copy_private_section_data - (bfd *ibfd, asection *isec, bfd *obfd, asection *osec); + (bfd *ibfd, asection *isec, bfd *obfd, asection *osec, + struct bfd_link_info *link_info); DESCRIPTION Copy private section information from @var{isec} in the BFD @@ -1678,9 +1679,9 @@ DESCRIPTION o <> - Not enough memory exists to create private data for @var{osec}. -.#define bfd_copy_private_section_data(ibfd, isection, obfd, osection) \ +.#define bfd_copy_private_section_data(ibfd, isec, obfd, osec, link_info) \ . BFD_SEND (obfd, _bfd_copy_private_section_data, \ -. (ibfd, isection, obfd, osection)) +. (ibfd, isec, obfd, osec, link_info)) */ /* diff --git a/bfd/som.c b/bfd/som.c index d3e0876efb1..5c60f605043 100644 --- a/bfd/som.c +++ b/bfd/som.c @@ -5372,17 +5372,17 @@ static bool som_bfd_copy_private_section_data (bfd *ibfd, asection *isection, bfd *obfd, - asection *osection) + asection *osection, + struct bfd_link_info *link_info) { - size_t amt; - /* One day we may try to grok other private data. */ - if (ibfd->xvec->flavour != bfd_target_som_flavour + if (link_info != NULL + || ibfd->xvec->flavour != bfd_target_som_flavour || obfd->xvec->flavour != bfd_target_som_flavour || (!som_is_space (isection) && !som_is_subspace (isection))) return true; - amt = sizeof (struct som_copyable_section_data_struct); + size_t amt = sizeof (struct som_copyable_section_data_struct); som_section_data (osection)->copy_data = bfd_zalloc (obfd, amt); if (som_section_data (osection)->copy_data == NULL) return false; @@ -5401,7 +5401,8 @@ som_bfd_copy_private_section_data (bfd *ibfd, { /* User has specified a subspace without its containing space. */ _bfd_error_handler (_("%pB[%pA]: no output section for space %pA"), - obfd, osection, som_section_data (osection)->copy_data->container); + obfd, osection, + som_section_data (osection)->copy_data->container); return false; } } @@ -6779,7 +6780,6 @@ som_bfd_link_split_section (bfd *abfd ATTRIBUTE_UNUSED, asection *sec) #define som_bfd_link_hide_symbol _bfd_generic_link_hide_symbol #define som_bfd_define_start_stop bfd_generic_define_start_stop #define som_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data -#define som_init_private_section_data _bfd_generic_init_private_section_data #define som_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data #define som_bfd_set_private_flags _bfd_generic_bfd_set_private_flags #define som_find_inliner_info _bfd_nosymbols_find_inliner_info diff --git a/bfd/targets.c b/bfd/targets.c index 18f5782daf7..23333701ec0 100644 --- a/bfd/targets.c +++ b/bfd/targets.c @@ -282,7 +282,6 @@ BFD_JUMP_TABLE macros. .#define BFD_JUMP_TABLE_COPY(NAME) \ . NAME##_bfd_copy_private_bfd_data, \ . NAME##_bfd_merge_private_bfd_data, \ -. NAME##_init_private_section_data, \ . NAME##_bfd_copy_private_section_data, \ . NAME##_bfd_copy_private_symbol_data, \ . NAME##_bfd_copy_private_header_data, \ @@ -295,16 +294,10 @@ BFD_JUMP_TABLE macros. . {* Called to merge BFD general private data from one object file . to a common output file when linking. *} . bool (*_bfd_merge_private_bfd_data) (bfd *, struct bfd_link_info *); -. {* Called to initialize BFD private section data from one object file -. to another. *} -.#define bfd_init_private_section_data(ibfd, isec, obfd, osec, link_info) \ -. BFD_SEND (obfd, _bfd_init_private_section_data, \ -. (ibfd, isec, obfd, osec, link_info)) -. bool (*_bfd_init_private_section_data) (bfd *, sec_ptr, bfd *, sec_ptr, -. struct bfd_link_info *); . {* Called to copy BFD private section data from one object file . to another. *} -. bool (*_bfd_copy_private_section_data) (bfd *, sec_ptr, bfd *, sec_ptr); +. bool (*_bfd_copy_private_section_data) (bfd *, sec_ptr, bfd *, sec_ptr, +. struct bfd_link_info *); . {* Called to copy BFD private symbol data from one symbol . to another. *} . bool (*_bfd_copy_private_symbol_data) (bfd *, asymbol *, diff --git a/bfd/vms-alpha.c b/bfd/vms-alpha.c index 548a9790100..c4b248494ee 100644 --- a/bfd/vms-alpha.c +++ b/bfd/vms-alpha.c @@ -10156,7 +10156,6 @@ bfd_vms_get_data (bfd *abfd) #define vms_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data #define vms_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data -#define vms_init_private_section_data _bfd_generic_init_private_section_data #define vms_bfd_copy_private_section_data _bfd_generic_bfd_copy_private_section_data #define vms_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data #define vms_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data diff --git a/binutils/objcopy.c b/binutils/objcopy.c index 2e98ba44c01..8c9077356f1 100644 --- a/binutils/objcopy.c +++ b/binutils/objcopy.c @@ -4398,7 +4398,7 @@ setup_section (bfd *ibfd, sec_ptr isection, bfd *obfd) /* Allow the BFD backend to copy any private data it understands from the input section to the output section. */ - if (!bfd_copy_private_section_data (ibfd, isection, obfd, osection)) + if (!bfd_copy_private_section_data (ibfd, isection, obfd, osection, NULL)) err = _("failed to copy private data"); if (make_nobits) diff --git a/ld/ldlang.c b/ld/ldlang.c index 32e6e7abdf1..cd1825b1bc0 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -2874,7 +2874,7 @@ lang_add_section (lang_statement_list_type *ptr, /* This must happen after flags have been updated. The output section may have been created before we saw its first input section, eg. for a data statement. */ - bfd_init_private_section_data (section->owner, section, + bfd_copy_private_section_data (section->owner, section, link_info.output_bfd, output->bfd_section, &link_info); @@ -10494,7 +10494,7 @@ setup_section (bfd *ibfd, sec_ptr isection, void *p) /* Allow the BFD backend to copy any private data it understands from the input section to the output section. */ - if (!bfd_copy_private_section_data (ibfd, isection, obfd, osection)) + if (!bfd_copy_private_section_data (ibfd, isection, obfd, osection, NULL)) { err = _("failed to copy private data"); goto loser; diff --git a/ld/ldwrite.c b/ld/ldwrite.c index 7613def6767..974245f602e 100644 --- a/ld/ldwrite.c +++ b/ld/ldwrite.c @@ -366,7 +366,7 @@ clone_section (bfd *abfd, asection *s, const char *name, int *count) n->reloc_count = 0; n->alignment_power = s->alignment_power; - bfd_copy_private_section_data (abfd, s, abfd, n); + bfd_copy_private_section_data (abfd, s, abfd, n, NULL); return n; }