Copy relocs are used in a scheme to avoid dynamic text relocations in
non-PIC executables that refer to variables defined in shared
libraries. The idea is to have the linker define any such variable in
the executable, with a copy reloc copying the initial value, then have
both the executable and shared library refer to the executable copy.
If the shared library defines the variable as protected then we have
two copies of the variable being used.
PR 15228
* elflink.c (_bfd_elf_adjust_dynamic_copy): Add "info" param.
Error on copy relocs against protected symbols.
(elf_merge_st_other): Set h->protected_def.
* elf-bfd.h (struct elf_link_hash_entry): Add "protected_def".
(_bfd_elf_adjust_dynamic_copy): Update prototype.
* elf-m10300.c (_bfd_mn10300_elf_adjust_dynamic_symbol): Update
_bfd_elf_adjust_dynamic_copy call.
* elf32-arm.c (elf32_arm_adjust_dynamic_symbol): Likewise.
* elf32-cr16.c (_bfd_cr16_elf_adjust_dynamic_symbol): Likewise.
* elf32-cris.c (elf_cris_adjust_dynamic_symbol): Likewise.
* elf32-hppa.c (elf32_hppa_adjust_dynamic_symbol): Likewise.
* elf32-i370.c (i370_elf_adjust_dynamic_symbol): Likewise.
* elf32-i386.c (elf_i386_adjust_dynamic_symbol): Likewise.
* elf32-lm32.c (lm32_elf_adjust_dynamic_symbol): Likewise.
* elf32-m32r.c (m32r_elf_adjust_dynamic_symbol): Likewise.
* elf32-m68k.c (elf_m68k_adjust_dynamic_symbol): Likewise.
* elf32-metag.c (elf_metag_adjust_dynamic_symbol): Likewise.
* elf32-or1k.c (or1k_elf_adjust_dynamic_symbol): Likewise.
* elf32-ppc.c (ppc_elf_adjust_dynamic_symbol): Likewise.
* elf32-s390.c (elf_s390_adjust_dynamic_symbol): Likewise.
* elf32-sh.c (sh_elf_adjust_dynamic_symbol): Likewise.
* elf32-tic6x.c (elf32_tic6x_adjust_dynamic_symbol): Likewise.
* elf32-tilepro.c (tilepro_elf_adjust_dynamic_symbol): Likewise.
* elf32-vax.c (elf_vax_adjust_dynamic_symbol): Likewise.
* elf64-ppc.c (ppc64_elf_adjust_dynamic_symbol): Likewise.
* elf64-s390.c (elf_s390_adjust_dynamic_symbol): Likewise.
* elf64-sh64.c (sh64_elf64_adjust_dynamic_symbol): Likewise.
* elf64-x86-64.c (elf_x86_64_adjust_dynamic_symbol): Likewise.
* elfnn-aarch64.c (elfNN_aarch64_adjust_dynamic_symbol): Likewise.
* elfxx-mips.c (_bfd_mips_elf_adjust_dynamic_symbol): Likewise.
* elfxx-sparc.c (_bfd_sparc_elf_adjust_dynamic_symbol): Likewise.
* elfxx-tilegx.c (tilegx_elf_adjust_dynamic_symbol): Likewise.
* elf32-cr16.c (R_CR16_GOT_REGREL20, R_CR16_GOTC_REGREL20 and
R_CR16_GLOB_DAT): New macros
(cr16_elf_howto_table): Add entries for for R_CR16_GOT_REGREL20,
R_CR16_GOTC_REGREL20 and R_CR16_GLOB_DAT.
(cr16_reloc_map): Ditto
(_bfd_cr16_elf_create_got_section): New function to create GOT section.
(_bfd_cr16_elf_create_dynamic_sections): New function to create dynamic
section.
(_bfd_cr16_elf_adjust_dynamic_symbol): New function to adjust symbol
defined by dynamic object.
(_bfd_cr16_elf_size_dynamic_sections): New function to find the size
of dynamic section.
(_bfd_cr16_elf_finish_dynamic_symbol): New function to handle dynamic
symbols.
(_bfd_cr16_elf_finish_dynamic_symbol): New function to handle dynamic
sections.
(bfd_cr16_elf32_create_embedded_relocs): New function to create
embedded relocs in .emreloc section in memory for .data.rel section.
(_bfd_cr16_elf_reloc_type_class): New function for classify reloc types.
(cr16_elf_check_relocs): New function for checking reloc types in
first phase.
(cr16_elf_final_link_relocate): Update for handling the new reloc
types R_CR16_GOT_REGREL20 and R_CR16_GOTC_REGREL20.
(elf32_cr16_relax_section): Update relax implementation.
* reloc.c (bfd_reloc_code_type): Add entries for R_CR16_GOT_REGREL20,
R_CR16_GOTC_REGREL20 and R_CR16_GLOB_DAT.
* bfd-in.h (bfd_boolean bfd_cr16_elf32_create_embedded_relocs): Declared
* libbfd.h, bfd-in2.h: Regenerate.
(read_n_bytes): Remove unhelpful comment.
(read_indirect_string): Pass symbol table to read_section in case
the .debug_str section needs relocating.
PR 7037
* elf32-cr16.c (cr16_elf_howto_table): Zero the src_mask field of
the reloc descriptions.