diff --git a/ChangeLog b/ChangeLog index 99ce993..03e1852 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +2018-02-13 Maciej W. Rozycki + + * configure.ac (noconfigdirs): Add `ld'. + * configure: Regenerate. + +2018-01-30 Nick Clifton + + * src-release.sh (do_proto_toplev): Add patterns for more junk files + to delete before creating the tarball. + +2018-01-29 Nick Clifton + + * src-release.sh (do_proto_toplev): Strip patch remnant files from + the sources before creating the tarball. + +2018-01-13 Nick Clifton + + * src-release.sh: Update copyright notice. Change reference to devo + to be a reference to root. + 2018-01-10 Nick Clifton * config-ml.in: Sync with gcc sources. diff --git a/bfd/ChangeLog b/bfd/ChangeLog index c310da6..6e20330 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,11 +1,1277 @@ -2018-01-27 Nick Clifton +2018-03-03 James Cowgill + Maciej W. Rozycki - This is the 2.30 release: + PR ld/21900 + * elfxx-mips.c (mips_elf_calculate_relocation): Only return + after calling `undefined_symbol' hook if this is an error + condition. Assume the value of 0 for the symbol requested + otherwise. - * version.m4 (BFD_VERSION): Set to 2.30 - * development.sh: Set to false. - * configure: Regenerate. - * po/bfd.pot: Regenerate. +2018-03-02 Jim Wilson + + PR 22903 + * elfnn-aarch64.c (_bfd_aarch64_resize_stubs): Add 8 bytes for branch + and nop instead of 4. + (elfNN_arch64_build_stubs): Add nop after branch. Increase size by + 8 instead of 4. + +2018-03-01 Jim Wilson + + PR 22756 + * elfnn-riscv.c (riscv_relax_delete_bytes): When adjust st_size, use + else if instead of if. + +2018-03-01 Alan Modra + + * elf32-ft32.c (ft32_info_to_howto_rela): Correct range test. + +2018-02-28 Alan Modra + + PR 22887 + * aoutx.h (swap_std_reloc_in): Correct r_index bound check. + +2018-02-28 Nick Clifton + + PR 22895 + PR 22893 + * dwarf2.c (read_n_bytes): Replace size parameter with dwarf_block + pointer. Drop unused abfd parameter. Check the size of the block + before initialising the data field. Return the end pointer if the + size is invalid. + (read_attribute_value): Adjust invocations of read_n_bytes. + + PR 22894 + * dwarf1.c (parse_die): Check the length of form blocks before + advancing the data pointer. + +2018-02-28 Alan Modra + + PR 22887 + * aoutx.h (translate_symbol_table): Print an error message and set + bfd_error on finding an invalid name string offset. + +2018-02-27 H.J. Lu + + * config.in: Regenerated. + * configure: Likewise. + * configure.ac: Add --enable-separate-code. + (DEFAULT_LD_Z_SEPARATE_CODE): New AC_DEFINE_UNQUOTED. Default + to 1 for Linux/x86 targets, + * elf64-x86-64.c (ELF_MAXPAGESIZE): Set to 0x1000 if + DEFAULT_LD_Z_SEPARATE_CODE is 1. + +2018-02-27 Nick Clifton + + * aout-cris.c (swap_ext_reloc_out): Standadize error/warning + message. + * elf-hppa.h (elf_hppa_info_to_howto_rel): Likewise. + * elf32-i386.c (elf_i386_reloc_type_lookup): Likewise. + * elf32-xtensa.c (elf_xtensa_reloc_type_lookup): Likewise. + * elf64-ppc.c (ppc64_elf_reloc_type_lookup): Likewise. + * elf64-s390.c (elf_s390_reloc_type_lookup): Likewise. + * elf64-sh64.c (sh_elf64_info_to_howto): Likewise. + * elfxx-ia64.c (ia64_elf_reloc_type_lookup): Likewise. + * elfxx-sparc.c (_bfd_sparc_elf_reloc_type_lookup): Likewise. + * elfxx-tilegx.c (tilegx_reloc_type_lookup): Likewise. + + PR 22875 + * elf-bfd.h (struct elf_backend_data): Change the return type of + the elf_info_to_howto and elf_info_to_howto_rel function pointers + to bfd_boolean. + * elfcode.h (elf_slurp_reloc_table_from_section): Check the return + value from the info_to_howto function and fail if that function + failed. + * elf32-h8300.c (elf32_h8_relocate_section): Check return value + from the info_to_howto function. + (elf32_h8_relax_section): Likewise. + * elf32-lm32.c (lm32_elf_relocate_section): Likewise. + * elf32-m68hc1x.c (elf32_m68hc11_relocate_section): Likewise. + * elf32-score.c (s3_bfd_score_elf_relocate_section): Likewise. + * elf32-score7.c (s7_bfd_score_elf_relocate_section): Likewise. + * elf32-tic6x.c (elf32_tic6x_relocate_section): Likewise. + * elf64-ia64-vms.c (elf64_ia64_relocate_section): Likewise. + * elf64-sparc.c (elf64_sparc_slurp_one_reloc_table): Likewise. + * elf64-x86-64.c (elf_x86_64_tls_transition): Likewise. + * elfnn-ia64.c (elfNN_ia64_relocate_section): Likewise. + * elfnn-riscv.c (riscv_elf_check_relocs): Likewise. + (riscv_elf_relocate_section): Likewise. + * elf-hppa.h (elf_hppa_info_to_howto): Change return type to + bfd_boolean. Issue an error message, set an error value and + return FALSE if the reloc is not recognized. + (elf_hppa_info_to_howto_rel): Likewise. + * elf-m10200.c (mn10200_info_to_howto): Likewise. + * elf-m10300.c (mn10300_info_to_howto): Likewise. + * elf.c (_bfd_elf_no_info_to_howto): Likewise. + * elf32-arc.c (arc_info_to_howto_rel): Likewise. + * elf32-arm.c (elf32_arm_info_to_howto): Likewise. + * elf32-avr.c (avr_info_to_howto_rela): Likewise. + * elf32-bfin.c (bfin_info_to_howto): Likewise. + * elf32-cr16.c (elf_cr16_info_to_howto): Likewise. + * elf32-cr16c.c (elf_cr16c_info_to_howto): Likewise. + * elf32-cris.c (elf_cr16c_info_to_howto_rel) + (cris_info_to_howto_rela): Likewise. + * elf32-crx.c (elf_crx_info_to_howto): Likewise. + * elf32-d10v.c (d10v_info_to_howto_rel): Likewise. + * elf32-d30v.c (d30v_info_to_howto_rel, d30v_info_to_howto_rela): + Likewise. + * elf32-dlx.c (dlx_rtype_to_howto, elf32_dlx_info_to_howto) + (elf32_dlx_info_to_howto_rel): Likewise. + * elf32-epiphany.c (epiphany_info_to_howto_rela): Likewise. + * elf32-fr30.c (fr30_info_to_howto_rela): Likewise. + * elf32-frv.c (frv_info_to_howto_rela) + (frvfdpic_info_to_howto_rel): Likewise. + * elf32-ft32.c (ft32_info_to_howto_rela): Likewise. + * elf32-gen.c (elf_generic_info_to_howto) + (elf_generic_info_to_howto_rel): Likewise. + * elf32-h8300.c (elf32_h8_info_to_howto) + (elf32_h8_info_to_howto_rel): Likewise. + * elf32-i370.c (i370_elf_info_to_howto): Likewise. + * elf32-i386.c (elf_i386_reloc_type_lookup) + (elf_i386_rtype_to_howto, elf_i386_info_to_howto_rel): Likewise. + * elf32-i860.c (lookup_howto, elf32_i860_info_to_howto_rela): + Likewise. + * elf32-i960.c (elf32_i960_info_to_howto_rel): Likewise. + * elf32-ip2k.c (ip2k_info_to_howto_rela): Likewise. + * elf32-iq2000.c (iq2000_info_to_howto_rela): Likewise. + * elf32-lm32.c (lm32_info_to_howto_rela): Likewise. + * elf32-m32c.c (m32c_info_to_howto_rela): Likewise. + * elf32-m32r.c (m32r_info_to_howto_rel, m32r_info_to_howto): + Likewise. + * elf32-m68hc11.c (m68hc11_info_to_howto_rel): Likewise. + * elf32-m68hc12.c (m68hc11_info_to_howto_rel): Likewise. + * elf32-m68k.c (rtype_to_howto): Likewise. + * elf32-mcore.c (mcore_elf_info_to_howto): Likewise. + * elf32-mep.c (mep_info_to_howto_rela): Likewise. + * elf32-metag.c (metag_info_to_howto_rela): Likewise. + * elf32-microblaze.c (microblaze_elf_info_to_howto): Likewise. + * elf32-mips.c (mips_info_to_howto_rel, mips_info_to_howto_rela): + Likewise. + * elf32-moxie.c (moxie_info_to_howto_rela): Likewise. + * elf32-msp430.c (msp430_info_to_howto_rela): Likewise. + * elf32-mt.c (mt_info_to_howto_rela): Likewise. + * elf32-nds32.c (nds32_info_to_howto_rel, nds32_info_to_howto): + Likewise. + * elf32-nios2.c (nios2_elf32_info_to_howto): Likewise. + * elf32-or1k.c (or1k_info_to_howto_rela): Likewise. + * elf32-pj.c (pj_elf_info_to_howto): Likewise. + * elf32-ppc.c (ppc_elf_info_to_howto): Likewise. + * elf32-pru.c (pru_elf32_info_to_howto): Likewise. + * elf32-rl78.c (rl78_info_to_howto_rela): Likewise. + * elf32-rx.c (rx_info_to_howto_rela): Likewise. + * elf32-s390.c (elf_s390_info_to_howto): Likewise. + * elf32-score.c (s3_bfd_score_info_to_howto) + (_bfd_score_info_to_howto): Likewise. + * elf32-score7.c (s7_bfd_score_info_to_howto): Likewise. + * elf32-sh.c (sh_elf_info_to_howto): Likewise. + * elf32-spu.c (spu_elf_info_to_howto): Likewise. + * elf32-tic6x.c (elf32_tic6x_info_to_howto) + (elf32_tic6x_info_to_howto_rel): Likewise. + * elf32-tilepro.c (tilepro_info_to_howto_rela): Likewise. + * elf32-v850.c (v850_elf_info_to_howto_rel) + (v850_elf_info_to_howto_rela, v800_elf_info_to_howto): Likewise. + * elf32-vax.c (rtype_to_howto): Likewise. + * elf32-visium.c (visium_info_to_howto_rela): Likewise. + * elf32-wasm32.c (elf32_wasm32_rtype_to_howto) + (elf32_wasm32_info_to_howto_rela): Likewise. + * elf32-xc16x.c (elf32_xc16x_info_to_howto): Likewise. + * elf32-xgate.c (xgate_info_to_howto_rel): Likewise. + * elf32-xstormy16.c (xstormy16_info_to_howto_rela): Likewise. + * elf32-xtensa.c (elf_xtensa_info_to_howto_rela): Likewise. + * elf64-alpha.c (elf64_alpha_info_to_howto): Likewise. + * elf64-gen.c (elf_generic_info_to_howto) + (elf_generic_info_to_howto_rel): Likewise. + * elf64-ia64-vms.c (elf64_ia64_info_to_howto): Likewise. + * elf64-mips.c (mips_elf64_info_to_howto_rela): Likewise. + * elf64-mmix.c (mmix_info_to_howto_rela): Likewise. + * elf64-ppc.c (ppc64_elf_info_to_howto): Likewise. + * elf64-s390.c (elf_s390_reloc_type_lookup): Likewise. + * elf64-sh64.c (elf_s390_info_to_howto, sh_elf64_info_to_howto): + Likewise. + * elf64-x86-64.c (elf_x86_64_info_to_howto): Likewise. + * elfn32-mips.c (mips_info_to_howto_rel, mips_info_to_howto_rela): + Likewise. + * elfnn-aarch64.c (elfNN_aarch64_info_to_howto): Likewise. + * elfnn-ia64.c (elfNN_ia64_info_to_howto): Likewise. + * elfnn-riscv.c (riscv_info_to_howto_rela): Likewise. + * elfxx-ia64.c (ia64_elf_reloc_type_lookup): Likewise. + * elfxx-sparc.c (_bfd_sparc_elf_info_to_howto): Likewise. + * elfxx-tilegx.c (tilegx_info_to_howto_rela): Likewise. + * elf32-score.h (s7_bfd_score_info_to_howto): Update prototype. + * elfxx-sparc.h (_bfd_sparc_elf_info_to_howto): Update prototype. + * elfxx-tilegx.h (tilegx_info_to_howto_rela): Update prototype. + * elfxx-target.h (elf_info_to_howto, elf_info_to_howto_rel): + Default to NULL. + +2018-02-26 Jim Wilson + Stephan Schreiber + + PR 15904 + * elfnn-ia64.c (elfNN_ia64_relax_section): After ia64_elf_relax_brl + call, set changed_contents and changed_relocs. Likewise after + successful ia64_elf_relax_br call. + +2018-02-26 Alan Modra + + * elf.c (assign_file_positions_except_relocs): Don't segfault + when actual number of phdrs is less than allocated. Delete + outdated comment. Formatting. + +2018-02-26 Alan Modra + + * elf-m10300.c, * elf-s390-common.c, * elf32-arc.c, * elf32-cris.c, + * elf32-dlx.c, * elf32-frv.c, * elf32-i370.c, * elf32-lm32.c, + * elf32-m32r.c, * elf32-m68hc1x.c, * elf32-m68k.c, + * elf32-microblaze.c, * elf32-msp430.c, * elf32-nds32.c, + * elf32-nios2.c, * elf32-or1k.c, * elf32-rl78.c, * elf32-rx.c, + * elf32-score.c, * elf32-score7.c, * elf32-sh-symbian.c, + * elf32-sh.c, * elf32-spu.c, * elf32-v850.c, * elf32-xtensa.c, + * elf64-alpha.c, * elf64-ia64-vms.c, * elf64-mmix.c, + * elf64-sh64.c, * elf64-sparc.c, * elfnn-ia64.c, * elfxx-tilegx.c, + * mmo.c, * osf-core.c, * srec.c, * vms-alpha.c: Standardize + error/warning messages. + +2018-02-26 Alan Modra + + * archive.c, * bfd.c, * linker.c, * reloc.c, * stabs.c, + * syms.c: Standardize error/warning messages. + +2018-02-26 Alan Modra + + * aout-adobe.c, * aout-cris.c, * i386linux.c, * m68klinux.c, + * sparclinux.c, * coff-alpha.c, * coff-arm.c, * coff-mcore.c, + * coffcode.h, * coffgen.c, * cofflink.c, * ecoff.c, * pe-mips.c, + * peXXigen.c, * peicode.h: Standardize error/warning messages. + +2018-02-26 Alan Modra + + * elf32-arm.c, * elfnn-aarch64.c: Standardize error/warning messages. + +2018-02-26 Alan Modra + + * elfxx-mips.c: Standardize error/warning messages. + +2018-02-26 Alan Modra + + * dwarf2.c, * elf-attrs.c, * elf-eh-frame.c, * elf.c, * elf32-gen.c, + * elflink.c: Standardize error/warning messages. Replace use of + linker callback einfo with _bfd_error_handler when possible. + +2018-02-26 Alan Modra + + * aoutx.h, * coff-alpha.c, * coff-i860.c, * coff-m68k.c, + * coff-mcore.c, * coff-ppc.c, * coff-rs6000.c, * coff-sh.c, + * coff-tic4x.c, * coff-tic54x.c, * coff-tic80.c, * coff-w65.c, + * elf-bfd.h, * elf-m10300.c, * elf.c, * elf32-avr.c, * elf32-bfin.c, + * elf32-cr16.c, * elf32-cr16c.c, * elf32-cris.c, * elf32-crx.c, + * elf32-d10v.c, * elf32-d30v.c, * elf32-dlx.c, * elf32-epiphany.c, + * elf32-fr30.c, * elf32-frv.c, * elf32-i370.c, * elf32-i386.c, + * elf32-i960.c, * elf32-ip2k.c, * elf32-iq2000.c, * elf32-lm32.c, + * elf32-m32c.c, * elf32-m32r.c, * elf32-m68hc11.c, * elf32-m68hc12.c, + * elf32-m68k.c, * elf32-mcore.c, * elf32-mep.c, * elf32-metag.c, + * elf32-microblaze.c, * elf32-mips.c, * elf32-moxie.c, + * elf32-msp430.c, * elf32-mt.c, * elf32-nds32.c, * elf32-or1k.c, + * elf32-pj.c, * elf32-ppc.c, * elf32-rl78.c, * elf32-rx.c, + * elf32-s390.c, * elf32-sh.c, * elf32-spu.c, * elf32-tic6x.c, + * elf32-v850.c, * elf32-vax.c, * elf32-visium.c, * elf32-wasm32.c, + * elf32-xgate.c, * elf32-xtensa.c, * elf64-alpha.c, + * elf64-ia64-vms.c, * elf64-mips.c, * elf64-mmix.c, + * elf64-ppc.c, * elf64-s390.c, * elf64-sparc.c, * elf64-x86-64.c, + * elfn32-mips.c, * elfnn-aarch64.c, * elfnn-ia64.c, + * elfnn-riscv.c, * elfxx-mips.c, * elfxx-riscv.c, * elfxx-riscv.h, + * elfxx-sparc.c, * elfxx-sparc.h, * reloc.c: Standardize + unrecognized/unsupported reloc message. + +2018-02-26 Alan Modra + + * elf32-ppc.c: Standardize error/warning messages. Use + _bfd_error_handler rather than einfo when einfo features not used. + * elf64-ppc.c: Likewise. + +2018-02-23 Alan Modra + + PR 22881 + * elf.c (assign_file_positions_for_non_load_sections): Remove RELRO + segment if no matching LOAD segment. + +2018-02-23 Kuan-Lin Chen + + * elf32-nds32.h: Define mask for ict_model. + +2018-02-20 Jason Duerstock + + * elfnn-ia64.c (elf_backend_can_gc_sections): Enable. + +2018-02-19 Maciej W. Rozycki + + Revert + 2018-01-12 Vlad Ivanov + + * elfxx-mips.c (_bfd_mips_elf_final_link): Notify user when + .reginfo section has wrong size. + +2018-02-19 Maciej W. Rozycki + + * elfxx-mips.c (_bfd_mips_elf_always_size_sections): Set + SEC_FIXED_SIZE and SEC_HAS_CONTENTS flags for `.reginfo' and + `.MIPS.abiflags' sections. + (_bfd_mips_elf_final_link): Avoid reading beyond `.reginfo' + section's end. + +2018-02-19 Maciej W. Rozycki + + * section.c (SEC_FIXED_SIZE): New macro. + * bfd-in2.h: Regenerate. + +2018-02-19 Maciej W. Rozycki + + * section.c (SEC_HAS_GOT_REF): Remove macro. + * bfd-in2.h: Regenerate. + +2018-02-19 Alan Modra + + * elf-attrs.c (_bfd_elf_parse_attributes): Correct _bfd_error_handler + arguments. + * elfxx-mips.c (_bfd_mips_elf_final_link): Likewise. + * elfnn-riscv.c (_bfd_riscv_relax_align): Likewise. + (_bfd_riscv_relax_pc): Likewise and fix typos. + * libbfd-in.h (_bfd_error_handler): Add attribute printf. + * libbfd.h: Regenerate. + +2018-02-19 Alan Modra + + * dwarf2.c (read_section): Don't use 'll' format modifier. + (find_abstract_instance): Likewise. + * elfcore.h (elf_core_file_p): Likewise. + +2018-02-19 Alan Modra + + * bfd-in.h: Include inttypes.h or if not available define + PRId64, PRIu64 and PRIx64. + * bfd.c (_bfd_doprnt, _bfd_doprnt_scan): Remove support for L + modifier to print bfd_vma. + * coff-arm.c, * coff-mcore.c, * coff-ppc.c, * coff-rs6000.c, + * coff-sh.c, * coff-tic80.c, * coffcode.h, * coffgen.c, * cofflink.c, + * compress.c, * dwarf2.c, * elf-m10300.c, * elf.c, * elf32-arc.c, + * elf32-arm.c, * elf32-bfin.c, * elf32-cris.c, * elf32-hppa.c, + * elf32-i386.c, * elf32-ip2k.c, * elf32-lm32.c, * elf32-m32r.c, + * elf32-m68k.c, * elf32-metag.c, * elf32-nds32.c, * elf32-nios2.c, + * elf32-ppc.c, * elf32-rx.c, * elf32-s390.c, * elf32-score.c, + * elf32-score7.c, * elf32-sh.c, * elf32-sh64.c, * elf32-spu.c, + * elf32-tic6x.c, * elf32-tilepro.c, * elf32-v850.c, * elf32-vax.c, + * elf32-xtensa.c, * elf64-alpha.c, * elf64-hppa.c, * elf64-ia64-vms.c, + * elf64-mmix.c, * elf64-s390.c, * elf64-sh64.c, * elf64-x86-64.c, + * elfcode.h, * elfcore.h, * elflink.c, * elfnn-aarch64.c, + * elfnn-ia64.c, * elfnn-riscv.c, * elfxx-mips.c, * elfxx-sparc.c, + * elfxx-tilegx.c, * ieee.c, * ihex.c, * mach-o.c, * merge.c, * mmo.c, + * peXXigen.c, * xcofflink.c: Replace use of Lx modifier with PRIx64, + and cast input to uint64_t, and similarly for Ld and Lu. + * bfd-in2.h: Regenerate. + +2018-02-19 Alan Modra + + * elf32-arm.c, * elf32-hppa.c, * elf32-lm32.c, * elf32-m32r.c, + * elf32-metag.c, * elf32-nds32.c, * elf32-or1k.c, * elf32-ppc.c, + * elf32-s390.c, * elf32-sh.c, * elf32-tic6x.c, * elf32-tilepro.c, + * elf64-ppc.c, * elf64-s390.c, * elflink.c, * elfnn-aarch64.c, + * elfnn-riscv.c, * elfxx-sparc.c, * elfxx-tilegx.c, * elfxx-x86.c, + * reloc.c: Replace use of %R and %T in format strings passed to + einfo and friends by %pR and %pT. + +2018-02-19 Alan Modra + + * bfd.c (_bfd_doprnt, _bfd_doprnt_scan): Handle %pA and %pB in place + of %A and %B. + * aout-adobe.c: Update all messages using %A and %B. + * aout-cris.c: Likewise. + * aoutx.h: Likewise. + * archive.c: Likewise. + * binary.c: Likewise. + * cache.c: Likewise. + * coff-alpha.c: Likewise. + * coff-arm.c: Likewise. + * coff-i860.c: Likewise. + * coff-mcore.c: Likewise. + * coff-ppc.c: Likewise. + * coff-rs6000.c: Likewise. + * coff-sh.c: Likewise. + * coff-tic4x.c: Likewise. + * coff-tic54x.c: Likewise. + * coff-tic80.c: Likewise. + * coff64-rs6000.c: Likewise. + * coffcode.h: Likewise. + * coffgen.c: Likewise. + * cofflink.c: Likewise. + * coffswap.h: Likewise. + * compress.c: Likewise. + * cpu-arm.c: Likewise. + * ecoff.c: Likewise. + * elf-attrs.c: Likewise. + * elf-eh-frame.c: Likewise. + * elf-ifunc.c: Likewise. + * elf-m10300.c: Likewise. + * elf-properties.c: Likewise. + * elf-s390-common.c: Likewise. + * elf.c: Likewise. + * elf32-arc.c: Likewise. + * elf32-arm.c: Likewise. + * elf32-avr.c: Likewise. + * elf32-bfin.c: Likewise. + * elf32-cr16.c: Likewise. + * elf32-cr16c.c: Likewise. + * elf32-cris.c: Likewise. + * elf32-crx.c: Likewise. + * elf32-d10v.c: Likewise. + * elf32-d30v.c: Likewise. + * elf32-epiphany.c: Likewise. + * elf32-fr30.c: Likewise. + * elf32-frv.c: Likewise. + * elf32-gen.c: Likewise. + * elf32-hppa.c: Likewise. + * elf32-i370.c: Likewise. + * elf32-i386.c: Likewise. + * elf32-i960.c: Likewise. + * elf32-ip2k.c: Likewise. + * elf32-iq2000.c: Likewise. + * elf32-lm32.c: Likewise. + * elf32-m32c.c: Likewise. + * elf32-m32r.c: Likewise. + * elf32-m68hc11.c: Likewise. + * elf32-m68hc12.c: Likewise. + * elf32-m68hc1x.c: Likewise. + * elf32-m68k.c: Likewise. + * elf32-mcore.c: Likewise. + * elf32-mep.c: Likewise. + * elf32-metag.c: Likewise. + * elf32-microblaze.c: Likewise. + * elf32-moxie.c: Likewise. + * elf32-msp430.c: Likewise. + * elf32-mt.c: Likewise. + * elf32-nds32.c: Likewise. + * elf32-nios2.c: Likewise. + * elf32-or1k.c: Likewise. + * elf32-pj.c: Likewise. + * elf32-ppc.c: Likewise. + * elf32-rl78.c: Likewise. + * elf32-rx.c: Likewise. + * elf32-s390.c: Likewise. + * elf32-score.c: Likewise. + * elf32-score7.c: Likewise. + * elf32-sh-symbian.c: Likewise. + * elf32-sh.c: Likewise. + * elf32-sh64.c: Likewise. + * elf32-sparc.c: Likewise. + * elf32-spu.c: Likewise. + * elf32-tic6x.c: Likewise. + * elf32-tilepro.c: Likewise. + * elf32-v850.c: Likewise. + * elf32-vax.c: Likewise. + * elf32-visium.c: Likewise. + * elf32-wasm32.c: Likewise. + * elf32-xgate.c: Likewise. + * elf32-xtensa.c: Likewise. + * elf64-alpha.c: Likewise. + * elf64-gen.c: Likewise. + * elf64-hppa.c: Likewise. + * elf64-ia64-vms.c: Likewise. + * elf64-mmix.c: Likewise. + * elf64-ppc.c: Likewise. + * elf64-s390.c: Likewise. + * elf64-sh64.c: Likewise. + * elf64-sparc.c: Likewise. + * elf64-x86-64.c: Likewise. + * elfcode.h: Likewise. + * elfcore.h: Likewise. + * elflink.c: Likewise. + * elfnn-aarch64.c: Likewise. + * elfnn-ia64.c: Likewise. + * elfnn-riscv.c: Likewise. + * elfxx-mips.c: Likewise. + * elfxx-sparc.c: Likewise. + * elfxx-tilegx.c: Likewise. + * elfxx-x86.c: Likewise. + * hpux-core.c: Likewise. + * ieee.c: Likewise. + * ihex.c: Likewise. + * libbfd.c: Likewise. + * linker.c: Likewise. + * mach-o.c: Likewise. + * merge.c: Likewise. + * mmo.c: Likewise. + * oasys.c: Likewise. + * pdp11.c: Likewise. + * pe-mips.c: Likewise. + * peXXigen.c: Likewise. + * peicode.h: Likewise. + * reloc.c: Likewise. + * rs6000-core.c: Likewise. + * srec.c: Likewise. + * stabs.c: Likewise. + * vms-alpha.c: Likewise. + * xcofflink.c: Likewise. + +2018-02-19 Alan Modra + + PR 22845 + * elf.c (IS_TBSS): Define. + (_bfd_elf_map_sections_to_segments): Use IS_TBSS. + (assign_file_positions_for_non_load_sections): Revert last change. + Properly calculate load segment limits to compare against relro limits. + +2018-02-17 Alan Modra + + PR 22845 + * elf.c (assign_file_positions_for_non_load_sections): Ignore + degenerate zero size PT_LOAD segments when finding one overlapping + the PT_GNU_RELRO segment. + +2018-02-16 Alan Modra + + * libbfd.c (_bfd_bool_bfd_false_error): Rename from bfd_false. + (_bfd_bool_bfd_true): Rename from bfd_true. + (_bfd_ptr_bfd_null_error): Rename from bfd_nullvoidptr. + (_bfd_int_bfd_0): Rename from bfd_0. + (_bfd_uint_bfd_0): Rename from bfd_0u. + (_bfd_long_bfd_0): Rename from bfd_0l. + (_bfd_long_bfd_n1_error): Rename from _bfd_n1. + (_bfd_void_bfd): Rename from bfd_void. + (_bfd_bool_bfd_false, _bfd_bool_bfd_asymbol_false), + (_bfd_bool_bfd_link_false_error), + (_bfd_bool_bfd_link_true, _bfd_bool_bfd_bfd_true), + (_bfd_bool_bfd_uint_true, _bfd_bool_bfd_ptr_true), + (_bfd_bool_bfd_asection_bfd_asection_true), + (_bfd_bool_bfd_asymbol_bfd_asymbol_true), + (_bfd_void_bfd_link, _bfd_void_bfd_asection): New functions. + * archive.c (_bfd_noarchive_get_elt_at_index), + (_bfd_noarchive_openr_next_archived_file), + (_bfd_noarchive_construct_extended_name_table), + (_bfd_noarchive_write_ar_hdr, _bfd_noarchive_truncate_arname), + (_bfd_noarchive_write_armap): New functions. + * archures.c (_bfd_nowrite_set_arch_mach): New function. + * coff-alpha.c (alpha_ecoff_swap_coff_aux_in), + (alpha_ecoff_swap_coff_sym_in, alpha_ecoff_swap_coff_lineno_in), + (alpha_ecoff_swap_coff_aux_out, alpha_ecoff_swap_coff_sym_out), + (alpha_ecoff_swap_coff_lineno_out), + (alpha_ecoff_swap_coff_reloc_out): New functions. + * coff-mips.c (mips_ecoff_swap_coff_aux_in), + (mips_ecoff_swap_coff_sym_in, mips_ecoff_swap_coff_lineno_in), + (mips_ecoff_swap_coff_aux_out, mips_ecoff_swap_coff_sym_out), + (mips_ecoff_swap_coff_lineno_out), + (mips_ecoff_swap_coff_reloc_out): New functions. + * coffcode.h (coff_set_alignment_hook): Replace define with + new function. + (symname_in_debug_hook): Likewise. + * ecoff.c (_bfd_ecoff_set_alignment_hook): New function. + * elfxx-target.h (elf_backend_allow_non_load_phdr): Default to 0. + * elf.c (assign_file_positions_except_relocs): Test + elf_backend_allow_non_load_phdr for NULL. + * elflink.c (_bfd_elf_omit_section_dynsym_default): Rename from + _bfd_elf_link_omit_section_dynsym. Update uses. + (_bfd_elf_omit_section_dynsym_all): New function. + * elf-bfd.h (_bfd_elf_link_omit_section_dynsym): Delete. + (_bfd_elf_omit_section_dynsym_default): Declare. + (_bfd_elf_omit_section_dynsym_all): Declare. + * linker.c (_bfd_nolink_sizeof_headers, _bfd_nolink_bfd_relax_section), + (_bfd_nolink_bfd_get_relocated_section_contents), + (_bfd_nolink_bfd_lookup_section_flags), + (_bfd_nolink_bfd_is_group_section, _bfd_nolink_bfd_discard_group), + (_bfd_nolink_bfd_link_hash_table_create), + (_bfd_nolink_bfd_link_just_syms), + (_bfd_nolink_bfd_copy_link_hash_symbol_type), + (_bfd_nolink_bfd_link_split_section), + (_bfd_nolink_section_already_linked), + (_bfd_nolink_bfd_define_common_symbol), + (_bfd_nolink_bfd_define_start_stop): New functions. + * reloc.c (_bfd_norelocs_bfd_reloc_type_lookup), + (_bfd_norelocs_bfd_reloc_name_lookup), + (_bfd_nodynamic_canonicalize_dynamic_reloc): New functions. + * section.c (_bfd_nowrite_set_section_contents): New function. + * syms.c (_bfd_nosymbols_canonicalize_symtab), + (_bfd_nosymbols_print_symbol, _bfd_nosymbols_get_symbol_info), + (_bfd_nosymbols_get_symbol_version_string), + (_bfd_nosymbols_bfd_is_local_label_name), + (_bfd_nosymbols_get_lineno, _bfd_nosymbols_find_nearest_line), + (_bfd_nosymbols_find_line, _bfd_nosymbols_find_inliner_info), + (_bfd_nosymbols_bfd_make_debug_symbol), + ( _bfd_nosymbols_read_minisymbols), + ( _bfd_nosymbols_minisymbol_to_symbol), + (_bfd_nodynamic_get_synthetic_symtab): New functions. + * libbfd-in.h: Declare new functions. Update existing defines, + removing casts. + * aix386-core.c: Update to use new hooks. Formatting. + * aout-adobe.c: Likewise. + * aout-arm.c: Likewise. + * aout-target.h: Likewise. + * aout-tic30.c: Likewise. + * aoutf1.h: Likewise. + * binary.c: Likewise. + * bout.c: Likewise. + * cisco-core.c: Likewise. + * coff-alpha.c: Likewise. + * coff-i386.c: Likewise. + * coff-i860.c: Likewise. + * coff-i960.c: Likewise. + * coff-ia64.c: Likewise. + * coff-mips.c: Likewise. + * coff-ppc.c: Likewise. + * coff-rs6000.c: Likewise. + * coff-sh.c: Likewise. + * coff-tic30.c: Likewise. + * coff-tic54x.c: Likewise. + * coff-x86_64.c: Likewise. + * coff64-rs6000.c: Likewise. + * coffcode.h: Likewise. + * elf-m10300.c: Likewise. + * elf32-cr16.c: Likewise. + * elf32-lm32.c: Likewise. + * elf32-m32r.c: Likewise. + * elf32-metag.c: Likewise. + * elf32-score.c: Likewise. + * elf32-score7.c: Likewise. + * elf32-tilepro.c: Likewise. + * elf32-xstormy16.c: Likewise. + * elf32-xtensa.c: Likewise. + * elf64-alpha.c: Likewise. + * elf64-hppa.c: Likewise. + * elf64-ia64-vms.c: Likewise. + * elf64-mmix.c: Likewise. + * elf64-sh64.c: Likewise. + * elfnn-ia64.c: Likewise. + * elfxx-sparc.c: Likewise. + * elfxx-target.h: Likewise. + * elfxx-tilegx.c: Likewise. + * elfxx-x86.h: Likewise. + * hp300hpux.c: Likewise. + * hppabsd-core.c: Likewise. + * hpux-core.c: Likewise. + * i386msdos.c: Likewise. + * i386os9k.c: Likewise. + * ieee.c: Likewise. + * ihex.c: Likewise. + * irix-core.c: Likewise. + * libaout.h: Likewise. + * libecoff.h: Likewise. + * mach-o-target.c: Likewise. + * mach-o.c: Likewise. + * mipsbsd.c: Likewise. + * mmo.c: Likewise. + * netbsd-core.c: Likewise. + * nlm-target.h: Likewise. + * oasys.c: Likewise. + * osf-core.c: Likewise. + * pdp11.c: Likewise. + * pe-mips.c: Likewise. + * pe-x86_64.c: Likewise. + * pef.c: Likewise. + * plugin.c: Likewise. + * ppcboot.c: Likewise. + * ptrace-core.c: Likewise. + * sco5-core.c: Likewise. + * som.c: Likewise. + * sparclynx.c: Likewise. + * srec.c: Likewise. + * tekhex.c: Likewise. + * trad-core.c: Likewise. + * verilog.c: Likewise. + * versados.c: Likewise. + * vms-alpha.c: Likewise. + * vms-lib.c: Likewise. + * wasm-module.c: Likewise. + * xsym.c: Likewise. + * libbfd.h: Regenerate. + +2018-02-15 Jim Wilson + + * elfnn-riscv.c (_bfd_riscv_relax_section): Ifdef out check to ignore + symbols whose section address is zero. + + * elfnn-riscv.c (riscv_elf_relocate_section): Use bfd_reloc_dangerous + when pcrel_lo reloc has an addend. Use reloc_dangerous callback for + bfd_reloc_dangerous. Use einfo instead of warning callback for errors. + Add %X%P to error messages. + +2018-02-15 Eric Botcazou + + PR ld/22832 + * elfxx-sparc.c (_bfd_sparc_elf_check_relocs) : + Pass FALSE instead of TRUE as 'create' argument to bfd_link_hash_lookup + and assert that the result of the call is not NULL. + +2018-02-14 Nick Clifton + + PR 22823 + Revert previous delta. Add extra casts to avoid compile time + warnings instead. + * libbfd-in.h (_bfd_generic_bfd_copy_private_bfd_data): Add extra + cast to avoid warning from gcc v8 compiler. + (_bfd_generic_bfd_merge_private_bfd_data): Likewise. + (_bfd_generic_bfd_set_private_flags): Likewise. + (_bfd_generic_bfd_copy_private_section_data): Likewise. + (_bfd_generic_bfd_copy_private_symbol_data): Likewise. + (_bfd_generic_bfd_copy_private_header_data): Likewise. + (_bfd_generic_bfd_print_private_bfd_data): Likewise. + (_bfd_noarchive_construct_extended_name_table): Likewise. + (_bfd_noarchive_truncate_arname): Likewise. + (_bfd_noarchive_write_ar_hdr): Likewise. + (_bfd_noarchive_get_elt_at_index): Likewise. + (_bfd_nosymbols_canonicalize_symtab): Likewise. + (_bfd_nosymbols_print_symbol): Likewise. + (_bfd_nosymbols_get_symbol_info): Likewise. + (_bfd_nosymbols_get_symbol_version_string): Likewise. + (_bfd_nosymbols_bfd_is_local_label_name): Likewise. + (_bfd_nosymbols_bfd_is_target_special_symbol): Likewise. + (_bfd_nosymbols_get_lineno): Likewise. + (_bfd_nosymbols_find_nearest_line): Likewise. + (_bfd_nosymbols_find_line): Likewise. + (_bfd_nosymbols_find_inliner_info): Likewise. + (_bfd_nosymbols_bfd_make_debug_symbol): Likewise. + (_bfd_nosymbols_read_minisymbols): Likewise. + (_bfd_nosymbols_minisymbol_to_symbol): Likewise. + (_bfd_norelocs_bfd_reloc_type_lookup): Likewise. + (_bfd_norelocs_bfd_reloc_name_lookup): Likewise. + (_bfd_nowrite_set_arch_mach): Likewise. + (_bfd_nowrite_set_section_contents): Likewise. + (_bfd_nolink_sizeof_headers): Likewise. + (_bfd_nolink_bfd_get_relocated_section_contents): Likewise. + (_bfd_nolink_bfd_relax_section): Likewise. + (_bfd_nolink_bfd_gc_sections): Likewise. + (_bfd_nolink_bfd_lookup_section_flags): Likewise. + (_bfd_nolink_bfd_merge_sections): Likewise. + (_bfd_nolink_bfd_is_group_section): Likewise. + (_bfd_nolink_bfd_discard_group): Likewise. + (_bfd_nolink_bfd_link_hash_table_create): Likewise. + (_bfd_nolink_bfd_link_add_symbols): Likewise. + (_bfd_nolink_bfd_link_just_syms): Likewise. + (_bfd_nolink_bfd_copy_link_hash_symbol_type): Likewise. + (_bfd_nolink_bfd_final_link): Likewise. + (_bfd_nolink_bfd_link_split_section): Likewise. + (_bfd_nolink_section_already_linked): Likewise. + (_bfd_nolink_bfd_define_common_symbol): Likewise. + (_bfd_nolink_bfd_define_start_stop): Likewise. + (_bfd_nodynamic_canonicalize_dynamic_symtab): Likewise. + (_bfd_nodynamic_get_synthetic_symtab): Likewise. + (_bfd_nodynamic_get_dynamic_reloc_upper_bound _bfd_): Likewise. + (_bfd_nodynamic_canonicalize_dynamic_reloc): Likewise. + * libbfd.c (bfd_false_any): Delete. + (bfd_true_any, bfd_nullvoidptr_any, bfd_0_any): Delete. + (bfd_0u_any, bfd_0l_any, _bfd_n1_any, bfd_void_any): Delete. + * libbfd.h (extern): Regenerate + * aout-target.h (MY_bfd_is_target_special_symbol): Add extra + cast to avoid warning from gcc v8 compiler. + * aout-tic30.c (tic30_aout_set_arch_mach): Likewise. + * binary.c (binary_get_symbol_info): Likewise. + * coff-alpha.c (alpha_ecoff_backend_data): Likewise. + * coff-mips.c (mips_ecoff_backend_data): Likewise. + * coffcode.h (coff_set_alignment_hook): Likewise. + (symname_in_debug_hook): Likewise. + (bfd_coff_backend_data bigobj_swap_table): Likewise. + * elf-m10300.c (elf_backend_omit_section_dynsym): Likewise. + * elf32-cr16.c (elf_backend_omit_section_dynsym): Likewise. + * elf32-lm32.c (elf_backend_omit_section_dynsym): Likewise. + * elf32-m32r.c (elf_backend_omit_section_dynsym): Likewise. + * elf32-metag.c (elf_backend_omit_section_dynsym): Likewise. + * elf32-score.c (elf_backend_omit_section_dynsym): Likewise. + * elf32-score7.c (elf_backend_omit_section_dynsym): Likewise. + * elf32-xstormy16.c (elf_backend_omit_section_dynsym): Likewise. + * elf32-xtensa.c (elf_backend_omit_section_dynsym): Likewise. + * elf64-alpha.c (elf_backend_omit_section_dynsym): Likewise. + * elf64-hppa.c (elf_backend_omit_section_dynsym): Likewise. + * elf64-ia64-vms.c (elf_backend_omit_section_dynsym): Likewise. + * elf64-mmix.c (elf_backend_omit_section_dynsym): Likewise. + * elf64-sh64.c (elf_backend_omit_section_dynsym): Likewise. + * elfnn-ia64.c (elf_backend_omit_section_dynsym): Likewise. + * elfxx-target.h (bfd_elfNN_bfd_debug_info_accumulate): Likewise. + (bfd_elfNN_bfd_make_debug_symbol): Likewise. + (bfd_elfNN_bfd_merge_private_bfd_data): Likewise. + (bfd_elfNN_bfd_set_private_flags): Likewise. + (bfd_elfNN_bfd_is_target_special_symbol): Likewise. + (elf_backend_init_index_section): Likewise. + (elf_backend_allow_non_load_phdr): Likewise. + * elfxx-x86.h (elf_backend_omit_section_dynsym): Likewise. + * i386msdos.c (msdos_bfd_is_target_special_symbol): Likewise. + * ieee.c (ieee_construct_extended_name_table): Likewise. + (ieee_write_armap): Likewise. + (ieee_write_ar_hdr): Likewise. + (ieee_bfd_is_target_special_symbol): Likewise. + * ihex.c (ihex_canonicalize_symtab): Likewise. + (ihex_bfd_is_target_special_symbol): Likewise. + * libaout.h (aout_32_bfd_is_target_special_symbol): Likewise. + * libecoff.h (_bfd_ecoff_bfd_is_target_special_symbol): Likewise. + (_bfd_ecoff_set_alignment_hook): Likewise. + * mach-o-target.c (bfd_mach_o_bfd_is_target_special_symbol): Likewise. + * mmo.c (mmo_bfd_is_target_special_symbol): Likewise. + * nlm-target.h (nlm_bfd_is_target_special_symbol): Likewise. + * oasys.c (oasys_construct_extended_name_table): Likewise. + (oasys_write_armap): Likewise. + (oasys_write_ar_hdr): Likewise. + (oasys_bfd_is_target_special_symbol): Likewise. + * pef.c (bfd_pef_bfd_is_target_special_symbol): Likewise. + * plugin.c (bfd_plugin_bfd_is_target_special_symbol): Likewise. + * ppcboot.c (ppcboot_bfd_is_target_special_symbol): Likewise. + * som.c (som_bfd_is_target_special_symbol): Likewise. + * srec.c (srec_bfd_is_target_special_symbol): Likewise. + * tekhex.c (tekhex_bfd_is_target_special_symbol): Likewise. + * verilog.c (verilog_bfd_is_target_special_symbol): Likewise. + * versados.c (versados_bfd_is_target_special_symbol): Likewise. + (versados_bfd_reloc_name_lookup): Likewise. + * vms-alpha.c (vms_bfd_is_target_special_symbol): Likewise. + (vms_bfd_define_start_stop): Likewise. + (alpha_vms_bfd_is_target_special_symbol): Likewise. + * wasm-module.c (wasm_bfd_is_target_special_symbol): Likewise. + * xsym.c (bfd_sym_bfd_is_target_special_symbol): Likewise. + +2018-02-14 H.J. Lu + + PR ld/22842 + * elf32-i386.c (elf_i386_check_relocs): Pass FALSE for non + PC-relative PLT to NEED_DYNAMIC_RELOCATION_P. + * elf64-x86-64.c (elf_x86_64_check_relocs): Create PLT for + R_X86_64_PC32 reloc against dynamic function in data section. + Pass TRUE for PC-relative PLT to NEED_DYNAMIC_RELOCATION_P. + (elf_x86_64_relocate_section): Use PLT for R_X86_64_PC32 reloc + against dynamic function in data section. + * elfxx-x86.c (elf_x86_allocate_dynrelocs): Use PLT in PIE as + function address only if pcrel_plt is true. + (_bfd_x86_elf_link_hash_table_create): Set pcrel_plt. + * elfxx-x86.h (NEED_DYNAMIC_RELOCATION_P): Add PCREL_PLT for + PC-relative PLT. If PLT is PC-relative, don't generate dynamic + PC-relative relocation against a function definition in data + secton in PIE. Remove the obsolete comments. + (elf_x86_link_hash_table): Add pcrel_plt. + +2018-02-13 H.J. Lu + + * elfxx-x86.c (elf_x86_allocate_dynrelocs): Check bfd_link_dll, + instead of bfd_link_pic, for building shared library. + +2018-02-13 H.J. Lu + + PR gas/22791 + * elf64-x86-64.c (is_32bit_relative_branch): Removed. + (elf_x86_64_relocate_section): Check PIC relocations in PIE. + Remove is_32bit_relative_branch usage. Disallow PC32 reloc + against protected function in shared object. + +2018-02-13 Sergei Trofimovich + + PR 22828 + * po/ru.po: Fix typo in Russian translation. + +2018-02-13 Maciej W. Rozycki + + * wasm-module.c (wasm_scan_name_function_section): Rename + `index' local variable to `idx'. + +2018-02-13 Nick Clifton + + PR 22823 + Fix compile time warnings generated by gcc version 8. + * libbfd-in.h: Remove extraneous text from prototypes. + Add prototypes for bfd_false_any, bfd_true_any, + bfd_nullvoidptr_any, bfd_0_any, bfd_0u_any, bfd_0l_any, + bfd_n1_any, bfd_void_any. + (_bfd_generic_bfd_copy_private_bfd_data): Use vararg based dummy + function. + (_bfd_generic_bfd_merge_private_bfd_data): Likewise. + (_bfd_generic_bfd_set_private_flags): Likewise. + (_bfd_generic_bfd_copy_private_section_data): Likewise. + (_bfd_generic_bfd_copy_private_symbol_data): Likewise. + (_bfd_generic_bfd_copy_private_header_data): Likewise. + (_bfd_generic_bfd_print_private_bfd_data): Likewise. + (_bfd_noarchive_construct_extended_name_table): Likewise. + (_bfd_noarchive_truncate_arname): Likewise. + (_bfd_noarchive_write_ar_hdr): Likewise. + (_bfd_noarchive_get_elt_at_index): Likewise. + (_bfd_nosymbols_canonicalize_symtab): Likewise. + (_bfd_nosymbols_print_symbol): Likewise. + (_bfd_nosymbols_get_symbol_info): Likewise. + (_bfd_nosymbols_get_symbol_version_string): Likewise. + (_bfd_nosymbols_bfd_is_local_label_name): Likewise. + (_bfd_nosymbols_bfd_is_target_special_symbol): Likewise. + (_bfd_nosymbols_get_lineno): Likewise. + (_bfd_nosymbols_find_nearest_line): Likewise. + (_bfd_nosymbols_find_line): Likewise. + (_bfd_nosymbols_find_inliner_info): Likewise. + (_bfd_nosymbols_bfd_make_debug_symbol): Likewise. + (_bfd_nosymbols_read_minisymbols): Likewise. + (_bfd_nosymbols_minisymbol_to_symbol): Likewise. + (_bfd_norelocs_bfd_reloc_type_lookup): Likewise. + (_bfd_norelocs_bfd_reloc_name_lookup): Likewise. + (_bfd_nowrite_set_arch_mach): Likewise. + (_bfd_nowrite_set_section_contents): Likewise. + (_bfd_nolink_sizeof_headers): Likewise. + (_bfd_nolink_bfd_get_relocated_section_contents): Likewise. + (_bfd_nolink_bfd_relax_section): Likewise. + (_bfd_nolink_bfd_gc_sections): Likewise. + (_bfd_nolink_bfd_lookup_section_flags): Likewise. + (_bfd_nolink_bfd_merge_sections): Likewise. + (_bfd_nolink_bfd_is_group_section): Likewise. + (_bfd_nolink_bfd_discard_group): Likewise. + (_bfd_nolink_bfd_link_hash_table_create): Likewise. + (_bfd_nolink_bfd_link_add_symbols): Likewise. + (_bfd_nolink_bfd_link_just_syms): Likewise. + (_bfd_nolink_bfd_copy_link_hash_symbol_type): Likewise. + (_bfd_nolink_bfd_final_link): Likewise. + (_bfd_nolink_bfd_link_split_section): Likewise. + (_bfd_nolink_section_already_linked): Likewise. + (_bfd_nolink_bfd_define_common_symbol): Likewise. + (_bfd_nolink_bfd_define_start_stop): Likewise. + (_bfd_nodynamic_canonicalize_dynamic_symtab): Likewise. + (_bfd_nodynamic_get_synthetic_symtab): Likewise. + (_bfd_nodynamic_get_dynamic_reloc_upper_bound _bfd_): Likewise. + (_bfd_nodynamic_canonicalize_dynamic_reloc): Likewise. + * libbfd.c (bfd_false_any): New function. Like bfd_false but + accepts one or more arguments. + (bfd_true_any): Likewise. + (bfd_nullvoidptr_any): Likewise. + (bfd_0_any): Likewise. + (bfd_0u_any): Likewise. + (bfd_0l_any): Likewise. + (_bfd_n1_any): Likewise. + (bfd_void_any): Likewise. + * libbfd.h (extern): Regenerate + * aout-target.h (MY_bfd_is_target_special_symbol): Use vararg + based dummy function. + * aout-tic30.c (tic30_aout_set_arch_mach): Likewise. + * binary.c (binary_get_symbol_info): Likewise. + * coff-alpha.c (alpha_ecoff_backend_data): Likewise. + * coff-mips.c (mips_ecoff_backend_data): Likewise. + * coffcode.h (coff_set_alignment_hook): Likewise. + (symname_in_debug_hook): Likewise. + (bfd_coff_backend_data bigobj_swap_table): Likewise. + * elf-m10300.c (elf_backend_omit_section_dynsym): Likewise. + * elf32-cr16.c (elf_backend_omit_section_dynsym): Likewise. + * elf32-lm32.c (elf_backend_omit_section_dynsym): Likewise. + * elf32-m32r.c (elf_backend_omit_section_dynsym): Likewise. + * elf32-metag.c (elf_backend_omit_section_dynsym): Likewise. + * elf32-score.c (elf_backend_omit_section_dynsym): Likewise. + * elf32-score7.c (elf_backend_omit_section_dynsym): Likewise. + * elf32-xstormy16.c (elf_backend_omit_section_dynsym): Likewise. + * elf32-xtensa.c (elf_backend_omit_section_dynsym): Likewise. + * elf64-alpha.c (elf_backend_omit_section_dynsym): Likewise. + * elf64-hppa.c (elf_backend_omit_section_dynsym): Likewise. + * elf64-ia64-vms.c (elf_backend_omit_section_dynsym): Likewise. + * elf64-mmix.c (elf_backend_omit_section_dynsym): Likewise. + * elf64-sh64.c (elf_backend_omit_section_dynsym): Likewise. + * elfnn-ia64.c (elf_backend_omit_section_dynsym): Likewise. + * elfxx-target.h (bfd_elfNN_bfd_debug_info_accumulate): Likewise. + (bfd_elfNN_bfd_make_debug_symbol): Likewise. + (bfd_elfNN_bfd_merge_private_bfd_data): Likewise. + (bfd_elfNN_bfd_set_private_flags): Likewise. + (bfd_elfNN_bfd_is_target_special_symbol): Likewise. + (elf_backend_init_index_section): Likewise. + (elf_backend_allow_non_load_phdr): Likewise. + * elfxx-x86.h (elf_backend_omit_section_dynsym): Likewise. + * i386msdos.c (msdos_bfd_is_target_special_symbol): Likewise. + * ieee.c (ieee_construct_extended_name_table): Likewise. + (ieee_write_armap): Likewise. + (ieee_write_ar_hdr): Likewise. + (ieee_bfd_is_target_special_symbol): Likewise. + * ihex.c (ihex_canonicalize_symtab): Likewise. + (ihex_bfd_is_target_special_symbol): Likewise. + * libaout.h (aout_32_bfd_is_target_special_symbol): Likewise. + * libecoff.h (_bfd_ecoff_bfd_is_target_special_symbol): Likewise. + (_bfd_ecoff_set_alignment_hook): Likewise. + * mach-o-target.c (bfd_mach_o_bfd_is_target_special_symbol): Likewise. + * mmo.c (mmo_bfd_is_target_special_symbol): Likewise. + * nlm-target.h (nlm_bfd_is_target_special_symbol): Likewise. + * oasys.c (oasys_construct_extended_name_table): Likewise. + (oasys_write_armap): Likewise. + (oasys_write_ar_hdr): Likewise. + (oasys_bfd_is_target_special_symbol): Likewise. + * pef.c (bfd_pef_bfd_is_target_special_symbol): Likewise. + * plugin.c (bfd_plugin_bfd_is_target_special_symbol): Likewise. + * ppcboot.c (ppcboot_bfd_is_target_special_symbol): Likewise. + * som.c (som_bfd_is_target_special_symbol): Likewise. + * srec.c (srec_bfd_is_target_special_symbol): Likewise. + * tekhex.c (tekhex_bfd_is_target_special_symbol): Likewise. + * verilog.c (verilog_bfd_is_target_special_symbol): Likewise. + * versados.c (versados_bfd_is_target_special_symbol): Likewise. + (versados_bfd_reloc_name_lookup): Likewise. + * vms-alpha.c (vms_bfd_is_target_special_symbol): Likewise. + (vms_bfd_define_start_stop): Likewise. + (alpha_vms_bfd_is_target_special_symbol): Likewise. + * wasm-module.c (wasm_bfd_is_target_special_symbol): Likewise. + * xsym.c (bfd_sym_bfd_is_target_special_symbol): Likewise. + * elf32-arc.c (get_replace_function): Assign replacement function + to func pointer. + * elf32-i370.c (i370_noop): Update prototype. + +2018-02-13 Alan Modra + + PR 22836 + * elf.c (_bfd_elf_fixup_group_sections): Account for removed + relocation sections. If size reduces to just the flag word, + remove that too and mark with SEC_EXCLUDE. + * elflink.c (bfd_elf_final_link): Strip empty group sections. + +2018-02-13 Alan Modra + + PR 22829 + * elf.c (assign_file_positions_for_non_load_sections): Rewrite + PT_GNU_RELRO setup. + +2018-02-12 Zebediah Figura + + * i386msdos.c (msdos_mkobject); New function. + (msdos_object_p): New function. + (i386_msdos_vec): Use msdos_object_p as the check_format + function. + * peicode.h: Rename external_PEI_DOS_hdr, DOSMAGIC, and + NT_SIGNATURE to external_DOS_hdr, IMAGE_DOS_SIGNATURE, and + IMAGE_NT_SIGNATURE. + * peXXigen.c: Likewise. + * coff-ia64.c: Likewise. + +2018-02-12 Nick Clifton + + * elf32-nds32.c (nds32_elf_relax_longjump3): Remove redundant + assignment. + * elf32-arc.c (elf_arc_relocate_section): Likewise. + +2018-02-09 Eric Botcazou + + * elfxx-sparc.c (UNDEFINED_WEAK_RESOLVED_TO_ZERO): Reorder conditions. + (sparc_elf_append_rela): Assert that there is enough room in section. + (_bfd_sparc_elf_copy_indirect_symbol): Fix formatting. + (_bfd_sparc_elf_adjust_dynamic_symbol): Minor tweak. + (allocate_dynrelocs): Remove outdated comments and reorder conditions. + For a symbol subject to a GOT relocation, reserve a slot in the + relocation section if the symbol isn't dynamic and we are in PIC mode. + (_bfd_sparc_elf_relocate_section) : If relocation + is relaxed and a slot was reserved, generate a R_SPARC_NONE relocation. + : Adjust comments. + : Reorder conditions. Remove always-false assertion. + (_bfd_sparc_elf_finish_dynamic_symbol): Rename local_undefweak into + resolved_to_zero. Do not generate a dynamic GOT relocation for an + undefined weak symbol with non-default visibility. Remove superfluous + 'else' and fix formatting. + +2018-02-09 H.J. Lu + + * elf32-i386.c (elf_i386_get_synthetic_symtab): Also handle + is_solaris. + (i386_elf32_sol2_vec): Don't declare. + (elf_i386_link_setup_gnu_properties): Also handle is_solaris. + Don't set need_global_offset_table. + (elf_i386_solaris_arch_bed): New. + (elf_backend_arch_data): Set to elf_i386_solaris_arch_bed for + Solaris. + * elf64-x86-64.c (elf_x86_64_get_synthetic_symtab): Check + target_os != is_nacl instead of target_os == is_normal. + (x86_64_elf64_sol2_vec): Don't declare. + (elf_x86_64_link_setup_gnu_properties): Check target_os != + is_nacl instead of target_os == is_normal. Don't set + need_global_offset_table. + (elf_x86_64_solaris_arch_bed): New. + (elf_backend_arch_data): Set to elf_x86_64_solaris_arch_bed for + Solaris. + * elfxx-x86.c (_bfd_x86_elf_size_dynamic_sections): Keep + _GLOBAL_OFFSET_TABLE_ for Solaris. + (_bfd_x86_elf_link_setup_gnu_properties): Don't copy + need_global_offset_table. + * elfxx-x86.h (elf_x86_target_os): Add is_solaris. + (elf_x86_link_hash_table): Remove need_global_offset_table. + (elf_x86_init_table): Likewise. + +2018-02-08 H.J. Lu + + * elf32-i386.c (elf32_i386_copy_solaris_special_section_fields): + Remove prototype. + (i386_elf32_sol2_vec): Declared. + (elf_i386_link_setup_gnu_properties): Set + need_global_offset_table with info->output_bfd->xvec. + * elf64-x86-64.c (elf64_x86_64_copy_solaris_special_section_fields): + Remove prototype. + (x86_64_elf64_sol2_vec): Declared. + (elf_x86_64_link_setup_gnu_properties): Set + need_global_offset_table with info->output_bfd->xvec. + +2018-02-08 H.J. Lu + + * elf32-i386.c (elf32_i386_copy_solaris_special_section_fields): + New prototype. + (elf_i386_link_setup_gnu_properties): Set need_global_offset_table + for Solaris. + * elf64-x86-64.c (elf64_x86_64_copy_solaris_special_section_fields): + New prototype. + (elf_x86_64_link_setup_gnu_properties): Set + need_global_offset_table for Solaris. + * elfxx-x86.c (_bfd_x86_elf_size_dynamic_sections): Keep the + unused _GLOBAL_OFFSET_TABLE_ for Solaris. + (_bfd_x86_elf_link_setup_gnu_properties): Copy + need_global_offset_table. + * elfxx-x86.h (elf_x86_link_hash_table): Add + need_global_offset_table. + (elf_x86_init_table): Likewise. + +2018-02-08 Jim Wilson + + * elfnn-riscv.c (riscv_elf_relocate_section): Add comment for previous + change. + +2018-02-08 Nick Clifton + + PR 22788 + * elf.c (elf_parse_notes): Reject notes with excessuively large + alignments. + +2018-02-07 Alan Modra + + Revert 2018-01-17 Alan Modra + * elf32-ppc.c: Remove speculation barrier support. + * elf32-ppc.h: Likewise. + * elf64-ppc.c: Likewise. + * elf64-ppc.h: Likewise. + +2018-02-06 Jim Wilson + + * elfnn-riscv.c (riscv_elf_relocate_section): Return TRUE if used + callback to report an error. + +2018-02-06 Eric Botcazou + + PR ld/22263 + * elfxx-sparc.c (sparc_elf_tls_transition): Turn call to bfd_link_pic + into call to !bfd_link_executable and tidy up. + (_bfd_sparc_elf_check_relocs): Fix formatting and tidy up. + : Turn call to bfd_link_pic into call to + !bfd_link_executable. + : Likewise. + : Remove useless code, tidy and merge related blocks. + : Turn call to bfd_link_pic into call to + !bfd_link_executable. + : Tidy up. + (_bfd_sparc_elf_gc_mark_hook): Turn call to bfd_link_pic into call to + !bfd_link_executable. + (allocate_dynrelocs): Likewise. + (_bfd_sparc_elf_relocate_section): Fix formatting and tidy up. + : Merge into... + : ...this. Adjust 4th argument in call to + sparc_elf_tls_transition and remove redundant code. + : Turn call to bfd_link_pic into call to + !bfd_link_executable. + : Likewise. + : Likewise. Tidy up. + : Likewise. + : Likewise. Tidy up. + : Likewise. + : Likewise. + : Likewise. + : Likewise. + +2018-02-06 Miloš Stojanović + + PR 22789 + * elfxx-mips.c (_bfd_mips_elf_find_nearest_line): If the dwarf + functions failed to find the function name, try the generic elf + find function instead. + +2018-02-06 Sergio Durigan Junior + + * coff-rs6000.c (xcoff_write_archive_contents_old): Use + 'memcpy' instead of 'strncpy' when writing the magic number. + +2018-02-06 Nick Clifton + + PR 22794 + * opncls.c (bfd_get_debug_link_info_1): Check the size of the + section before attempting to read it in. + (bfd_get_alt_debug_link_info): Likewise. + +2018-02-06 Paul Carroll + + * bfd/dwarf2.c (find_abstract_name): Modified to return file and + line information in addition to name, if they can be found. + +2018-02-05 Renlin Li + + PR ld/22764 + * elfnn-aarch64.c (elfNN_aarch64_check_relocs): Relax the + R_AARCH64_ABS32 and R_AARCH64_ABS16 for absolute symbol. Apply the + check for writeable section as well. + +2018-02-05 H.J. Lu + + PR ld/22782 + * elf32-i386.c (elf_i386_check_relocs): Set got_referenced if + _GLOBAL_OFFSET_TABLE_ is referenced or GOT is needed to resolve + undefined weak symbol to 0. + * elf64-x86-64.c (elf_x86_64_check_relocs): Set got_referenced + if _GLOBAL_OFFSET_TABLE_ is referenced. + * elfxx-x86.c (_bfd_x86_elf_size_dynamic_sections): Check + got_referenced instead of ref_regular_nonweak. Remove the + unused _GLOBAL_OFFSET_TABLE_ from symbol table. + * elfxx-x86.h (elf_x86_link_hash_table): Add got_referenced. + +2018-02-05 Maciej W. Rozycki + + * elfnn-riscv.c (_bfd_riscv_relax_pc): Use `memset' to + initialize `hi_reloc'. + +2018-02-05 Maciej W. Rozycki + + * elfxx-mips.c (_bfd_mips_elf_section_processing): For + SHT_MIPS_REGINFO sections don't assert the correct size and + report an error instead. + +2018-02-05 Maciej W. Rozycki + + * elf.c (_bfd_elf_write_object_contents): Propagate a failure + status from `->elf_backend_section_processing'. + +2018-02-02 Jim Wilson + + PR ld/22756 + * elfnn-riscv.c (riscv_relax_delete_bytes): New parameter link_info. + If link_info->wrap_hash, check for a duplicate symbol and ignore. + (_bfd_riscv_relax_call, bfd_riscv_relax_lui, _bfd_riscv_relax_tls_le): + Pass new argument to riscv_relax_delete_bytes. + (_bfd_riscv_relax_align, _bfd_riscv_relax_delete): Likewise. Remove + ATTRIBUTE_UNUSED from link_info parameter. + +2018-02-02 Alan Modra + + * elf64-ppc.c (ppc64_elf_relocate_section): Don't relocate nops + emitted for toc sequence optimization. Set and use "howto" later. + +2018-02-01 Simon Marchi + + * elf64-ppc.c (ppc64_elf_archive_symbol_lookup): Avoid pointer + arithmetic on NULL pointer. + * elflink.c (_bfd_elf_archive_symbol_lookup, + elf_link_add_archive_symbols): Likewise. + +2018-01-31 Michael Matz + + * elflink.c (bfd_elf_define_start_stop): Fix check of + def_dynamic. + +2018-01-31 H.J. Lu + + PR ld/21964 + * elflink.c (bfd_elf_define_start_stop): Check if __start and + __stop symbols are referenced by shared objects. + +2018-01-30 Alan Modra + + PR 22758 + * elf.c (_bfd_elf_map_sections_to_segments): Don't start a new + segment when demand paged with lma on the same page. Test this + before load/non-load, executable/non-executable, + writable/non-writable tests and simplify. Delete bogus relro + condition in writable/non-writable test. Delete outdated + comment. Formatting. + +2018-01-30 Alan Modra + + * elflink.c (bfd_elf_define_start_stop): Make __start and __stop + symbols dynamic. + +2018-01-29 Alan Modra + + PR 22741 + * coffgen.c (coff_pointerize_aux): Ensure auxent tagndx is in + range before converting to a symbol table pointer. 2018-01-27 Nick Clifton @@ -13,9 +1279,19 @@ 2018-01-26 Alan Modra + * elflink.c (bfd_elf_define_start_stop): Override symbols when + they are defined dynamically. + +2018-01-26 Alan Modra + * elf64-ppc.c (ppc64_elf_size_stubs): Iterate sizing when .branch_lt changes size. +2018-01-25 Alan Modra + + PR 22746 + * elfcode.h (elf_object_p): Avoid integer overflow. + 2018-01-25 Eric Botcazou PR ld/22727 @@ -33,10 +1309,34 @@ (allocate_dynrelocs): Likewise. (_bfd_sparc_elf_relocate_section): Likewise. -2018-01-23 Nick Clifton +2018-01-24 Renlin Li - * version.m4: Reset version number to 2.29.90. - * configure: Regenerate. + * elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Add support for + BFD_RELOC_AARCH64_MOVW_PREL_G0, BFD_RELOC_AARCH64_MOVW_PREL_G0_NC, + BFD_RELOC_AARCH64_MOVW_PREL_G1, BFD_RELOC_AARCH64_MOVW_PREL_G1_NC, + BFD_RELOC_AARCH64_MOVW_PREL_G2, BFD_RELOC_AARCH64_MOVW_PREL_G2_NC, + BFD_RELOC_AARCH64_MOVW_PREL_G3. + * elfxx-aarch64.c (_bfd_aarch64_elf_put_addend): Likewise. + (_bfd_aarch64_elf_resolve_relocation): Likewise. + +2018-01-24 Renlin Li + + * reloc.c: Add BFD_RELOC_AARCH64_MOVW_PREL_G0, + BFD_RELOC_AARCH64_MOVW_PREL_G0_NC, BFD_RELOC_AARCH64_MOVW_PREL_G1, + BFD_RELOC_AARCH64_MOVW_PREL_G1_NC, BFD_RELOC_AARCH64_MOVW_PREL_G2, + BFD_RELOC_AARCH64_MOVW_PREL_G2_NC, BFD_RELOC_AARCH64_MOVW_PREL_G3. + * elfnn-aarch64.c (elfNN_aarch64_howto_table): Add entries for + BFD_RELOC_AARCH64_MOVW_PREL_G0, BFD_RELOC_AARCH64_MOVW_PREL_G0_NC, + BFD_RELOC_AARCH64_MOVW_PREL_G1, BFD_RELOC_AARCH64_MOVW_PREL_G1_NC, + BFD_RELOC_AARCH64_MOVW_PREL_G2, BFD_RELOC_AARCH64_MOVW_PREL_G2_NC, + BFD_RELOC_AARCH64_MOVW_PREL_G3. + * bfd-in2.h: Regenerate. + * libbfd.h: Regenerate. + +2018-01-23 Maciej W. Rozycki + + * elfxx-mips.c (_bfd_mips_elf_final_link): Update a stale + `mips_elf32_section_processing' comment reference. 2018-01-20 H.J. Lu @@ -54,7 +1354,16 @@ * elf64-ppc.c (ppc64_elf_size_stubs): Handle negative plt_stub_align. (ppc64_elf_build_stubs): Likewise. -2018-01-18 Alan Modra +2018-01-17 Nick Clifton + + * po/ru.po: Updated Russian translation. + * po/uk/po: Updated Ukranian translation. + +2018-01-17 Alan Modra + + * elf64-ppc.c (ppc64_elf_build_stubs): Silence gcc warning. + +2018-01-17 Alan Modra * elf32-ppc.c (GLINK_ENTRY_SIZE): Handle speculation barrier. (CRSETEQ, BEQCTRM): Define. @@ -80,11 +1389,7 @@ (ppc64_elf_build_stubs): Likewise in __glink_PLTresolve stub. * elf64-ppc.h (struct ppc64_elf_params): Add speculate_indirect_jumps. -2018-01-18 Alan Modra - - * elf64-ppc.c (ppc64_elf_build_stubs): Silence gcc warning. - -2018-01-18 Alan Modra +2018-01-17 Alan Modra * elf32-ppc.c (GLINK_ENTRY_SIZE): Add parameters, handle __tls_get_addr_opt, and alignment sizing. @@ -121,20 +1426,18 @@ Build lazy link stubs out to end of section. Build global entry stubs in new section. -2018-01-17 Nick Clifton - - * po/ru.po: Updated Russian translation. - * po/uk/po: Updated Ukranian translation. - 2018-01-15 Nick Clifton * po/uk.po: Updated Ukranian translation. 2018-01-13 Nick Clifton - * version.m4 (BFD_VERSION): Change to 2.30.0. + * po/bfd.pot: Regenerated. + +2018-01-13 Nick Clifton + + * version.m4: Bump version to 2.30.51 * configure: Regenerate. - * po/bfd.pot: Regenerate. 2018-01-13 Nick Clifton @@ -183,7 +1486,7 @@ * elflink.c (bfd_elf_gc_sections): Keep all PREINIT_ARRAY, INIT_ARRAY as well as FINI_ARRAY sections for ld -r --gc-section. -2017-09-27 Kuan-Lin Chen +2018-01-09 Kuan-Lin Chen PR 22662 * elf32-nds32.c (nds32_elf_relax_loadstore): Fix a typographical error. diff --git a/bfd/aix386-core.c b/bfd/aix386-core.c index 77d068f..de3afd5 100644 --- a/bfd/aix386-core.c +++ b/bfd/aix386-core.c @@ -246,12 +246,24 @@ const bfd_target core_aix386_vec = NO_GET, NO_GETS, NO_PUT, NO_GET, NO_GETS, NO_PUT, /* hdrs */ - {_bfd_dummy_target, _bfd_dummy_target, - _bfd_dummy_target, aix386_core_file_p}, - {bfd_false, bfd_false, /* bfd_create_object */ - bfd_false, bfd_false}, - {bfd_false, bfd_false, /* bfd_write_contents */ - bfd_false, bfd_false}, + { /* bfd_check_format */ + _bfd_dummy_target, + _bfd_dummy_target, + _bfd_dummy_target, + aix386_core_file_p + }, + { /* bfd_create_object */ + _bfd_bool_bfd_false_error, + _bfd_bool_bfd_false_error, + _bfd_bool_bfd_false_error, + _bfd_bool_bfd_false_error + }, + { /* bfd_write_contents */ + _bfd_bool_bfd_false_error, + _bfd_bool_bfd_false_error, + _bfd_bool_bfd_false_error, + _bfd_bool_bfd_false_error + }, BFD_JUMP_TABLE_GENERIC (_bfd_generic), BFD_JUMP_TABLE_COPY (_bfd_generic), diff --git a/bfd/aout-adobe.c b/bfd/aout-adobe.c index 4063a8a..48189d8 100644 --- a/bfd/aout-adobe.c +++ b/bfd/aout-adobe.c @@ -123,7 +123,7 @@ aout_adobe_callback (bfd *abfd) default: _bfd_error_handler /* xgettext:c-format */ - (_("%B: Unknown section type in a.out.adobe file: %x\n"), + (_("%pB: unknown section type in a.out.adobe file: %x"), abfd, ext->e_type[0]); goto no_more_sections; } @@ -500,12 +500,24 @@ const bfd_target aout_adobe_vec = bfd_getb32, bfd_getb_signed_32, bfd_putb32, bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* Headers. */ - {_bfd_dummy_target, aout_adobe_object_p, /* bfd_check_format. */ - bfd_generic_archive_p, _bfd_dummy_target}, - {bfd_false, aout_adobe_mkobject, /* bfd_set_format. */ - _bfd_generic_mkarchive, bfd_false}, - {bfd_false, aout_adobe_write_object_contents,/* bfd_write_contents. */ - _bfd_write_archive_contents, bfd_false}, + { /* bfd_check_format. */ + _bfd_dummy_target, + aout_adobe_object_p, + bfd_generic_archive_p, + _bfd_dummy_target + }, + { /* bfd_set_format. */ + _bfd_bool_bfd_false_error, + aout_adobe_mkobject, + _bfd_generic_mkarchive, + _bfd_bool_bfd_false_error + }, + { /* bfd_write_contents. */ + _bfd_bool_bfd_false_error, + aout_adobe_write_object_contents, + _bfd_write_archive_contents, + _bfd_bool_bfd_false_error + }, BFD_JUMP_TABLE_GENERIC (aout_32), BFD_JUMP_TABLE_COPY (_bfd_generic), diff --git a/bfd/aout-arm.c b/bfd/aout-arm.c index ac05b93..211f51f 100644 --- a/bfd/aout-arm.c +++ b/bfd/aout-arm.c @@ -483,12 +483,25 @@ const bfd_target arm_aout_le_vec = bfd_getl64, bfd_getl_signed_64, bfd_putl64, bfd_getl32, bfd_getl_signed_32, bfd_putl32, bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* Headers. */ - {_bfd_dummy_target, MY_object_p, /* bfd_check_format. */ - bfd_generic_archive_p, MY_core_file_p}, - {bfd_false, MY_mkobject, /* bfd_set_format. */ - _bfd_generic_mkarchive, bfd_false}, - {bfd_false, MY_write_object_contents, /* bfd_write_contents. */ - _bfd_write_archive_contents, bfd_false}, + + { /* bfd_check_format. */ + _bfd_dummy_target, + MY_object_p, + bfd_generic_archive_p, + MY_core_file_p + }, + { /* bfd_set_format. */ + _bfd_bool_bfd_false_error, + MY_mkobject, + _bfd_generic_mkarchive, + _bfd_bool_bfd_false_error + }, + { /* bfd_write_contents. */ + _bfd_bool_bfd_false_error, + MY_write_object_contents, + _bfd_write_archive_contents, + _bfd_bool_bfd_false_error + }, BFD_JUMP_TABLE_GENERIC (MY), BFD_JUMP_TABLE_COPY (MY), @@ -525,12 +538,25 @@ const bfd_target arm_aout_be_vec = bfd_getb64, bfd_getb_signed_64, bfd_putb64, bfd_getb32, bfd_getb_signed_32, bfd_putb32, bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* Headers. */ - {_bfd_dummy_target, MY_object_p, /* bfd_check_format. */ - bfd_generic_archive_p, MY_core_file_p}, - {bfd_false, MY_mkobject, /* bfd_set_format. */ - _bfd_generic_mkarchive, bfd_false}, - {bfd_false, MY_write_object_contents, /* bfd_write_contents. */ - _bfd_write_archive_contents, bfd_false}, + + { /* bfd_check_format. */ + _bfd_dummy_target, + MY_object_p, + bfd_generic_archive_p, + MY_core_file_p + }, + { /* bfd_set_format. */ + _bfd_bool_bfd_false_error, + MY_mkobject, + _bfd_generic_mkarchive, + _bfd_bool_bfd_false_error + }, + { /* bfd_write_contents. */ + _bfd_bool_bfd_false_error, + MY_write_object_contents, + _bfd_write_archive_contents, + _bfd_bool_bfd_false_error + }, BFD_JUMP_TABLE_GENERIC (MY), BFD_JUMP_TABLE_COPY (MY), diff --git a/bfd/aout-cris.c b/bfd/aout-cris.c index d1a2366..2b150cd 100644 --- a/bfd/aout-cris.c +++ b/bfd/aout-cris.c @@ -197,7 +197,7 @@ MY (swap_ext_reloc_out) (bfd *abfd, if (r_type > 2) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: Invalid relocation type exported: %d"), + _bfd_error_handler (_("%pB: unsupported relocation type exported: %#x"), abfd, r_type); bfd_set_error (bfd_error_wrong_format); @@ -241,7 +241,7 @@ MY (swap_ext_reloc_in) (bfd *abfd, if (r_type > 2) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: Invalid relocation type imported: %d"), + _bfd_error_handler (_("%pB: unsupported relocation type imported: %#x"), abfd, r_type); bfd_set_error (bfd_error_wrong_format); @@ -253,7 +253,7 @@ MY (swap_ext_reloc_in) (bfd *abfd, { _bfd_error_handler /* xgettext:c-format */ - (_("%B: Bad relocation record imported: %d"), abfd, r_index); + (_("%pB: bad relocation record imported: %d"), abfd, r_index); bfd_set_error (bfd_error_wrong_format); diff --git a/bfd/aout-target.h b/bfd/aout-target.h index cb14b98..f245b1e 100644 --- a/bfd/aout-target.h +++ b/bfd/aout-target.h @@ -407,14 +407,13 @@ MY_bfd_final_link (bfd *abfd, struct bfd_link_info *info) #endif #ifndef MY_bfd_debug_info_start -#define MY_bfd_debug_info_start bfd_void +#define MY_bfd_debug_info_start _bfd_void_bfd #endif #ifndef MY_bfd_debug_info_end -#define MY_bfd_debug_info_end bfd_void +#define MY_bfd_debug_info_end _bfd_void_bfd #endif #ifndef MY_bfd_debug_info_accumulate -#define MY_bfd_debug_info_accumulate \ - (void (*) (bfd *, struct bfd_section *)) bfd_void +#define MY_bfd_debug_info_accumulate _bfd_void_bfd_asection #endif #ifndef MY_core_file_failing_command @@ -581,7 +580,7 @@ MY_bfd_final_link (bfd *abfd, struct bfd_link_info *info) #endif #ifndef MY_bfd_is_target_special_symbol -#define MY_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false) +#define MY_bfd_is_target_special_symbol _bfd_bool_bfd_asymbol_false #endif #ifndef MY_bfd_free_cached_info @@ -669,12 +668,24 @@ const bfd_target MY (vec) = bfd_getl32, bfd_getl_signed_32, bfd_putl32, bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* Headers. */ #endif - {_bfd_dummy_target, MY_object_p, /* bfd_check_format. */ - bfd_generic_archive_p, MY_core_file_p}, - {bfd_false, MY_mkobject, /* bfd_set_format. */ - _bfd_generic_mkarchive, bfd_false}, - {bfd_false, MY_write_object_contents, /* bfd_write_contents. */ - _bfd_write_archive_contents, bfd_false}, + { /* bfd_check_format. */ + _bfd_dummy_target, + MY_object_p, + bfd_generic_archive_p, + MY_core_file_p + }, + { /* bfd_set_format. */ + _bfd_bool_bfd_false_error, + MY_mkobject, + _bfd_generic_mkarchive, + _bfd_bool_bfd_false_error + }, + { /* bfd_write_contents. */ + _bfd_bool_bfd_false_error, + MY_write_object_contents, + _bfd_write_archive_contents, + _bfd_bool_bfd_false_error + }, BFD_JUMP_TABLE_GENERIC (MY), BFD_JUMP_TABLE_COPY (MY), diff --git a/bfd/aout-tic30.c b/bfd/aout-tic30.c index d8ad415..31248ec 100644 --- a/bfd/aout-tic30.c +++ b/bfd/aout-tic30.c @@ -862,14 +862,13 @@ tic30_aout_set_arch_mach (bfd *abfd, #endif #ifndef MY_bfd_debug_info_start -#define MY_bfd_debug_info_start bfd_void +#define MY_bfd_debug_info_start _bfd_void_bfd #endif #ifndef MY_bfd_debug_info_end -#define MY_bfd_debug_info_end bfd_void +#define MY_bfd_debug_info_end _bfd_void_bfd #endif #ifndef MY_bfd_debug_info_accumulate -#define MY_bfd_debug_info_accumulate \ - (void (*) (bfd*, struct bfd_section *)) bfd_void +#define MY_bfd_debug_info_accumulate _bfd_void_bfd_asection #endif #ifndef MY_core_file_failing_command @@ -1036,8 +1035,7 @@ tic30_aout_set_arch_mach (bfd *abfd, #endif #ifndef MY_bfd_is_target_special_symbol -#define MY_bfd_is_target_special_symbol \ - ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false) +#define MY_bfd_is_target_special_symbol _bfd_bool_bfd_asymbol_false #endif #ifndef MY_bfd_free_cached_info @@ -1099,12 +1097,24 @@ const bfd_target tic30_aout_vec = bfd_getb64, bfd_getb_signed_64, bfd_putb64, bfd_getb32, bfd_getb_signed_32, bfd_putb32, bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* Headers. */ - {_bfd_dummy_target, MY_object_p, /* bfd_check_format. */ - bfd_generic_archive_p, MY_core_file_p}, - {bfd_false, MY_mkobject, /* bfd_set_format. */ - _bfd_generic_mkarchive, bfd_false}, - {bfd_false, MY_write_object_contents, /* bfd_write_contents. */ - _bfd_write_archive_contents, bfd_false}, + { /* bfd_check_format. */ + _bfd_dummy_target, + MY_object_p, + bfd_generic_archive_p, + MY_core_file_p + }, + { /* bfd_set_format. */ + _bfd_bool_bfd_false_error, + MY_mkobject, + _bfd_generic_mkarchive, + _bfd_bool_bfd_false_error + }, + { /* bfd_write_contents. */ + _bfd_bool_bfd_false_error, + MY_write_object_contents, + _bfd_write_archive_contents, + _bfd_bool_bfd_false_error + }, BFD_JUMP_TABLE_GENERIC (MY), BFD_JUMP_TABLE_COPY (MY), diff --git a/bfd/aoutf1.h b/bfd/aoutf1.h index 88ecf1e..b039d6a 100644 --- a/bfd/aoutf1.h +++ b/bfd/aoutf1.h @@ -779,9 +779,9 @@ static const struct aout_backend_data sunos4_aout_backend = #define MY_core_file_failing_signal sunos4_core_file_failing_signal #define MY_core_file_matches_executable_p sunos4_core_file_matches_executable_p -#define MY_bfd_debug_info_start bfd_void -#define MY_bfd_debug_info_end bfd_void -#define MY_bfd_debug_info_accumulate (void (*) (bfd *, struct bfd_section *)) bfd_void +#define MY_bfd_debug_info_start _bfd_void_bfd +#define MY_bfd_debug_info_end _bfd_void_bfd +#define MY_bfd_debug_info_accumulate _bfd_void_bfd_asection #define MY_core_file_p sunos4_core_file_p #define MY_write_object_contents NAME(aout, sunos4_write_object_contents) #define MY_backend_data & sunos4_aout_backend diff --git a/bfd/aoutx.h b/bfd/aoutx.h index eec9c4a..525e560 100644 --- a/bfd/aoutx.h +++ b/bfd/aoutx.h @@ -1281,7 +1281,7 @@ NAME (aout, set_section_contents) (bfd *abfd, { _bfd_error_handler /* xgettext:c-format */ - (_("%B: can not represent section `%A' in a.out object file format"), + (_("%pB: can not represent section `%pA' in a.out object file format"), abfd, section); bfd_set_error (bfd_error_nonrepresentable_section); return FALSE; @@ -1597,7 +1597,7 @@ translate_to_native_sym_flags (bfd *abfd, file. */ _bfd_error_handler /* xgettext:c-format */ - (_("%B: can not represent section for symbol `%s' in a.out " + (_("%pB: can not represent section for symbol `%s' in a.out " "object file format"), abfd, cache_ptr->name != NULL ? cache_ptr->name : _("*unknown*")); @@ -1633,7 +1633,7 @@ translate_to_native_sym_flags (bfd *abfd, { _bfd_error_handler /* xgettext:c-format */ - (_("%B: can not represent section `%A' in a.out object file format"), + (_("%pB: can not represent section `%pA' in a.out object file format"), abfd, sec); bfd_set_error (bfd_error_nonrepresentable_section); return FALSE; @@ -1734,7 +1734,13 @@ NAME (aout, translate_symbol_table) (bfd *abfd, else if (x < strsize) in->symbol.name = str + x; else - return FALSE; + { + _bfd_error_handler + (_("%pB: invalid string offset %" PRIu64 " >= %" PRIu64), + abfd, (uint64_t) x, (uint64_t) strsize); + bfd_set_error (bfd_error_bad_value); + return FALSE; + } in->symbol.value = GET_SWORD (abfd, ext->e_value); in->desc = H_GET_16 (abfd, ext->e_desc); @@ -2283,10 +2289,12 @@ NAME (aout, swap_std_reloc_in) (bfd *abfd, if (r_baserel) r_extern = 1; - if (r_extern && r_index > symcount) + if (r_extern && r_index >= symcount) { /* We could arrange to return an error, but it might be useful - to see the file even if it is bad. */ + to see the file even if it is bad. FIXME: Of course this + means that objdump -r *doesn't* see the actual reloc, and + objcopy silently writes a different reloc. */ r_extern = 0; r_index = N_ABS; } @@ -2420,7 +2428,7 @@ NAME (aout, squirt_out_relocs) (bfd *abfd, asection *section) { bfd_set_error (bfd_error_invalid_operation); _bfd_error_handler (_("\ -%B: attempt to write out unknown reloc type"), abfd); +%pB: attempt to write out unknown reloc type"), abfd); return FALSE; } MY_swap_ext_reloc_out (abfd, *generic, @@ -2438,7 +2446,7 @@ NAME (aout, squirt_out_relocs) (bfd *abfd, asection *section) { bfd_set_error (bfd_error_invalid_operation); _bfd_error_handler (_("\ -%B: attempt to write out unknown reloc type"), abfd); +%pB: attempt to write out unknown reloc type"), abfd); return FALSE; } MY_swap_std_reloc_out (abfd, *generic, @@ -4089,8 +4097,8 @@ aout_link_input_section_std (struct aout_final_link_info *flaginfo, if (howto == NULL) { - (*flaginfo->info->callbacks->einfo) - (_("%P: %B: unexpected relocation type\n"), input_bfd); + _bfd_error_handler (_("%pB: unsupported relocation type"), + input_bfd); bfd_set_error (bfd_error_bad_value); return FALSE; } @@ -4410,8 +4418,8 @@ aout_link_input_section_ext (struct aout_final_link_info *flaginfo, if (r_type >= TABLE_SIZE (howto_table_ext)) { - (*flaginfo->info->callbacks->einfo) - (_("%P: %B: unexpected relocation type\n"), input_bfd); + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + input_bfd, r_type); bfd_set_error (bfd_error_bad_value); return FALSE; } @@ -5437,7 +5445,7 @@ NAME (aout, final_link) (bfd *abfd, by the reloc size. */ _bfd_error_handler /* xgettext:c-format */ - (_("%B: relocatable link from %s to %s not supported"), + (_("%pB: relocatable link from %s to %s not supported"), abfd, sub->xvec->name, abfd->xvec->name); bfd_set_error (bfd_error_invalid_operation); goto error_return; diff --git a/bfd/archive.c b/bfd/archive.c index de08b19..d58f172 100644 --- a/bfd/archive.c +++ b/bfd/archive.c @@ -754,6 +754,13 @@ _bfd_generic_get_elt_at_index (bfd *abfd, symindex sym_index) return _bfd_get_elt_at_filepos (abfd, entry->file_offset); } +bfd * +_bfd_noarchive_get_elt_at_index (bfd *abfd, + symindex sym_index ATTRIBUTE_UNUSED) +{ + return (bfd *) _bfd_ptr_bfd_null_error (abfd); +} + /* FUNCTION bfd_openr_next_archived_file @@ -816,6 +823,13 @@ bfd_generic_openr_next_archived_file (bfd *archive, bfd *last_file) return _bfd_get_elt_at_filepos (archive, filestart); } +bfd * +_bfd_noarchive_openr_next_archived_file (bfd *archive, + bfd *last_file ATTRIBUTE_UNUSED) +{ + return (bfd *) _bfd_ptr_bfd_null_error (archive); +} + const bfd_target * bfd_generic_archive_p (bfd *abfd) { @@ -1586,6 +1600,15 @@ _bfd_archive_coff_construct_extended_name_table (bfd *abfd, return _bfd_construct_extended_name_table (abfd, TRUE, tabloc, tablen); } +bfd_boolean +_bfd_noarchive_construct_extended_name_table (bfd *abfd ATTRIBUTE_UNUSED, + char **tabloc ATTRIBUTE_UNUSED, + bfd_size_type *len ATTRIBUTE_UNUSED, + const char **name ATTRIBUTE_UNUSED) +{ + return TRUE; +} + /* Follows archive_head and produces an extended name table if necessary. Returns (in tabloc) a pointer to an extended name table, and in tablen the length of the table. If it makes an entry @@ -1884,6 +1907,12 @@ _bfd_bsd44_write_ar_hdr (bfd *archive, bfd *abfd) } return TRUE; } + +bfd_boolean +_bfd_noarchive_write_ar_hdr (bfd *archive, bfd *abfd ATTRIBUTE_UNUSED) +{ + return _bfd_bool_bfd_false_error (archive); +} /* A couple of functions for creating ar_hdrs. */ @@ -2154,6 +2183,13 @@ bfd_gnu_truncate_arname (bfd *abfd, const char *pathname, char *arhdr) if (length < 16) (hdr->ar_name)[length] = ar_padchar (abfd); } + +void +_bfd_noarchive_truncate_arname (bfd *abfd ATTRIBUTE_UNUSED, + const char *pathname ATTRIBUTE_UNUSED, + char *arhdr ATTRIBUTE_UNUSED) +{ +} /* The BFD is open for write and has its format set to bfd_archive. */ @@ -2302,7 +2338,7 @@ _bfd_write_archive_contents (bfd *arch) if (bfd_update_armap_timestamp (arch)) break; _bfd_error_handler - (_("Warning: writing archive was slow: rewriting timestamp\n")); + (_("warning: writing archive was slow: rewriting timestamp")); } while (++tries < 6); } @@ -2418,7 +2454,7 @@ _bfd_compute_and_write_armap (bfd *arch, unsigned int elength) + (syms[src_count]->name[2] == '_'), "__gnu_lto_slim") == 0) _bfd_error_handler - (_("%B: plugin needed to handle lto object"), + (_("%pB: plugin needed to handle lto object"), current); namelen = strlen (syms[src_count]->name); amt = sizeof (char *); @@ -2834,6 +2870,17 @@ _bfd_coff_write_armap (bfd *arch, return TRUE; } +bfd_boolean +_bfd_noarchive_write_armap + (bfd *arch ATTRIBUTE_UNUSED, + unsigned int elength ATTRIBUTE_UNUSED, + struct orl *map ATTRIBUTE_UNUSED, + unsigned int orl_count ATTRIBUTE_UNUSED, + int stridx ATTRIBUTE_UNUSED) +{ + return TRUE; +} + static int archive_close_worker (void **slot, void *inf ATTRIBUTE_UNUSED) { diff --git a/bfd/archures.c b/bfd/archures.c index e83c57a..7327f5f 100644 --- a/bfd/archures.c +++ b/bfd/archures.c @@ -1452,3 +1452,11 @@ bfd_arch_default_fill (bfd_size_type count, memset (fill, 0, count); return fill; } + +bfd_boolean +_bfd_nowrite_set_arch_mach (bfd *abfd, + enum bfd_architecture arch ATTRIBUTE_UNUSED, + unsigned long mach ATTRIBUTE_UNUSED) +{ + return _bfd_bool_bfd_false_error (abfd); +} diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h index 2195ce3..a06cd74 100644 --- a/bfd/bfd-in.h +++ b/bfd/bfd-in.h @@ -91,6 +91,24 @@ typedef BFD_HOST_64_BIT bfd_int64_t; typedef BFD_HOST_U_64_BIT bfd_uint64_t; #endif +#ifdef HAVE_INTTYPES_H +# include +#else +# if BFD_HOST_64BIT_LONG +# define BFD_PRI64 "l" +# elif defined (__MSVCRT__) +# define BFD_PRI64 "I64" +# else +# define BFD_PRI64 "ll" +# endif +# undef PRId64 +# define PRId64 BFD_PRI64 "d" +# undef PRIu64 +# define PRIu64 BFD_PRI64 "u" +# undef PRIx64 +# define PRIx64 BFD_PRI64 "x" +#endif + #if BFD_ARCH_SIZE >= 64 #define BFD64 #endif diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index f4b3720..c158f43 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -98,6 +98,24 @@ typedef BFD_HOST_64_BIT bfd_int64_t; typedef BFD_HOST_U_64_BIT bfd_uint64_t; #endif +#ifdef HAVE_INTTYPES_H +# include +#else +# if BFD_HOST_64BIT_LONG +# define BFD_PRI64 "l" +# elif defined (__MSVCRT__) +# define BFD_PRI64 "I64" +# else +# define BFD_PRI64 "ll" +# endif +# undef PRId64 +# define PRId64 BFD_PRI64 "d" +# undef PRIu64 +# define PRIu64 BFD_PRI64 "u" +# undef PRIx64 +# define PRIx64 BFD_PRI64 "x" +#endif + #if BFD_ARCH_SIZE >= 64 #define BFD64 #endif @@ -1324,13 +1342,10 @@ typedef struct bfd_section /* The section contains thread local data. */ #define SEC_THREAD_LOCAL 0x400 - /* The section has GOT references. This flag is only for the - linker, and is currently only used by the elf32-hppa back end. - It will be set if global offset table references were detected - in this section, which indicate to the linker that the section - contains PIC code, and must be handled specially when doing a - static link. */ -#define SEC_HAS_GOT_REF 0x800 + /* The section's size is fixed. Generic linker code will not + recalculate it and it is up to whoever has set this flag to + get the size right. */ +#define SEC_FIXED_SIZE 0x800 /* The section contains common symbols (symbols may be defined multiple times, the value of a symbol is the amount of @@ -4137,6 +4152,9 @@ and shift left by 1 for use in lhi.gp, shi.gp... */ and shift left by 0 for use in lbi.gp, sbi.gp... */ BFD_RELOC_NDS32_SDA19S0, +/* This is a 24-bit reloc for security check sum. */ + BFD_RELOC_NDS32_SECURITY_16, + /* for PIC */ BFD_RELOC_NDS32_GOT20, BFD_RELOC_NDS32_9_PLTREL, @@ -4248,18 +4266,43 @@ This is a 5 bit absolute address. */ /* For TLS. */ BFD_RELOC_NDS32_TPOFF, + BFD_RELOC_NDS32_GOTTPOFF, BFD_RELOC_NDS32_TLS_LE_HI20, BFD_RELOC_NDS32_TLS_LE_LO12, - BFD_RELOC_NDS32_TLS_LE_ADD, - BFD_RELOC_NDS32_TLS_LE_LS, - BFD_RELOC_NDS32_GOTTPOFF, - BFD_RELOC_NDS32_TLS_IE_HI20, - BFD_RELOC_NDS32_TLS_IE_LO12S2, - BFD_RELOC_NDS32_TLS_TPOFF, BFD_RELOC_NDS32_TLS_LE_20, BFD_RELOC_NDS32_TLS_LE_15S0, BFD_RELOC_NDS32_TLS_LE_15S1, BFD_RELOC_NDS32_TLS_LE_15S2, + BFD_RELOC_NDS32_TLS_LE_ADD, + BFD_RELOC_NDS32_TLS_LE_LS, + BFD_RELOC_NDS32_TLS_IE_HI20, + BFD_RELOC_NDS32_TLS_IE_LO12, + BFD_RELOC_NDS32_TLS_IE_LO12S2, + BFD_RELOC_NDS32_TLS_IEGP_HI20, + BFD_RELOC_NDS32_TLS_IEGP_LO12, + BFD_RELOC_NDS32_TLS_IEGP_LO12S2, + BFD_RELOC_NDS32_TLS_IEGP_LW, + BFD_RELOC_NDS32_TLS_DESC, + BFD_RELOC_NDS32_TLS_DESC_HI20, + BFD_RELOC_NDS32_TLS_DESC_LO12, + BFD_RELOC_NDS32_TLS_DESC_20, + BFD_RELOC_NDS32_TLS_DESC_SDA17S2, + BFD_RELOC_NDS32_TLS_DESC_ADD, + BFD_RELOC_NDS32_TLS_DESC_FUNC, + BFD_RELOC_NDS32_TLS_DESC_CALL, + BFD_RELOC_NDS32_TLS_DESC_MEM, + BFD_RELOC_NDS32_REMOVE, + BFD_RELOC_NDS32_GROUP, + +/* Jump-patch table relative relocations. */ + BFD_RELOC_NDS32_ICT, + BFD_RELOC_NDS32_ICT_HI20, + BFD_RELOC_NDS32_ICT_LO12, + BFD_RELOC_NDS32_ICT_25PC, + BFD_RELOC_NDS32_ICT_LO12S2, + +/* For bug 12566. */ + BFD_RELOC_NDS32_LSI, /* This is a 9-bit reloc */ BFD_RELOC_V850_9_PCREL, @@ -5957,6 +6000,36 @@ of a signed value. Changes instruction to MOVZ or MOVN depending on the value's sign. */ BFD_RELOC_AARCH64_MOVW_G2_S, +/* AArch64 MOV[NZ] instruction with most significant bits 0 to 15 +of a signed value. Changes instruction to MOVZ or MOVN depending on the +value's sign. */ + BFD_RELOC_AARCH64_MOVW_PREL_G0, + +/* AArch64 MOV[NZ] instruction with most significant bits 0 to 15 +of a signed value. Changes instruction to MOVZ or MOVN depending on the +value's sign. */ + BFD_RELOC_AARCH64_MOVW_PREL_G0_NC, + +/* AArch64 MOVK instruction with most significant bits 16 to 31 +of a signed value. */ + BFD_RELOC_AARCH64_MOVW_PREL_G1, + +/* AArch64 MOVK instruction with most significant bits 16 to 31 +of a signed value. */ + BFD_RELOC_AARCH64_MOVW_PREL_G1_NC, + +/* AArch64 MOVK instruction with most significant bits 32 to 47 +of a signed value. */ + BFD_RELOC_AARCH64_MOVW_PREL_G2, + +/* AArch64 MOVK instruction with most significant bits 32 to 47 +of a signed value. */ + BFD_RELOC_AARCH64_MOVW_PREL_G2_NC, + +/* AArch64 MOVK instruction with most significant bits 47 to 63 +of a signed value. */ + BFD_RELOC_AARCH64_MOVW_PREL_G3, + /* AArch64 Load Literal instruction, holding a 19 bit pc-relative word offset. The lowest two bits must be zero and are not stored in the instruction, giving a 21 bit signed byte offset. */ diff --git a/bfd/bfd.c b/bfd/bfd.c index 985c825..288b5b1 100644 --- a/bfd/bfd.c +++ b/bfd/bfd.c @@ -451,28 +451,28 @@ static bfd_error_type input_error = bfd_error_no_error; const char *const bfd_errmsgs[] = { - N_("No error"), - N_("System call error"), - N_("Invalid bfd target"), - N_("File in wrong format"), - N_("Archive object file in wrong format"), - N_("Invalid operation"), - N_("Memory exhausted"), - N_("No symbols"), - N_("Archive has no index; run ranlib to add one"), - N_("No more archived files"), - N_("Malformed archive"), + N_("no error"), + N_("system call error"), + N_("invalid bfd target"), + N_("file in wrong format"), + N_("archive object file in wrong format"), + N_("invalid operation"), + N_("memory exhausted"), + N_("no symbols"), + N_("archive has no index; run ranlib to add one"), + N_("no more archived files"), + N_("malformed archive"), N_("DSO missing from command line"), - N_("File format not recognized"), - N_("File format is ambiguous"), - N_("Section has no contents"), - N_("Nonrepresentable section on output"), - N_("Symbol needs debug section which does not exist"), - N_("Bad value"), - N_("File truncated"), - N_("File too big"), - N_("Error reading %s: %s"), - N_("#") + N_("file format not recognized"), + N_("file format is ambiguous"), + N_("section has no contents"), + N_("nonrepresentable section on output"), + N_("symbol needs debug section which does not exist"), + N_("bad value"), + N_("file truncated"), + N_("file too big"), + N_("error reading %s: %s"), + N_("#") }; /* @@ -649,10 +649,7 @@ union _bfd_doprnt_args }; /* This macro and _bfd_doprnt taken from libiberty _doprnt.c, tidied a - little and extended to handle '%A', '%B' and positional parameters. - 'L' as a modifer for integer formats is used for bfd_vma and - bfd_size_type args, which vary in size depending on BFD - configuration. */ + little and extended to handle '%pA', '%pB' and positional parameters. */ #define PRINT_TYPE(TYPE, FIELD) \ do \ @@ -800,21 +797,6 @@ _bfd_doprnt (FILE *stream, const char *format, union _bfd_doprnt_args *args) PRINT_TYPE (int, i); else { - /* L modifier for bfd_vma or bfd_size_type may be - either long long or long. */ - if (ptr[-2] == 'L') - { - sptr[-2] = 'l'; - if (BFD_ARCH_SIZE < 64 || BFD_HOST_64BIT_LONG) - wide_width = 1; - else - { - sptr[-1] = 'l'; - *sptr++ = ptr[-1]; - *sptr = '\0'; - } - } - switch (wide_width) { case 0: @@ -866,53 +848,55 @@ _bfd_doprnt (FILE *stream, const char *format, union _bfd_doprnt_args *args) PRINT_TYPE (char *, p); break; case 'p': - PRINT_TYPE (void *, p); - break; - case 'A': - { - asection *sec; - bfd *abfd; - const char *group = NULL; - struct coff_comdat_info *ci; - - sec = (asection *) args[arg_no].p; - if (sec == NULL) - /* Invoking %A with a null section pointer is an - internal error. */ - abort (); - abfd = sec->owner; - if (abfd != NULL - && bfd_get_flavour (abfd) == bfd_target_elf_flavour - && elf_next_in_group (sec) != NULL - && (sec->flags & SEC_GROUP) == 0) - group = elf_group_name (sec); - else if (abfd != NULL - && bfd_get_flavour (abfd) == bfd_target_coff_flavour - && (ci = bfd_coff_get_comdat_section (sec->owner, - sec)) != NULL) - group = ci->name; - if (group != NULL) - result = fprintf (stream, "%s[%s]", sec->name, group); - else - result = fprintf (stream, "%s", sec->name); - } - break; - case 'B': - { - bfd *abfd; - - abfd = (bfd *) args[arg_no].p; - if (abfd == NULL) - /* Invoking %B with a null bfd pointer is an - internal error. */ - abort (); - else if (abfd->my_archive - && !bfd_is_thin_archive (abfd->my_archive)) - result = fprintf (stream, "%s(%s)", - abfd->my_archive->filename, abfd->filename); - else - result = fprintf (stream, "%s", abfd->filename); - } + if (*ptr == 'A') + { + asection *sec; + bfd *abfd; + const char *group = NULL; + struct coff_comdat_info *ci; + + ptr++; + sec = (asection *) args[arg_no].p; + if (sec == NULL) + /* Invoking %pA with a null section pointer is an + internal error. */ + abort (); + abfd = sec->owner; + if (abfd != NULL + && bfd_get_flavour (abfd) == bfd_target_elf_flavour + && elf_next_in_group (sec) != NULL + && (sec->flags & SEC_GROUP) == 0) + group = elf_group_name (sec); + else if (abfd != NULL + && bfd_get_flavour (abfd) == bfd_target_coff_flavour + && (ci = bfd_coff_get_comdat_section (sec->owner, + sec)) != NULL) + group = ci->name; + if (group != NULL) + result = fprintf (stream, "%s[%s]", sec->name, group); + else + result = fprintf (stream, "%s", sec->name); + } + else if (*ptr == 'B') + { + bfd *abfd; + + ptr++; + abfd = (bfd *) args[arg_no].p; + if (abfd == NULL) + /* Invoking %pB with a null bfd pointer is an + internal error. */ + abort (); + else if (abfd->my_archive + && !bfd_is_thin_archive (abfd->my_archive)) + result = fprintf (stream, "%s(%s)", + abfd->my_archive->filename, + abfd->filename); + else + result = fprintf (stream, "%s", abfd->filename); + } + else + PRINT_TYPE (void *, p); break; default: abort(); @@ -1049,12 +1033,6 @@ _bfd_doprnt_scan (const char *format, union _bfd_doprnt_args *args) arg_type = Int; else { - if (ptr[-2] == 'L') - { - if (BFD_ARCH_SIZE < 64 || BFD_HOST_64BIT_LONG) - wide_width = 1; - } - switch (wide_width) { case 0: @@ -1094,9 +1072,11 @@ _bfd_doprnt_scan (const char *format, union _bfd_doprnt_args *args) } break; case 's': + arg_type = Ptr; + break; case 'p': - case 'A': - case 'B': + if (*ptr == 'A' || *ptr == 'B') + ptr++; arg_type = Ptr; break; default: @@ -1116,8 +1096,8 @@ _bfd_doprnt_scan (const char *format, union _bfd_doprnt_args *args) /* This is the default routine to handle BFD error messages. Like fprintf (stderr, ...), but also handles some extra format specifiers. - %A section name from section. For group components, prints group name too. - %B file name from bfd. For archive components, prints archive too. + %pA section name from section. For group components, prints group name too. + %pB file name from bfd. For archive components, prints archive too. Beware: Only supports a maximum of 9 format arguments. */ diff --git a/bfd/binary.c b/bfd/binary.c index 518b845..0713f5a 100644 --- a/bfd/binary.c +++ b/bfd/binary.c @@ -211,7 +211,7 @@ binary_get_symbol_info (bfd *ignore_abfd ATTRIBUTE_UNUSED, #define binary_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol #define binary_read_minisymbols _bfd_generic_read_minisymbols #define binary_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol -#define binary_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false) +#define binary_bfd_is_target_special_symbol _bfd_bool_bfd_asymbol_false /* Set the architecture of a binary file. */ #define binary_set_arch_mach _bfd_generic_set_arch_mach @@ -273,7 +273,7 @@ binary_set_section_contents (bfd *abfd, if (s->filepos < 0) _bfd_error_handler /* xgettext:c-format */ - (_("warning: writing section `%A' at huge (ie negative) " + (_("warning: writing section `%pA' at huge (ie negative) " "file offset"), s); } @@ -346,16 +346,16 @@ const bfd_target binary_vec = _bfd_dummy_target, }, { /* bfd_set_format */ - bfd_false, + _bfd_bool_bfd_false_error, binary_mkobject, - bfd_false, - bfd_false, + _bfd_bool_bfd_false_error, + _bfd_bool_bfd_false_error, }, { /* bfd_write_contents */ - bfd_false, - bfd_true, - bfd_false, - bfd_false, + _bfd_bool_bfd_false_error, + _bfd_bool_bfd_true, + _bfd_bool_bfd_false_error, + _bfd_bool_bfd_false_error, }, BFD_JUMP_TABLE_GENERIC (binary), diff --git a/bfd/bout.c b/bfd/bout.c index 1098cf9..c766633 100644 --- a/bfd/bout.c +++ b/bfd/bout.c @@ -1417,24 +1417,37 @@ const bfd_target bout_be_vec = bfd_getb64, bfd_getb_signed_64, bfd_putb64, bfd_getb32, bfd_getb_signed_32, bfd_putb32, bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* Headers. */ - {_bfd_dummy_target, b_out_object_p, /* bfd_check_format. */ - bfd_generic_archive_p, _bfd_dummy_target}, - {bfd_false, b_out_mkobject, /* bfd_set_format. */ - _bfd_generic_mkarchive, bfd_false}, - {bfd_false, b_out_write_object_contents, /* bfd_write_contents. */ - _bfd_write_archive_contents, bfd_false}, - - BFD_JUMP_TABLE_GENERIC (aout_32), - BFD_JUMP_TABLE_COPY (_bfd_generic), - BFD_JUMP_TABLE_CORE (_bfd_nocore), - BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_bsd), - BFD_JUMP_TABLE_SYMBOLS (aout_32), - BFD_JUMP_TABLE_RELOCS (b_out), - BFD_JUMP_TABLE_WRITE (b_out), - BFD_JUMP_TABLE_LINK (b_out), - BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), - - & bout_le_vec, + + { /* bfd_check_format. */ + _bfd_dummy_target, + b_out_object_p, + bfd_generic_archive_p, + _bfd_dummy_target + }, + { /* bfd_set_format. */ + _bfd_bool_bfd_false_error, + b_out_mkobject, + _bfd_generic_mkarchive, + _bfd_bool_bfd_false_error + }, + { /* bfd_write_contents. */ + _bfd_bool_bfd_false_error, + b_out_write_object_contents, + _bfd_write_archive_contents, + _bfd_bool_bfd_false_error + }, + + BFD_JUMP_TABLE_GENERIC (aout_32), + BFD_JUMP_TABLE_COPY (_bfd_generic), + BFD_JUMP_TABLE_CORE (_bfd_nocore), + BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_bsd), + BFD_JUMP_TABLE_SYMBOLS (aout_32), + BFD_JUMP_TABLE_RELOCS (b_out), + BFD_JUMP_TABLE_WRITE (b_out), + BFD_JUMP_TABLE_LINK (b_out), + BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), + + &bout_le_vec, NULL }; @@ -1460,24 +1473,36 @@ const bfd_target bout_le_vec = bfd_getl32, bfd_getl_signed_32, bfd_putl32, bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* Headers. */ - {_bfd_dummy_target, b_out_object_p, /* bfd_check_format. */ - bfd_generic_archive_p, _bfd_dummy_target}, - {bfd_false, b_out_mkobject, /* bfd_set_format. */ - _bfd_generic_mkarchive, bfd_false}, - {bfd_false, b_out_write_object_contents, /* bfd_write_contents. */ - _bfd_write_archive_contents, bfd_false}, - - BFD_JUMP_TABLE_GENERIC (aout_32), - BFD_JUMP_TABLE_COPY (_bfd_generic), - BFD_JUMP_TABLE_CORE (_bfd_nocore), - BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_bsd), - BFD_JUMP_TABLE_SYMBOLS (aout_32), - BFD_JUMP_TABLE_RELOCS (b_out), - BFD_JUMP_TABLE_WRITE (b_out), - BFD_JUMP_TABLE_LINK (b_out), - BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), - - & bout_be_vec, + { /* bfd_check_format. */ + _bfd_dummy_target, + b_out_object_p, + bfd_generic_archive_p, + _bfd_dummy_target + }, + { /* bfd_set_format. */ + _bfd_bool_bfd_false_error, + b_out_mkobject, + _bfd_generic_mkarchive, + _bfd_bool_bfd_false_error + }, + { /* bfd_write_contents. */ + _bfd_bool_bfd_false_error, + b_out_write_object_contents, + _bfd_write_archive_contents, + _bfd_bool_bfd_false_error + }, + + BFD_JUMP_TABLE_GENERIC (aout_32), + BFD_JUMP_TABLE_COPY (_bfd_generic), + BFD_JUMP_TABLE_CORE (_bfd_nocore), + BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_bsd), + BFD_JUMP_TABLE_SYMBOLS (aout_32), + BFD_JUMP_TABLE_RELOCS (b_out), + BFD_JUMP_TABLE_WRITE (b_out), + BFD_JUMP_TABLE_LINK (b_out), + BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), + + &bout_be_vec, NULL }; diff --git a/bfd/cache.c b/bfd/cache.c index d33301f..4b14043 100644 --- a/bfd/cache.c +++ b/bfd/cache.c @@ -270,7 +270,7 @@ bfd_cache_lookup_worker (bfd *abfd, enum cache_flag flag) return (FILE *) abfd->iostream; /* xgettext:c-format */ - _bfd_error_handler (_("reopening %B: %s\n"), + _bfd_error_handler (_("reopening %pB: %s\n"), orig_bfd, bfd_errmsg (bfd_get_error ())); return NULL; } diff --git a/bfd/cisco-core.c b/bfd/cisco-core.c index e591ef6..7c0654b 100644 --- a/bfd/cisco-core.c +++ b/bfd/cisco-core.c @@ -317,102 +317,110 @@ extern const bfd_target core_cisco_le_vec; const bfd_target core_cisco_be_vec = { - "cisco-ios-core-big", - bfd_target_unknown_flavour, - BFD_ENDIAN_BIG, /* target byte order */ - BFD_ENDIAN_BIG, /* target headers byte order */ - (HAS_RELOC | EXEC_P | /* object flags */ - HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED), - (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ - 0, /* symbol prefix */ - ' ', /* ar_pad_char */ - 16, /* ar_max_namelen */ - 0, /* match priority. */ - bfd_getb64, bfd_getb_signed_64, bfd_putb64, - bfd_getb32, bfd_getb_signed_32, bfd_putb32, - bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */ - bfd_getb64, bfd_getb_signed_64, bfd_putb64, - bfd_getb32, bfd_getb_signed_32, bfd_putb32, - bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */ - - { /* bfd_check_format */ - _bfd_dummy_target, /* unknown format */ - _bfd_dummy_target, /* object file */ - _bfd_dummy_target, /* archive */ - cisco_core_file_p /* a core file */ - }, - { /* bfd_set_format */ - bfd_false, bfd_false, - bfd_false, bfd_false - }, - { /* bfd_write_contents */ - bfd_false, bfd_false, - bfd_false, bfd_false - }, - - BFD_JUMP_TABLE_GENERIC (_bfd_generic), - BFD_JUMP_TABLE_COPY (_bfd_generic), - BFD_JUMP_TABLE_CORE (cisco), - BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive), - BFD_JUMP_TABLE_SYMBOLS (_bfd_nosymbols), - BFD_JUMP_TABLE_RELOCS (_bfd_norelocs), - BFD_JUMP_TABLE_WRITE (_bfd_generic), - BFD_JUMP_TABLE_LINK (_bfd_nolink), - BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), - - & core_cisco_le_vec, - - NULL /* backend_data */ + "cisco-ios-core-big", + bfd_target_unknown_flavour, + BFD_ENDIAN_BIG, /* target byte order */ + BFD_ENDIAN_BIG, /* target headers byte order */ + (HAS_RELOC | EXEC_P /* object flags */ + | HAS_LINENO | HAS_DEBUG + | HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED), + (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ + 0, /* symbol prefix */ + ' ', /* ar_pad_char */ + 16, /* ar_max_namelen */ + 0, /* match priority. */ + bfd_getb64, bfd_getb_signed_64, bfd_putb64, + bfd_getb32, bfd_getb_signed_32, bfd_putb32, + bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */ + bfd_getb64, bfd_getb_signed_64, bfd_putb64, + bfd_getb32, bfd_getb_signed_32, bfd_putb32, + bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */ + + { /* bfd_check_format */ + _bfd_dummy_target, /* unknown format */ + _bfd_dummy_target, /* object file */ + _bfd_dummy_target, /* archive */ + cisco_core_file_p /* a core file */ + }, + { /* bfd_set_format */ + _bfd_bool_bfd_false_error, + _bfd_bool_bfd_false_error, + _bfd_bool_bfd_false_error, + _bfd_bool_bfd_false_error + }, + { /* bfd_write_contents */ + _bfd_bool_bfd_false_error, + _bfd_bool_bfd_false_error, + _bfd_bool_bfd_false_error, + _bfd_bool_bfd_false_error + }, + + BFD_JUMP_TABLE_GENERIC (_bfd_generic), + BFD_JUMP_TABLE_COPY (_bfd_generic), + BFD_JUMP_TABLE_CORE (cisco), + BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive), + BFD_JUMP_TABLE_SYMBOLS (_bfd_nosymbols), + BFD_JUMP_TABLE_RELOCS (_bfd_norelocs), + BFD_JUMP_TABLE_WRITE (_bfd_generic), + BFD_JUMP_TABLE_LINK (_bfd_nolink), + BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), + + &core_cisco_le_vec, + + NULL /* backend_data */ }; const bfd_target core_cisco_le_vec = { - "cisco-ios-core-little", - bfd_target_unknown_flavour, - BFD_ENDIAN_LITTLE, /* target byte order */ - BFD_ENDIAN_LITTLE, /* target headers byte order */ - (HAS_RELOC | EXEC_P | /* object flags */ - HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED), - (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ - 0, /* symbol prefix */ - ' ', /* ar_pad_char */ - 16, /* ar_max_namelen */ - 0, /* match_priority */ - bfd_getl64, bfd_getl_signed_64, bfd_putl64, - bfd_getl32, bfd_getl_signed_32, bfd_putl32, - bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */ - bfd_getl64, bfd_getl_signed_64, bfd_putl64, - bfd_getl32, bfd_getl_signed_32, bfd_putl32, - bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */ - - { /* bfd_check_format */ - _bfd_dummy_target, /* unknown format */ - _bfd_dummy_target, /* object file */ - _bfd_dummy_target, /* archive */ - cisco_core_file_p /* a core file */ - }, - { /* bfd_set_format */ - bfd_false, bfd_false, - bfd_false, bfd_false - }, - { /* bfd_write_contents */ - bfd_false, bfd_false, - bfd_false, bfd_false - }, - - BFD_JUMP_TABLE_GENERIC (_bfd_generic), - BFD_JUMP_TABLE_COPY (_bfd_generic), - BFD_JUMP_TABLE_CORE (cisco), - BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive), - BFD_JUMP_TABLE_SYMBOLS (_bfd_nosymbols), - BFD_JUMP_TABLE_RELOCS (_bfd_norelocs), - BFD_JUMP_TABLE_WRITE (_bfd_generic), - BFD_JUMP_TABLE_LINK (_bfd_nolink), - BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), - - &core_cisco_be_vec, - - NULL /* backend_data */ + "cisco-ios-core-little", + bfd_target_unknown_flavour, + BFD_ENDIAN_LITTLE, /* target byte order */ + BFD_ENDIAN_LITTLE, /* target headers byte order */ + (HAS_RELOC | EXEC_P /* object flags */ + | HAS_LINENO | HAS_DEBUG + | HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED), + (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ + 0, /* symbol prefix */ + ' ', /* ar_pad_char */ + 16, /* ar_max_namelen */ + 0, /* match_priority */ + bfd_getl64, bfd_getl_signed_64, bfd_putl64, + bfd_getl32, bfd_getl_signed_32, bfd_putl32, + bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */ + bfd_getl64, bfd_getl_signed_64, bfd_putl64, + bfd_getl32, bfd_getl_signed_32, bfd_putl32, + bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */ + + { /* bfd_check_format */ + _bfd_dummy_target, /* unknown format */ + _bfd_dummy_target, /* object file */ + _bfd_dummy_target, /* archive */ + cisco_core_file_p /* a core file */ + }, + { /* bfd_set_format */ + _bfd_bool_bfd_false_error, + _bfd_bool_bfd_false_error, + _bfd_bool_bfd_false_error, + _bfd_bool_bfd_false_error + }, + { /* bfd_write_contents */ + _bfd_bool_bfd_false_error, + _bfd_bool_bfd_false_error, + _bfd_bool_bfd_false_error, + _bfd_bool_bfd_false_error + }, + + BFD_JUMP_TABLE_GENERIC (_bfd_generic), + BFD_JUMP_TABLE_COPY (_bfd_generic), + BFD_JUMP_TABLE_CORE (cisco), + BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive), + BFD_JUMP_TABLE_SYMBOLS (_bfd_nosymbols), + BFD_JUMP_TABLE_RELOCS (_bfd_norelocs), + BFD_JUMP_TABLE_WRITE (_bfd_generic), + BFD_JUMP_TABLE_LINK (_bfd_nolink), + BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), + + &core_cisco_be_vec, + + NULL /* backend_data */ }; diff --git a/bfd/coff-alpha.c b/bfd/coff-alpha.c index fe8669f..0e39f31 100644 --- a/bfd/coff-alpha.c +++ b/bfd/coff-alpha.c @@ -447,8 +447,8 @@ alpha_ecoff_bad_format_hook (bfd *abfd ATTRIBUTE_UNUSED, if (ALPHA_ECOFF_COMPRESSEDMAG (*internal_f)) _bfd_error_handler - (_("%B: Cannot handle compressed Alpha binaries.\n" - " Use compiler flags, or objZ, to generate uncompressed binaries."), + (_("%pB: cannot handle compressed Alpha binaries; " + "use compiler flags, or objZ, to generate uncompressed binaries"), abfd); return FALSE; @@ -598,9 +598,8 @@ alpha_adjust_reloc_in (bfd *abfd, if (intern->r_type > ALPHA_R_GPVALUE) { /* xgettext:c-format */ - _bfd_error_handler - (_("%B: unknown/unsupported relocation type %d"), - abfd, intern->r_type); + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, intern->r_type); bfd_set_error (bfd_error_bad_value); rptr->addend = 0; rptr->howto = NULL; @@ -1499,24 +1498,21 @@ alpha_relocate_section (bfd *output_bfd, switch (r_type) { case ALPHA_R_GPRELHIGH: - _bfd_error_handler - (_("%B: unsupported relocation: ALPHA_R_GPRELHIGH"), - input_bfd); + _bfd_error_handler (_("%pB: %s unsupported"), + input_bfd, "ALPHA_R_GPRELHIGH"); bfd_set_error (bfd_error_bad_value); continue; case ALPHA_R_GPRELLOW: - _bfd_error_handler - (_("%B: unsupported relocation: ALPHA_R_GPRELLOW"), - input_bfd); + _bfd_error_handler (_("%pB: %s unsupported"), + input_bfd, "ALPHA_R_GPRELLOW"); bfd_set_error (bfd_error_bad_value); continue; default: - _bfd_error_handler - /* xgettext:c-format */ - (_("%B: unknown relocation type %d"), - input_bfd, (int) r_type); + /* xgettext:c-format */ + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + input_bfd, (int) r_type); bfd_set_error (bfd_error_bad_value); continue; @@ -2218,6 +2214,67 @@ alpha_ecoff_get_elt_at_index (bfd *abfd, symindex sym_index) entry = bfd_ardata (abfd)->symdefs + sym_index; return alpha_ecoff_get_elt_at_filepos (abfd, entry->file_offset); } + +static void +alpha_ecoff_swap_coff_aux_in (bfd *abfd ATTRIBUTE_UNUSED, + void *ext1 ATTRIBUTE_UNUSED, + int type ATTRIBUTE_UNUSED, + int in_class ATTRIBUTE_UNUSED, + int indx ATTRIBUTE_UNUSED, + int numaux ATTRIBUTE_UNUSED, + void *in1 ATTRIBUTE_UNUSED) +{ +} + +static void +alpha_ecoff_swap_coff_sym_in (bfd *abfd ATTRIBUTE_UNUSED, + void *ext1 ATTRIBUTE_UNUSED, + void *in1 ATTRIBUTE_UNUSED) +{ +} + +static void +alpha_ecoff_swap_coff_lineno_in (bfd *abfd ATTRIBUTE_UNUSED, + void *ext1 ATTRIBUTE_UNUSED, + void *in1 ATTRIBUTE_UNUSED) +{ +} + +static unsigned int +alpha_ecoff_swap_coff_aux_out (bfd *abfd ATTRIBUTE_UNUSED, + void *inp ATTRIBUTE_UNUSED, + int type ATTRIBUTE_UNUSED, + int in_class ATTRIBUTE_UNUSED, + int indx ATTRIBUTE_UNUSED, + int numaux ATTRIBUTE_UNUSED, + void *extp ATTRIBUTE_UNUSED) +{ + return 0; +} + +static unsigned int +alpha_ecoff_swap_coff_sym_out (bfd *abfd ATTRIBUTE_UNUSED, + void *inp ATTRIBUTE_UNUSED, + void *extp ATTRIBUTE_UNUSED) +{ + return 0; +} + +static unsigned int +alpha_ecoff_swap_coff_lineno_out (bfd *abfd ATTRIBUTE_UNUSED, + void *inp ATTRIBUTE_UNUSED, + void *extp ATTRIBUTE_UNUSED) +{ + return 0; +} + +static unsigned int +alpha_ecoff_swap_coff_reloc_out (bfd *abfd ATTRIBUTE_UNUSED, + void *inp ATTRIBUTE_UNUSED, + void *extp ATTRIBUTE_UNUSED) +{ + return 0; +} /* This is the ECOFF backend structure. The backend field of the target vector points to this. */ @@ -2226,13 +2283,10 @@ static const struct ecoff_backend_data alpha_ecoff_backend_data = { /* COFF backend structure. */ { - (void (*) (bfd *,void *,int,int,int,int,void *)) bfd_void, /* aux_in */ - (void (*) (bfd *,void *,void *)) bfd_void, /* sym_in */ - (void (*) (bfd *,void *,void *)) bfd_void, /* lineno_in */ - (unsigned (*) (bfd *,void *,int,int,int,int,void *)) bfd_void,/*aux_out*/ - (unsigned (*) (bfd *,void *,void *)) bfd_void, /* sym_out */ - (unsigned (*) (bfd *,void *,void *)) bfd_void, /* lineno_out */ - (unsigned (*) (bfd *,void *,void *)) bfd_void, /* reloc_out */ + alpha_ecoff_swap_coff_aux_in, alpha_ecoff_swap_coff_sym_in, + alpha_ecoff_swap_coff_lineno_in, alpha_ecoff_swap_coff_aux_out, + alpha_ecoff_swap_coff_sym_out, alpha_ecoff_swap_coff_lineno_out, + alpha_ecoff_swap_coff_reloc_out, alpha_ecoff_swap_filehdr_out, alpha_ecoff_swap_aouthdr_out, alpha_ecoff_swap_scnhdr_out, FILHSZ, AOUTSZ, SCNHSZ, 0, 0, 0, 0, FILNMLEN, TRUE, @@ -2353,9 +2407,9 @@ const bfd_target alpha_ecoff_le_vec = BFD_ENDIAN_LITTLE, /* data byte order is little */ BFD_ENDIAN_LITTLE, /* header byte order is little */ - (HAS_RELOC | EXEC_P | /* object flags */ - HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED), + (HAS_RELOC | EXEC_P /* object flags */ + | HAS_LINENO | HAS_DEBUG + | HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED), (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA), 0, /* leading underscore */ @@ -2369,24 +2423,36 @@ const bfd_target alpha_ecoff_le_vec = bfd_getl32, bfd_getl_signed_32, bfd_putl32, bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */ - {_bfd_dummy_target, alpha_ecoff_object_p, /* bfd_check_format */ - bfd_generic_archive_p, _bfd_dummy_target}, - {bfd_false, _bfd_ecoff_mkobject, /* bfd_set_format */ - _bfd_generic_mkarchive, bfd_false}, - {bfd_false, _bfd_ecoff_write_object_contents, /* bfd_write_contents */ - _bfd_write_archive_contents, bfd_false}, - - BFD_JUMP_TABLE_GENERIC (_bfd_ecoff), - BFD_JUMP_TABLE_COPY (_bfd_ecoff), - BFD_JUMP_TABLE_CORE (_bfd_nocore), - BFD_JUMP_TABLE_ARCHIVE (alpha_ecoff), - BFD_JUMP_TABLE_SYMBOLS (_bfd_ecoff), - BFD_JUMP_TABLE_RELOCS (_bfd_ecoff), - BFD_JUMP_TABLE_WRITE (_bfd_ecoff), - BFD_JUMP_TABLE_LINK (_bfd_ecoff), - BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), + { /* bfd_check_format */ + _bfd_dummy_target, + alpha_ecoff_object_p, + bfd_generic_archive_p, + _bfd_dummy_target + }, + { /* bfd_set_format */ + _bfd_bool_bfd_false_error, + _bfd_ecoff_mkobject, + _bfd_generic_mkarchive, + _bfd_bool_bfd_false_error + }, + { /* bfd_write_contents */ + _bfd_bool_bfd_false_error, + _bfd_ecoff_write_object_contents, + _bfd_write_archive_contents, + _bfd_bool_bfd_false_error + }, + + BFD_JUMP_TABLE_GENERIC (_bfd_ecoff), + BFD_JUMP_TABLE_COPY (_bfd_ecoff), + BFD_JUMP_TABLE_CORE (_bfd_nocore), + BFD_JUMP_TABLE_ARCHIVE (alpha_ecoff), + BFD_JUMP_TABLE_SYMBOLS (_bfd_ecoff), + BFD_JUMP_TABLE_RELOCS (_bfd_ecoff), + BFD_JUMP_TABLE_WRITE (_bfd_ecoff), + BFD_JUMP_TABLE_LINK (_bfd_ecoff), + BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), NULL, - & alpha_ecoff_backend_data + &alpha_ecoff_backend_data }; diff --git a/bfd/coff-arm.c b/bfd/coff-arm.c index 4e80a59..ca107b1 100644 --- a/bfd/coff-arm.c +++ b/bfd/coff-arm.c @@ -1034,7 +1034,7 @@ find_thumb_glue (struct bfd_link_info *info, if (myh == NULL) /* xgettext:c-format */ - _bfd_error_handler (_("%B: unable to find THUMB glue '%s' for `%s'"), + _bfd_error_handler (_("%pB: unable to find THUMB glue '%s' for `%s'"), input_bfd, tmp_name, name); free (tmp_name); @@ -1063,7 +1063,7 @@ find_arm_glue (struct bfd_link_info *info, if (myh == NULL) /* xgettext:c-format */ - _bfd_error_handler (_("%B: unable to find ARM glue '%s' for `%s'"), + _bfd_error_handler (_("%pB: unable to find ARM glue '%s' for `%s'"), input_bfd, tmp_name, name); free (tmp_name); @@ -1365,8 +1365,8 @@ coff_arm_relocate_section (bfd *output_bfd, && ! INTERWORK_FLAG (h_sec->owner)) _bfd_error_handler /* xgettext:c-format */ - (_("%B(%s): warning: interworking not enabled.\n" - " first occurrence: %B: arm call to thumb"), + (_("%pB(%s): warning: interworking not enabled; " + "first occurrence: %pB: arm call to thumb"), h_sec->owner, name, input_bfd); --my_offset; @@ -1455,9 +1455,10 @@ coff_arm_relocate_section (bfd *output_bfd, && ! globals->support_old_code) _bfd_error_handler /* xgettext:c-format */ - (_("%B(%s): warning: interworking not enabled.\n" - " first occurrence: %B: thumb call to arm\n" - " consider relinking with --support-old-code enabled"), + (_("%pB(%s): warning: interworking not enabled; " + "first occurrence: %pB: thumb call to arm; " + "consider relinking with --support-old-code " + "enabled"), h_sec->owner, name, input_bfd); -- my_offset; @@ -1748,8 +1749,8 @@ coff_arm_relocate_section (bfd *output_bfd, case bfd_reloc_outofrange: _bfd_error_handler /* xgettext:c-format */ - (_("%B: bad reloc address %#Lx in section `%A'"), - input_bfd, rel->r_vaddr, input_section); + (_("%pB: bad reloc address %#" PRIx64 " in section `%pA'"), + input_bfd, (uint64_t) rel->r_vaddr, input_section); return FALSE; case bfd_reloc_overflow: { @@ -2073,7 +2074,7 @@ bfd_arm_process_before_allocation (bfd * abfd, if (symndx >= obj_conv_table_size (abfd)) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: illegal symbol index in reloc: %ld"), + _bfd_error_handler (_("%pB: illegal symbol index in reloc: %ld"), abfd, symndx); continue; } @@ -2205,7 +2206,7 @@ coff_arm_merge_private_bfd_data (bfd * ibfd, struct bfd_link_info *info) { _bfd_error_handler /* xgettext: c-format */ - (_("error: %B is compiled for APCS-%d, whereas %B is compiled for APCS-%d"), + (_("error: %pB is compiled for APCS-%d, whereas %pB is compiled for APCS-%d"), ibfd, APCS_26_FLAG (ibfd) ? 26 : 32, obfd, APCS_26_FLAG (obfd) ? 26 : 32 ); @@ -2219,12 +2220,12 @@ coff_arm_merge_private_bfd_data (bfd * ibfd, struct bfd_link_info *info) if (APCS_FLOAT_FLAG (ibfd)) /* xgettext: c-format */ _bfd_error_handler (_("\ -error: %B passes floats in float registers, whereas %B passes them in integer registers"), +error: %pB passes floats in float registers, whereas %pB passes them in integer registers"), ibfd, obfd); else /* xgettext: c-format */ _bfd_error_handler (_("\ -error: %B passes floats in integer registers, whereas %B passes them in float registers"), +error: %pB passes floats in integer registers, whereas %pB passes them in float registers"), ibfd, obfd); bfd_set_error (bfd_error_wrong_format); @@ -2236,12 +2237,12 @@ error: %B passes floats in integer registers, whereas %B passes them in float re if (PIC_FLAG (ibfd)) /* xgettext: c-format */ _bfd_error_handler (_("\ -error: %B is compiled as position independent code, whereas target %B is absolute position"), +error: %pB is compiled as position independent code, whereas target %pB is absolute position"), ibfd, obfd); else /* xgettext: c-format */ _bfd_error_handler (_("\ -error: %B is compiled as absolute position code, whereas target %B is position independent"), +error: %pB is compiled as absolute position code, whereas target %pB is position independent"), ibfd, obfd); bfd_set_error (bfd_error_wrong_format); @@ -2268,12 +2269,12 @@ error: %B is compiled as absolute position code, whereas target %B is position i if (INTERWORK_FLAG (ibfd)) /* xgettext: c-format */ _bfd_error_handler (_("\ -Warning: %B supports interworking, whereas %B does not"), +warning: %pB supports interworking, whereas %pB does not"), ibfd, obfd); else /* xgettext: c-format */ _bfd_error_handler (_("\ -Warning: %B does not support interworking, whereas %B does"), +warning: %pB does not support interworking, whereas %pB does"), ibfd, obfd); } } @@ -2363,10 +2364,10 @@ _bfd_coff_arm_set_private_flags (bfd * abfd, flagword flags) if (INTERWORK_SET (abfd) && (INTERWORK_FLAG (abfd) != flag)) { if (flag) - _bfd_error_handler (_("Warning: Not setting interworking flag of %B since it has already been specified as non-interworking"), + _bfd_error_handler (_("warning: not setting interworking flag of %pB since it has already been specified as non-interworking"), abfd); else - _bfd_error_handler (_("Warning: Clearing the interworking flag of %B due to outside request"), + _bfd_error_handler (_("warning: clearing the interworking flag of %pB due to outside request"), abfd); flag = 0; } @@ -2424,7 +2425,7 @@ coff_arm_copy_private_bfd_data (bfd * src, bfd * dest) { /* xgettext:c-format */ _bfd_error_handler (_("\ -Warning: Clearing the interworking flag of %B because non-interworking code in %B has been linked with it"), +warning: clearing the interworking flag of %pB because non-interworking code in %pB has been linked with it"), dest, src); } diff --git a/bfd/coff-i386.c b/bfd/coff-i386.c index 8b8f601..9782206 100644 --- a/bfd/coff-i386.c +++ b/bfd/coff-i386.c @@ -661,27 +661,44 @@ const bfd_target bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */ /* Note that we allow an object file to be treated as a core file as well. */ - /* bfd_check_format */ + #ifdef COFF_CHECK_FORMAT - {_bfd_dummy_target, COFF_CHECK_FORMAT, - bfd_generic_archive_p, COFF_CHECK_FORMAT}, + { /* bfd_check_format */ + _bfd_dummy_target, + COFF_CHECK_FORMAT, + bfd_generic_archive_p, + COFF_CHECK_FORMAT + }, #else - {_bfd_dummy_target, coff_object_p, bfd_generic_archive_p, coff_object_p}, + { + _bfd_dummy_target, + coff_object_p, + bfd_generic_archive_p, + coff_object_p + }, #endif - {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */ - bfd_false}, - {bfd_false, coff_write_object_contents, /* bfd_write_contents */ - _bfd_write_archive_contents, bfd_false}, - - BFD_JUMP_TABLE_GENERIC (coff), - BFD_JUMP_TABLE_COPY (coff), - BFD_JUMP_TABLE_CORE (_bfd_nocore), - BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff), - BFD_JUMP_TABLE_SYMBOLS (coff), - BFD_JUMP_TABLE_RELOCS (coff), - BFD_JUMP_TABLE_WRITE (coff), - BFD_JUMP_TABLE_LINK (coff), - BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), + { /* bfd_set_format */ + _bfd_bool_bfd_false_error, + coff_mkobject, + _bfd_generic_mkarchive, + _bfd_bool_bfd_false_error + }, + { /* bfd_write_contents */ + _bfd_bool_bfd_false_error, + coff_write_object_contents, + _bfd_write_archive_contents, + _bfd_bool_bfd_false_error + }, + + BFD_JUMP_TABLE_GENERIC (coff), + BFD_JUMP_TABLE_COPY (coff), + BFD_JUMP_TABLE_CORE (_bfd_nocore), + BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff), + BFD_JUMP_TABLE_SYMBOLS (coff), + BFD_JUMP_TABLE_RELOCS (coff), + BFD_JUMP_TABLE_WRITE (coff), + BFD_JUMP_TABLE_LINK (coff), + BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), NULL, diff --git a/bfd/coff-i860.c b/bfd/coff-i860.c index 13c84af..9ff96ea 100644 --- a/bfd/coff-i860.c +++ b/bfd/coff-i860.c @@ -139,7 +139,7 @@ coff_i860_reloc (bfd *abfd, these relocations. */ static bfd_reloc_status_type -coff_i860_reloc_nyi (bfd *abfd ATTRIBUTE_UNUSED, +coff_i860_reloc_nyi (bfd *abfd, arelent *reloc_entry, asymbol *symbol ATTRIBUTE_UNUSED, void *data ATTRIBUTE_UNUSED, @@ -148,7 +148,7 @@ coff_i860_reloc_nyi (bfd *abfd ATTRIBUTE_UNUSED, char **error_message ATTRIBUTE_UNUSED) { reloc_howto_type *howto = reloc_entry->howto; - _bfd_error_handler (_("relocation `%s' not yet implemented"), howto->name); + _bfd_error_handler (_("%pB: %s unsupported"), abfd, howto->name); return bfd_reloc_notsupported; } @@ -610,7 +610,7 @@ i860_reloc_processing (arelent *cache_ptr, struct internal_reloc *dst, { _bfd_error_handler /* xgettext: c-format */ - (_("%B: warning: illegal symbol index %ld in relocs"), + (_("%pB: warning: illegal symbol index %ld in relocs"), abfd, dst->r_symndx); cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; ptr = NULL; @@ -677,9 +677,9 @@ const bfd_target BFD_ENDIAN_LITTLE, /* data byte order is little */ BFD_ENDIAN_LITTLE, /* header byte order is little */ - (HAS_RELOC | EXEC_P | /* object flags */ - HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED), + (HAS_RELOC | EXEC_P /* object flags */ + | HAS_LINENO | HAS_DEBUG + | HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED), (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ '_', /* leading underscore */ @@ -695,22 +695,34 @@ const bfd_target bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */ /* Note that we allow an object file to be treated as a core file as well. */ - {_bfd_dummy_target, i3coff_object_p, /* bfd_check_format */ - bfd_generic_archive_p, i3coff_object_p}, - {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */ - bfd_false}, - {bfd_false, coff_write_object_contents, /* bfd_write_contents */ - _bfd_write_archive_contents, bfd_false}, - - BFD_JUMP_TABLE_GENERIC (coff), - BFD_JUMP_TABLE_COPY (coff), - BFD_JUMP_TABLE_CORE (_bfd_nocore), - BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff), - BFD_JUMP_TABLE_SYMBOLS (coff), - BFD_JUMP_TABLE_RELOCS (coff), - BFD_JUMP_TABLE_WRITE (coff), - BFD_JUMP_TABLE_LINK (coff), - BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), + { /* bfd_check_format */ + _bfd_dummy_target, + i3coff_object_p, + bfd_generic_archive_p, + i3coff_object_p + }, + { /* bfd_set_format */ + _bfd_bool_bfd_false_error, + coff_mkobject, + _bfd_generic_mkarchive, + _bfd_bool_bfd_false_error + }, + { /* bfd_write_contents */ + _bfd_bool_bfd_false_error, + coff_write_object_contents, + _bfd_write_archive_contents, + _bfd_bool_bfd_false_error + }, + + BFD_JUMP_TABLE_GENERIC (coff), + BFD_JUMP_TABLE_COPY (coff), + BFD_JUMP_TABLE_CORE (_bfd_nocore), + BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff), + BFD_JUMP_TABLE_SYMBOLS (coff), + BFD_JUMP_TABLE_RELOCS (coff), + BFD_JUMP_TABLE_WRITE (coff), + BFD_JUMP_TABLE_LINK (coff), + BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), NULL, diff --git a/bfd/coff-i960.c b/bfd/coff-i960.c index 8b91bfe..4e68d44 100644 --- a/bfd/coff-i960.c +++ b/bfd/coff-i960.c @@ -614,9 +614,9 @@ const bfd_target icoff_be_vec = BFD_ENDIAN_LITTLE, /* data byte order is little */ BFD_ENDIAN_BIG, /* header byte order is big */ - (HAS_RELOC | EXEC_P | /* object flags */ - HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | WP_TEXT), + (HAS_RELOC | EXEC_P /* object flags */ + | HAS_LINENO | HAS_DEBUG + | HAS_SYMS | HAS_LOCALS | WP_TEXT), (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ '_', /* leading underscore */ @@ -624,31 +624,43 @@ const bfd_target icoff_be_vec = 15, /* ar_max_namelen */ 0, /* match priority. */ -bfd_getl64, bfd_getl_signed_64, bfd_putl64, + bfd_getl64, bfd_getl_signed_64, bfd_putl64, bfd_getl32, bfd_getl_signed_32, bfd_putl32, bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */ -bfd_getb64, bfd_getb_signed_64, bfd_putb64, + bfd_getb64, bfd_getb_signed_64, bfd_putb64, bfd_getb32, bfd_getb_signed_32, bfd_putb32, bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */ - {_bfd_dummy_target, coff_object_p, /* bfd_check_format */ - bfd_generic_archive_p, _bfd_dummy_target}, - {bfd_false, coff_mkobject, /* bfd_set_format */ - _bfd_generic_mkarchive, bfd_false}, - {bfd_false, coff_write_object_contents, /* bfd_write_contents */ - _bfd_write_archive_contents, bfd_false}, - - BFD_JUMP_TABLE_GENERIC (coff), - BFD_JUMP_TABLE_COPY (coff), - BFD_JUMP_TABLE_CORE (_bfd_nocore), - BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff), - BFD_JUMP_TABLE_SYMBOLS (coff), - BFD_JUMP_TABLE_RELOCS (coff), - BFD_JUMP_TABLE_WRITE (coff), - BFD_JUMP_TABLE_LINK (coff), - BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), - - & icoff_le_vec, + { /* bfd_check_format */ + _bfd_dummy_target, + coff_object_p, + bfd_generic_archive_p, + _bfd_dummy_target + }, + { /* bfd_set_format */ + _bfd_bool_bfd_false_error, + coff_mkobject, + _bfd_generic_mkarchive, + _bfd_bool_bfd_false_error + }, + { /* bfd_write_contents */ + _bfd_bool_bfd_false_error, + coff_write_object_contents, + _bfd_write_archive_contents, + _bfd_bool_bfd_false_error + }, + + BFD_JUMP_TABLE_GENERIC (coff), + BFD_JUMP_TABLE_COPY (coff), + BFD_JUMP_TABLE_CORE (_bfd_nocore), + BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff), + BFD_JUMP_TABLE_SYMBOLS (coff), + BFD_JUMP_TABLE_RELOCS (coff), + BFD_JUMP_TABLE_WRITE (coff), + BFD_JUMP_TABLE_LINK (coff), + BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), + + &icoff_le_vec, COFF_SWAP_TABLE }; diff --git a/bfd/coff-ia64.c b/bfd/coff-ia64.c index 56100dd..dfe8d94 100644 --- a/bfd/coff-ia64.c +++ b/bfd/coff-ia64.c @@ -72,7 +72,7 @@ ia64coff_object_p (bfd *abfd) { #ifdef COFF_IMAGE_WITH_PE { - struct external_PEI_DOS_hdr dos_hdr; + struct external_DOS_hdr dos_hdr; struct external_PEI_IMAGE_hdr image_hdr; file_ptr offset; @@ -87,7 +87,7 @@ ia64coff_object_p (bfd *abfd) /* There are really two magic numbers involved; the magic number that says this is a NT executable (PEI) and the magic number - that determines the architecture. The former is DOSMAGIC, + that determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in the e_magic field. The latter is stored in the f_magic field. If the NT magic number isn't valid, the architecture magic number could be mimicked by some other @@ -95,7 +95,7 @@ ia64coff_object_p (bfd *abfd) this routine can only be called correctly for a PEI file, check the e_magic number here, and, if it doesn't match, clobber the f_magic number so that we don't get a false match. */ - if (H_GET_16 (abfd, dos_hdr.e_magic) != DOSMAGIC) + if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) { bfd_set_error (bfd_error_wrong_format); return NULL; @@ -149,9 +149,9 @@ const bfd_target BFD_ENDIAN_LITTLE, /* data byte order is little */ BFD_ENDIAN_LITTLE, /* header byte order is little */ - (HAS_RELOC | EXEC_P | /* object flags */ - HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED), + (HAS_RELOC | EXEC_P /* object flags */ + | HAS_LINENO | HAS_DEBUG + | HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED), #ifndef COFF_WITH_PE (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC /* section flags */ @@ -179,22 +179,34 @@ const bfd_target bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */ /* Note that we allow an object file to be treated as a core file as well. */ - {_bfd_dummy_target, ia64coff_object_p, /* bfd_check_format */ - bfd_generic_archive_p, ia64coff_object_p}, - {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */ - bfd_false}, - {bfd_false, coff_write_object_contents, /* bfd_write_contents */ - _bfd_write_archive_contents, bfd_false}, - - BFD_JUMP_TABLE_GENERIC (coff), - BFD_JUMP_TABLE_COPY (coff), - BFD_JUMP_TABLE_CORE (_bfd_nocore), - BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff), - BFD_JUMP_TABLE_SYMBOLS (coff), - BFD_JUMP_TABLE_RELOCS (coff), - BFD_JUMP_TABLE_WRITE (coff), - BFD_JUMP_TABLE_LINK (coff), - BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), + { /* bfd_check_format */ + _bfd_dummy_target, + ia64coff_object_p, + bfd_generic_archive_p, + ia64coff_object_p + }, + { /* bfd_set_format */ + _bfd_bool_bfd_false_error, + coff_mkobject, + _bfd_generic_mkarchive, + _bfd_bool_bfd_false_error + }, + { /* bfd_write_contents */ + _bfd_bool_bfd_false_error, + coff_write_object_contents, + _bfd_write_archive_contents, + _bfd_bool_bfd_false_error + }, + + BFD_JUMP_TABLE_GENERIC (coff), + BFD_JUMP_TABLE_COPY (coff), + BFD_JUMP_TABLE_CORE (_bfd_nocore), + BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff), + BFD_JUMP_TABLE_SYMBOLS (coff), + BFD_JUMP_TABLE_RELOCS (coff), + BFD_JUMP_TABLE_WRITE (coff), + BFD_JUMP_TABLE_LINK (coff), + BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), NULL, diff --git a/bfd/coff-m68k.c b/bfd/coff-m68k.c index 0fbff22..f7777a1 100644 --- a/bfd/coff-m68k.c +++ b/bfd/coff-m68k.c @@ -485,7 +485,7 @@ bfd_m68k_coff_create_embedded_relocs (bfd *abfd, /* We can only relocate absolute longword relocs at run time. */ if (irel->r_type != R_RELLONG) { - *errmsg = _("unsupported reloc type"); + *errmsg = _("unsupported relocation type"); bfd_set_error (bfd_error_bad_value); return FALSE; } diff --git a/bfd/coff-mcore.c b/bfd/coff-mcore.c index 80432d1..2327d72 100644 --- a/bfd/coff-mcore.c +++ b/bfd/coff-mcore.c @@ -242,7 +242,7 @@ mcore_coff_unsupported_reloc (bfd * abfd, BFD_ASSERT (reloc_entry->howto != (reloc_howto_type *)0); /* xgettext: c-format */ - _bfd_error_handler (_("%B: Relocation %s (%d) is not currently supported.\n"), + _bfd_error_handler (_("%pB: Relocation %s (%d) is not currently supported.\n"), abfd, reloc_entry->howto->name, reloc_entry->howto->type); @@ -368,7 +368,7 @@ coff_mcore_relocate_section (bfd * output_bfd, { _bfd_error_handler /* xgettext: c-format */ - (_("%B: compiled for a %s system and target is %s.\n"), + (_("%pB: compiled for a %s system and target is %s.\n"), input_bfd, bfd_big_endian (input_bfd) ? _("big endian") : _("little endian"), bfd_big_endian (output_bfd) ? _("big endian") : _("little endian")); @@ -470,7 +470,7 @@ coff_mcore_relocate_section (bfd * output_bfd, { default: /* xgettext: c-format */ - _bfd_error_handler (_("%B: unsupported relocation type 0x%02x"), + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), input_bfd, r_type); bfd_set_error (bfd_error_bad_value); return FALSE; @@ -478,10 +478,11 @@ coff_mcore_relocate_section (bfd * output_bfd, case IMAGE_REL_MCORE_ABSOLUTE: _bfd_error_handler /* xgettext: c-format */ - (_("Warning: unsupported reloc %s \n" - "sym %ld (%s), r_vaddr %Ld (%#Lx)"), + (_("warning: unsupported reloc %s \n" + "sym %ld (%s), r_vaddr %" PRId64 " (%#" PRIx64 ")"), howto->name, input_bfd, input_section, - rel->r_symndx, my_name, rel->r_vaddr, rel->r_vaddr); + rel->r_symndx, my_name, (int64_t) rel->r_vaddr, + (uint64_t) rel->r_vaddr); break; case IMAGE_REL_MCORE_PCREL_IMM8BY4: diff --git a/bfd/coff-mips.c b/bfd/coff-mips.c index 2891133..3a0163a 100644 --- a/bfd/coff-mips.c +++ b/bfd/coff-mips.c @@ -1236,6 +1236,67 @@ mips_relocate_section (bfd *output_bfd, return TRUE; } + +static void +mips_ecoff_swap_coff_aux_in (bfd *abfd ATTRIBUTE_UNUSED, + void *ext1 ATTRIBUTE_UNUSED, + int type ATTRIBUTE_UNUSED, + int in_class ATTRIBUTE_UNUSED, + int indx ATTRIBUTE_UNUSED, + int numaux ATTRIBUTE_UNUSED, + void *in1 ATTRIBUTE_UNUSED) +{ +} + +static void +mips_ecoff_swap_coff_sym_in (bfd *abfd ATTRIBUTE_UNUSED, + void *ext1 ATTRIBUTE_UNUSED, + void *in1 ATTRIBUTE_UNUSED) +{ +} + +static void +mips_ecoff_swap_coff_lineno_in (bfd *abfd ATTRIBUTE_UNUSED, + void *ext1 ATTRIBUTE_UNUSED, + void *in1 ATTRIBUTE_UNUSED) +{ +} + +static unsigned int +mips_ecoff_swap_coff_aux_out (bfd *abfd ATTRIBUTE_UNUSED, + void *inp ATTRIBUTE_UNUSED, + int type ATTRIBUTE_UNUSED, + int in_class ATTRIBUTE_UNUSED, + int indx ATTRIBUTE_UNUSED, + int numaux ATTRIBUTE_UNUSED, + void *extp ATTRIBUTE_UNUSED) +{ + return 0; +} + +static unsigned int +mips_ecoff_swap_coff_sym_out (bfd *abfd ATTRIBUTE_UNUSED, + void *inp ATTRIBUTE_UNUSED, + void *extp ATTRIBUTE_UNUSED) +{ + return 0; +} + +static unsigned int +mips_ecoff_swap_coff_lineno_out (bfd *abfd ATTRIBUTE_UNUSED, + void *inp ATTRIBUTE_UNUSED, + void *extp ATTRIBUTE_UNUSED) +{ + return 0; +} + +static unsigned int +mips_ecoff_swap_coff_reloc_out (bfd *abfd ATTRIBUTE_UNUSED, + void *inp ATTRIBUTE_UNUSED, + void *extp ATTRIBUTE_UNUSED) +{ + return 0; +} /* This is the ECOFF backend structure. The backend field of the target vector points to this. */ @@ -1244,13 +1305,10 @@ static const struct ecoff_backend_data mips_ecoff_backend_data = { /* COFF backend structure. */ { - (void (*) (bfd *,void *,int,int,int,int,void *)) bfd_void, /* aux_in */ - (void (*) (bfd *,void *,void *)) bfd_void, /* sym_in */ - (void (*) (bfd *,void *,void *)) bfd_void, /* lineno_in */ - (unsigned (*) (bfd *,void *,int,int,int,int,void *)) bfd_void,/*aux_out*/ - (unsigned (*) (bfd *,void *,void *)) bfd_void, /* sym_out */ - (unsigned (*) (bfd *,void *,void *)) bfd_void, /* lineno_out */ - (unsigned (*) (bfd *,void *,void *)) bfd_void, /* reloc_out */ + mips_ecoff_swap_coff_aux_in, mips_ecoff_swap_coff_sym_in, + mips_ecoff_swap_coff_lineno_in, mips_ecoff_swap_coff_aux_out, + mips_ecoff_swap_coff_sym_out, mips_ecoff_swap_coff_lineno_out, + mips_ecoff_swap_coff_reloc_out, mips_ecoff_swap_filehdr_out, mips_ecoff_swap_aouthdr_out, mips_ecoff_swap_scnhdr_out, FILHSZ, AOUTSZ, SCNHSZ, 0, 0, 0, 0, FILNMLEN, TRUE, @@ -1374,9 +1432,9 @@ const bfd_target mips_ecoff_le_vec = BFD_ENDIAN_LITTLE, /* data byte order is little */ BFD_ENDIAN_LITTLE, /* header byte order is little */ - (HAS_RELOC | EXEC_P | /* object flags */ - HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED), + (HAS_RELOC | EXEC_P /* object flags */ + | HAS_LINENO | HAS_DEBUG + | HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED), (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA), 0, /* leading underscore */ @@ -1390,26 +1448,38 @@ const bfd_target mips_ecoff_le_vec = bfd_getl32, bfd_getl_signed_32, bfd_putl32, bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */ - {_bfd_dummy_target, coff_object_p, /* bfd_check_format */ - bfd_generic_archive_p, _bfd_dummy_target}, - {bfd_false, _bfd_ecoff_mkobject, /* bfd_set_format */ - _bfd_generic_mkarchive, bfd_false}, - {bfd_false, _bfd_ecoff_write_object_contents, /* bfd_write_contents */ - _bfd_write_archive_contents, bfd_false}, - - BFD_JUMP_TABLE_GENERIC (_bfd_ecoff), - BFD_JUMP_TABLE_COPY (_bfd_ecoff), - BFD_JUMP_TABLE_CORE (_bfd_nocore), - BFD_JUMP_TABLE_ARCHIVE (_bfd_ecoff), - BFD_JUMP_TABLE_SYMBOLS (_bfd_ecoff), - BFD_JUMP_TABLE_RELOCS (_bfd_ecoff), - BFD_JUMP_TABLE_WRITE (_bfd_ecoff), - BFD_JUMP_TABLE_LINK (_bfd_ecoff), - BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), - - & mips_ecoff_be_vec, - - & mips_ecoff_backend_data + { /* bfd_check_format */ + _bfd_dummy_target, + coff_object_p, + bfd_generic_archive_p, + _bfd_dummy_target + }, + { /* bfd_set_format */ + _bfd_bool_bfd_false_error, + _bfd_ecoff_mkobject, + _bfd_generic_mkarchive, + _bfd_bool_bfd_false_error + }, + { /* bfd_write_contents */ + _bfd_bool_bfd_false_error, + _bfd_ecoff_write_object_contents, + _bfd_write_archive_contents, + _bfd_bool_bfd_false_error + }, + + BFD_JUMP_TABLE_GENERIC (_bfd_ecoff), + BFD_JUMP_TABLE_COPY (_bfd_ecoff), + BFD_JUMP_TABLE_CORE (_bfd_nocore), + BFD_JUMP_TABLE_ARCHIVE (_bfd_ecoff), + BFD_JUMP_TABLE_SYMBOLS (_bfd_ecoff), + BFD_JUMP_TABLE_RELOCS (_bfd_ecoff), + BFD_JUMP_TABLE_WRITE (_bfd_ecoff), + BFD_JUMP_TABLE_LINK (_bfd_ecoff), + BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), + + &mips_ecoff_be_vec, + + &mips_ecoff_backend_data }; const bfd_target mips_ecoff_be_vec = @@ -1419,9 +1489,9 @@ const bfd_target mips_ecoff_be_vec = BFD_ENDIAN_BIG, /* data byte order is big */ BFD_ENDIAN_BIG, /* header byte order is big */ - (HAS_RELOC | EXEC_P | /* object flags */ - HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED), + (HAS_RELOC | EXEC_P /* object flags */ + | HAS_LINENO | HAS_DEBUG + | HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED), (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA), 0, /* leading underscore */ @@ -1434,26 +1504,39 @@ const bfd_target mips_ecoff_be_vec = bfd_getb64, bfd_getb_signed_64, bfd_putb64, bfd_getb32, bfd_getb_signed_32, bfd_putb32, bfd_getb16, bfd_getb_signed_16, bfd_putb16, - {_bfd_dummy_target, coff_object_p, /* bfd_check_format */ - bfd_generic_archive_p, _bfd_dummy_target}, - {bfd_false, _bfd_ecoff_mkobject, /* bfd_set_format */ - _bfd_generic_mkarchive, bfd_false}, - {bfd_false, _bfd_ecoff_write_object_contents, /* bfd_write_contents */ - _bfd_write_archive_contents, bfd_false}, - - BFD_JUMP_TABLE_GENERIC (_bfd_ecoff), - BFD_JUMP_TABLE_COPY (_bfd_ecoff), - BFD_JUMP_TABLE_CORE (_bfd_nocore), - BFD_JUMP_TABLE_ARCHIVE (_bfd_ecoff), - BFD_JUMP_TABLE_SYMBOLS (_bfd_ecoff), - BFD_JUMP_TABLE_RELOCS (_bfd_ecoff), - BFD_JUMP_TABLE_WRITE (_bfd_ecoff), - BFD_JUMP_TABLE_LINK (_bfd_ecoff), - BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), - - & mips_ecoff_le_vec, - - & mips_ecoff_backend_data + + { /* bfd_check_format */ + _bfd_dummy_target, + coff_object_p, + bfd_generic_archive_p, + _bfd_dummy_target + }, + { /* bfd_set_format */ + _bfd_bool_bfd_false_error, + _bfd_ecoff_mkobject, + _bfd_generic_mkarchive, + _bfd_bool_bfd_false_error + }, + { /* bfd_write_contents */ + _bfd_bool_bfd_false_error, + _bfd_ecoff_write_object_contents, + _bfd_write_archive_contents, + _bfd_bool_bfd_false_error + }, + + BFD_JUMP_TABLE_GENERIC (_bfd_ecoff), + BFD_JUMP_TABLE_COPY (_bfd_ecoff), + BFD_JUMP_TABLE_CORE (_bfd_nocore), + BFD_JUMP_TABLE_ARCHIVE (_bfd_ecoff), + BFD_JUMP_TABLE_SYMBOLS (_bfd_ecoff), + BFD_JUMP_TABLE_RELOCS (_bfd_ecoff), + BFD_JUMP_TABLE_WRITE (_bfd_ecoff), + BFD_JUMP_TABLE_LINK (_bfd_ecoff), + BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), + + &mips_ecoff_le_vec, + + &mips_ecoff_backend_data }; const bfd_target mips_ecoff_bele_vec = @@ -1463,9 +1546,9 @@ const bfd_target mips_ecoff_bele_vec = BFD_ENDIAN_LITTLE, /* data byte order is little */ BFD_ENDIAN_BIG, /* header byte order is big */ - (HAS_RELOC | EXEC_P | /* object flags */ - HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED), + (HAS_RELOC | EXEC_P /* object flags */ + | HAS_LINENO | HAS_DEBUG + | HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED), (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA), 0, /* leading underscore */ @@ -1479,24 +1562,36 @@ const bfd_target mips_ecoff_bele_vec = bfd_getb32, bfd_getb_signed_32, bfd_putb32, bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */ - {_bfd_dummy_target, coff_object_p, /* bfd_check_format */ - bfd_generic_archive_p, _bfd_dummy_target}, - {bfd_false, _bfd_ecoff_mkobject, /* bfd_set_format */ - _bfd_generic_mkarchive, bfd_false}, - {bfd_false, _bfd_ecoff_write_object_contents, /* bfd_write_contents */ - _bfd_write_archive_contents, bfd_false}, - - BFD_JUMP_TABLE_GENERIC (_bfd_ecoff), - BFD_JUMP_TABLE_COPY (_bfd_ecoff), - BFD_JUMP_TABLE_CORE (_bfd_nocore), - BFD_JUMP_TABLE_ARCHIVE (_bfd_ecoff), - BFD_JUMP_TABLE_SYMBOLS (_bfd_ecoff), - BFD_JUMP_TABLE_RELOCS (_bfd_ecoff), - BFD_JUMP_TABLE_WRITE (_bfd_ecoff), - BFD_JUMP_TABLE_LINK (_bfd_ecoff), - BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), + { /* bfd_check_format */ + _bfd_dummy_target, + coff_object_p, + bfd_generic_archive_p, + _bfd_dummy_target + }, + { /* bfd_set_format */ + _bfd_bool_bfd_false_error, + _bfd_ecoff_mkobject, + _bfd_generic_mkarchive, + _bfd_bool_bfd_false_error + }, + { /* bfd_write_contents */ + _bfd_bool_bfd_false_error, + _bfd_ecoff_write_object_contents, + _bfd_write_archive_contents, + _bfd_bool_bfd_false_error + }, + + BFD_JUMP_TABLE_GENERIC (_bfd_ecoff), + BFD_JUMP_TABLE_COPY (_bfd_ecoff), + BFD_JUMP_TABLE_CORE (_bfd_nocore), + BFD_JUMP_TABLE_ARCHIVE (_bfd_ecoff), + BFD_JUMP_TABLE_SYMBOLS (_bfd_ecoff), + BFD_JUMP_TABLE_RELOCS (_bfd_ecoff), + BFD_JUMP_TABLE_WRITE (_bfd_ecoff), + BFD_JUMP_TABLE_LINK (_bfd_ecoff), + BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), NULL, - & mips_ecoff_backend_data + &mips_ecoff_backend_data }; diff --git a/bfd/coff-ppc.c b/bfd/coff-ppc.c index 74f93d5..375ed18 100644 --- a/bfd/coff-ppc.c +++ b/bfd/coff-ppc.c @@ -1038,9 +1038,9 @@ coff_ppc_relocate_section (bfd *output_bfd, switch (r_type) { default: - _bfd_error_handler - /* xgettext: c-format */ - (_("%B: unsupported relocation type 0x%02x"), input_bfd, r_type); + /* xgettext: c-format */ + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + input_bfd, r_type); bfd_set_error (bfd_error_bad_value); return FALSE; case IMAGE_REL_PPC_TOCREL16: @@ -1131,9 +1131,9 @@ coff_ppc_relocate_section (bfd *output_bfd, { _bfd_error_handler /* xgettext: c-format */ - (_("%B: Relocation for %s of %#Lx exceeds " + (_("%pB: Relocation for %s of %#" PRIx64 " exceeds " "Toc size limit"), - input_bfd, name, our_toc_offset); + input_bfd, name, (uint64_t) our_toc_offset); bfd_set_error (bfd_error_bad_value); return FALSE; } @@ -1185,8 +1185,8 @@ coff_ppc_relocate_section (bfd *output_bfd, { _bfd_error_handler /* xgettext: c-format */ - (_("%B: Relocation exceeds allocated TOC (%#Lx)"), - input_bfd, toc_section->size); + (_("%pB: Relocation exceeds allocated TOC (%#" PRIx64 ")"), + input_bfd, (uint64_t) toc_section->size); bfd_set_error (bfd_error_bad_value); return FALSE; } @@ -1240,10 +1240,11 @@ coff_ppc_relocate_section (bfd *output_bfd, _bfd_error_handler /* xgettext: c-format */ - (_("Warning: unsupported reloc %s \n" - "sym %ld (%s), r_vaddr %Ld (%#Lx)"), + (_("warning: unsupported reloc %s \n" + "sym %ld (%s), r_vaddr %" PRId64 " (%#" PRIx64 ")"), howto->name, input_bfd, input_section, - rel->r_symndx, my_name, rel->r_vaddr, rel->r_vaddr); + rel->r_symndx, my_name, + (int64_t) rel->r_vaddr, (uint64_t) rel->r_vaddr); } break; case IMAGE_REL_PPC_IMGLUE: @@ -1258,7 +1259,7 @@ coff_ppc_relocate_section (bfd *output_bfd, _bfd_error_handler /* xgettext: c-format */ - (_("%B: Out of order IMGLUE reloc for %s"), input_bfd, my_name); + (_("%pB: Out of order IMGLUE reloc for %s"), input_bfd, my_name); bfd_set_error (bfd_error_bad_value); return FALSE; } @@ -2480,9 +2481,9 @@ const bfd_target TARGET_LITTLE_SYM = BFD_ENDIAN_LITTLE, /* data byte order is little */ BFD_ENDIAN_LITTLE, /* header byte order is little */ - (HAS_RELOC | EXEC_P | /* FIXME: object flags */ - HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED), + (HAS_RELOC | EXEC_P /* FIXME: object flags */ + | HAS_LINENO | HAS_DEBUG + | HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED), #ifndef COFF_WITH_PE (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_READONLY @@ -2505,12 +2506,24 @@ const bfd_target TARGET_LITTLE_SYM = bfd_getl32, bfd_getl_signed_32, bfd_putl32, bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */ - {_bfd_dummy_target, coff_object_p, /* bfd_check_format */ - bfd_generic_archive_p, /* _bfd_dummy_target */ coff_object_p }, - {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */ - bfd_false}, - {bfd_false, coff_write_object_contents, /* bfd_write_contents */ - _bfd_write_archive_contents, bfd_false}, + { /* bfd_check_format */ + _bfd_dummy_target, + coff_object_p, + bfd_generic_archive_p, + coff_object_p + }, + { /* bfd_set_format */ + _bfd_bool_bfd_false_error, + coff_mkobject, + _bfd_generic_mkarchive, + _bfd_bool_bfd_false_error + }, + { /* bfd_write_contents */ + _bfd_bool_bfd_false_error, + coff_write_object_contents, + _bfd_write_archive_contents, + _bfd_bool_bfd_false_error + }, BFD_JUMP_TABLE_GENERIC (coff), BFD_JUMP_TABLE_COPY (coff), @@ -2524,7 +2537,7 @@ const bfd_target TARGET_LITTLE_SYM = /* Alternative_target. */ #ifdef TARGET_BIG_SYM - & TARGET_BIG_SYM, + &TARGET_BIG_SYM, #else NULL, #endif @@ -2541,9 +2554,9 @@ const bfd_target TARGET_BIG_SYM = BFD_ENDIAN_BIG, /* data byte order is big */ BFD_ENDIAN_BIG, /* header byte order is big */ - (HAS_RELOC | EXEC_P | /* FIXME: object flags */ - HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED), + (HAS_RELOC | EXEC_P /* FIXME: object flags */ + | HAS_LINENO | HAS_DEBUG + | HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED), #ifndef COFF_WITH_PE (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_READONLY @@ -2566,12 +2579,24 @@ const bfd_target TARGET_BIG_SYM = bfd_getb32, bfd_getb_signed_32, bfd_putb32, bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */ - {_bfd_dummy_target, coff_object_p, /* bfd_check_format */ - bfd_generic_archive_p, /* _bfd_dummy_target */ coff_object_p }, - {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */ - bfd_false}, - {bfd_false, coff_write_object_contents, /* bfd_write_contents */ - _bfd_write_archive_contents, bfd_false}, + { /* bfd_check_format */ + _bfd_dummy_target, + coff_object_p, + bfd_generic_archive_p, + coff_object_p + }, + { /* bfd_set_format */ + _bfd_bool_bfd_false_error, + coff_mkobject, + _bfd_generic_mkarchive, + _bfd_bool_bfd_false_error + }, + { /* bfd_write_contents */ + _bfd_bool_bfd_false_error, + coff_write_object_contents, + _bfd_write_archive_contents, + _bfd_bool_bfd_false_error + }, BFD_JUMP_TABLE_GENERIC (coff), BFD_JUMP_TABLE_COPY (coff), @@ -2585,7 +2610,7 @@ const bfd_target TARGET_BIG_SYM = /* Alternative_target. */ #ifdef TARGET_LITTLE_SYM - & TARGET_LITTLE_SYM, + &TARGET_LITTLE_SYM, #else NULL, #endif diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c index 2fc1feb..d8db1f3 100644 --- a/bfd/coff-rs6000.c +++ b/bfd/coff-rs6000.c @@ -2090,7 +2090,7 @@ xcoff_write_archive_contents_old (bfd *abfd) char decbuf[XCOFFARMAG_ELEMENT_SIZE + 1]; memset (&fhdr, 0, sizeof fhdr); - (void) strncpy (fhdr.magic, XCOFFARMAG, SXCOFFARMAG); + (void) memcpy (fhdr.magic, XCOFFARMAG, SXCOFFARMAG); sprintf (fhdr.firstmemoff, "%d", SIZEOF_AR_FILE_HDR); sprintf (fhdr.freeoff, "%d", 0); @@ -2770,7 +2770,7 @@ xcoff_reloc_type_fail (bfd *input_bfd, { _bfd_error_handler /* xgettext: c-format */ - (_("%B: unsupported relocation type 0x%02x"), + (_("%pB: unsupported relocation type %#x"), input_bfd, (unsigned int) rel->r_type); bfd_set_error (bfd_error_bad_value); return FALSE; @@ -2856,8 +2856,8 @@ xcoff_reloc_type_toc (bfd *input_bfd, { _bfd_error_handler /* xgettext: c-format */ - (_("%B: TOC reloc at %#Lx to symbol `%s' with no TOC entry"), - input_bfd, rel->r_vaddr, h->root.root.string); + (_("%pB: TOC reloc at %#" PRIx64 " to symbol `%s' with no TOC entry"), + input_bfd, (uint64_t) rel->r_vaddr, h->root.root.string); bfd_set_error (bfd_error_bad_value); return FALSE; } @@ -3602,7 +3602,7 @@ xcoff_create_csect_from_smclas (bfd *abfd, { _bfd_error_handler /* xgettext: c-format */ - (_("%B: symbol `%s' has unrecognized smclas %d"), + (_("%pB: symbol `%s' has unrecognized smclas %d"), abfd, symbol_name, aux->x_csect.x_smclas); bfd_set_error (bfd_error_bad_value); } @@ -3970,7 +3970,7 @@ const struct xcoff_dwsect_name xcoff_dwsect_names[] = { /* For generic entry points. */ #define _bfd_xcoff_close_and_cleanup _bfd_archive_close_and_cleanup -#define _bfd_xcoff_bfd_free_cached_info bfd_true +#define _bfd_xcoff_bfd_free_cached_info _bfd_bool_bfd_true #define _bfd_xcoff_new_section_hook coff_new_section_hook #define _bfd_xcoff_get_section_contents _bfd_generic_get_section_contents #define _bfd_xcoff_get_section_contents_in_window \ @@ -4001,7 +4001,7 @@ const struct xcoff_dwsect_name xcoff_dwsect_names[] = { #define _bfd_xcoff_write_ar_hdr _bfd_generic_write_ar_hdr #define _bfd_xcoff_get_elt_at_index _bfd_generic_get_elt_at_index #define _bfd_xcoff_generic_stat_arch_elt _bfd_xcoff_stat_arch_elt -#define _bfd_xcoff_update_armap_timestamp bfd_true +#define _bfd_xcoff_update_armap_timestamp _bfd_bool_bfd_true /* For symbols entry points. */ #define _bfd_xcoff_get_symtab_upper_bound coff_get_symtab_upper_bound @@ -4195,17 +4195,17 @@ const bfd_target rs6000_xcoff_vec = }, { /* bfd_set_format */ - bfd_false, + _bfd_bool_bfd_false_error, coff_mkobject, _bfd_generic_mkarchive, - bfd_false + _bfd_bool_bfd_false_error }, {/* bfd_write_contents */ - bfd_false, + _bfd_bool_bfd_false_error, coff_write_object_contents, _bfd_xcoff_write_archive_contents, - bfd_false + _bfd_bool_bfd_false_error }, BFD_JUMP_TABLE_GENERIC (_bfd_xcoff), @@ -4376,17 +4376,17 @@ const bfd_target powerpc_xcoff_vec = }, { /* bfd_set_format */ - bfd_false, + _bfd_bool_bfd_false_error, coff_mkobject, _bfd_generic_mkarchive, - bfd_false + _bfd_bool_bfd_false_error }, {/* bfd_write_contents */ - bfd_false, + _bfd_bool_bfd_false_error, coff_write_object_contents, _bfd_xcoff_write_archive_contents, - bfd_false + _bfd_bool_bfd_false_error }, BFD_JUMP_TABLE_GENERIC (_bfd_xcoff), diff --git a/bfd/coff-sh.c b/bfd/coff-sh.c index 3a921fd..3251d41 100644 --- a/bfd/coff-sh.c +++ b/bfd/coff-sh.c @@ -492,7 +492,7 @@ static const struct shcoff_reloc_map sh_reloc_map[] = #define coff_bfd_reloc_name_lookup sh_coff_reloc_name_lookup static reloc_howto_type * -sh_coff_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED, +sh_coff_reloc_type_lookup (bfd *abfd, bfd_reloc_code_real_type code) { unsigned int i; @@ -501,7 +501,8 @@ sh_coff_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED, if (sh_reloc_map[i].bfd_reloc_val == code) return &sh_coff_howtos[(int) sh_reloc_map[i].shcoff_reloc_val]; - _bfd_error_handler (_("SH Error: unknown reloc type %d"), code); + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, (unsigned int) code); return NULL; } @@ -775,8 +776,9 @@ sh_relax_section (bfd *abfd, if (laddr >= sec->size) { /* xgettext: c-format */ - _bfd_error_handler (_("%B: %#Lx: warning: bad R_SH_USES offset"), - abfd, irel->r_vaddr); + _bfd_error_handler + (_("%pB: %#" PRIx64 ": warning: bad R_SH_USES offset"), + abfd, (uint64_t) irel->r_vaddr); continue; } insn = bfd_get_16 (abfd, contents + laddr); @@ -786,8 +788,8 @@ sh_relax_section (bfd *abfd, { _bfd_error_handler /* xgettext: c-format */ - (_("%B: %#Lx: warning: R_SH_USES points to unrecognized insn %#x"), - abfd, irel->r_vaddr, insn); + (_("%pB: %#" PRIx64 ": warning: R_SH_USES points to unrecognized insn %#x"), + abfd, (uint64_t) irel->r_vaddr, insn); continue; } @@ -804,8 +806,8 @@ sh_relax_section (bfd *abfd, { _bfd_error_handler /* xgettext: c-format */ - (_("%B: %#Lx: warning: bad R_SH_USES load offset"), - abfd, irel->r_vaddr); + (_("%pB: %#" PRIx64 ": warning: bad R_SH_USES load offset"), + abfd, (uint64_t) irel->r_vaddr); continue; } @@ -829,8 +831,8 @@ sh_relax_section (bfd *abfd, { _bfd_error_handler /* xgettext: c-format */ - (_("%B: %#Lx: warning: could not find expected reloc"), - abfd, paddr); + (_("%pB: %#" PRIx64 ": warning: could not find expected reloc"), + abfd, (uint64_t) paddr); continue; } @@ -846,8 +848,8 @@ sh_relax_section (bfd *abfd, { _bfd_error_handler /* xgettext: c-format */ - (_("%B: %#Lx: warning: symbol in unexpected section"), - abfd, paddr); + (_("%pB: %#" PRIx64 ": warning: symbol in unexpected section"), + abfd, (uint64_t) paddr); continue; } @@ -972,8 +974,8 @@ sh_relax_section (bfd *abfd, { _bfd_error_handler /* xgettext: c-format */ - (_("%B: %#Lx: warning: could not find expected COUNT reloc"), - abfd, paddr); + (_("%pB: %#" PRIx64 ": warning: could not find expected COUNT reloc"), + abfd, (uint64_t) paddr); continue; } @@ -982,8 +984,8 @@ sh_relax_section (bfd *abfd, if (irelcount->r_offset == 0) { /* xgettext: c-format */ - _bfd_error_handler (_("%B: %#Lx: warning: bad count"), - abfd, paddr); + _bfd_error_handler (_("%pB: %#" PRIx64 ": warning: bad count"), + abfd, (uint64_t) paddr); continue; } @@ -1354,8 +1356,8 @@ sh_relax_delete_bytes (bfd *abfd, { _bfd_error_handler /* xgettext: c-format */ - (_("%B: %#Lx: fatal: reloc overflow while relaxing"), - abfd, irel->r_vaddr); + (_("%pB: %#" PRIx64 ": fatal: reloc overflow while relaxing"), + abfd, (uint64_t) irel->r_vaddr); bfd_set_error (bfd_error_bad_value); return FALSE; } @@ -1449,7 +1451,7 @@ sh_relax_delete_bytes (bfd *abfd, || obj_raw_syments (abfd) != NULL) { _bfd_error_handler - (_("%B: fatal: generic symbols retrieved before relaxing"), abfd); + (_("%pB: fatal: generic symbols retrieved before relaxing"), abfd); bfd_set_error (bfd_error_invalid_operation); return FALSE; } @@ -2642,8 +2644,8 @@ sh_swap_insns (bfd * abfd, { _bfd_error_handler /* xgettext: c-format */ - (_("%B: %#Lx: fatal: reloc overflow while relaxing"), - abfd, irel->r_vaddr); + (_("%pB: %#" PRIx64 ": fatal: reloc overflow while relaxing"), + abfd, (uint64_t) irel->r_vaddr); bfd_set_error (bfd_error_bad_value); return FALSE; } @@ -2780,7 +2782,7 @@ sh_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, { _bfd_error_handler /* xgettext: c-format */ - (_("%B: illegal symbol index %ld in relocs"), + (_("%pB: illegal symbol index %ld in relocs"), input_bfd, symndx); bfd_set_error (bfd_error_bad_value); return FALSE; @@ -3130,9 +3132,9 @@ const bfd_target sh_coff_small_vec = BFD_ENDIAN_BIG, /* data byte order is big */ BFD_ENDIAN_BIG, /* header byte order is big */ - (HAS_RELOC | EXEC_P | /* object flags */ - HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | WP_TEXT | BFD_IS_RELAXABLE), + (HAS_RELOC | EXEC_P /* object flags */ + | HAS_LINENO | HAS_DEBUG + | HAS_SYMS | HAS_LOCALS | WP_TEXT | BFD_IS_RELAXABLE), (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), '_', /* leading symbol underscore */ @@ -3146,12 +3148,24 @@ const bfd_target sh_coff_small_vec = bfd_getb32, bfd_getb_signed_32, bfd_putb32, bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */ - {_bfd_dummy_target, coff_small_object_p, /* bfd_check_format */ - bfd_generic_archive_p, _bfd_dummy_target}, - {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */ - bfd_false}, - {bfd_false, coff_write_object_contents, /* bfd_write_contents */ - _bfd_write_archive_contents, bfd_false}, + { /* bfd_check_format */ + _bfd_dummy_target, + coff_small_object_p, + bfd_generic_archive_p, + _bfd_dummy_target + }, + { /* bfd_set_format */ + _bfd_bool_bfd_false_error, + coff_mkobject, + _bfd_generic_mkarchive, + _bfd_bool_bfd_false_error + }, + { /* bfd_write_contents */ + _bfd_bool_bfd_false_error, + coff_write_object_contents, + _bfd_write_archive_contents, + _bfd_bool_bfd_false_error + }, BFD_JUMP_TABLE_GENERIC (coff_small), BFD_JUMP_TABLE_COPY (coff), @@ -3163,9 +3177,9 @@ const bfd_target sh_coff_small_vec = BFD_JUMP_TABLE_LINK (coff), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), - & sh_coff_small_le_vec, + &sh_coff_small_le_vec, - & bfd_coff_small_swap_table + &bfd_coff_small_swap_table }; const bfd_target sh_coff_small_le_vec = @@ -3175,9 +3189,9 @@ const bfd_target sh_coff_small_le_vec = BFD_ENDIAN_LITTLE, /* data byte order is little */ BFD_ENDIAN_LITTLE, /* header byte order is little endian too*/ - (HAS_RELOC | EXEC_P | /* object flags */ - HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | WP_TEXT | BFD_IS_RELAXABLE), + (HAS_RELOC | EXEC_P /* object flags */ + | HAS_LINENO | HAS_DEBUG + | HAS_SYMS | HAS_LOCALS | WP_TEXT | BFD_IS_RELAXABLE), (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), '_', /* leading symbol underscore */ @@ -3191,12 +3205,24 @@ const bfd_target sh_coff_small_le_vec = bfd_getl32, bfd_getl_signed_32, bfd_putl32, bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */ - {_bfd_dummy_target, coff_small_object_p, /* bfd_check_format */ - bfd_generic_archive_p, _bfd_dummy_target}, - {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */ - bfd_false}, - {bfd_false, coff_write_object_contents, /* bfd_write_contents */ - _bfd_write_archive_contents, bfd_false}, + { /* bfd_check_format */ + _bfd_dummy_target, + coff_small_object_p, + bfd_generic_archive_p, + _bfd_dummy_target + }, + { /* bfd_set_format */ + _bfd_bool_bfd_false_error, + coff_mkobject, + _bfd_generic_mkarchive, + _bfd_bool_bfd_false_error + }, + { /* bfd_write_contents */ + _bfd_bool_bfd_false_error, + coff_write_object_contents, + _bfd_write_archive_contents, + _bfd_bool_bfd_false_error + }, BFD_JUMP_TABLE_GENERIC (coff_small), BFD_JUMP_TABLE_COPY (coff), @@ -3208,8 +3234,8 @@ const bfd_target sh_coff_small_le_vec = BFD_JUMP_TABLE_LINK (coff), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), - & sh_coff_small_vec, + &sh_coff_small_vec, - & bfd_coff_small_swap_table + &bfd_coff_small_swap_table }; #endif diff --git a/bfd/coff-tic30.c b/bfd/coff-tic30.c index f597a28..79d2ba1 100644 --- a/bfd/coff-tic30.c +++ b/bfd/coff-tic30.c @@ -183,9 +183,9 @@ const bfd_target tic30_coff_vec = BFD_ENDIAN_BIG, /* data byte order is big */ BFD_ENDIAN_LITTLE, /* header byte order is little */ - (HAS_RELOC | EXEC_P | /* object flags */ - HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | WP_TEXT), + (HAS_RELOC | EXEC_P /* object flags */ + | HAS_LINENO | HAS_DEBUG + | HAS_SYMS | HAS_LOCALS | WP_TEXT), (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ '_', /* leading symbol underscore */ @@ -199,12 +199,24 @@ const bfd_target tic30_coff_vec = bfd_getl32, bfd_getl_signed_32, bfd_putl32, bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */ - {_bfd_dummy_target, coff_object_p, /* bfd_check_format */ - bfd_generic_archive_p, _bfd_dummy_target}, - {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */ - bfd_false}, - {bfd_false, coff_write_object_contents, /* bfd_write_contents */ - _bfd_write_archive_contents, bfd_false}, + { /* bfd_check_format */ + _bfd_dummy_target, + coff_object_p, + bfd_generic_archive_p, + _bfd_dummy_target + }, + { /* bfd_set_format */ + _bfd_bool_bfd_false_error, + coff_mkobject, + _bfd_generic_mkarchive, + _bfd_bool_bfd_false_error + }, + { /* bfd_write_contents */ + _bfd_bool_bfd_false_error, + coff_write_object_contents, + _bfd_write_archive_contents, + _bfd_bool_bfd_false_error + }, BFD_JUMP_TABLE_GENERIC (coff), BFD_JUMP_TABLE_COPY (coff), diff --git a/bfd/coff-tic4x.c b/bfd/coff-tic4x.c index 660b519..cb0f6a4 100644 --- a/bfd/coff-tic4x.c +++ b/bfd/coff-tic4x.c @@ -165,7 +165,8 @@ tic4x_coff_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, Called after some initial checking by the tic4x_rtype_to_howto fn below. */ static void -tic4x_lookup_howto (arelent *internal, +tic4x_lookup_howto (bfd *abfd, + arelent *internal, struct internal_reloc *dst) { unsigned int i; @@ -180,13 +181,13 @@ tic4x_lookup_howto (arelent *internal, } } - _bfd_error_handler (_("Unrecognized reloc type 0x%x"), - (unsigned int) dst->r_type); + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, (unsigned int) dst->r_type); abort(); } static reloc_howto_type * -coff_tic4x_rtype_to_howto (bfd *abfd ATTRIBUTE_UNUSED, +coff_tic4x_rtype_to_howto (bfd *abfd, asection *sec, struct internal_reloc *rel, struct coff_link_hash_entry *h ATTRIBUTE_UNUSED, @@ -201,7 +202,7 @@ coff_tic4x_rtype_to_howto (bfd *abfd ATTRIBUTE_UNUSED, in the output section. */ *addendp = (sec->output_section->vma + sec->output_offset) - sec->vma; - tic4x_lookup_howto (&genrel, rel); + tic4x_lookup_howto (abfd, &genrel, rel); return genrel.howto; } @@ -224,7 +225,7 @@ tic4x_reloc_processing (arelent *relent, { _bfd_error_handler /* xgettext: c-format */ - (_("%B: warning: illegal symbol index %ld in relocs"), + (_("%pB: warning: illegal symbol index %ld in relocs"), abfd, reloc->r_symndx); relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; ptr = NULL; @@ -256,7 +257,7 @@ tic4x_reloc_processing (arelent *relent, /* !! relent->section = (asection *) NULL; */ /* Fill in the relent->howto field from reloc->r_type. */ - tic4x_lookup_howto (relent, reloc); + tic4x_lookup_howto (abfd, relent, reloc); } diff --git a/bfd/coff-tic54x.c b/bfd/coff-tic54x.c index 0b6848f..75b9fb8 100644 --- a/bfd/coff-tic54x.c +++ b/bfd/coff-tic54x.c @@ -260,7 +260,8 @@ tic54x_coff_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, Called after some initial checking by the tic54x_rtype_to_howto fn below. */ static void -tic54x_lookup_howto (arelent *internal, +tic54x_lookup_howto (bfd *abfd, + arelent *internal, struct internal_reloc *dst) { unsigned i; @@ -275,8 +276,8 @@ tic54x_lookup_howto (arelent *internal, } } - _bfd_error_handler (_("Unrecognized reloc type 0x%x"), - (unsigned int) dst->r_type); + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, (unsigned int) dst->r_type); abort (); } @@ -286,7 +287,7 @@ tic54x_lookup_howto (arelent *internal, #define coff_rtype_to_howto coff_tic54x_rtype_to_howto static reloc_howto_type * -coff_tic54x_rtype_to_howto (bfd *abfd ATTRIBUTE_UNUSED, +coff_tic54x_rtype_to_howto (bfd *abfd, asection *sec, struct internal_reloc *rel, struct coff_link_hash_entry *h ATTRIBUTE_UNUSED, @@ -303,7 +304,7 @@ coff_tic54x_rtype_to_howto (bfd *abfd ATTRIBUTE_UNUSED, *addendp = (sec->output_section->vma + sec->output_offset) - sec->vma; } - tic54x_lookup_howto (&genrel, rel); + tic54x_lookup_howto (abfd, &genrel, rel); return genrel.howto; } @@ -362,7 +363,7 @@ tic54x_reloc_processing (arelent *relent, { _bfd_error_handler /* xgettext: c-format */ - (_("%B: warning: illegal symbol index %ld in relocs"), + (_("%pB: warning: illegal symbol index %ld in relocs"), abfd, reloc->r_symndx); relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; ptr = NULL; @@ -394,24 +395,24 @@ tic54x_reloc_processing (arelent *relent, /* !! relent->section = (asection *) NULL;*/ /* Fill in the relent->howto field from reloc->r_type. */ - tic54x_lookup_howto (relent, reloc); + tic54x_lookup_howto (abfd, relent, reloc); } /* TI COFF v0, DOS tools (little-endian headers). */ const bfd_target tic54x_coff0_vec = { - "coff0-c54x", /* name */ + "coff0-c54x", /* name */ bfd_target_coff_flavour, BFD_ENDIAN_LITTLE, /* data byte order is little */ BFD_ENDIAN_LITTLE, /* header byte order is little (DOS tools) */ - (HAS_RELOC | EXEC_P | /* object flags */ - HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | WP_TEXT ), + (HAS_RELOC | EXEC_P /* object flags */ + | HAS_LINENO | HAS_DEBUG + | HAS_SYMS | HAS_LOCALS | WP_TEXT ), (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ - '_', /* leading symbol underscore */ - '/', /* ar_pad_char */ + '_', /* leading symbol underscore */ + '/', /* ar_pad_char */ 15, /* ar_max_namelen */ 0, /* match priority. */ bfd_getl64, bfd_getl_signed_64, bfd_putl64, @@ -421,12 +422,24 @@ const bfd_target tic54x_coff0_vec = bfd_getl32, bfd_getl_signed_32, bfd_putl32, bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */ - {_bfd_dummy_target, coff_object_p, /* bfd_check_format */ - bfd_generic_archive_p, _bfd_dummy_target}, - {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */ - bfd_false}, - {bfd_false, coff_write_object_contents, /* bfd_write_contents */ - _bfd_write_archive_contents, bfd_false}, + { /* bfd_check_format */ + _bfd_dummy_target, + coff_object_p, + bfd_generic_archive_p, + _bfd_dummy_target + }, + { /* bfd_set_format */ + _bfd_bool_bfd_false_error, + coff_mkobject, + _bfd_generic_mkarchive, + _bfd_bool_bfd_false_error + }, + { /* bfd_write_contents */ + _bfd_bool_bfd_false_error, + coff_write_object_contents, + _bfd_write_archive_contents, + _bfd_bool_bfd_false_error + }, BFD_JUMP_TABLE_GENERIC (coff), BFD_JUMP_TABLE_COPY (coff), @@ -439,24 +452,24 @@ const bfd_target tic54x_coff0_vec = BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), NULL, - & ticoff0_swap_table + &ticoff0_swap_table }; /* TI COFF v0, SPARC tools (big-endian headers). */ const bfd_target tic54x_coff0_beh_vec = { - "coff0-beh-c54x", /* name */ + "coff0-beh-c54x", /* name */ bfd_target_coff_flavour, BFD_ENDIAN_LITTLE, /* data byte order is little */ BFD_ENDIAN_BIG, /* header byte order is big */ - (HAS_RELOC | EXEC_P | /* object flags */ - HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | WP_TEXT ), + (HAS_RELOC | EXEC_P /* object flags */ + | HAS_LINENO | HAS_DEBUG + | HAS_SYMS | HAS_LOCALS | WP_TEXT ), (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ - '_', /* leading symbol underscore */ - '/', /* ar_pad_char */ + '_', /* leading symbol underscore */ + '/', /* ar_pad_char */ 15, /* ar_max_namelen */ 0, /* match priority. */ bfd_getl64, bfd_getl_signed_64, bfd_putl64, @@ -466,12 +479,24 @@ const bfd_target tic54x_coff0_beh_vec = bfd_getb32, bfd_getb_signed_32, bfd_putb32, bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */ - {_bfd_dummy_target, coff_object_p, /* bfd_check_format */ - bfd_generic_archive_p, _bfd_dummy_target}, - {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */ - bfd_false}, - {bfd_false, coff_write_object_contents, /* bfd_write_contents */ - _bfd_write_archive_contents, bfd_false}, + { /* bfd_check_format */ + _bfd_dummy_target, + coff_object_p, + bfd_generic_archive_p, + _bfd_dummy_target + }, + { /* bfd_set_format */ + _bfd_bool_bfd_false_error, + coff_mkobject, + _bfd_generic_mkarchive, + _bfd_bool_bfd_false_error + }, + { /* bfd_write_contents */ + _bfd_bool_bfd_false_error, + coff_write_object_contents, + _bfd_write_archive_contents, + _bfd_bool_bfd_false_error + }, BFD_JUMP_TABLE_GENERIC (coff), BFD_JUMP_TABLE_COPY (coff), @@ -483,26 +508,26 @@ const bfd_target tic54x_coff0_beh_vec = BFD_JUMP_TABLE_LINK (coff), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), - & tic54x_coff0_vec, + &tic54x_coff0_vec, - & ticoff0_swap_table + &ticoff0_swap_table }; /* TI COFF v1, DOS tools (little-endian headers). */ const bfd_target tic54x_coff1_vec = { - "coff1-c54x", /* name */ + "coff1-c54x", /* name */ bfd_target_coff_flavour, BFD_ENDIAN_LITTLE, /* data byte order is little */ BFD_ENDIAN_LITTLE, /* header byte order is little (DOS tools) */ - (HAS_RELOC | EXEC_P | /* object flags */ - HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | WP_TEXT ), + (HAS_RELOC | EXEC_P /* object flags */ + | HAS_LINENO | HAS_DEBUG + | HAS_SYMS | HAS_LOCALS | WP_TEXT ), (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ - '_', /* leading symbol underscore */ - '/', /* ar_pad_char */ + '_', /* leading symbol underscore */ + '/', /* ar_pad_char */ 15, /* ar_max_namelen */ 0, /* match priority. */ bfd_getl64, bfd_getl_signed_64, bfd_putl64, @@ -512,12 +537,24 @@ const bfd_target tic54x_coff1_vec = bfd_getl32, bfd_getl_signed_32, bfd_putl32, bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */ - {_bfd_dummy_target, coff_object_p, /* bfd_check_format */ - bfd_generic_archive_p, _bfd_dummy_target}, - {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */ - bfd_false}, - {bfd_false, coff_write_object_contents, /* bfd_write_contents */ - _bfd_write_archive_contents, bfd_false}, + { /* bfd_check_format */ + _bfd_dummy_target, + coff_object_p, + bfd_generic_archive_p, + _bfd_dummy_target + }, + { /* bfd_set_format */ + _bfd_bool_bfd_false_error, + coff_mkobject, + _bfd_generic_mkarchive, + _bfd_bool_bfd_false_error + }, + { /* bfd_write_contents */ + _bfd_bool_bfd_false_error, + coff_write_object_contents, + _bfd_write_archive_contents, + _bfd_bool_bfd_false_error + }, BFD_JUMP_TABLE_GENERIC (coff), BFD_JUMP_TABLE_COPY (coff), @@ -529,26 +566,26 @@ const bfd_target tic54x_coff1_vec = BFD_JUMP_TABLE_LINK (coff), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), - & tic54x_coff0_beh_vec, + &tic54x_coff0_beh_vec, - & ticoff1_swap_table + &ticoff1_swap_table }; /* TI COFF v1, SPARC tools (big-endian headers). */ const bfd_target tic54x_coff1_beh_vec = { - "coff1-beh-c54x", /* name */ + "coff1-beh-c54x", /* name */ bfd_target_coff_flavour, BFD_ENDIAN_LITTLE, /* data byte order is little */ BFD_ENDIAN_BIG, /* header byte order is big */ - (HAS_RELOC | EXEC_P | /* object flags */ - HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | WP_TEXT ), + (HAS_RELOC | EXEC_P /* object flags */ + | HAS_LINENO | HAS_DEBUG + | HAS_SYMS | HAS_LOCALS | WP_TEXT ), (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ - '_', /* leading symbol underscore */ - '/', /* ar_pad_char */ + '_', /* leading symbol underscore */ + '/', /* ar_pad_char */ 15, /* ar_max_namelen */ 0, /* match priority. */ bfd_getl64, bfd_getl_signed_64, bfd_putl64, @@ -558,12 +595,24 @@ const bfd_target tic54x_coff1_beh_vec = bfd_getb32, bfd_getb_signed_32, bfd_putb32, bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */ - {_bfd_dummy_target, coff_object_p, /* bfd_check_format */ - bfd_generic_archive_p, _bfd_dummy_target}, - {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */ - bfd_false}, - {bfd_false, coff_write_object_contents, /* bfd_write_contents */ - _bfd_write_archive_contents, bfd_false}, + { /* bfd_check_format */ + _bfd_dummy_target, + coff_object_p, + bfd_generic_archive_p, + _bfd_dummy_target + }, + { /* bfd_set_format */ + _bfd_bool_bfd_false_error, + coff_mkobject, + _bfd_generic_mkarchive, + _bfd_bool_bfd_false_error + }, + { /* bfd_write_contents */ + _bfd_bool_bfd_false_error, + coff_write_object_contents, + _bfd_write_archive_contents, + _bfd_bool_bfd_false_error + }, BFD_JUMP_TABLE_GENERIC (coff), BFD_JUMP_TABLE_COPY (coff), @@ -575,26 +624,26 @@ const bfd_target tic54x_coff1_beh_vec = BFD_JUMP_TABLE_LINK (coff), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), - & tic54x_coff1_vec, + &tic54x_coff1_vec, - & ticoff1_swap_table + &ticoff1_swap_table }; /* TI COFF v2, TI DOS tools output (little-endian headers). */ const bfd_target tic54x_coff2_vec = { - "coff2-c54x", /* name */ + "coff2-c54x", /* name */ bfd_target_coff_flavour, BFD_ENDIAN_LITTLE, /* data byte order is little */ BFD_ENDIAN_LITTLE, /* header byte order is little (DOS tools) */ - (HAS_RELOC | EXEC_P | /* object flags */ - HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | WP_TEXT ), + (HAS_RELOC | EXEC_P /* object flags */ + | HAS_LINENO | HAS_DEBUG + | HAS_SYMS | HAS_LOCALS | WP_TEXT ), (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ - '_', /* leading symbol underscore */ - '/', /* ar_pad_char */ + '_', /* leading symbol underscore */ + '/', /* ar_pad_char */ 15, /* ar_max_namelen */ 0, /* match priority. */ bfd_getl64, bfd_getl_signed_64, bfd_putl64, @@ -604,12 +653,24 @@ const bfd_target tic54x_coff2_vec = bfd_getl32, bfd_getl_signed_32, bfd_putl32, bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */ - {_bfd_dummy_target, coff_object_p, /* bfd_check_format */ - bfd_generic_archive_p, _bfd_dummy_target}, - {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */ - bfd_false}, - {bfd_false, coff_write_object_contents, /* bfd_write_contents */ - _bfd_write_archive_contents, bfd_false}, + { /* bfd_check_format */ + _bfd_dummy_target, + coff_object_p, + bfd_generic_archive_p, + _bfd_dummy_target + }, + { /* bfd_set_format */ + _bfd_bool_bfd_false_error, + coff_mkobject, + _bfd_generic_mkarchive, + _bfd_bool_bfd_false_error + }, + { /* bfd_write_contents */ + _bfd_bool_bfd_false_error, + coff_write_object_contents, + _bfd_write_archive_contents, + _bfd_bool_bfd_false_error + }, BFD_JUMP_TABLE_GENERIC (coff), BFD_JUMP_TABLE_COPY (coff), @@ -621,7 +682,7 @@ const bfd_target tic54x_coff2_vec = BFD_JUMP_TABLE_LINK (coff), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), - & tic54x_coff1_beh_vec, + &tic54x_coff1_beh_vec, COFF_SWAP_TABLE }; @@ -629,18 +690,18 @@ const bfd_target tic54x_coff2_vec = /* TI COFF v2, TI SPARC tools output (big-endian headers). */ const bfd_target tic54x_coff2_beh_vec = { - "coff2-beh-c54x", /* name */ + "coff2-beh-c54x", /* name */ bfd_target_coff_flavour, BFD_ENDIAN_LITTLE, /* data byte order is little */ BFD_ENDIAN_BIG, /* header byte order is big */ - (HAS_RELOC | EXEC_P | /* object flags */ - HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | WP_TEXT ), + (HAS_RELOC | EXEC_P /* object flags */ + | HAS_LINENO | HAS_DEBUG + | HAS_SYMS | HAS_LOCALS | WP_TEXT ), (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ - '_', /* leading symbol underscore */ - '/', /* ar_pad_char */ + '_', /* leading symbol underscore */ + '/', /* ar_pad_char */ 15, /* ar_max_namelen */ 0, /* match priority. */ bfd_getl64, bfd_getl_signed_64, bfd_putl64, @@ -650,12 +711,24 @@ const bfd_target tic54x_coff2_beh_vec = bfd_getb32, bfd_getb_signed_32, bfd_putb32, bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */ - {_bfd_dummy_target, coff_object_p, /* bfd_check_format */ - bfd_generic_archive_p, _bfd_dummy_target}, - {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */ - bfd_false}, - {bfd_false, coff_write_object_contents, /* bfd_write_contents */ - _bfd_write_archive_contents, bfd_false}, + { /* bfd_check_format */ + _bfd_dummy_target, + coff_object_p, + bfd_generic_archive_p, + _bfd_dummy_target + }, + { /* bfd_set_format */ + _bfd_bool_bfd_false_error, + coff_mkobject, + _bfd_generic_mkarchive, + _bfd_bool_bfd_false_error + }, + { /* bfd_write_contents */ + _bfd_bool_bfd_false_error, + coff_write_object_contents, + _bfd_write_archive_contents, + _bfd_bool_bfd_false_error + }, BFD_JUMP_TABLE_GENERIC (coff), BFD_JUMP_TABLE_COPY (coff), @@ -667,7 +740,7 @@ const bfd_target tic54x_coff2_beh_vec = BFD_JUMP_TABLE_LINK (coff), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), - & tic54x_coff2_vec, + &tic54x_coff2_vec, COFF_SWAP_TABLE }; diff --git a/bfd/coff-tic80.c b/bfd/coff-tic80.c index 3496a05..4120b60 100644 --- a/bfd/coff-tic80.c +++ b/bfd/coff-tic80.c @@ -438,7 +438,7 @@ rtype2howto (arelent *cache_ptr, struct internal_reloc *dst) } } - _bfd_error_handler (_("Unrecognized reloc type 0x%x"), + _bfd_error_handler (_("unsupported relocation type %#x"), (unsigned int) dst->r_type); cache_ptr->howto = tic80_howto_table + 0; } @@ -669,8 +669,8 @@ coff_tic80_relocate_section (bfd *output_bfd, case bfd_reloc_outofrange: _bfd_error_handler /* xgettext: c-format */ - (_("%B: bad reloc address %#Lx in section `%A'"), - input_bfd, rel->r_vaddr, input_section); + (_("%pB: bad reloc address %#" PRIx64 " in section `%pA'"), + input_bfd, (uint64_t) rel->r_vaddr, input_section); return FALSE; case bfd_reloc_overflow: { diff --git a/bfd/coff-w65.c b/bfd/coff-w65.c index c9c58f7..68b2c94 100644 --- a/bfd/coff-w65.c +++ b/bfd/coff-w65.c @@ -349,7 +349,7 @@ w65_reloc16_extra_cases (bfd *abfd, } break; default: - printf (_("ignoring reloc %s\n"), reloc->howto->name); + _bfd_error_handler (_("%pB: %s unsupported"), abfd, reloc->howto->name); break; } diff --git a/bfd/coff-x86_64.c b/bfd/coff-x86_64.c index 25e9883..f0108ea 100644 --- a/bfd/coff-x86_64.c +++ b/bfd/coff-x86_64.c @@ -761,9 +761,9 @@ const bfd_target BFD_ENDIAN_LITTLE, /* Data byte order is little. */ BFD_ENDIAN_LITTLE, /* Header byte order is little. */ - (HAS_RELOC | EXEC_P | /* Object flags. */ - HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED | BFD_COMPRESS | BFD_DECOMPRESS), + (HAS_RELOC | EXEC_P /* Object flags. */ + | HAS_LINENO | HAS_DEBUG + | HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED | BFD_COMPRESS | BFD_DECOMPRESS), (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC /* Section flags. */ #if defined(COFF_WITH_PE) @@ -788,12 +788,24 @@ const bfd_target bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* Hdrs. */ /* Note that we allow an object file to be treated as a core file as well. */ - { _bfd_dummy_target, amd64coff_object_p, /* BFD_check_format. */ - bfd_generic_archive_p, amd64coff_object_p }, - { bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format. */ - bfd_false }, - { bfd_false, coff_write_object_contents, /* bfd_write_contents. */ - _bfd_write_archive_contents, bfd_false }, + { /* bfd_check_format. */ + _bfd_dummy_target, + amd64coff_object_p, + bfd_generic_archive_p, + amd64coff_object_p + }, + { /* bfd_set_format. */ + _bfd_bool_bfd_false_error, + coff_mkobject, + _bfd_generic_mkarchive, + _bfd_bool_bfd_false_error + }, + { /* bfd_write_contents. */ + _bfd_bool_bfd_false_error, + coff_write_object_contents, + _bfd_write_archive_contents, + _bfd_bool_bfd_false_error + }, BFD_JUMP_TABLE_GENERIC (coff), BFD_JUMP_TABLE_COPY (coff), diff --git a/bfd/coff64-rs6000.c b/bfd/coff64-rs6000.c index 884d82a..78f14a0 100644 --- a/bfd/coff64-rs6000.c +++ b/bfd/coff64-rs6000.c @@ -2147,7 +2147,7 @@ xcoff64_create_csect_from_smclas (bfd *abfd, union internal_auxent *aux, { _bfd_error_handler /* xgettext: c-format */ - (_("%B: symbol `%s' has unrecognized smclas %d"), + (_("%pB: symbol `%s' has unrecognized smclas %d"), abfd, symbol_name, aux->x_csect.x_smclas); bfd_set_error (bfd_error_bad_value); } @@ -2694,22 +2694,22 @@ const bfd_target rs6000_xcoff64_vec = }, { /* bfd_set_format */ - bfd_false, + _bfd_bool_bfd_false_error, coff_mkobject, _bfd_generic_mkarchive, - bfd_false + _bfd_bool_bfd_false_error }, {/* bfd_write_contents */ - bfd_false, + _bfd_bool_bfd_false_error, xcoff64_write_object_contents, _bfd_xcoff_write_archive_contents, - bfd_false + _bfd_bool_bfd_false_error }, /* Generic */ _bfd_archive_close_and_cleanup, - bfd_true, + _bfd_bool_bfd_true, coff_new_section_hook, _bfd_generic_get_section_contents, _bfd_generic_get_section_contents_in_window, @@ -2738,7 +2738,7 @@ const bfd_target rs6000_xcoff64_vec = xcoff64_openr_next_archived_file, _bfd_generic_get_elt_at_index, _bfd_xcoff_stat_arch_elt, - bfd_true, + _bfd_bool_bfd_true, /* Symbols */ coff_get_symtab_upper_bound, @@ -2955,22 +2955,22 @@ const bfd_target rs6000_xcoff64_aix_vec = }, { /* bfd_set_format */ - bfd_false, + _bfd_bool_bfd_false_error, coff_mkobject, _bfd_generic_mkarchive, - bfd_false + _bfd_bool_bfd_false_error }, {/* bfd_write_contents */ - bfd_false, + _bfd_bool_bfd_false_error, xcoff64_write_object_contents, _bfd_xcoff_write_archive_contents, - bfd_false + _bfd_bool_bfd_false_error }, /* Generic */ _bfd_archive_close_and_cleanup, - bfd_true, + _bfd_bool_bfd_true, coff_new_section_hook, _bfd_generic_get_section_contents, _bfd_generic_get_section_contents_in_window, @@ -2999,7 +2999,7 @@ const bfd_target rs6000_xcoff64_aix_vec = xcoff64_openr_next_archived_file, _bfd_generic_get_elt_at_index, _bfd_xcoff_stat_arch_elt, - bfd_true, + _bfd_bool_bfd_true, /* Symbols */ coff_get_symtab_upper_bound, diff --git a/bfd/coffcode.h b/bfd/coffcode.h index ec0103e..caa8bcb 100644 --- a/bfd/coffcode.h +++ b/bfd/coffcode.h @@ -965,7 +965,7 @@ handle_COMDAT (bfd * abfd, /* PR 17512 file: 078-11867-0.004 */ if (symname == NULL) { - _bfd_error_handler (_("%B: unable to load COMDAT section name"), + _bfd_error_handler (_("%pB: unable to load COMDAT section name"), abfd); break; } @@ -1000,7 +1000,7 @@ handle_COMDAT (bfd * abfd, { /* Malformed input files can trigger this test. cf PR 21781. */ - _bfd_error_handler (_("%B: error: unexpected symbol '%s' in COMDAT section"), + _bfd_error_handler (_("%pB: error: unexpected symbol '%s' in COMDAT section"), abfd, symname); goto breakloop; } @@ -1012,7 +1012,7 @@ handle_COMDAT (bfd * abfd, if (isym.n_sclass == C_STAT && strcmp (name, symname) != 0) /* xgettext:c-format */ - _bfd_error_handler (_("%B: warning: COMDAT symbol '%s'" + _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'" " does not match section name '%s'"), abfd, symname, name); @@ -1022,7 +1022,7 @@ handle_COMDAT (bfd * abfd, if (esym + bfd_coff_symesz (abfd) >= esymend) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: warning: No symbol for" + _bfd_error_handler (_("%pB: warning: no symbol for" " section '%s' found"), abfd, symname); break; @@ -1248,9 +1248,9 @@ styp_to_sec_flags (bfd *abfd, variable as this will allow some .sys files generate by other toolchains to be processed. See bugzilla issue 196. */ /* xgettext:c-format */ - _bfd_error_handler (_("%B: Warning: Ignoring section flag" - " IMAGE_SCN_MEM_NOT_PAGED in section %s"), - abfd, name); + _bfd_error_handler (_("%pB: warning: ignoring section flag" + " %s in section %s"), + abfd, "IMAGE_SCN_MEM_NOT_PAGED", name); break; case IMAGE_SCN_MEM_EXECUTE: sec_flags |= SEC_CODE; @@ -1317,7 +1317,7 @@ styp_to_sec_flags (bfd *abfd, { _bfd_error_handler /* xgettext:c-format */ - (_("%B (%s): Section flag %s (%#lx) ignored"), + (_("%pB (%s): section flag %s (%#lx) ignored"), abfd, name, unhandled, flag); result = FALSE; } @@ -1947,7 +1947,7 @@ coff_set_alignment_hook (bfd * abfd ATTRIBUTE_UNUSED, } else if (hdr->s_nreloc == 0xffff) _bfd_error_handler - (_("%B: warning: claims to have 0xffff relocs, without overflow"), + (_("%pB: warning: claims to have 0xffff relocs, without overflow"), abfd); } #undef ALIGN_SET @@ -1985,8 +1985,12 @@ coff_set_alignment_hook (bfd *abfd, asection *section, void * scnhdr) #else /* ! RS6000COFF_C */ -#define coff_set_alignment_hook \ - ((void (*) (bfd *, asection *, void *)) bfd_void) +static void +coff_set_alignment_hook (bfd *abfd ATTRIBUTE_UNUSED, + asection *section ATTRIBUTE_UNUSED, + void *scnhdr ATTRIBUTE_UNUSED) +{ +} #endif /* ! RS6000COFF_C */ #endif /* ! COFF_WITH_PE */ @@ -2463,7 +2467,7 @@ coff_set_arch_mach_hook (bfd *abfd, void * filehdr) default: arch = bfd_arch_obscure; _bfd_error_handler - (_("Unrecognized TI COFF target id '0x%x'"), + (_("unrecognized TI COFF target id '0x%x'"), internal_f->f_target_id); break; } @@ -2497,20 +2501,16 @@ coff_set_arch_mach_hook (bfd *abfd, void * filehdr) return TRUE; } -#ifdef SYMNAME_IN_DEBUG - static bfd_boolean -symname_in_debug_hook (bfd * abfd ATTRIBUTE_UNUSED, struct internal_syment *sym) +symname_in_debug_hook (bfd *abfd ATTRIBUTE_UNUSED, + struct internal_syment *sym ATTRIBUTE_UNUSED) { +#ifdef SYMNAME_IN_DEBUG return SYMNAME_IN_DEBUG (sym) != 0; -} - #else - -#define symname_in_debug_hook \ - (bfd_boolean (*) (bfd *, struct internal_syment *)) bfd_false - + return FALSE; #endif +} #ifdef RS6000COFF_C @@ -2781,7 +2781,7 @@ coff_write_relocs (bfd * abfd, int first_undef) { bfd_set_error (bfd_error_bad_value); /* xgettext:c-format */ - _bfd_error_handler (_("%B: reloc against a non-existent" + _bfd_error_handler (_("%pB: reloc against a non-existent" " symbol index: %ld"), abfd, n.r_symndx); return FALSE; @@ -3184,7 +3184,7 @@ coff_compute_section_file_positions (bfd * abfd) bfd_set_error (bfd_error_file_too_big); _bfd_error_handler /* xgettext:c-format */ - (_("%B: page size is too large (0x%x)"), abfd, page_size); + (_("%pB: page size is too large (0x%x)"), abfd, page_size); return FALSE; } } @@ -3344,7 +3344,7 @@ coff_compute_section_file_positions (bfd * abfd) bfd_set_error (bfd_error_file_too_big); _bfd_error_handler /* xgettext:c-format */ - (_("%B: too many sections (%d)"), abfd, target_index); + (_("%pB: too many sections (%d)"), abfd, target_index); return FALSE; } @@ -3765,7 +3765,7 @@ coff_write_object_contents (bfd * abfd) bfd_set_error (bfd_error_file_too_big); _bfd_error_handler /* xgettext:c-format */ - (_("%B: section %A: string table overflow at offset %ld"), + (_("%pB: section %pA: string table overflow at offset %ld"), abfd, current, (unsigned long) string_size); return FALSE; } @@ -3870,7 +3870,7 @@ coff_write_object_contents (bfd * abfd) _bfd_error_handler /* xgettext:c-format */ - (_("%B:%s section %s: alignment 2**%u not representable"), + (_("%pB:%s section %s: alignment 2**%u not representable"), abfd, warn ? " warning:" : "", current->name, current->alignment_power); if (!warn) @@ -4589,7 +4589,7 @@ coff_slurp_line_table (bfd *abfd, asection *asect) if (asect->lineno_count > asect->size) { _bfd_error_handler - (_("%B: warning: line number count (%#lx) exceeds section size (%#lx)"), + (_("%pB: warning: line number count (%#lx) exceeds section size (%#lx)"), abfd, (unsigned long) asect->lineno_count, (unsigned long) asect->size); return FALSE; } @@ -4604,7 +4604,7 @@ coff_slurp_line_table (bfd *abfd, asection *asect) if (native_lineno == NULL) { _bfd_error_handler - (_("%B: warning: line number table read failed"), abfd); + (_("%pB: warning: line number table read failed"), abfd); bfd_release (abfd, lineno_cache); return FALSE; } @@ -4638,7 +4638,7 @@ coff_slurp_line_table (bfd *abfd, asection *asect) { _bfd_error_handler /* xgettext:c-format */ - (_("%B: warning: illegal symbol index 0x%lx in line number entry %d"), + (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), abfd, symndx, counter); cache_ptr->line_number = -1; ret = FALSE; @@ -4652,7 +4652,7 @@ coff_slurp_line_table (bfd *abfd, asection *asect) { _bfd_error_handler /* xgettext:c-format */ - (_("%B: warning: illegal symbol index 0x%lx in line number entry %d"), + (_("%pB: warning: illegal symbol index 0x%lx in line number entry %d"), abfd, symndx, counter); cache_ptr->line_number = -1; ret = FALSE; @@ -4666,7 +4666,7 @@ coff_slurp_line_table (bfd *abfd, asection *asect) { _bfd_error_handler /* xgettext:c-format */ - (_("%B: warning: illegal symbol in line number entry %d"), + (_("%pB: warning: illegal symbol in line number entry %d"), abfd, counter); cache_ptr->line_number = -1; ret = FALSE; @@ -4679,7 +4679,7 @@ coff_slurp_line_table (bfd *abfd, asection *asect) if (sym->lineno != NULL) _bfd_error_handler /* xgettext:c-format */ - (_("%B: warning: duplicate line number information for `%s'"), + (_("%pB: warning: duplicate line number information for `%s'"), abfd, bfd_asymbol_name (&sym->symbol)); sym->lineno = cache_ptr; @@ -5100,7 +5100,7 @@ coff_slurp_symbol_table (bfd * abfd) default: _bfd_error_handler /* xgettext:c-format */ - (_("%B: Unrecognized storage class %d for %s symbol `%s'"), + (_("%pB: unrecognized storage class %d for %s symbol `%s'"), abfd, src->u.syment.n_sclass, dst->symbol.section->name, dst->symbol.name); ret = FALSE; @@ -5233,7 +5233,7 @@ coff_classify_symbol (bfd *abfd, _bfd_error_handler /* xgettext:c-format */ - (_("warning: %B: local symbol `%s' has no section"), + (_("warning: %pB: local symbol `%s' has no section"), abfd, _bfd_coff_internal_syment_name (abfd, syment, buf)); } @@ -5340,7 +5340,7 @@ coff_slurp_reloc_table (bfd * abfd, sec_ptr asect, asymbol ** symbols) { _bfd_error_handler /* xgettext:c-format */ - (_("%B: warning: illegal symbol index %ld in relocs"), + (_("%pB: warning: illegal symbol index %ld in relocs"), abfd, dst.r_symndx); cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; ptr = NULL; @@ -5380,8 +5380,8 @@ coff_slurp_reloc_table (bfd * abfd, sec_ptr asect, asymbol ** symbols) { _bfd_error_handler /* xgettext:c-format */ - (_("%B: illegal relocation type %d at address %#Lx"), - abfd, dst.r_type, dst.r_vaddr); + (_("%pB: illegal relocation type %d at address %#" PRIx64), + abfd, dst.r_type, (uint64_t) dst.r_vaddr); bfd_set_error (bfd_error_bad_value); return FALSE; } @@ -6024,7 +6024,7 @@ static bfd_coff_backend_data bigobj_swap_table = #endif #ifndef coff_bfd_is_target_special_symbol -#define coff_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false) +#define coff_bfd_is_target_special_symbol _bfd_bool_bfd_asymbol_false #endif #ifndef coff_read_minisymbols @@ -6113,14 +6113,24 @@ const bfd_target VAR = \ bfd_getb32, bfd_getb_signed_32, bfd_putb32, \ bfd_getb16, bfd_getb_signed_16, bfd_putb16, \ \ - /* bfd_check_format. */ \ - { _bfd_dummy_target, coff_object_p, bfd_generic_archive_p, \ - _bfd_dummy_target }, \ - /* bfd_set_format. */ \ - { bfd_false, coff_mkobject, _bfd_generic_mkarchive, bfd_false }, \ - /* bfd_write_contents. */ \ - { bfd_false, coff_write_object_contents, _bfd_write_archive_contents, \ - bfd_false }, \ + { /* bfd_check_format. */ \ + _bfd_dummy_target, \ + coff_object_p, \ + bfd_generic_archive_p, \ + _bfd_dummy_target \ + }, \ + { /* bfd_set_format. */ \ + _bfd_bool_bfd_false_error, \ + coff_mkobject, \ + _bfd_generic_mkarchive, \ + _bfd_bool_bfd_false_error \ + }, \ + { /* bfd_write_contents. */ \ + _bfd_bool_bfd_false_error, \ + coff_write_object_contents, \ + _bfd_write_archive_contents, \ + _bfd_bool_bfd_false_error \ + }, \ \ BFD_JUMP_TABLE_GENERIC (coff), \ BFD_JUMP_TABLE_COPY (coff), \ @@ -6164,14 +6174,24 @@ const bfd_target VAR = \ bfd_getb32, bfd_getb_signed_32, bfd_putb32, \ bfd_getb16, bfd_getb_signed_16, bfd_putb16, \ \ - /* bfd_check_format. */ \ - { _bfd_dummy_target, coff_object_p, bfd_generic_archive_p, \ - _bfd_dummy_target }, \ - /* bfd_set_format. */ \ - { bfd_false, coff_mkobject, _bfd_generic_mkarchive, bfd_false }, \ - /* bfd_write_contents. */ \ - { bfd_false, coff_write_object_contents, _bfd_write_archive_contents, \ - bfd_false }, \ + { /* bfd_check_format. */ \ + _bfd_dummy_target, \ + coff_object_p, \ + bfd_generic_archive_p, \ + _bfd_dummy_target \ + }, \ + { /* bfd_set_format. */ \ + _bfd_bool_bfd_false_error, \ + coff_mkobject, \ + _bfd_generic_mkarchive, \ + _bfd_bool_bfd_false_error \ + }, \ + { /* bfd_write_contents. */ \ + _bfd_bool_bfd_false_error, \ + coff_write_object_contents, \ + _bfd_write_archive_contents, \ + _bfd_bool_bfd_false_error \ + }, \ \ BFD_JUMP_TABLE_GENERIC (coff), \ BFD_JUMP_TABLE_COPY (coff), \ @@ -6213,14 +6233,25 @@ const bfd_target VAR = \ bfd_getl64, bfd_getl_signed_64, bfd_putl64, \ bfd_getl32, bfd_getl_signed_32, bfd_putl32, \ bfd_getl16, bfd_getl_signed_16, bfd_putl16, \ - /* bfd_check_format. */ \ - { _bfd_dummy_target, coff_object_p, bfd_generic_archive_p, \ - _bfd_dummy_target }, \ - /* bfd_set_format. */ \ - { bfd_false, coff_mkobject, _bfd_generic_mkarchive, bfd_false }, \ - /* bfd_write_contents. */ \ - { bfd_false, coff_write_object_contents, _bfd_write_archive_contents, \ - bfd_false }, \ + \ + { /* bfd_check_format. */ \ + _bfd_dummy_target, \ + coff_object_p, \ + bfd_generic_archive_p, \ + _bfd_dummy_target \ + }, \ + { /* bfd_set_format. */ \ + _bfd_bool_bfd_false_error, \ + coff_mkobject, \ + _bfd_generic_mkarchive, \ + _bfd_bool_bfd_false_error \ + }, \ + { /* bfd_write_contents. */ \ + _bfd_bool_bfd_false_error, \ + coff_write_object_contents, \ + _bfd_write_archive_contents, \ + _bfd_bool_bfd_false_error \ + }, \ \ BFD_JUMP_TABLE_GENERIC (coff), \ BFD_JUMP_TABLE_COPY (coff), \ diff --git a/bfd/coffgen.c b/bfd/coffgen.c index b241087..ff445d2 100644 --- a/bfd/coffgen.c +++ b/bfd/coffgen.c @@ -175,7 +175,7 @@ make_a_section_from_file (bfd *abfd, { _bfd_error_handler /* xgettext: c-format */ - (_("%B: unable to initialize compress status for section %s"), + (_("%pB: unable to initialize compress status for section %s"), abfd, name); return FALSE; } @@ -199,7 +199,7 @@ make_a_section_from_file (bfd *abfd, { _bfd_error_handler /* xgettext: c-format */ - (_("%B: unable to initialize decompress status for section %s"), + (_("%pB: unable to initialize decompress status for section %s"), abfd, name); return FALSE; } @@ -1555,7 +1555,8 @@ coff_pointerize_aux (bfd *abfd, } /* A negative tagndx is meaningless, but the SCO 3.2v4 cc can generate one, so we must be careful to ignore it. */ - if (auxent->u.auxent.x_sym.x_tagndx.l > 0) + if ((unsigned long) auxent->u.auxent.x_sym.x_tagndx.l + < obj_raw_syment_count (abfd)) { auxent->u.auxent.x_sym.x_tagndx.p = table_base + auxent->u.auxent.x_sym.x_tagndx.l; @@ -1646,8 +1647,8 @@ _bfd_coff_get_external_symbols (bfd *abfd) && size > bfd_get_file_size (abfd))) { - _bfd_error_handler (_("%B: corrupt symbol count: %#Lx"), - abfd, obj_raw_syment_count (abfd)); + _bfd_error_handler (_("%pB: corrupt symbol count: %#" PRIx64 ""), + abfd, (uint64_t) obj_raw_syment_count (abfd)); return FALSE; } @@ -1655,8 +1656,10 @@ _bfd_coff_get_external_symbols (bfd *abfd) if (syms == NULL) { /* PR 21013: Provide an error message when the alloc fails. */ - _bfd_error_handler (_("%B: not enough memory to allocate space for %#Lx symbols of size %#Lx"), - abfd, obj_raw_syment_count (abfd), symesz); + _bfd_error_handler (_("%pB: not enough memory to allocate space " + "for %#" PRIx64 " symbols of size %#" PRIx64), + abfd, (uint64_t) obj_raw_syment_count (abfd), + (uint64_t) symesz); return FALSE; } @@ -1722,7 +1725,7 @@ _bfd_coff_read_string_table (bfd *abfd) { _bfd_error_handler /* xgettext: c-format */ - (_("%B: bad string table size %Lu"), abfd, strsize); + (_("%pB: bad string table size %" PRIu64), abfd, (uint64_t) strsize); bfd_set_error (bfd_error_bad_value); return NULL; } @@ -3021,7 +3024,7 @@ coff_gc_sweep (bfd *abfd ATTRIBUTE_UNUSED, struct bfd_link_info *info) if (info->print_gc_sections && o->size != 0) /* xgettext: c-format */ - _bfd_error_handler (_("Removing unused section '%A' in file '%B'"), + _bfd_error_handler (_("removing unused section '%pA' in file '%pB'"), o, sub); #if 0 @@ -3098,7 +3101,7 @@ bfd_coff_gc_sections (bfd *abfd ATTRIBUTE_UNUSED, struct bfd_link_info *info) if (!bed->can_gc_sections || !is_coff_hash_table (info->hash)) { - _bfd_error_handler(_("Warning: gc-sections option ignored")); + _bfd_error_handler(_("warning: gc-sections option ignored")); return TRUE; } #endif diff --git a/bfd/cofflink.c b/bfd/cofflink.c index beff5cd..fb1696a 100644 --- a/bfd/cofflink.c +++ b/bfd/cofflink.c @@ -349,7 +349,7 @@ coff_link_add_symbols (bfd *abfd, && (*sym_hash)->root.type != bfd_link_hash_undefined && (*sym_hash)->root.type != bfd_link_hash_undefweak) _bfd_error_handler - (_("Warning: symbol `%s' is both section and non-section"), + (_("warning: symbol `%s' is both section and non-section"), name); addit = FALSE; @@ -451,8 +451,8 @@ coff_link_add_symbols (bfd *abfd, || BTYPE (sym.n_type) == T_NULL))) _bfd_error_handler /* xgettext: c-format */ - (_("Warning: type of symbol `%s' changed" - " from %d to %d in %B"), + (_("warning: type of symbol `%s' changed" + " from %d to %d in %pB"), name, (*sym_hash)->type, sym.n_type, abfd); /* We don't want to change from a meaningful @@ -2370,7 +2370,7 @@ _bfd_coff_link_input_bfd (struct coff_final_link_info *flaginfo, bfd *input_bfd) { _bfd_error_handler /* xgettext: c-format */ - (_("%B: relocs in section `%A', but it has no contents"), + (_("%pB: relocs in section `%pA', but it has no contents"), input_bfd, o); bfd_set_error (bfd_error_no_contents); return FALSE; @@ -2433,8 +2433,8 @@ _bfd_coff_link_input_bfd (struct coff_final_link_info *flaginfo, bfd *input_bfd) if (ps->flags & SEC_EXCLUDE) (*flaginfo->info->callbacks->einfo) /* xgettext: c-format */ - (_("%X`%s' referenced in section `%A' of %B: " - "defined in discarded section `%A' of %B\n"), + (_("%X`%s' referenced in section `%pA' of %pB: " + "defined in discarded section `%pA' of %pB\n"), h->root.root.string, o, input_bfd, ps, ps->owner); } @@ -2731,7 +2731,7 @@ _bfd_coff_write_global_sym (struct bfd_hash_entry *bh, void *data) || bfd_link_relocatable (flaginfo->info))) _bfd_error_handler /* xgettext: c-format */ - (_("%B: %A: reloc overflow: %#x > 0xffff"), + (_("%pB: %pA: reloc overflow: %#x > 0xffff"), output_bfd, sec, sec->reloc_count); if (sec->lineno_count > 0xffff @@ -2739,7 +2739,7 @@ _bfd_coff_write_global_sym (struct bfd_hash_entry *bh, void *data) || bfd_link_relocatable (flaginfo->info))) _bfd_error_handler /* xgettext: c-format */ - (_("%B: warning: %A: line number overflow: %#x > 0xffff"), + (_("%pB: warning: %pA: line number overflow: %#x > 0xffff"), output_bfd, sec, sec->lineno_count); auxp->x_scn.x_nreloc = sec->reloc_count; @@ -2962,7 +2962,7 @@ _bfd_coff_generic_relocate_section (bfd *output_bfd, { _bfd_error_handler /* xgettext: c-format */ - (_("%B: illegal symbol index %ld in relocs"), input_bfd, symndx); + (_("%pB: illegal symbol index %ld in relocs"), input_bfd, symndx); return FALSE; } else @@ -3124,8 +3124,8 @@ _bfd_coff_generic_relocate_section (bfd *output_bfd, case bfd_reloc_outofrange: _bfd_error_handler /* xgettext: c-format */ - (_("%B: bad reloc address %#Lx in section `%A'"), - input_bfd, rel->r_vaddr, input_section); + (_("%pB: bad reloc address %#" PRIx64 " in section `%pA'"), + input_bfd, (uint64_t) rel->r_vaddr, input_section); return FALSE; case bfd_reloc_overflow: { diff --git a/bfd/coffswap.h b/bfd/coffswap.h index 8375af5..7b000e0 100644 --- a/bfd/coffswap.h +++ b/bfd/coffswap.h @@ -808,7 +808,7 @@ coff_swap_scnhdr_out (bfd * abfd, void * in, void * out) buf[sizeof (scnhdr_int->s_name)] = '\0'; _bfd_error_handler /* xgettext:c-format */ - (_("%B: warning: %s: line number overflow: 0x%lx > 0xffff"), + (_("%pB: warning: %s: line number overflow: 0x%lx > 0xffff"), abfd, buf, scnhdr_int->s_nlnno); PUT_SCNHDR_NLNNO (abfd, 0xffff, scnhdr_ext->s_nlnno); } @@ -822,7 +822,7 @@ coff_swap_scnhdr_out (bfd * abfd, void * in, void * out) memcpy (buf, scnhdr_int->s_name, sizeof (scnhdr_int->s_name)); buf[sizeof (scnhdr_int->s_name)] = '\0'; /* xgettext:c-format */ - _bfd_error_handler (_("%B: %s: reloc overflow: 0x%lx > 0xffff"), + _bfd_error_handler (_("%pB: %s: reloc overflow: 0x%lx > 0xffff"), abfd, buf, scnhdr_int->s_nreloc); bfd_set_error (bfd_error_file_truncated); PUT_SCNHDR_NRELOC (abfd, 0xffff, scnhdr_ext->s_nreloc); diff --git a/bfd/compress.c b/bfd/compress.c index 1a531ea..53e566e 100644 --- a/bfd/compress.c +++ b/bfd/compress.c @@ -252,8 +252,8 @@ bfd_get_full_section_contents (bfd *abfd, sec_ptr sec, bfd_byte **ptr) if (bfd_get_error () == bfd_error_no_memory) _bfd_error_handler /* xgettext:c-format */ - (_("error: %B(%A) is too large (%#Lx bytes)"), - abfd, sec, sz); + (_("error: %pB(%pA) is too large (%#" PRIx64 " bytes)"), + abfd, sec, (uint64_t) sz); return FALSE; } } diff --git a/bfd/config.bfd b/bfd/config.bfd index f04a993..9aa2fc6 100644 --- a/bfd/config.bfd +++ b/bfd/config.bfd @@ -1260,11 +1260,13 @@ case "${targ}" in nds32*le-*-linux*) targ_defvec=nds32_elf32_linux_le_vec targ_selvecs=nds32_elf32_linux_be_vec + targ_cflags=-DNDS32_LINUX_TOOLCHAIN ;; nds32*be-*-linux*) targ_defvec=nds32_elf32_linux_be_vec targ_selvecs=nds32_elf32_linux_le_vec + targ_cflags=-DNDS32_LINUX_TOOLCHAIN ;; nds32*le-*-*) diff --git a/bfd/config.in b/bfd/config.in index 75a5ff0..186741d 100644 --- a/bfd/config.in +++ b/bfd/config.in @@ -10,6 +10,10 @@ /* Name of host specific core header file to include in elf.c. */ #undef CORE_HEADER +/* Define to 1 if you want to enable -z separate-code in ELF linker by + default. */ +#undef DEFAULT_LD_Z_SEPARATE_CODE + /* Define to 1 if translation of program messages to the user's native language is requested. */ #undef ENABLE_NLS diff --git a/bfd/configure b/bfd/configure index 1f51789..d1fe335 100755 --- a/bfd/configure +++ b/bfd/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.64 for bfd 2.30. +# Generated by GNU Autoconf 2.64 for bfd 2.30.51. # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software @@ -556,8 +556,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='bfd' PACKAGE_TARNAME='bfd' -PACKAGE_VERSION='2.30' -PACKAGE_STRING='bfd 2.30' +PACKAGE_VERSION='2.30.51' +PACKAGE_STRING='bfd 2.30.51' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -793,6 +793,7 @@ enable_targets enable_64_bit_archive with_mmap enable_secureplt +enable_separate_code enable_leading_mingw64_underscores with_separate_debug_dir with_pkgversion @@ -1354,7 +1355,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures bfd 2.30 to adapt to many kinds of systems. +\`configure' configures bfd 2.30.51 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1425,7 +1426,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of bfd 2.30:";; + short | recursive ) echo "Configuration of bfd 2.30.51:";; esac cat <<\_ACEOF @@ -1446,6 +1447,7 @@ Optional Features: --enable-targets alternative target configurations --enable-64-bit-archive force 64-bit archives --enable-secureplt Default to creating read-only plt entries + --enable-separate-code enable -z separate-code in ELF linker by default --enable-leading-mingw64-underscores Enable leading underscores on 64 bit mingw targets --enable-werror treat compile warnings as errors @@ -1546,7 +1548,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -bfd configure 2.30 +bfd configure 2.30.51 generated by GNU Autoconf 2.64 Copyright (C) 2009 Free Software Foundation, Inc. @@ -2188,7 +2190,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by bfd $as_me 2.30, which was +It was created by bfd $as_me 2.30.51, which was generated by GNU Autoconf 2.64. Invocation command line was $ $0 $@ @@ -3997,7 +3999,7 @@ fi # Define the identity of the package. PACKAGE='bfd' - VERSION='2.30' + VERSION='2.30.51' cat >>confdefs.h <<_ACEOF @@ -11428,7 +11430,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11431 "configure" +#line 11433 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11534,7 +11536,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11537 "configure" +#line 11539 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -12171,6 +12173,33 @@ $as_echo "#define USE_SECUREPLT 1" >>confdefs.h fi +# Decide if -z separate-code should be enabled in ELF linker by default. +ac_default_ld_z_separate_code=unset +# Check whether --enable-separate-code was given. +if test "${enable_separate_code+set}" = set; then : + enableval=$enable_separate_code; case "${enableval}" in + yes) ac_default_ld_z_separate_code=1 ;; + no) ac_default_ld_z_separate_code=0 ;; +esac +fi + +# Enable -z separate-code by default for Linux/x86. +case "${target}" in +i3-786-*-linux-* | x86_64-*-linux-*) + if test ${ac_default_ld_z_separate_code} = unset; then + ac_default_ld_z_separate_code=1 + fi + ;; +esac +if test "${ac_default_ld_z_separate_code}" = unset; then + ac_default_ld_z_separate_code=0 +fi + +cat >>confdefs.h <<_ACEOF +#define DEFAULT_LD_Z_SEPARATE_CODE $ac_default_ld_z_separate_code +_ACEOF + + # Check whether --enable-leading-mingw64-underscores was given. if test "${enable_leading_mingw64_underscores+set}" = set; then : enableval=$enable_leading_mingw64_underscores; @@ -16666,7 +16695,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by bfd $as_me 2.30, which was +This file was extended by bfd $as_me 2.30.51, which was generated by GNU Autoconf 2.64. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -16730,7 +16759,7 @@ Report bugs to the package provider." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_version="\\ -bfd config.status 2.30 +bfd config.status 2.30.51 configured by $0, generated by GNU Autoconf 2.64, with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" diff --git a/bfd/configure.ac b/bfd/configure.ac index 2342f3f..20e2c02 100644 --- a/bfd/configure.ac +++ b/bfd/configure.ac @@ -97,6 +97,30 @@ if test $use_secureplt = true; then [Define if we should default to creating read-only plt entries]) fi +# Decide if -z separate-code should be enabled in ELF linker by default. +ac_default_ld_z_separate_code=unset +AC_ARG_ENABLE(separate-code, + AS_HELP_STRING([--enable-separate-code], + [enable -z separate-code in ELF linker by default]), +[case "${enableval}" in + yes) ac_default_ld_z_separate_code=1 ;; + no) ac_default_ld_z_separate_code=0 ;; +esac]) +# Enable -z separate-code by default for Linux/x86. +case "${target}" in +i[3-7]86-*-linux-* | x86_64-*-linux-*) + if test ${ac_default_ld_z_separate_code} = unset; then + ac_default_ld_z_separate_code=1 + fi + ;; +esac +if test "${ac_default_ld_z_separate_code}" = unset; then + ac_default_ld_z_separate_code=0 +fi +AC_DEFINE_UNQUOTED(DEFAULT_LD_Z_SEPARATE_CODE, + $ac_default_ld_z_separate_code, + [Define to 1 if you want to enable -z separate-code in ELF linker by default.]) + AC_ARG_ENABLE(leading-mingw64-underscores, AS_HELP_STRING([--enable-leading-mingw64-underscores], [Enable leading underscores on 64 bit mingw targets]), diff --git a/bfd/cpu-arm.c b/bfd/cpu-arm.c index 151f273..c6682d4 100644 --- a/bfd/cpu-arm.c +++ b/bfd/cpu-arm.c @@ -190,7 +190,7 @@ bfd_arm_merge_machines (bfd *ibfd, bfd *obfd) { /* xgettext: c-format */ _bfd_error_handler (_("\ -error: %B is compiled for the EP9312, whereas %B is compiled for XScale"), +error: %pB is compiled for the EP9312, whereas %pB is compiled for XScale"), ibfd, obfd); bfd_set_error (bfd_error_wrong_format); return FALSE; @@ -202,7 +202,7 @@ error: %B is compiled for the EP9312, whereas %B is compiled for XScale"), { /* xgettext: c-format */ _bfd_error_handler (_("\ -error: %B is compiled for the EP9312, whereas %B is compiled for XScale"), +error: %pB is compiled for the EP9312, whereas %pB is compiled for XScale"), obfd, ibfd); bfd_set_error (bfd_error_wrong_format); return FALSE; @@ -335,7 +335,7 @@ bfd_arm_update_notes (bfd *abfd, const char *note_section) { _bfd_error_handler /* xgettext: c-format */ - (_("warning: unable to update contents of %s section in %B"), + (_("warning: unable to update contents of %s section in %pB"), note_section, abfd); goto FAIL; } diff --git a/bfd/development.sh b/bfd/development.sh index 918150f..27a7150 100644 --- a/bfd/development.sh +++ b/bfd/development.sh @@ -16,4 +16,4 @@ # along with this program. If not, see . # Controls whether to enable development-mode features by default. -development=false +development=true diff --git a/bfd/dwarf1.c b/bfd/dwarf1.c index 71bc57b..f272ea8 100644 --- a/bfd/dwarf1.c +++ b/bfd/dwarf1.c @@ -213,6 +213,7 @@ parse_die (bfd * abfd, /* Then the attributes. */ while (xptr + 2 <= aDiePtrEnd) { + unsigned int block_len; unsigned short attr; /* Parse the attribute based on its form. This section @@ -255,12 +256,24 @@ parse_die (bfd * abfd, break; case FORM_BLOCK2: if (xptr + 2 <= aDiePtrEnd) - xptr += bfd_get_16 (abfd, xptr); + { + block_len = bfd_get_16 (abfd, xptr); + if (xptr + block_len > aDiePtrEnd + || xptr + block_len < xptr) + return FALSE; + xptr += block_len; + } xptr += 2; break; case FORM_BLOCK4: if (xptr + 4 <= aDiePtrEnd) - xptr += bfd_get_32 (abfd, xptr); + { + block_len = bfd_get_32 (abfd, xptr); + if (xptr + block_len > aDiePtrEnd + || xptr + block_len < xptr) + return FALSE; + xptr += block_len; + } xptr += 4; break; case FORM_STRING: diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c index a4a0dda..ca22db7 100644 --- a/bfd/dwarf2.c +++ b/bfd/dwarf2.c @@ -540,7 +540,7 @@ read_section (bfd * abfd, } if (! msec) { - _bfd_error_handler (_("Dwarf Error: Can't find %s section."), + _bfd_error_handler (_("DWARF error: can't find %s section."), sec->uncompressed_name); bfd_set_error (bfd_error_bad_value); return FALSE; @@ -569,9 +569,10 @@ read_section (bfd * abfd, if (offset != 0 && offset >= *section_size) { /* xgettext: c-format */ - _bfd_error_handler (_("Dwarf Error: Offset (%llu)" - " greater than or equal to %s size (%Lu)."), - (long long) offset, section_name, *section_size); + _bfd_error_handler (_("DWARF error: offset (%" PRIu64 ")" + " greater than or equal to %s size (%" PRIu64 ")"), + (uint64_t) offset, section_name, + (uint64_t) *section_size); bfd_set_error (bfd_error_bad_value); return FALSE; } @@ -622,14 +623,24 @@ read_8_bytes (bfd *abfd, bfd_byte *buf, bfd_byte *end) } static bfd_byte * -read_n_bytes (bfd *abfd ATTRIBUTE_UNUSED, - bfd_byte *buf, - bfd_byte *end, - unsigned int size ATTRIBUTE_UNUSED) +read_n_bytes (bfd_byte * buf, + bfd_byte * end, + struct dwarf_block * block) { - if (buf + size > end) - return NULL; - return buf; + unsigned int size = block->size; + bfd_byte * block_end = buf + size; + + if (block_end > end || block_end < buf) + { + block->data = NULL; + block->size = 0; + return end; + } + else + { + block->data = buf; + return block_end; + } } /* Scans a NUL terminated string starting at BUF, returning a pointer to it. @@ -1086,7 +1097,7 @@ read_attribute_value (struct attribute * attr, if (info_ptr >= info_ptr_end && form != DW_FORM_flag_present) { - _bfd_error_handler (_("Dwarf Error: Info pointer extends beyond end of attributes")); + _bfd_error_handler (_("DWARF error: info pointer extends beyond end of attributes")); bfd_set_error (bfd_error_bad_value); return info_ptr; } @@ -1127,8 +1138,7 @@ read_attribute_value (struct attribute * attr, return NULL; blk->size = read_2_bytes (abfd, info_ptr, info_ptr_end); info_ptr += 2; - blk->data = read_n_bytes (abfd, info_ptr, info_ptr_end, blk->size); - info_ptr += blk->size; + info_ptr = read_n_bytes (info_ptr, info_ptr_end, blk); attr->u.blk = blk; break; case DW_FORM_block4: @@ -1138,8 +1148,7 @@ read_attribute_value (struct attribute * attr, return NULL; blk->size = read_4_bytes (abfd, info_ptr, info_ptr_end); info_ptr += 4; - blk->data = read_n_bytes (abfd, info_ptr, info_ptr_end, blk->size); - info_ptr += blk->size; + info_ptr = read_n_bytes (info_ptr, info_ptr_end, blk); attr->u.blk = blk; break; case DW_FORM_data2: @@ -1179,8 +1188,7 @@ read_attribute_value (struct attribute * attr, blk->size = _bfd_safe_read_leb128 (abfd, info_ptr, &bytes_read, FALSE, info_ptr_end); info_ptr += bytes_read; - blk->data = read_n_bytes (abfd, info_ptr, info_ptr_end, blk->size); - info_ptr += blk->size; + info_ptr = read_n_bytes (info_ptr, info_ptr_end, blk); attr->u.blk = blk; break; case DW_FORM_block1: @@ -1190,8 +1198,7 @@ read_attribute_value (struct attribute * attr, return NULL; blk->size = read_1_byte (abfd, info_ptr, info_ptr_end); info_ptr += 1; - blk->data = read_n_bytes (abfd, info_ptr, info_ptr_end, blk->size); - info_ptr += blk->size; + info_ptr = read_n_bytes (info_ptr, info_ptr_end, blk); attr->u.blk = blk; break; case DW_FORM_data1: @@ -1258,7 +1265,7 @@ read_attribute_value (struct attribute * attr, attr->u.sval = implicit_const; break; default: - _bfd_error_handler (_("Dwarf Error: Invalid or unhandled FORM value: %#x."), + _bfd_error_handler (_("DWARF error: invalid or unhandled FORM value: %#x"), form); bfd_set_error (bfd_error_bad_value); return NULL; @@ -1564,7 +1571,7 @@ concat_filename (struct line_info_table *table, unsigned int file) /* FILE == 0 means unknown. */ if (file) _bfd_error_handler - (_("Dwarf Error: mangled line number section (bad file number).")); + (_("DWARF error: mangled line number section (bad file number)")); return strdup (""); } @@ -1909,7 +1916,7 @@ read_formatted_entries (struct comp_unit *unit, bfd_byte **bufp, buf += bytes_read; if (format_count == 0 && data_count != 0) { - _bfd_error_handler (_("Dwarf Error: Zero format count.")); + _bfd_error_handler (_("DWARF error: zero format count")); bfd_set_error (bfd_error_bad_value); return FALSE; } @@ -1918,8 +1925,9 @@ read_formatted_entries (struct comp_unit *unit, bfd_byte **bufp, if we know that we are going to run out of buffer. */ if (data_count > (bfd_vma) (buf_end - buf)) { - _bfd_error_handler (_("Dwarf Error: data count (%Lx) larger than buffer size."), - data_count); + _bfd_error_handler + (_("DWARF error: data count (%" PRIx64 ") larger than buffer size"), + (uint64_t) data_count); bfd_set_error (bfd_error_bad_value); return FALSE; } @@ -1959,8 +1967,8 @@ read_formatted_entries (struct comp_unit *unit, bfd_byte **bufp, break; default: _bfd_error_handler - (_("Dwarf Error: Unknown format content type %Lu."), - content_type); + (_("DWARF error: unknown format content type %" PRIu64), + (uint64_t) content_type); bfd_set_error (bfd_error_bad_value); return FALSE; } @@ -2039,8 +2047,8 @@ decode_line_info (struct comp_unit *unit, struct dwarf2_debug *stash) if (stash->dwarf_line_size < 16) { _bfd_error_handler - (_("Dwarf Error: Line info section is too small (%Ld)"), - stash->dwarf_line_size); + (_("DWARF error: line info section is too small (%" PRId64 ")"), + (int64_t) stash->dwarf_line_size); bfd_set_error (bfd_error_bad_value); return NULL; } @@ -2069,9 +2077,9 @@ decode_line_info (struct comp_unit *unit, struct dwarf2_debug *stash) { _bfd_error_handler /* xgettext: c-format */ - (_("Dwarf Error: Line info data is bigger (%#Lx)" + (_("DWARF error: line info data is bigger (%#" PRIx64 ")" " than the space remaining in the section (%#lx)"), - lh.total_length, (unsigned long) (line_end - line_ptr)); + (uint64_t) lh.total_length, (unsigned long) (line_end - line_ptr)); bfd_set_error (bfd_error_bad_value); return NULL; } @@ -2082,7 +2090,7 @@ decode_line_info (struct comp_unit *unit, struct dwarf2_debug *stash) if (lh.version < 2 || lh.version > 5) { _bfd_error_handler - (_("Dwarf Error: Unhandled .debug_line version %d."), lh.version); + (_("DWARF error: unhandled .debug_line version %d"), lh.version); bfd_set_error (bfd_error_bad_value); return NULL; } @@ -2092,7 +2100,7 @@ decode_line_info (struct comp_unit *unit, struct dwarf2_debug *stash) >= line_end) { _bfd_error_handler - (_("Dwarf Error: Ran out of room reading prologue")); + (_("DWARF error: ran out of room reading prologue")); bfd_set_error (bfd_error_bad_value); return NULL; } @@ -2110,7 +2118,7 @@ decode_line_info (struct comp_unit *unit, struct dwarf2_debug *stash) if (segment_selector_size != 0) { _bfd_error_handler - (_("Dwarf Error: Line info unsupported segment selector size %u."), + (_("DWARF error: line info unsupported segment selector size %u"), segment_selector_size); bfd_set_error (bfd_error_bad_value); return NULL; @@ -2137,7 +2145,7 @@ decode_line_info (struct comp_unit *unit, struct dwarf2_debug *stash) if (lh.maximum_ops_per_insn == 0) { _bfd_error_handler - (_("Dwarf Error: Invalid maximum operations per instruction.")); + (_("DWARF error: invalid maximum operations per instruction")); bfd_set_error (bfd_error_bad_value); return NULL; } @@ -2156,7 +2164,7 @@ decode_line_info (struct comp_unit *unit, struct dwarf2_debug *stash) if (line_ptr + (lh.opcode_base - 1) >= line_end) { - _bfd_error_handler (_("Dwarf Error: Ran out of room reading opcodes")); + _bfd_error_handler (_("DWARF error: ran out of room reading opcodes")); bfd_set_error (bfd_error_bad_value); return NULL; } @@ -2329,7 +2337,7 @@ decode_line_info (struct comp_unit *unit, struct dwarf2_debug *stash) break; default: _bfd_error_handler - (_("Dwarf Error: mangled line number section.")); + (_("DWARF error: mangled line number section")); bfd_set_error (bfd_error_bad_value); line_fail: if (filename != NULL) @@ -2788,11 +2796,13 @@ lookup_symbol_in_variable_table (struct comp_unit *unit, } static bfd_boolean -find_abstract_instance_name (struct comp_unit *unit, - bfd_byte *orig_info_ptr, - struct attribute *attr_ptr, - const char **pname, - bfd_boolean *is_linkage) +find_abstract_instance (struct comp_unit * unit, + bfd_byte * orig_info_ptr, + struct attribute * attr_ptr, + const char ** pname, + bfd_boolean * is_linkage, + char ** filename_ptr, + int * linenumber_ptr) { bfd *abfd = unit->abfd; bfd_byte *info_ptr; @@ -2830,7 +2840,7 @@ find_abstract_instance_name (struct comp_unit *unit, if (!die_ref || die_ref >= total) { _bfd_error_handler - (_("Dwarf Error: Invalid abstract instance DIE ref.")); + (_("DWARF error: invalid abstract instance DIE ref")); bfd_set_error (bfd_error_bad_value); return FALSE; } @@ -2867,8 +2877,8 @@ find_abstract_instance_name (struct comp_unit *unit, if (info_ptr == NULL) { _bfd_error_handler - (_("Dwarf Error: Unable to read alt ref %llu."), - (long long) die_ref); + (_("DWARF error: unable to read alt ref %" PRIu64), + (uint64_t) die_ref); bfd_set_error (bfd_error_bad_value); return FALSE; } @@ -2891,7 +2901,7 @@ find_abstract_instance_name (struct comp_unit *unit, if (!die_ref || die_ref >= total) { _bfd_error_handler - (_("Dwarf Error: Invalid abstract instance DIE ref.")); + (_("DWARF error: invalid abstract instance DIE ref")); bfd_set_error (bfd_error_bad_value); return FALSE; } @@ -2908,7 +2918,7 @@ find_abstract_instance_name (struct comp_unit *unit, if (! abbrev) { _bfd_error_handler - (_("Dwarf Error: Could not find abbrev number %u."), abbrev_number); + (_("DWARF error: could not find abbrev number %u"), abbrev_number); bfd_set_error (bfd_error_bad_value); return FALSE; } @@ -2925,7 +2935,7 @@ find_abstract_instance_name (struct comp_unit *unit, if (info_ptr == orig_info_ptr) { _bfd_error_handler - (_("Dwarf Error: Abstract instance recursion detected.")); + (_("DWARF error: abstract instance recursion detected")); bfd_set_error (bfd_error_bad_value); return FALSE; } @@ -2942,8 +2952,9 @@ find_abstract_instance_name (struct comp_unit *unit, } break; case DW_AT_specification: - if (!find_abstract_instance_name (unit, info_ptr, &attr, - pname, is_linkage)) + if (!find_abstract_instance (unit, info_ptr, &attr, + pname, is_linkage, + filename_ptr, linenumber_ptr)) return FALSE; break; case DW_AT_linkage_name: @@ -2956,6 +2967,13 @@ find_abstract_instance_name (struct comp_unit *unit, *is_linkage = TRUE; } break; + case DW_AT_decl_file: + *filename_ptr = concat_filename (unit->line_table, + attr.u.val); + break; + case DW_AT_decl_line: + *linenumber_ptr = attr.u.val; + break; default: break; } @@ -3073,7 +3091,7 @@ scan_unit_for_symbols (struct comp_unit *unit) if (abbrev_number != previous_failed_abbrev) { _bfd_error_handler - (_("Dwarf Error: Could not find abbrev number %u."), + (_("DWARF error: could not find abbrev number %u"), abbrev_number); previous_failed_abbrev = abbrev_number; } @@ -3148,9 +3166,11 @@ scan_unit_for_symbols (struct comp_unit *unit) case DW_AT_abstract_origin: case DW_AT_specification: - if (!find_abstract_instance_name (unit, info_ptr, &attr, - &func->name, - &func->is_linkage)) + if (!find_abstract_instance (unit, info_ptr, &attr, + &func->name, + &func->is_linkage, + &func->file, + &func->line)) goto fail; break; @@ -3344,8 +3364,8 @@ parse_comp_unit (struct dwarf2_debug *stash, if (version) { _bfd_error_handler - (_("Dwarf Error: found dwarf version '%u', this reader" - " only handles version 2, 3, 4 and 5 information."), version); + (_("DWARF error: found dwarf version '%u', this reader" + " only handles version 2, 3, 4 and 5 information"), version); bfd_set_error (bfd_error_bad_value); } return NULL; @@ -3388,8 +3408,8 @@ parse_comp_unit (struct dwarf2_debug *stash, { _bfd_error_handler /* xgettext: c-format */ - (_("Dwarf Error: found address size '%u', this reader" - " can not handle sizes greater than '%u'."), + (_("DWARF error: found address size '%u', this reader" + " can not handle sizes greater than '%u'"), addr_size, (unsigned int) sizeof (bfd_vma)); bfd_set_error (bfd_error_bad_value); @@ -3399,8 +3419,8 @@ parse_comp_unit (struct dwarf2_debug *stash, if (addr_size != 2 && addr_size != 4 && addr_size != 8) { _bfd_error_handler - ("Dwarf Error: found address size '%u', this reader" - " can only handle address sizes '2', '4' and '8'.", addr_size); + ("DWARF error: found address size '%u', this reader" + " can only handle address sizes '2', '4' and '8'", addr_size); bfd_set_error (bfd_error_bad_value); return NULL; } @@ -3425,7 +3445,7 @@ parse_comp_unit (struct dwarf2_debug *stash, abbrev = lookup_abbrev (abbrev_number, abbrevs); if (! abbrev) { - _bfd_error_handler (_("Dwarf Error: Could not find abbrev number %u."), + _bfd_error_handler (_("DWARF error: could not find abbrev number %u"), abbrev_number); bfd_set_error (bfd_error_bad_value); return NULL; @@ -3491,7 +3511,7 @@ parse_comp_unit (struct dwarf2_debug *stash, if (! is_str_attr (attr.form)) { _bfd_error_handler - (_("Dwarf Error: DW_AT_comp_dir attribute encountered with a non-string form.")); + (_("DWARF error: DW_AT_comp_dir attribute encountered with a non-string form")); comp_dir = NULL; } diff --git a/bfd/ecoff.c b/bfd/ecoff.c index e9d1eae..c947e60 100644 --- a/bfd/ecoff.c +++ b/bfd/ecoff.c @@ -182,6 +182,13 @@ _bfd_ecoff_new_section_hook (bfd *abfd, asection *section) return _bfd_generic_new_section_hook (abfd, section); } +void +_bfd_ecoff_set_alignment_hook (bfd *abfd ATTRIBUTE_UNUSED, + asection *section ATTRIBUTE_UNUSED, + void *scnhdr ATTRIBUTE_UNUSED) +{ +} + /* Determine the machine architecture and type. This is called from the generic COFF routines. It is the inverse of ecoff_get_magic, below. This could be an ECOFF backend routine, with one version @@ -961,7 +968,7 @@ _bfd_ecoff_slurp_symbol_table (bfd *abfd) bfd_get_symcount (abfd) = internal_ptr - internal; _bfd_error_handler /* xgettext:c-format */ - (_("%B: warning: isymMax (%ld) is greater than ifdMax (%ld)"), + (_("%pB: warning: isymMax (%ld) is greater than ifdMax (%ld)"), abfd, ecoff_data (abfd)->debug_info.symbolic_header.isymMax, ecoff_data (abfd)->debug_info.symbolic_header.ifdMax); } @@ -1258,7 +1265,7 @@ ecoff_type_to_string (bfd *abfd, FDR *fdr, unsigned int indx) break; default: - sprintf (p1, _("Unknown basic type %d"), (int) basic_type); + sprintf (p1, _("unknown basic type %d"), (int) basic_type); break; } diff --git a/bfd/elf-attrs.c b/bfd/elf-attrs.c index 1783f63..dfdf1a5 100644 --- a/bfd/elf-attrs.c +++ b/bfd/elf-attrs.c @@ -472,8 +472,9 @@ _bfd_elf_parse_attributes (bfd *abfd, Elf_Internal_Shdr * hdr) len -= section_len; if (section_len <= 4) { - _bfd_error_handler (_("%B: error: attribute section length too small: %ld"), - abfd, section_len); + _bfd_error_handler + (_("%pB: error: attribute section length too small: %" PRId64), + abfd, (int64_t) section_len); break; } section_len -= 4; @@ -600,7 +601,7 @@ _bfd_elf_merge_object_attributes (bfd *ibfd, struct bfd_link_info *info) { _bfd_error_handler /* xgettext:c-format */ - (_("error: %B: Object has vendor-specific contents that " + (_("error: %pB: object has vendor-specific contents that " "must be processed by the '%s' toolchain"), ibfd, in_attr->s); return FALSE; @@ -610,7 +611,7 @@ _bfd_elf_merge_object_attributes (bfd *ibfd, struct bfd_link_info *info) || (in_attr->i != 0 && strcmp (in_attr->s, out_attr->s) != 0)) { /* xgettext:c-format */ - _bfd_error_handler (_("error: %B: Object tag '%d, %s' is " + _bfd_error_handler (_("error: %pB: object tag '%d, %s' is " "incompatible with tag '%d, %s'"), ibfd, in_attr->i, in_attr->s ? in_attr->s : "", diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index b580dc2..afd6982 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -872,13 +872,13 @@ struct elf_backend_data const void *arch_data; /* A function to translate an ELF RELA relocation to a BFD arelent - structure. */ - void (*elf_info_to_howto) + structure. Returns TRUE upon success, FALSE otherwise. */ + bfd_boolean (*elf_info_to_howto) (bfd *, arelent *, Elf_Internal_Rela *); /* A function to translate an ELF REL relocation to a BFD arelent - structure. */ - void (*elf_info_to_howto_rel) + structure. Returns TRUE upon success, FALSE otherwise. */ + bfd_boolean (*elf_info_to_howto_rel) (bfd *, arelent *, Elf_Internal_Rela *); /* A function to determine whether a symbol is global when @@ -1352,7 +1352,7 @@ struct elf_backend_data (bfd *); reloc_howto_type *(*elf_backend_mips_rtype_to_howto) - (unsigned int, bfd_boolean); + (bfd *, unsigned int, bfd_boolean); /* The swapping table to use when dealing with ECOFF information. Used for the MIPS ELF .mdebug section. */ @@ -2181,7 +2181,7 @@ extern const struct bfd_elf_special_section *_bfd_elf_get_sec_type_attr (bfd *, asection *); /* If the target doesn't have reloc handling written yet: */ -extern void _bfd_elf_no_info_to_howto +extern bfd_boolean _bfd_elf_no_info_to_howto (bfd *, arelent *, Elf_Internal_Rela *); extern bfd_boolean bfd_section_from_shdr @@ -2270,7 +2270,9 @@ extern bfd_boolean _bfd_elf_validate_reloc extern bfd_boolean _bfd_elf_link_create_dynamic_sections (bfd *, struct bfd_link_info *); -extern bfd_boolean _bfd_elf_link_omit_section_dynsym +extern bfd_boolean _bfd_elf_omit_section_dynsym_default + (bfd *, struct bfd_link_info *, asection *); +extern bfd_boolean _bfd_elf_omit_section_dynsym_all (bfd *, struct bfd_link_info *, asection *); extern bfd_boolean _bfd_elf_create_dynamic_sections (bfd *, struct bfd_link_info *); diff --git a/bfd/elf-eh-frame.c b/bfd/elf-eh-frame.c index 95697c4..12f06ef 100644 --- a/bfd/elf-eh-frame.c +++ b/bfd/elf-eh-frame.c @@ -939,7 +939,7 @@ _bfd_elf_parse_eh_frame (bfd *abfd, struct bfd_link_info *info, { (*info->callbacks->minfo) /* xgettext:c-format */ - (_("discarding zero address range FDE in %B(%A).\n"), + (_("discarding zero address range FDE in %pB(%pA).\n"), abfd, sec); this_inf->u.fde.cie_inf = NULL; } @@ -1042,9 +1042,9 @@ _bfd_elf_parse_eh_frame (bfd *abfd, struct bfd_link_info *info, goto success; free_no_table: - (*info->callbacks->einfo) + _bfd_error_handler /* xgettext:c-format */ - (_("%P: error in %B(%A); no .eh_frame_hdr table will be created.\n"), + (_("error in %pB(%pA); no .eh_frame_hdr table will be created"), abfd, sec); hdr_info->u.dwarf.table = FALSE; if (sec_info) @@ -1532,16 +1532,16 @@ _bfd_elf_discard_section_eh_frame hdr_info->u.dwarf.table = FALSE; if (num_warnings_issued < 10) { - (*info->callbacks->einfo) + _bfd_error_handler /* xgettext:c-format */ - (_("%P: FDE encoding in %B(%A) prevents .eh_frame_hdr" - " table being created.\n"), abfd, sec); + (_("FDE encoding in %pB(%pA) prevents .eh_frame_hdr" + " table being created"), abfd, sec); num_warnings_issued ++; } else if (num_warnings_issued == 10) { - (*info->callbacks->einfo) - (_("%P: Further warnings about FDE encoding preventing .eh_frame_hdr generation dropped.\n")); + _bfd_error_handler + (_("further warnings about FDE encoding preventing .eh_frame_hdr generation dropped")); num_warnings_issued ++; } } @@ -1863,7 +1863,7 @@ _bfd_elf_write_section_eh_frame_entry (bfd *abfd, struct bfd_link_info *info, if (addr <= last_addr) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: %A not in order"), sec->owner, sec); + _bfd_error_handler (_("%pB: %pA not in order"), sec->owner, sec); return FALSE; } @@ -1877,7 +1877,7 @@ _bfd_elf_write_section_eh_frame_entry (bfd *abfd, struct bfd_link_info *info, if (addr & 1) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: %A invalid input section size"), + _bfd_error_handler (_("%pB: %pA invalid input section size"), sec->owner, sec); bfd_set_error (bfd_error_bad_value); return FALSE; @@ -1885,7 +1885,7 @@ _bfd_elf_write_section_eh_frame_entry (bfd *abfd, struct bfd_link_info *info, if (last_addr >= addr + sec->rawsize) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: %A points past end of text section"), + _bfd_error_handler (_("%pB: %pA points past end of text section"), sec->owner, sec); bfd_set_error (bfd_error_bad_value); return FALSE; @@ -2133,9 +2133,9 @@ _bfd_elf_write_section_eh_frame (bfd *abfd, address += elf_gp (abfd); break; default: - (*info->callbacks->einfo) - (_("%P: DW_EH_PE_datarel unspecified" - " for this architecture.\n")); + _bfd_error_handler + (_("DW_EH_PE_datarel unspecified" + " for this architecture")); /* Fall thru */ case bfd_arch_frv: case bfd_arch_i386: @@ -2304,7 +2304,7 @@ _bfd_elf_fixup_eh_frame_hdr (struct bfd_link_info *info) if (sec->output_section != osec) { _bfd_error_handler - (_("Invalid output section for .eh_frame_entry: %A"), + (_("invalid output section for .eh_frame_entry: %pA"), sec->output_section); return FALSE; } @@ -2327,7 +2327,7 @@ _bfd_elf_fixup_eh_frame_hdr (struct bfd_link_info *info) if (i != 0) { _bfd_error_handler - (_("Invalid contents in %A section"), osec); + (_("invalid contents in %pA section"), osec); return FALSE; } @@ -2483,10 +2483,9 @@ write_dwarf_eh_frame_hdr (bfd *abfd, struct bfd_link_info *info) overlap = TRUE; } if (overflow) - (*info->callbacks->einfo) (_("%P: .eh_frame_hdr entry overflow.\n")); + _bfd_error_handler (_(".eh_frame_hdr entry overflow")); if (overlap) - (*info->callbacks->einfo) - (_("%P: .eh_frame_hdr refers to overlapping FDEs.\n")); + _bfd_error_handler (_(".eh_frame_hdr refers to overlapping FDEs")); if (overflow || overlap) { bfd_set_error (bfd_error_bad_value); diff --git a/bfd/elf-hppa.h b/bfd/elf-hppa.h index b87ee83..95ac96c 100644 --- a/bfd/elf-hppa.h +++ b/bfd/elf-hppa.h @@ -1020,26 +1020,44 @@ _bfd_elf_hppa_gen_reloc_type (bfd *abfd, /* Translate from an elf into field into a howto relocation pointer. */ -static void +static bfd_boolean elf_hppa_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, arelent *bfd_reloc, Elf_Internal_Rela *elf_reloc) { - BFD_ASSERT (ELF_R_TYPE (elf_reloc->r_info) - < (unsigned int) R_PARISC_UNIMPLEMENTED); - bfd_reloc->howto = &elf_hppa_howto_table[ELF_R_TYPE (elf_reloc->r_info)]; + unsigned int r_type = ELF32_R_TYPE (elf_reloc->r_info); + + if (r_type >= (unsigned int) R_PARISC_UNIMPLEMENTED) + { + /* xgettext:c-format */ + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; + } + bfd_reloc->howto = &elf_hppa_howto_table[r_type]; + return TRUE; } /* Translate from an elf into field into a howto relocation pointer. */ -static void -elf_hppa_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED, +static bfd_boolean +elf_hppa_info_to_howto_rel (bfd *abfd, arelent *bfd_reloc, Elf_Internal_Rela *elf_reloc) { - BFD_ASSERT (ELF_R_TYPE (elf_reloc->r_info) - < (unsigned int) R_PARISC_UNIMPLEMENTED); - bfd_reloc->howto = &elf_hppa_howto_table[ELF_R_TYPE (elf_reloc->r_info)]; + unsigned int r_type = ELF_R_TYPE (elf_reloc->r_info); + + if (r_type >= (unsigned int) R_PARISC_UNIMPLEMENTED) + { + /* xgettext:c-format */ + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; + } + + bfd_reloc->howto = &elf_hppa_howto_table[r_type]; + return TRUE; } /* Return the address of the howto table entry to perform the CODE diff --git a/bfd/elf-ifunc.c b/bfd/elf-ifunc.c index 1fab440..5716ab3 100644 --- a/bfd/elf-ifunc.c +++ b/bfd/elf-ifunc.c @@ -140,7 +140,7 @@ _bfd_elf_allocate_ifunc_dyn_relocs (struct bfd_link_info *info, info->callbacks->einfo /* xgettext:c-format */ (_("%F%P: dynamic STT_GNU_IFUNC symbol `%s' with pointer " - "equality in `%B' can not be used when making an " + "equality in `%pB' can not be used when making an " "executable; recompile with -fPIE and relink with -pie\n"), h->root.root.string, h->root.u.def.section->owner); diff --git a/bfd/elf-m10200.c b/bfd/elf-m10200.c index 82c4ee7..cc71c1e 100644 --- a/bfd/elf-m10200.c +++ b/bfd/elf-m10200.c @@ -212,16 +212,25 @@ bfd_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, /* Set the howto pointer for an MN10200 ELF reloc. */ -static void -mn10200_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, +static bfd_boolean +mn10200_info_to_howto (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst) { unsigned int r_type; r_type = ELF32_R_TYPE (dst->r_info); - BFD_ASSERT (r_type < (unsigned int) R_MN10200_MAX); + if (r_type >= (unsigned int) R_MN10200_MAX) + { + /* xgettext:c-format */ + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; + } + cache_ptr->howto = &elf_mn10200_howto_table[r_type]; + return cache_ptr->howto != NULL; } /* Perform a relocation as part of a final link. */ @@ -1378,7 +1387,7 @@ mn10200_elf_get_relocated_section_contents (bfd *output_bfd, #define elf_backend_rela_normal 1 #define elf_info_to_howto mn10200_info_to_howto -#define elf_info_to_howto_rel 0 +#define elf_info_to_howto_rel NULL #define elf_backend_relocate_section mn10200_elf_relocate_section #define bfd_elf32_bfd_relax_section mn10200_elf_relax_section #define bfd_elf32_bfd_get_relocated_section_contents \ diff --git a/bfd/elf-m10300.c b/bfd/elf-m10300.c index a91257e..f86346e 100644 --- a/bfd/elf-m10300.c +++ b/bfd/elf-m10300.c @@ -798,8 +798,8 @@ bfd_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, /* Set the howto pointer for an MN10300 ELF reloc. */ -static void -mn10300_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, +static bfd_boolean +mn10300_info_to_howto (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst) { @@ -809,12 +809,13 @@ mn10300_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, if (r_type >= R_MN10300_MAX) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: unrecognised MN10300 reloc number: %d"), + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), abfd, r_type); bfd_set_error (bfd_error_bad_value); - r_type = R_MN10300_NONE; + return FALSE; } cache_ptr->howto = elf_mn10300_howto_table + r_type; + return TRUE; } static int @@ -1025,7 +1026,7 @@ mn10300_do_tls_transition (bfd * input_bfd, default: _bfd_error_handler /* xgettext:c-format */ - (_("%B: Unsupported transition from %s to %s"), + (_("%pB: unsupported transition from %s to %s"), input_bfd, elf_mn10300_howto_table[r_type].name, elf_mn10300_howto_table[tls_r_type].name); @@ -1194,7 +1195,7 @@ mn10300_elf_check_relocs (bfd *abfd, else _bfd_error_handler /* xgettext:c-format */ - (_("%B: %s' accessed both as normal and thread local symbol"), + (_("%pB: %s' accessed both as normal and thread local symbol"), abfd, h ? h->root.root.string : ""); } @@ -2090,10 +2091,11 @@ mn10300_elf_relocate_section (bfd *output_bfd, _bfd_error_handler /* xgettext:c-format */ - (_("%B(%A+%#Lx): unresolvable %s relocation against symbol `%s'"), + (_("%pB(%pA+%#" PRIx64 "): " + "unresolvable %s relocation against symbol `%s'"), input_bfd, input_section, - rel->r_offset, + (uint64_t) rel->r_offset, howto->name, h->root.root.root.string); } @@ -2155,7 +2157,7 @@ mn10300_elf_relocate_section (bfd *output_bfd, " library (did you forget -fpic?)"); else if (r_type == R_MN10300_GOT32) /* xgettext:c-format */ - msg = _("%B: taking the address of protected function" + msg = _("%pB: taking the address of protected function" " '%s' cannot be done when making a shared library"); else msg = _("internal error: suspicious relocation type used" @@ -5543,7 +5545,7 @@ mn10300_elf_mkobject (bfd *abfd) #endif #define elf_info_to_howto mn10300_info_to_howto -#define elf_info_to_howto_rel 0 +#define elf_info_to_howto_rel NULL #define elf_backend_can_gc_sections 1 #define elf_backend_rela_normal 1 #define elf_backend_check_relocs mn10300_elf_check_relocs @@ -5574,8 +5576,7 @@ mn10300_elf_mkobject (bfd *abfd) _bfd_mn10300_elf_adjust_dynamic_symbol #define elf_backend_size_dynamic_sections \ _bfd_mn10300_elf_size_dynamic_sections -#define elf_backend_omit_section_dynsym \ - ((bfd_boolean (*) (bfd *, struct bfd_link_info *, asection *)) bfd_true) +#define elf_backend_omit_section_dynsym _bfd_elf_omit_section_dynsym_all #define elf_backend_finish_dynamic_symbol \ _bfd_mn10300_elf_finish_dynamic_symbol #define elf_backend_finish_dynamic_sections \ diff --git a/bfd/elf-properties.c b/bfd/elf-properties.c index 2549dd0..50c0e9d 100644 --- a/bfd/elf-properties.c +++ b/bfd/elf-properties.c @@ -62,7 +62,7 @@ _bfd_elf_get_property (bfd *abfd, unsigned int type, unsigned int datasz) p = (elf_property_list *) bfd_alloc (abfd, sizeof (*p)); if (p == NULL) { - _bfd_error_handler (_("%B: out of memory in _bfd_elf_get_property"), + _bfd_error_handler (_("%pB: out of memory in _bfd_elf_get_property"), abfd); _exit (EXIT_FAILURE); } @@ -88,7 +88,7 @@ _bfd_elf_parse_gnu_properties (bfd *abfd, Elf_Internal_Note *note) { bad_size: _bfd_error_handler - (_("warning: %B: corrupt GNU_PROPERTY_TYPE (%ld) size: %#lx"), + (_("warning: %pB: corrupt GNU_PROPERTY_TYPE (%ld) size: %#lx"), abfd, note->type, note->descsz); return FALSE; } @@ -109,7 +109,7 @@ bad_size: if (datasz > (size_t) (ptr_end - ptr)) { _bfd_error_handler - (_("warning: %B: corrupt GNU_PROPERTY_TYPE (%ld) type (0x%x) datasz: 0x%x"), + (_("warning: %pB: corrupt GNU_PROPERTY_TYPE (%ld) type (0x%x) datasz: 0x%x"), abfd, note->type, type, datasz); /* Clear all properties. */ elf_properties (abfd) = NULL; @@ -148,7 +148,7 @@ bad_size: if (datasz != align_size) { _bfd_error_handler - (_("warning: %B: corrupt stack size: 0x%x"), + (_("warning: %pB: corrupt stack size: 0x%x"), abfd, datasz); /* Clear all properties. */ elf_properties (abfd) = NULL; @@ -166,7 +166,7 @@ bad_size: if (datasz != 0) { _bfd_error_handler - (_("warning: %B: corrupt no copy on protected size: 0x%x"), + (_("warning: %pB: corrupt no copy on protected size: 0x%x"), abfd, datasz); /* Clear all properties. */ elf_properties (abfd) = NULL; @@ -183,7 +183,7 @@ bad_size: } _bfd_error_handler - (_("warning: %B: unsupported GNU_PROPERTY_TYPE (%ld) type: 0x%x"), + (_("warning: %pB: unsupported GNU_PROPERTY_TYPE (%ld) type: 0x%x"), abfd, note->type, type); next: diff --git a/bfd/elf-s390-common.c b/bfd/elf-s390-common.c index 4aa6666..21195f2 100644 --- a/bfd/elf-s390-common.c +++ b/bfd/elf-s390-common.c @@ -286,12 +286,12 @@ elf_s390_merge_obj_attributes (bfd *ibfd, struct bfd_link_info *info) if (in_attr->i > 2) _bfd_error_handler /* xgettext:c-format */ - (_("Warning: %B uses unknown vector ABI %d"), ibfd, + (_("warning: %pB uses unknown vector ABI %d"), ibfd, in_attr->i); else if (out_attr->i > 2) _bfd_error_handler /* xgettext:c-format */ - (_("Warning: %B uses unknown vector ABI %d"), obfd, + (_("warning: %pB uses unknown vector ABI %d"), obfd, out_attr->i); else if (in_attr->i != out_attr->i) { @@ -303,7 +303,7 @@ elf_s390_merge_obj_attributes (bfd *ibfd, struct bfd_link_info *info) _bfd_error_handler /* xgettext:c-format */ - (_("Warning: %B uses vector %s ABI, %B uses %s ABI"), + (_("warning: %pB uses vector %s ABI, %pB uses %s ABI"), ibfd, abi_str[in_attr->i], obfd, abi_str[out_attr->i]); } if (in_attr->i > out_attr->i) diff --git a/bfd/elf.c b/bfd/elf.c index 90aef09..8ea5a81 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -340,7 +340,7 @@ bfd_elf_string_from_elf_section (bfd *abfd, { /* PR 17512: file: f057ec89. */ /* xgettext:c-format */ - _bfd_error_handler (_("%B: attempt to load strings from" + _bfd_error_handler (_("%pB: attempt to load strings from" " a non-string section (number %d)"), abfd, shindex); return NULL; @@ -355,8 +355,8 @@ bfd_elf_string_from_elf_section (bfd *abfd, unsigned int shstrndx = elf_elfheader(abfd)->e_shstrndx; _bfd_error_handler /* xgettext:c-format */ - (_("%B: invalid string offset %u >= %Lu for section `%s'"), - abfd, strindex, hdr->sh_size, + (_("%pB: invalid string offset %u >= %" PRIu64 " for section `%s'"), + abfd, strindex, (uint64_t) hdr->sh_size, (shindex == shstrndx && strindex == hdr->sh_name ? ".shstrtab" : bfd_elf_string_from_elf_section (abfd, shstrndx, hdr->sh_name))); @@ -494,7 +494,7 @@ bfd_elf_get_elf_syms (bfd *ibfd, { symoffset += (esym - (bfd_byte *) extsym_buf) / extsym_size; /* xgettext:c-format */ - _bfd_error_handler (_("%B symbol number %lu references" + _bfd_error_handler (_("%pB symbol number %lu references" " nonexistent SHT_SYMTAB_SHNDX section"), ibfd, (unsigned long) symoffset); if (alloc_intsym != NULL) @@ -658,8 +658,9 @@ setup_group (bfd *abfd, Elf_Internal_Shdr *hdr, asection *newsect) { _bfd_error_handler /* xgettext:c-format */ - (_("%B: corrupt size field in group section" - " header: %#Lx"), abfd, shdr->sh_size); + (_("%pB: corrupt size field in group section" + " header: %#" PRIx64), + abfd, (uint64_t) shdr->sh_size); bfd_set_error (bfd_error_bad_value); -- num_group; continue; @@ -673,8 +674,9 @@ setup_group (bfd *abfd, Elf_Internal_Shdr *hdr, asection *newsect) { _bfd_error_handler /* xgettext:c-format */ - (_("%B: invalid size field in group section" - " header: %#Lx"), abfd, shdr->sh_size); + (_("%pB: invalid size field in group section" + " header: %#" PRIx64 ""), + abfd, (uint64_t) shdr->sh_size); bfd_set_error (bfd_error_bad_value); -- num_group; /* PR 17510: If the group contents are even @@ -709,7 +711,7 @@ setup_group (bfd *abfd, Elf_Internal_Shdr *hdr, asection *newsect) if (idx >= shnum) { _bfd_error_handler - (_("%B: invalid SHT_GROUP entry"), abfd); + (_("%pB: invalid SHT_GROUP entry"), abfd); idx = 0; } dest->shdr = elf_elfsections (abfd)[idx]; @@ -728,7 +730,7 @@ setup_group (bfd *abfd, Elf_Internal_Shdr *hdr, asection *newsect) elf_tdata (abfd)->group_sect_ptr = NULL; elf_tdata (abfd)->num_group = num_group = -1; _bfd_error_handler - (_("%B: no valid group sections found"), abfd); + (_("%pB: no valid group sections found"), abfd); bfd_set_error (bfd_error_bad_value); } } @@ -757,7 +759,7 @@ setup_group (bfd *abfd, Elf_Internal_Shdr *hdr, asection *newsect) { /* See PR 21957 for a reproducer. */ /* xgettext:c-format */ - _bfd_error_handler (_("%B: group section '%A' has no contents"), + _bfd_error_handler (_("%pB: group section '%pA' has no contents"), abfd, shdr->bfd_section); elf_tdata (abfd)->group_sect_ptr[i] = NULL; bfd_set_error (bfd_error_bad_value); @@ -817,7 +819,7 @@ setup_group (bfd *abfd, Elf_Internal_Shdr *hdr, asection *newsect) if (elf_group_name (newsect) == NULL) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: no group info for section '%A'"), + _bfd_error_handler (_("%pB: no group info for section '%pA'"), abfd, newsect); return FALSE; } @@ -848,7 +850,7 @@ _bfd_elf_setup_sections (bfd *abfd) if (bed->link_order_error_handler) bed->link_order_error_handler /* xgettext:c-format */ - (_("%B: warning: sh_link not set for section `%A'"), + (_("%pB: warning: sh_link not set for section `%pA'"), abfd, s); } else @@ -868,7 +870,7 @@ _bfd_elf_setup_sections (bfd *abfd) { _bfd_error_handler /* xgettext:c-format */ - (_("%B: sh_link [%d] in section `%A' is incorrect"), + (_("%pB: sh_link [%d] in section `%pA' is incorrect"), s->owner, elfsec, s); result = FALSE; } @@ -881,7 +883,7 @@ _bfd_elf_setup_sections (bfd *abfd) { _bfd_error_handler /* xgettext:c-format */ - (_("%B: SHT_GROUP section [index %d] has no SHF_GROUP sections"), + (_("%pB: SHT_GROUP section [index %d] has no SHF_GROUP sections"), abfd, elf_section_data (s)->this_idx); result = FALSE; } @@ -902,7 +904,7 @@ _bfd_elf_setup_sections (bfd *abfd) { _bfd_error_handler /* xgettext:c-format */ - (_("%B: section group entry number %u is corrupt"), + (_("%pB: section group entry number %u is corrupt"), abfd, i); result = FALSE; continue; @@ -925,7 +927,7 @@ _bfd_elf_setup_sections (bfd *abfd) /* There are some unknown sections in the group. */ _bfd_error_handler /* xgettext:c-format */ - (_("%B: unknown type [%#x] section `%s' in group [%A]"), + (_("%pB: unknown type [%#x] section `%s' in group [%pA]"), abfd, idx->shdr->sh_type, bfd_elf_string_from_elf_section (abfd, @@ -1195,7 +1197,7 @@ _bfd_elf_make_section_from_shdr (bfd *abfd, { _bfd_error_handler /* xgettext:c-format */ - (_("%B: unable to initialize compress status for section %s"), + (_("%pB: unable to initialize compress status for section %s"), abfd, name); return FALSE; } @@ -1206,7 +1208,7 @@ _bfd_elf_make_section_from_shdr (bfd *abfd, { _bfd_error_handler /* xgettext:c-format */ - (_("%B: unable to initialize decompress status for section %s"), + (_("%pB: unable to initialize decompress status for section %s"), abfd, name); return FALSE; } @@ -1387,7 +1389,7 @@ copy_special_section_fields (const bfd *ibfd, { _bfd_error_handler /* xgettext:c-format */ - (_("%B: Invalid sh_link field (%d) in section number %d"), + (_("%pB: invalid sh_link field (%d) in section number %d"), ibfd, iheader->sh_link, secnum); return FALSE; } @@ -1403,7 +1405,7 @@ copy_special_section_fields (const bfd *ibfd, if we could not find a match ? */ _bfd_error_handler /* xgettext:c-format */ - (_("%B: Failed to find link section for section %d"), obfd, secnum); + (_("%pB: failed to find link section for section %d"), obfd, secnum); } if (iheader->sh_info) @@ -1430,7 +1432,7 @@ copy_special_section_fields (const bfd *ibfd, else _bfd_error_handler /* xgettext:c-format */ - (_("%B: Failed to find info section for section %d"), obfd, secnum); + (_("%pB: failed to find info section for section %d"), obfd, secnum); } return changed; @@ -2013,7 +2015,7 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex) if (sections_being_created [shindex]) { _bfd_error_handler - (_("%B: warning: loop in section dependencies detected"), abfd); + (_("%pB: warning: loop in section dependencies detected"), abfd); return FALSE; } sections_being_created [shindex] = TRUE; @@ -2121,7 +2123,7 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex) { _bfd_error_handler /* xgettext:c-format */ - (_("%B: warning: multiple symbol tables detected" + (_("%pB: warning: multiple symbol tables detected" " - ignoring the table in section %u"), abfd, shindex); goto success; @@ -2205,7 +2207,7 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex) { _bfd_error_handler /* xgettext:c-format */ - (_("%B: warning: multiple dynamic symbol tables detected" + (_("%pB: warning: multiple dynamic symbol tables detected" " - ignoring the table in section %u"), abfd, shindex); goto success; @@ -2318,7 +2320,7 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex) { _bfd_error_handler /* xgettext:c-format */ - (_("%B: invalid link %u for reloc section %s (index %u)"), + (_("%pB: invalid link %u for reloc section %s (index %u)"), abfd, hdr->sh_link, name, shindex); ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); @@ -2477,7 +2479,7 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex) for applications? */ _bfd_error_handler /* xgettext:c-format */ - (_("%B: unknown type [%#x] section `%s'"), + (_("%pB: unknown type [%#x] section `%s'"), abfd, hdr->sh_type, name); else { @@ -2492,7 +2494,7 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex) /* FIXME: We should handle this section. */ _bfd_error_handler /* xgettext:c-format */ - (_("%B: unknown type [%#x] section `%s'"), + (_("%pB: unknown type [%#x] section `%s'"), abfd, hdr->sh_type, name); else if (hdr->sh_type >= SHT_LOOS && hdr->sh_type <= SHT_HIOS) { @@ -2503,7 +2505,7 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex) be rejected with an error message. */ _bfd_error_handler /* xgettext:c-format */ - (_("%B: unknown type [%#x] section `%s'"), + (_("%pB: unknown type [%#x] section `%s'"), abfd, hdr->sh_type, name); else { @@ -2516,7 +2518,7 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex) /* FIXME: We should handle this section. */ _bfd_error_handler /* xgettext:c-format */ - (_("%B: unknown type [%#x] section `%s'"), + (_("%pB: unknown type [%#x] section `%s'"), abfd, hdr->sh_type, name); goto fail; @@ -3221,7 +3223,7 @@ elf_fake_sections (bfd *abfd, asection *asect, void *fsarg) { _bfd_error_handler /* xgettext:c-format */ - (_("%B: error: Alignment power %d of section `%A' is too big"), + (_("%pB: error: alignment power %d of section `%pA' is too big"), abfd, asect->alignment_power, asect); arg->failed = TRUE; return; @@ -3251,7 +3253,7 @@ elf_fake_sections (bfd *abfd, asection *asect, void *fsarg) non-bss input sections to bss output sections, or emit data to a bss output section via a linker script. */ _bfd_error_handler - (_("warning: section `%A' type changed to PROGBITS"), asect); + (_("warning: section `%pA' type changed to PROGBITS"), asect); this_hdr->sh_type = sh_type; } @@ -3727,7 +3729,7 @@ assign_section_numbers (bfd *abfd, struct bfd_link_info *link_info) if (section_number >= SHN_LORESERVE) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: too many sections: %u"), + _bfd_error_handler (_("%pB: too many sections: %u"), abfd, section_number); return FALSE; } @@ -3812,8 +3814,8 @@ assign_section_numbers (bfd *abfd, struct bfd_link_info *link_info) asection *kept; _bfd_error_handler /* xgettext:c-format */ - (_("%B: sh_link of section `%A' points to" - " discarded section `%A' of `%B'"), + (_("%pB: sh_link of section `%pA' points to" + " discarded section `%pA' of `%pB'"), abfd, d->this_hdr.bfd_section, s, s->owner); /* Point to the kept section if it has the same @@ -3837,8 +3839,8 @@ assign_section_numbers (bfd *abfd, struct bfd_link_info *link_info) { _bfd_error_handler /* xgettext:c-format */ - (_("%B: sh_link of section `%A' points to" - " removed section `%A' of `%B'"), + (_("%pB: sh_link of section `%pA' points to" + " removed section `%pA' of `%pB'"), abfd, d->this_hdr.bfd_section, s, s->owner); bfd_set_error (bfd_error_bad_value); return FALSE; @@ -3859,7 +3861,7 @@ assign_section_numbers (bfd *abfd, struct bfd_link_info *link_info) if (bed->link_order_error_handler) bed->link_order_error_handler /* xgettext:c-format */ - (_("%B: warning: sh_link not set for section `%A'"), + (_("%pB: warning: sh_link not set for section `%pA'"), abfd, sec); } } @@ -4389,7 +4391,7 @@ get_program_header_size (bfd *abfd, struct bfd_link_info *info) { _bfd_error_handler /* xgettext:c-format */ - (_("%B: GNU_MBIN section `%A' has invalid sh_info field: %d"), + (_("%pB: GNU_MBIN section `%pA' has invalid sh_info field: %d"), abfd, s, elf_section_data (s)->this_hdr.sh_info); continue; } @@ -4542,6 +4544,9 @@ elf_modify_segment_map (bfd *abfd, return TRUE; } +#define IS_TBSS(s) \ + ((s->flags & (SEC_THREAD_LOCAL | SEC_LOAD)) == SEC_THREAD_LOCAL) + /* Set up a mapping from BFD sections to program segments. */ bfd_boolean @@ -4727,33 +4732,35 @@ _bfd_elf_map_sections_to_segments (bfd *abfd, struct bfd_link_info *info) the previous section, then we need a new segment. */ new_segment = TRUE; } + else if ((abfd->flags & D_PAGED) != 0 + && (((last_hdr->lma + last_size - 1) & -maxpagesize) + == (hdr->lma & -maxpagesize))) + { + /* If we are demand paged then we can't map two disk + pages onto the same memory page. */ + new_segment = FALSE; + } /* In the next test we have to be careful when last_hdr->lma is close to the end of the address space. If the aligned address wraps around to the start of the address space, then there are no more pages left in memory and it is OK to assume that the current section can be included in the current segment. */ - else if ((BFD_ALIGN (last_hdr->lma + last_size, maxpagesize) + maxpagesize - > last_hdr->lma) - && (BFD_ALIGN (last_hdr->lma + last_size, maxpagesize) + maxpagesize - <= hdr->lma)) + else if ((BFD_ALIGN (last_hdr->lma + last_size, maxpagesize) + + maxpagesize > last_hdr->lma) + && (BFD_ALIGN (last_hdr->lma + last_size, maxpagesize) + + maxpagesize <= hdr->lma)) { /* If putting this section in this segment would force us to skip a page in the segment, then we need a new segment. */ new_segment = TRUE; } else if ((last_hdr->flags & (SEC_LOAD | SEC_THREAD_LOCAL)) == 0 - && (hdr->flags & (SEC_LOAD | SEC_THREAD_LOCAL)) != 0 - && ((abfd->flags & D_PAGED) == 0 - || (((last_hdr->lma + last_size - 1) & -maxpagesize) - != (hdr->lma & -maxpagesize)))) + && (hdr->flags & (SEC_LOAD | SEC_THREAD_LOCAL)) != 0) { /* We don't want to put a loaded section after a nonloaded (ie. bss style) section in the same segment as that will force the non-loaded section to be loaded. - Consider .tbss sections as loaded for this purpose. - However, like the writable/non-writable case below, - if they are on the same page then they must be put - in the same segment. */ + Consider .tbss sections as loaded for this purpose. */ new_segment = TRUE; } else if ((abfd->flags & D_PAGED) == 0) @@ -4770,20 +4777,10 @@ _bfd_elf_map_sections_to_segments (bfd *abfd, struct bfd_link_info *info) new_segment = TRUE; } else if (! writable - && (hdr->flags & SEC_READONLY) == 0 - && ((info != NULL - && info->relro_end > info->relro_start) - || (((last_hdr->lma + last_size - 1) & -maxpagesize) - != (hdr->lma & -maxpagesize)))) + && (hdr->flags & SEC_READONLY) == 0) { /* We don't want to put a writable section in a read only - segment, unless they are on the same page in memory - anyhow and there is no RELRO segment. We already - know that the last section does not bring us past the - current section on the page, so the only case in which - the new section is not on the same page as the previous - section is when the previous section ends precisely on - a page boundary. */ + segment. */ new_segment = TRUE; } else @@ -4809,11 +4806,7 @@ _bfd_elf_map_sections_to_segments (bfd *abfd, struct bfd_link_info *info) executable = TRUE; last_hdr = hdr; /* .tbss sections effectively have zero size. */ - if ((hdr->flags & (SEC_THREAD_LOCAL | SEC_LOAD)) - != SEC_THREAD_LOCAL) - last_size = hdr->size; - else - last_size = 0; + last_size = !IS_TBSS (hdr) ? hdr->size : 0; continue; } @@ -4839,10 +4832,7 @@ _bfd_elf_map_sections_to_segments (bfd *abfd, struct bfd_link_info *info) last_hdr = hdr; /* .tbss sections effectively have zero size. */ - if ((hdr->flags & (SEC_THREAD_LOCAL | SEC_LOAD)) != SEC_THREAD_LOCAL) - last_size = hdr->size; - else - last_size = 0; + last_size = !IS_TBSS (hdr) ? hdr->size : 0; phdr_index = i; phdr_in_segment = FALSE; } @@ -4851,8 +4841,7 @@ _bfd_elf_map_sections_to_segments (bfd *abfd, struct bfd_link_info *info) for .tbss. */ if (last_hdr != NULL && (i - phdr_index != 1 - || ((last_hdr->flags & (SEC_THREAD_LOCAL | SEC_LOAD)) - != SEC_THREAD_LOCAL))) + || !IS_TBSS (last_hdr))) { m = make_mapping (abfd, sections, phdr_index, i, phdr_in_segment); if (m == NULL) @@ -4948,18 +4937,18 @@ _bfd_elf_map_sections_to_segments (bfd *abfd, struct bfd_link_info *info) if ((s->flags & SEC_THREAD_LOCAL) == 0) { _bfd_error_handler - (_("%B: TLS sections are not adjacent:"), abfd); + (_("%pB: TLS sections are not adjacent:"), abfd); s = first_tls; i = 0; while (i < (unsigned int) tls_count) { if ((s->flags & SEC_THREAD_LOCAL) != 0) { - _bfd_error_handler (_(" TLS: %A"), s); + _bfd_error_handler (_(" TLS: %pA"), s); i++; } else - _bfd_error_handler (_(" non-TLS: %A"), s); + _bfd_error_handler (_(" non-TLS: %pA"), s); s = s->next; } bfd_set_error (bfd_error_bad_value); @@ -5455,7 +5444,7 @@ assign_file_positions_for_load_sections (bfd *abfd, && strcmp (m->sections[0]->name, ".dynamic") != 0) { _bfd_error_handler - (_("%B: The first section in the PT_DYNAMIC segment" + (_("%pB: The first section in the PT_DYNAMIC segment" " is not the .dynamic section"), abfd); bfd_set_error (bfd_error_bad_value); @@ -5483,7 +5472,7 @@ assign_file_positions_for_load_sections (bfd *abfd, && p->p_paddr < (bfd_vma) off)) { _bfd_error_handler - (_("%B: Not enough room for program headers," + (_("%pB: not enough room for program headers," " try linking with -N"), abfd); bfd_set_error (bfd_error_bad_value); @@ -5571,8 +5560,8 @@ assign_file_positions_for_load_sections (bfd *abfd, { _bfd_error_handler /* xgettext:c-format */ - (_("%B: section %A lma %#Lx adjusted to %#Lx"), - abfd, sec, s_start, p_end); + (_("%pB: section %pA lma %#" PRIx64 " adjusted to %#" PRIx64), + abfd, sec, (uint64_t) s_start, (uint64_t) p_end); adjust = 0; sec->lma = p_end; } @@ -5708,7 +5697,7 @@ assign_file_positions_for_load_sections (bfd *abfd, { _bfd_error_handler /* xgettext:c-format */ - (_("%B: section `%A' can't be allocated in segment %d"), + (_("%pB: section `%pA' can't be allocated in segment %d"), abfd, sec, j); print_segment_map (m); } @@ -5756,7 +5745,7 @@ assign_file_positions_for_non_load_sections (bfd *abfd, if (hdr->sh_size != 0) _bfd_error_handler /* xgettext:c-format */ - (_("%B: warning: allocated section `%s' not in segment"), + (_("%pB: warning: allocated section `%s' not in segment"), abfd, (hdr->bfd_section == NULL ? "*unknown*" @@ -5869,65 +5858,100 @@ assign_file_positions_for_non_load_sections (bfd *abfd, { if (p->p_type == PT_GNU_RELRO) { - const Elf_Internal_Phdr *lp; - struct elf_segment_map *lm; + bfd_vma start, end; + bfd_boolean ok; if (link_info != NULL) { /* During linking the range of the RELRO segment is passed - in link_info. */ + in link_info. Note that there may be padding between + relro_start and the first RELRO section. */ + start = link_info->relro_start; + end = link_info->relro_end; + } + else if (m->count != 0) + { + if (!m->p_size_valid) + abort (); + start = m->sections[0]->vma; + end = start + m->p_size; + } + else + { + start = 0; + end = 0; + } + + ok = FALSE; + if (start < end) + { + struct elf_segment_map *lm; + const Elf_Internal_Phdr *lp; + unsigned int i; + + /* Find a LOAD segment containing a section in the RELRO + segment. */ for (lm = elf_seg_map (abfd), lp = phdrs; lm != NULL; lm = lm->next, lp++) { if (lp->p_type == PT_LOAD - && lp->p_vaddr < link_info->relro_end && lm->count != 0 - && lm->sections[0]->vma >= link_info->relro_start) + && (lm->sections[lm->count - 1]->vma + + (!IS_TBSS (lm->sections[lm->count - 1]) + ? lm->sections[lm->count - 1]->size + : 0)) > start + && lm->sections[0]->vma < end) break; } - BFD_ASSERT (lm != NULL); - } - else - { - /* Otherwise we are copying an executable or shared - library, but we need to use the same linker logic. */ - for (lp = phdrs; lp < phdrs + count; ++lp) + if (lm != NULL) { - if (lp->p_type == PT_LOAD - && lp->p_paddr == p->p_paddr) - break; - } - } + /* Find the section starting the RELRO segment. */ + for (i = 0; i < lm->count; i++) + { + asection *s = lm->sections[i]; + if (s->vma >= start + && s->vma < end + && s->size != 0) + break; + } - if (lp < phdrs + count) - { - p->p_vaddr = lp->p_vaddr; - p->p_paddr = lp->p_paddr; - p->p_offset = lp->p_offset; - if (link_info != NULL) - p->p_filesz = link_info->relro_end - lp->p_vaddr; - else if (m->p_size_valid) - p->p_filesz = m->p_size; - else - abort (); - p->p_memsz = p->p_filesz; - /* Preserve the alignment and flags if they are valid. The - gold linker generates RW/4 for the PT_GNU_RELRO section. - It is better for objcopy/strip to honor these attributes - otherwise gdb will choke when using separate debug files. - */ - if (!m->p_align_valid) - p->p_align = 1; - if (!m->p_flags_valid) - p->p_flags = PF_R; - } - else - { - memset (p, 0, sizeof *p); - p->p_type = PT_NULL; + if (i < lm->count) + { + p->p_vaddr = lm->sections[i]->vma; + p->p_paddr = lm->sections[i]->lma; + p->p_offset = lm->sections[i]->filepos; + p->p_memsz = end - p->p_vaddr; + p->p_filesz = p->p_memsz; + + /* The RELRO segment typically ends a few bytes + into .got.plt but other layouts are possible. + In cases where the end does not match any + loaded section (for instance is in file + padding), trim p_filesz back to correspond to + the end of loaded section contents. */ + if (p->p_filesz > lp->p_vaddr + lp->p_filesz - p->p_vaddr) + p->p_filesz = lp->p_vaddr + lp->p_filesz - p->p_vaddr; + + /* Preserve the alignment and flags if they are + valid. The gold linker generates RW/4 for + the PT_GNU_RELRO section. It is better for + objcopy/strip to honor these attributes + otherwise gdb will choke when using separate + debug files. */ + if (!m->p_align_valid) + p->p_align = 1; + if (!m->p_flags_valid) + p->p_flags = PF_R; + ok = TRUE; + } + } } + if (link_info != NULL) + BFD_ASSERT (ok); + if (!ok) + memset (p, 0, sizeof *p); } else if (p->p_type == PT_GNU_STACK) { @@ -5954,7 +5978,7 @@ assign_file_positions_for_non_load_sections (bfd *abfd, { /* PR 17512: file: 2195325e. */ _bfd_error_handler - (_("%B: error: non-load segment %d includes file header " + (_("%pB: error: non-load segment %d includes file header " "and/or program header"), abfd, (int) (p - phdrs)); return FALSE; @@ -6103,9 +6127,7 @@ assign_file_positions_except_relocs (bfd *abfd, } /* Write out the program headers. */ - alloc = elf_program_header_size (abfd) / bed->s->sizeof_phdr; - - /* Sort the program headers into the ordering required by the ELF standard. */ + alloc = elf_elfheader (abfd)->e_phnum; if (alloc == 0) return TRUE; @@ -6122,17 +6144,19 @@ assign_file_positions_except_relocs (bfd *abfd, changed or the programs updated. */ if (alloc > 1 && tdata->phdr[0].p_type == PT_PHDR - && ! bed->elf_backend_allow_non_load_phdr (abfd, tdata->phdr, alloc) + && (bed->elf_backend_allow_non_load_phdr == NULL + || !bed->elf_backend_allow_non_load_phdr (abfd, tdata->phdr, + alloc)) && tdata->phdr[1].p_type == PT_LOAD && (tdata->phdr[1].p_vaddr > tdata->phdr[0].p_vaddr - || (tdata->phdr[1].p_vaddr + tdata->phdr[1].p_memsz) - < (tdata->phdr[0].p_vaddr + tdata->phdr[0].p_memsz))) + || (tdata->phdr[1].p_vaddr + tdata->phdr[1].p_memsz + < tdata->phdr[0].p_vaddr + tdata->phdr[0].p_memsz))) { /* The fix for this error is usually to edit the linker script being used and set up the program headers manually. Either that or leave room for the headers at the start of the SECTIONS. */ - _bfd_error_handler (_("\ -%B: error: PHDR segment not covered by LOAD segment"), + _bfd_error_handler (_("%pB: error: PHDR segment not covered" + " by LOAD segment"), abfd); return FALSE; } @@ -6362,7 +6386,8 @@ _bfd_elf_write_object_contents (bfd *abfd) = _bfd_elf_strtab_offset (elf_shstrtab (abfd), i_shdrp[count]->sh_name); if (bed->elf_backend_section_processing) - (*bed->elf_backend_section_processing) (abfd, i_shdrp[count]); + if (!(*bed->elf_backend_section_processing) (abfd, i_shdrp[count])) + return FALSE; if (i_shdrp[count]->contents) { bfd_size_type amt = i_shdrp[count]->sh_size; @@ -6475,7 +6500,7 @@ _bfd_elf_symbol_from_bfd_symbol (bfd *abfd, asymbol **asym_ptr_ptr) which is used in a relocation entry. */ _bfd_error_handler /* xgettext:c-format */ - (_("%B: symbol `%s' required but not present"), + (_("%pB: symbol `%s' required but not present"), abfd, bfd_asymbol_name (asym_ptr)); bfd_set_error (bfd_error_no_symbols); return -1; @@ -6818,9 +6843,10 @@ rewrite_elf_program_header (bfd *ibfd, bfd *obfd) if (segment->p_type == PT_LOAD && (segment->p_filesz > 0 || segment->p_memsz == 0)) /* xgettext:c-format */ - _bfd_error_handler (_("%B: warning: Empty loadable segment detected" - " at vaddr=%#Lx, is this intentional?"), - ibfd, segment->p_vaddr); + _bfd_error_handler + (_("%pB: warning: empty loadable segment detected" + " at vaddr=%#" PRIx64 ", is this intentional?"), + ibfd, (uint64_t) segment->p_vaddr); map->count = 0; *pointer_to_map = map; @@ -7432,9 +7458,9 @@ rewrite: /* PR 17512: file: f17299af. */ if (segment->p_align > (bfd_vma) 1 << ((sizeof (bfd_vma) * 8) - 2)) /* xgettext:c-format */ - _bfd_error_handler (_("%B: warning: segment alignment of %#Lx" - " is too large"), - ibfd, segment->p_align); + _bfd_error_handler (_("%pB: warning: segment alignment of %#" + PRIx64 " is too large"), + ibfd, (uint64_t) segment->p_align); else maxpagesize = segment->p_align; } @@ -7587,7 +7613,16 @@ _bfd_elf_fixup_group_sections (bfd *ibfd, asection *discarded) but the SHT_GROUP section is, then adjust its size. */ else if (s->output_section == discarded && isec->output_section != discarded) - removed += 4; + { + struct bfd_elf_section_data *elf_sec = elf_section_data (s); + removed += 4; + if (elf_sec->rel.hdr != NULL + && (elf_sec->rel.hdr->sh_flags & SHF_GROUP) != 0) + removed += 4; + if (elf_sec->rela.hdr != NULL + && (elf_sec->rela.hdr->sh_flags & SHF_GROUP) != 0) + removed += 4; + } s = elf_next_in_group (s); if (s == first) break; @@ -7597,18 +7632,26 @@ _bfd_elf_fixup_group_sections (bfd *ibfd, asection *discarded) if (discarded != NULL) { /* If we've been called for ld -r, then we need to - adjust the input section size. This function may - be called multiple times, so save the original - size. */ + adjust the input section size. */ if (isec->rawsize == 0) isec->rawsize = isec->size; isec->size = isec->rawsize - removed; + if (isec->size <= 4) + { + isec->size = 0; + isec->flags |= SEC_EXCLUDE; + } } else { /* Adjust the output section size when called from objcopy. */ isec->output_section->size -= removed; + if (isec->output_section->size <= 4) + { + isec->output_section->size = 0; + isec->output_section->flags |= SEC_EXCLUDE; + } } } } @@ -7913,10 +7956,11 @@ error_return: if (shndx == SHN_BAD) { /* xgettext:c-format */ - _bfd_error_handler (_("\ -Unable to find equivalent output section for symbol '%s' from section '%s'"), - syms[idx]->name ? syms[idx]->name : "", - sec->name); + _bfd_error_handler + (_("unable to find equivalent output section" + " for symbol '%s' from section '%s'"), + syms[idx]->name ? syms[idx]->name : "", + sec->name); bfd_set_error (bfd_error_invalid_operation); goto error_return; } @@ -8246,7 +8290,7 @@ _bfd_elf_slurp_version_tables (bfd *abfd, bfd_boolean default_imported_symver) { error_return_bad_verref: _bfd_error_handler - (_("%B: .gnu.version_r invalid entry"), abfd); + (_("%pB: .gnu.version_r invalid entry"), abfd); bfd_set_error (bfd_error_bad_value); error_return_verref: elf_tdata (abfd)->verref = NULL; @@ -8373,7 +8417,7 @@ error_return_verref: { error_return_bad_verdef: _bfd_error_handler - (_("%B: .gnu.version_d invalid entry"), abfd); + (_("%pB: .gnu.version_d invalid entry"), abfd); bfd_set_error (bfd_error_bad_value); error_return_verdef: elf_tdata (abfd)->verdef = NULL; @@ -8826,12 +8870,13 @@ _bfd_elf_set_section_contents (bfd *abfd, return TRUE; } -void +bfd_boolean _bfd_elf_no_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, arelent *cache_ptr ATTRIBUTE_UNUSED, Elf_Internal_Rela *dst ATTRIBUTE_UNUSED) { abort (); + return FALSE; } /* Try to convert a non-ELF reloc into an ELF one. */ @@ -8923,10 +8968,9 @@ _bfd_elf_validate_reloc (bfd *abfd, arelent *areloc) return TRUE; fail: - _bfd_error_handler - /* xgettext:c-format */ - (_("%B: unsupported relocation type %s"), - abfd, areloc->howto->name); + /* xgettext:c-format */ + _bfd_error_handler (_("%pB: %s unsupported"), + abfd, areloc->howto->name); bfd_set_error (bfd_error_bad_value); return FALSE; } @@ -11019,6 +11063,8 @@ elf_parse_notes (bfd *abfd, char *buf, size_t size, file_ptr offset, align is less than 4, we use 4 byte alignment. */ if (align < 4) align = 4; + if (align != 4 && align != 8) + return FALSE; p = buf; while (p < buf + size) diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c index 5921cc2..33fff58 100644 --- a/bfd/elf32-arc.c +++ b/bfd/elf32-arc.c @@ -98,6 +98,7 @@ reloc_type_to_name (unsigned int type) break; } } + #undef ARC_RELOC_HOWTO /* Try to minimize the amount of space occupied by relocation tables @@ -160,7 +161,7 @@ struct arc_relocation_data }; /* Should be included at this location due to static declarations - * defined before this point. */ + defined before this point. */ #include "arc-got.h" #define arc_bfd_get_8(A,B,C) bfd_get_8(A,B) @@ -199,11 +200,13 @@ arc_elf_reloc (bfd *abfd ATTRIBUTE_UNUSED, #define ARC_RELOC_HOWTO(TYPE, VALUE, SIZE, BITSIZE, RELOC_FUNCTION, OVERFLOW, FORMULA) \ TYPE = VALUE, + enum howto_list { #include "elf/arc-reloc.def" HOWTO_LIST_LAST }; + #undef ARC_RELOC_HOWTO #define ARC_RELOC_HOWTO(TYPE, VALUE, RSIZE, BITSIZE, RELOC_FUNCTION, OVERFLOW, FORMULA) \ @@ -233,16 +236,17 @@ static struct reloc_howto_struct elf_arc_howto_table[] = }; #undef ARC_RELOC_HOWTO -static void arc_elf_howto_init (void) +static void +arc_elf_howto_init (void) { #define ARC_RELOC_HOWTO(TYPE, VALUE, SIZE, BITSIZE, RELOC_FUNCTION, OVERFLOW, FORMULA) \ - elf_arc_howto_table[TYPE].pc_relative = \ + elf_arc_howto_table[TYPE].pc_relative = \ (strstr (#FORMULA, " P ") != NULL || strstr (#FORMULA, " PDATA ") != NULL); \ - elf_arc_howto_table[TYPE].dst_mask = RELOC_FUNCTION(0, ~0); \ - /* Only 32 bit data relocations should be marked as ME. */ \ - if (strstr (#FORMULA, " ME ") != NULL) \ - { \ - BFD_ASSERT (SIZE == 2); \ + elf_arc_howto_table[TYPE].dst_mask = RELOC_FUNCTION(0, ~0); \ + /* Only 32 bit data relocations should be marked as ME. */ \ + if (strstr (#FORMULA, " ME ") != NULL) \ + { \ + BFD_ASSERT (SIZE == 2); \ } #include "elf/arc-reloc.def" @@ -253,10 +257,12 @@ static void arc_elf_howto_init (void) #define ARC_RELOC_HOWTO(TYPE, VALUE, SIZE, BITSIZE, RELOC_FUNCTION, OVERFLOW, FORMULA) \ [TYPE] = VALUE, + const int howto_table_lookup[] = { #include "elf/arc-reloc.def" }; + #undef ARC_RELOC_HOWTO static reloc_howto_type * @@ -358,6 +364,7 @@ arc_elf_link_hash_table_create (bfd *abfd) #define ARC_RELOC_HOWTO(TYPE, VALUE, SIZE, BITSIZE, RELOC_FUNCTION, OVERFLOW, FORMULA) \ { BFD_RELOC_##TYPE, R_##TYPE }, + static const struct arc_reloc_map arc_reloc_map[] = { #include "elf/arc-reloc.def" @@ -368,6 +375,7 @@ static const struct arc_reloc_map arc_reloc_map[] = {BFD_RELOC_24, R_ARC_24}, {BFD_RELOC_32, R_ARC_32}, }; + #undef ARC_RELOC_HOWTO typedef ATTRIBUTE_UNUSED bfd_vma (*replace_func) (unsigned, int ATTRIBUTE_UNUSED); @@ -376,6 +384,7 @@ typedef ATTRIBUTE_UNUSED bfd_vma (*replace_func) (unsigned, int ATTRIBUTE_UNUSED case TYPE: \ func = (void *) RELOC_FUNCTION; \ break; + static replace_func get_replace_function (bfd *abfd, unsigned int r_type) { @@ -387,7 +396,7 @@ get_replace_function (bfd *abfd, unsigned int r_type) } if (func == replace_bits24 && bfd_big_endian (abfd)) - return (replace_func) replace_bits24_be; + func = replace_bits24_be; return (replace_func) func; } @@ -496,16 +505,25 @@ bfd_elf32_bfd_reloc_name_lookup (bfd * abfd ATTRIBUTE_UNUSED, /* Set the howto pointer for an ARC ELF reloc. */ -static void -arc_info_to_howto_rel (bfd * abfd ATTRIBUTE_UNUSED, +static bfd_boolean +arc_info_to_howto_rel (bfd * abfd, arelent * cache_ptr, Elf_Internal_Rela * dst) { unsigned int r_type; r_type = ELF32_R_TYPE (dst->r_info); - BFD_ASSERT (r_type < (unsigned int) R_ARC_max); + if (r_type >= (unsigned int) R_ARC_max) + { + /* xgettext:c-format */ + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; + } + cache_ptr->howto = arc_elf_howto (r_type); + return TRUE; } /* Extract CPU features from an NTBS. */ @@ -608,8 +626,8 @@ arc_elf_merge_attributes (bfd *ibfd, struct bfd_link_info *info) /* It's sometimes ok to mix different configs, so this is only a warning. */ _bfd_error_handler - (_("Warning: %B: Conflicting platform configuration " - "%s with %s.\n"), ibfd, + (_("warning: %pB: conflicting platform configuration " + "%s with %s"), ibfd, tagval[in_attr[i].i], tagval[out_attr[i].i]); } @@ -627,8 +645,8 @@ arc_elf_merge_attributes (bfd *ibfd, struct bfd_link_info *info) BFD_ASSERT (out_attr[i].i < 5); /* We cannot mix code for different CPUs. */ _bfd_error_handler - (_("error: %B: unable to merge CPU base attributes " - "%s with %s.\n"), + (_("error: %pB: unable to merge CPU base attributes " + "%s with %s"), obfd, tagval[in_attr[i].i], tagval[out_attr[i].i]); @@ -664,8 +682,8 @@ arc_elf_merge_attributes (bfd *ibfd, struct bfd_link_info *info) && (!(cpu_out & bfd_feature_list[j].cpus))) { _bfd_error_handler - (_("error: %B: unable to merge ISA extension attributes " - "%s.\n"), + (_("error: %pB: unable to merge ISA extension attributes " + "%s"), obfd, bfd_feature_list[j].name); result = FALSE; break; @@ -688,8 +706,8 @@ arc_elf_merge_attributes (bfd *ibfd, struct bfd_link_info *info) p2 = (char *) bfd_feature_list[k].name; } _bfd_error_handler - (_("error: %B: conflicting ISA extension attributes " - "%s with %s.\n"), + (_("error: %pB: conflicting ISA extension attributes " + "%s with %s"), obfd, p1, p2); result = FALSE; break; @@ -723,7 +741,7 @@ arc_elf_merge_attributes (bfd *ibfd, struct bfd_link_info *info) { /* We cannot mix code with rf16 and without. */ _bfd_error_handler - (_("error: %B: cannot mix rf16 with full register set %B.\n"), + (_("error: %pB: cannot mix rf16 with full register set %pB"), obfd, ibfd); result = FALSE; } @@ -749,7 +767,7 @@ arc_elf_merge_attributes (bfd *ibfd, struct bfd_link_info *info) && out_attr[i].i != in_attr[i].i) { _bfd_error_handler - (_("error: %B: conflicting attributes %s: %s with %s.\n"), + (_("error: %pB: conflicting attributes %s: %s with %s"), obfd, tagname, tagval[in_attr[i].i], tagval[out_attr[i].i]); @@ -774,7 +792,7 @@ arc_elf_merge_attributes (bfd *ibfd, struct bfd_link_info *info) && out_attr[i].i != in_attr[i].i) { _bfd_error_handler - (_("error: %B: conflicting attributes %s.\n"), + (_("error: %pB: conflicting attributes %s"), obfd, tagname); result = FALSE; } @@ -874,8 +892,8 @@ arc_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) if (mach_ibfd != mach_obfd) { /* xgettext:c-format */ - _bfd_error_handler (_("ERROR: Attempting to link %B " - "with a binary %B of different architecture"), + _bfd_error_handler (_("error: attempting to link %pB " + "with a binary %pB of different architecture"), ibfd, obfd); return FALSE; } @@ -888,7 +906,7 @@ arc_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) /* Warn if different flags. */ _bfd_error_handler /* xgettext:c-format */ - (_("%B: uses different e_flags (%#x) fields than " + (_("%pB: uses different e_flags (%#x) fields than " "previous modules (%#x)"), ibfd, in_flags, out_flags); if (in_flags && out_flags) @@ -977,14 +995,14 @@ arc_elf_object_p (bfd * abfd) if (e_machine == EM_ARC) { _bfd_error_handler - (_("Error: The ARC4 architecture is no longer supported.\n")); + (_("error: the ARC4 architecture is no longer supported")); return FALSE; } else { _bfd_error_handler - (_("Warning: unset or old architecture flags. \n" - " Use default machine.\n")); + (_("warning: unset or old architecture flags; " + "use default machine")); } } @@ -1116,26 +1134,26 @@ arc_special_overflow_checks (const struct arc_relocation_data reloc_data, if (reloc_data.reloc_addend == 0) _bfd_error_handler /* xgettext:c-format */ - (_("%B(%A+%#Lx): CMEM relocation to `%s' is invalid, " - "16 MSB should be %#x (value is %#Lx)"), + (_("%pB(%pA+%#" PRIx64 "): CMEM relocation to `%s' is invalid, " + "16 MSB should be %#x (value is %#" PRIx64 ")"), reloc_data.input_section->owner, reloc_data.input_section, - reloc_data.reloc_offset, + (uint64_t) reloc_data.reloc_offset, reloc_data.symbol_name, NPS_CMEM_HIGH_VALUE, - relocation); + (uint64_t) relocation); else _bfd_error_handler /* xgettext:c-format */ - (_("%B(%A+%#Lx): CMEM relocation to `%s+%#Lx' is invalid, " - "16 MSB should be %#x (value is %#Lx)"), + (_("%pB(%pA+%#" PRIx64 "): CMEM relocation to `%s+%#" PRIx64 + "' is invalid, 16 MSB should be %#x (value is %#" PRIx64 ")"), reloc_data.input_section->owner, reloc_data.input_section, - reloc_data.reloc_offset, + (uint64_t) reloc_data.reloc_offset, reloc_data.symbol_name, - reloc_data.reloc_addend, + (uint64_t) reloc_data.reloc_addend, NPS_CMEM_HIGH_VALUE, - relocation); + (uint64_t) relocation); return bfd_reloc_overflow; } break; @@ -1534,7 +1552,6 @@ elf_arc_relocate_section (bfd * output_bfd, { _bfd_clear_contents (howto, input_bfd, input_section, contents + rel->r_offset); - rel->r_offset = rel->r_offset; rel->r_info = 0; rel->r_addend = 0; @@ -1820,7 +1837,7 @@ elf_arc_relocate_section (bfd * output_bfd, && !reloc_data.sdata_begin_symbol_vma_set) { _bfd_error_handler - ("Error: Linker symbol __SDATA_BEGIN__ not found"); + ("error: linker symbol __SDATA_BEGIN__ not found"); bfd_set_error (bfd_error_bad_value); return FALSE; } @@ -1833,7 +1850,7 @@ elf_arc_relocate_section (bfd * output_bfd, && reloc_data.sym_section == NULL) { _bfd_error_handler - (_("GOT and PLT relocations cannot be fixed with a non dynamic linker.")); + (_("GOT and PLT relocations cannot be fixed with a non dynamic linker")); bfd_set_error (bfd_error_bad_value); return FALSE; } @@ -1857,27 +1874,27 @@ elf_arc_relocate_section (bfd * output_bfd, case bfd_reloc_other: /* xgettext:c-format */ - msg = _("%B(%A): warning: unaligned access to symbol '%s' in the small data area"); + msg = _("%pB(%pA): warning: unaligned access to symbol '%s' in the small data area"); break; case bfd_reloc_outofrange: /* xgettext:c-format */ - msg = _("%B(%A): internal error: out of range error"); + msg = _("%pB(%pA): internal error: out of range error"); break; case bfd_reloc_notsupported: /* xgettext:c-format */ - msg = _("%B(%A): internal error: unsupported relocation error"); + msg = _("%pB(%pA): internal error: unsupported relocation error"); break; case bfd_reloc_dangerous: /* xgettext:c-format */ - msg = _("%B(%A): internal error: dangerous relocation"); + msg = _("%pB(%pA): internal error: dangerous relocation"); break; default: /* xgettext:c-format */ - msg = _("%B(%A): internal error: unknown error"); + msg = _("%pB(%pA): internal error: unknown error"); break; } @@ -1965,11 +1982,11 @@ elf_arc_check_relocs (bfd * abfd, name = "UNKNOWN"; _bfd_error_handler /* xgettext:c-format */ - (_("\ -%B: relocation %s against `%s' can not be used when making a shared object; recompile with -fPIC"), - abfd, - arc_elf_howto (r_type)->name, - name); + (_("%pB: relocation %s against `%s' can not be used" + " when making a shared object; recompile with -fPIC"), + abfd, + arc_elf_howto (r_type)->name, + name); bfd_set_error (bfd_error_bad_value); return FALSE; } @@ -2857,7 +2874,7 @@ elf32_arc_obj_attrs_handle_unknown (bfd *abfd, int tag) if ((tag & 127) < (Tag_ARC_ISA_mpy_option + 1)) { _bfd_error_handler - (_("%B: Unknown mandatory ARC object attribute %d."), + (_("%pB: unknown mandatory ARC object attribute %d"), abfd, tag); bfd_set_error (bfd_error_bad_value); return FALSE; @@ -2865,7 +2882,7 @@ elf32_arc_obj_attrs_handle_unknown (bfd *abfd, int tag) else { _bfd_error_handler - (_("Warning: %B: Unknown ARC object attribute %d."), + (_("warning: %pB: unknown ARC object attribute %d"), abfd, tag); return TRUE; } diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index 0b250ce..ce9c2f2 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -56,7 +56,7 @@ ? bfd_elf32_swap_reloc_out \ : bfd_elf32_swap_reloca_out) -#define elf_info_to_howto 0 +#define elf_info_to_howto NULL #define elf_info_to_howto_rel elf32_arm_info_to_howto #define ARM_ELF_ABI_VERSION 0 @@ -1839,14 +1839,22 @@ elf32_arm_howto_from_type (unsigned int r_type) return NULL; } -static void -elf32_arm_info_to_howto (bfd * abfd ATTRIBUTE_UNUSED, arelent * bfd_reloc, +static bfd_boolean +elf32_arm_info_to_howto (bfd * abfd, arelent * bfd_reloc, Elf_Internal_Rela * elf_reloc) { unsigned int r_type; r_type = ELF32_R_TYPE (elf_reloc->r_info); - bfd_reloc->howto = elf32_arm_howto_from_type (r_type); + if ((bfd_reloc->howto = elf32_arm_howto_from_type (r_type)) == NULL) + { + /* xgettext:c-format */ + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; + } + return TRUE; } struct elf32_arm_reloc_map @@ -3142,7 +3150,7 @@ struct elf32_arm_link_hash_table int nacl_p; /* True if the target uses REL relocations. */ - int use_rel; + bfd_boolean use_rel; /* Nonzero if import library must be a secure gateway import library as per ARMv8-M Security Extensions. */ @@ -3796,7 +3804,7 @@ elf32_arm_link_hash_table_create (bfd *abfd) ret->plt_header_size = 20; ret->plt_entry_size = elf32_arm_use_long_plt_entry ? 16 : 12; #endif - ret->use_rel = 1; + ret->use_rel = TRUE; ret->obfd = abfd; if (!bfd_hash_table_init (&ret->stub_hash_table, stub_hash_newfunc, @@ -4019,10 +4027,10 @@ arm_type_of_stub (struct bfd_link_info *info, { if (input_sec->flags & SEC_ELF_PURECODE) _bfd_error_handler - (_("%B(%A): warning: long branch veneers used in" + (_("%pB(%pA): warning: long branch veneers used in" " section with SHF_ARM_PURECODE section" " attribute is only supported for M-profile" - " targets that implement the movw instruction."), + " targets that implement the movw instruction"), input_bfd, input_sec); stub_type = (bfd_link_pic (info) | globals->pic_veneer) @@ -4053,10 +4061,10 @@ arm_type_of_stub (struct bfd_link_info *info, { if (input_sec->flags & SEC_ELF_PURECODE) _bfd_error_handler - (_("%B(%A): warning: long branch veneers used in" + (_("%pB(%pA): warning: long branch veneers used in" " section with SHF_ARM_PURECODE section" " attribute is only supported for M-profile" - " targets that implement the movw instruction."), + " targets that implement the movw instruction"), input_bfd, input_sec); stub_type = (bfd_link_pic (info) | globals->pic_veneer) @@ -4072,10 +4080,10 @@ arm_type_of_stub (struct bfd_link_info *info, { if (input_sec->flags & SEC_ELF_PURECODE) _bfd_error_handler - (_("%B(%A): warning: long branch veneers used in" + (_("%pB(%pA): warning: long branch veneers used in" " section with SHF_ARM_PURECODE section" " attribute is only supported" " for M-profile" - " targets that implement the movw instruction."), + " targets that implement the movw instruction"), input_bfd, input_sec); /* Thumb to arm. */ @@ -4084,9 +4092,9 @@ arm_type_of_stub (struct bfd_link_info *info, && !INTERWORK_FLAG (sym_sec->owner)) { _bfd_error_handler - (_("%B(%s): warning: interworking not enabled.\n" - " first occurrence: %B: Thumb call to ARM"), - sym_sec->owner, name, input_bfd); + (_("%pB(%s): warning: interworking not enabled;" + " first occurrence: %pB: %s call to %s"), + sym_sec->owner, name, input_bfd, "Thumb", "ARM"); } stub_type = @@ -4124,10 +4132,10 @@ arm_type_of_stub (struct bfd_link_info *info, { if (input_sec->flags & SEC_ELF_PURECODE) _bfd_error_handler - (_("%B(%A): warning: long branch veneers used in" + (_("%pB(%pA): warning: long branch veneers used in" " section with SHF_ARM_PURECODE section" " attribute is only supported for M-profile" - " targets that implement the movw instruction."), + " targets that implement the movw instruction"), input_bfd, input_sec); if (branch_type == ST_BRANCH_TO_THUMB) { @@ -4138,9 +4146,9 @@ arm_type_of_stub (struct bfd_link_info *info, && !INTERWORK_FLAG (sym_sec->owner)) { _bfd_error_handler - (_("%B(%s): warning: interworking not enabled.\n" - " first occurrence: %B: ARM call to Thumb"), - sym_sec->owner, name, input_bfd); + (_("%pB(%s): warning: interworking not enabled;" + " first occurrence: %pB: %s call to %s"), + sym_sec->owner, name, input_bfd, "ARM", "Thumb"); } /* We have an extra 2-bytes reach because of @@ -4412,7 +4420,7 @@ elf32_arm_create_or_find_stub_sec (asection **link_sec_p, asection *section, out_sec = bfd_get_section_by_name (output_bfd, out_sec_name); if (out_sec == NULL) { - _bfd_error_handler (_("No address assigned to the veneers output " + _bfd_error_handler (_("no address assigned to the veneers output " "section %s"), out_sec_name); return NULL; } @@ -4487,7 +4495,7 @@ elf32_arm_add_stub (const char *stub_name, asection *section, { if (section == NULL) section = stub_sec; - _bfd_error_handler (_("%B: cannot create stub entry %s"), + _bfd_error_handler (_("%pB: cannot create stub entry %s"), section->owner, stub_name); return NULL; } @@ -5672,8 +5680,8 @@ cmse_scan (bfd *input_bfd, struct elf32_arm_link_hash_table *htab, if (!is_v8m) { - _bfd_error_handler (_("%B: Special symbol `%s' only allowed for " - "ARMv8-M architecture or later."), + _bfd_error_handler (_("%pB: special symbol `%s' only allowed for " + "ARMv8-M architecture or later"), input_bfd, sym_name); is_v8m = TRUE; /* Avoid multiple warning. */ ret = FALSE; @@ -5681,10 +5689,9 @@ cmse_scan (bfd *input_bfd, struct elf32_arm_link_hash_table *htab, if (cmse_invalid) { - _bfd_error_handler (_("%B: invalid special symbol `%s'."), + _bfd_error_handler (_("%pB: invalid special symbol `%s'; it must be" + " a global or weak function symbol"), input_bfd, sym_name); - _bfd_error_handler (_("It must be a global or weak function " - "symbol.")); ret = FALSE; if (i < ext_start) continue; @@ -5721,13 +5728,13 @@ cmse_scan (bfd *input_bfd, struct elf32_arm_link_hash_table *htab, if (hash || j < ext_start) { _bfd_error_handler - (_("%B: invalid standard symbol `%s'."), input_bfd, sym_name); - _bfd_error_handler - (_("It must be a global or weak function symbol.")); + (_("%pB: invalid standard symbol `%s'; it must be " + "a global or weak function symbol"), + input_bfd, sym_name); } else _bfd_error_handler - (_("%B: absent standard symbol `%s'."), input_bfd, sym_name); + (_("%pB: absent standard symbol `%s'"), input_bfd, sym_name); ret = FALSE; if (!hash) continue; @@ -5739,7 +5746,7 @@ cmse_scan (bfd *input_bfd, struct elf32_arm_link_hash_table *htab, if (cmse_hash->root.root.u.def.section != section) { _bfd_error_handler - (_("%B: `%s' and its special symbol are in different sections."), + (_("%pB: `%s' and its special symbol are in different sections"), input_bfd, sym_name); ret = FALSE; } @@ -5751,14 +5758,14 @@ cmse_scan (bfd *input_bfd, struct elf32_arm_link_hash_table *htab, if (section->output_section == NULL) { _bfd_error_handler - (_("%B: entry function `%s' not output."), input_bfd, sym_name); + (_("%pB: entry function `%s' not output"), input_bfd, sym_name); continue; } if (hash->root.size == 0) { _bfd_error_handler - (_("%B: entry function `%s' is empty."), input_bfd, sym_name); + (_("%pB: entry function `%s' is empty"), input_bfd, sym_name); ret = FALSE; } @@ -5887,8 +5894,8 @@ set_cmse_veneer_addr_from_implib (struct bfd_link_info *info, in_implib_bfd = htab->in_implib_bfd; if (!htab->cmse_implib) { - _bfd_error_handler (_("%B: --in-implib only supported for Secure " - "Gateway import libraries."), in_implib_bfd); + _bfd_error_handler (_("%pB: --in-implib only supported for Secure " + "Gateway import libraries"), in_implib_bfd); return FALSE; } @@ -5933,10 +5940,10 @@ set_cmse_veneer_addr_from_implib (struct bfd_link_info *info, || (ARM_GET_SYM_BRANCH_TYPE (intsym->st_target_internal) != ST_BRANCH_TO_THUMB)) { - _bfd_error_handler (_("%B: invalid import library entry: `%s'."), + _bfd_error_handler (_("%pB: invalid import library entry: `%s'; " + "symbol should be absolute, global and " + "refer to Thumb functions"), in_implib_bfd, sym_name); - _bfd_error_handler (_("Symbol should be absolute, global and " - "refer to Thumb functions.")); ret = FALSE; continue; } @@ -5955,7 +5962,7 @@ set_cmse_veneer_addr_from_implib (struct bfd_link_info *info, bfd_boolean new_stub; _bfd_error_handler - (_("Entry function `%s' disappeared from secure code."), sym_name); + (_("entry function `%s' disappeared from secure code"), sym_name); hash = (struct elf32_arm_link_hash_entry *) elf_link_hash_lookup (&(htab)->root, sym_name, TRUE, TRUE, TRUE); stub_entry @@ -5979,7 +5986,7 @@ set_cmse_veneer_addr_from_implib (struct bfd_link_info *info, { if (!cmse_entry_fct_p (hash)) { - _bfd_error_handler (_("`%s' refers to a non entry function."), + _bfd_error_handler (_("`%s' refers to a non entry function"), sym_name); ret = FALSE; } @@ -5994,7 +6001,7 @@ set_cmse_veneer_addr_from_implib (struct bfd_link_info *info, if (!!(flags & BSF_GLOBAL) != (hash->root.root.type == bfd_link_hash_defined)) _bfd_error_handler - (_("%B: visibility of symbol `%s' has changed."), in_implib_bfd, + (_("%pB: visibility of symbol `%s' has changed"), in_implib_bfd, sym_name); stub_entry->stub_offset = stub_offset; @@ -6003,7 +6010,7 @@ set_cmse_veneer_addr_from_implib (struct bfd_link_info *info, /* Size should match that of a SG veneer. */ if (intsym->st_size != cmse_stub_size) { - _bfd_error_handler (_("%B: incorrect size for symbol `%s'."), + _bfd_error_handler (_("%pB: incorrect size for symbol `%s'"), in_implib_bfd, sym_name); ret = FALSE; } @@ -6022,8 +6029,8 @@ set_cmse_veneer_addr_from_implib (struct bfd_link_info *info, if (stub_offset % cmse_stub_size) { _bfd_error_handler - (_("Offset of veneer for entry function `%s' not a multiple of " - "its size."), sym_name); + (_("offset of veneer for entry function `%s' not a multiple of " + "its size"), sym_name); ret = FALSE; } @@ -6050,7 +6057,7 @@ set_cmse_veneer_addr_from_implib (struct bfd_link_info *info, if (cmse_stub_array_start != cmse_stub_sec_vma) { _bfd_error_handler - (_("Start address of `%s' is different from previous link."), + (_("start address of `%s' is different from previous link"), out_sec_name); ret = FALSE; } @@ -6624,7 +6631,7 @@ elf32_arm_size_stubs (bfd *output_bfd, TRUE, FALSE); if (stub_entry == NULL) { - _bfd_error_handler (_("%B: cannot create stub entry %s"), + _bfd_error_handler (_("%pB: cannot create stub entry %s"), section->owner, stub_name); return FALSE; } @@ -6757,8 +6764,8 @@ find_thumb_glue (struct bfd_link_info *link_info, (&(hash_table)->root, tmp_name, FALSE, FALSE, TRUE); if (hash == NULL - && asprintf (error_message, _("unable to find THUMB glue '%s' for '%s'"), - tmp_name, name) == -1) + && asprintf (error_message, _("unable to find %s glue '%s' for '%s'"), + "Thumb", tmp_name, name) == -1) *error_message = (char *) bfd_errmsg (bfd_error_system_call); free (tmp_name); @@ -6793,8 +6800,8 @@ find_arm_glue (struct bfd_link_info *link_info, (&(hash_table)->root, tmp_name, FALSE, FALSE, TRUE); if (myh == NULL - && asprintf (error_message, _("unable to find ARM glue '%s' for '%s'"), - tmp_name, name) == -1) + && asprintf (error_message, _("unable to find %s glue '%s' for '%s'"), + "ARM", tmp_name, name) == -1) *error_message = (char *) bfd_errmsg (bfd_error_system_call); free (tmp_name); @@ -7508,7 +7515,7 @@ bfd_elf32_arm_process_before_allocation (bfd *abfd, if (globals->byteswap_code && !bfd_big_endian (abfd)) { - _bfd_error_handler (_("%B: BE8 images only valid in big-endian mode."), + _bfd_error_handler (_("%pB: BE8 images only valid in big-endian mode"), abfd); return FALSE; } @@ -7739,7 +7746,7 @@ bfd_elf32_arm_set_vfp11_fix (bfd *obfd, struct bfd_link_info *link_info) default: /* Give a warning, but do as the user requests anyway. */ - _bfd_error_handler (_("%B: warning: selected VFP11 erratum " + _bfd_error_handler (_("%pB: warning: selected VFP11 erratum " "workaround is not necessary for target architecture"), obfd); } } @@ -7766,7 +7773,7 @@ bfd_elf32_arm_set_stm32l4xx_fix (bfd *obfd, struct bfd_link_info *link_info) if (globals->stm32l4xx_fix != BFD_ARM_STM32L4XX_FIX_NONE) /* Give a warning, but do as the user requests anyway. */ _bfd_error_handler - (_("%B: warning: selected STM32L4XX erratum " + (_("%pB: warning: selected STM32L4XX erratum " "workaround is not necessary for target architecture"), obfd); } } @@ -8303,8 +8310,8 @@ bfd_elf32_arm_vfp11_fix_veneer_locations (bfd *abfd, (&(globals)->root, tmp_name, FALSE, FALSE, TRUE); if (myh == NULL) - _bfd_error_handler (_("%B: unable to find VFP11 veneer " - "`%s'"), abfd, tmp_name); + _bfd_error_handler (_("%pB: unable to find %s veneer `%s'"), + abfd, "VFP11", tmp_name); vma = myh->root.u.def.section->output_section->vma + myh->root.u.def.section->output_offset @@ -8323,8 +8330,8 @@ bfd_elf32_arm_vfp11_fix_veneer_locations (bfd *abfd, (&(globals)->root, tmp_name, FALSE, FALSE, TRUE); if (myh == NULL) - _bfd_error_handler (_("%B: unable to find VFP11 veneer " - "`%s'"), abfd, tmp_name); + _bfd_error_handler (_("%pB: unable to find %s veneer `%s'"), + abfd, "VFP11", tmp_name); vma = myh->root.u.def.section->output_section->vma + myh->root.u.def.section->output_offset @@ -8389,8 +8396,8 @@ bfd_elf32_arm_stm32l4xx_fix_veneer_locations (bfd *abfd, (&(globals)->root, tmp_name, FALSE, FALSE, TRUE); if (myh == NULL) - _bfd_error_handler (_("%B: unable to find STM32L4XX veneer " - "`%s'"), abfd, tmp_name); + _bfd_error_handler (_("%pB: unable to find %s veneer `%s'"), + abfd, "STM32L4XX", tmp_name); vma = myh->root.u.def.section->output_section->vma + myh->root.u.def.section->output_offset @@ -8408,8 +8415,8 @@ bfd_elf32_arm_stm32l4xx_fix_veneer_locations (bfd *abfd, (&(globals)->root, tmp_name, FALSE, FALSE, TRUE); if (myh == NULL) - _bfd_error_handler (_("%B: unable to find STM32L4XX veneer " - "`%s'"), abfd, tmp_name); + _bfd_error_handler (_("%pB: unable to find %s veneer `%s'"), + abfd, "STM32L4XX", tmp_name); vma = myh->root.u.def.section->output_section->vma + myh->root.u.def.section->output_offset @@ -8615,11 +8622,11 @@ bfd_elf32_arm_stm32l4xx_erratum_scan (bfd *abfd, { _bfd_error_handler /* xgettext:c-format */ - (_("%B(%A+%#x): error: multiple load detected" - " in non-last IT block instruction :" - " STM32L4XX veneer cannot be generated.\n" - "Use gcc option -mrestrict-it to generate" - " only one instruction per IT block.\n"), + (_("%pB(%pA+%#x): error: multiple load detected" + " in non-last IT block instruction:" + " STM32L4XX veneer cannot be generated; " + "use gcc option -mrestrict-it to generate" + " only one instruction per IT block"), abfd, sec, i); } else @@ -8713,7 +8720,7 @@ bfd_elf32_arm_set_target_params (struct bfd *output_bfd, globals->target2_reloc = R_ARM_GOT_PREL; else { - _bfd_error_handler (_("Invalid TARGET2 relocation type '%s'."), + _bfd_error_handler (_("invalid TARGET2 relocation type '%s'"), params->target2_type); } globals->fix_v4bx = params->fix_v4bx; @@ -8803,9 +8810,9 @@ elf32_thumb_to_arm_stub (struct bfd_link_info * info, && !INTERWORK_FLAG (sym_sec->owner)) { _bfd_error_handler - (_("%B(%s): warning: interworking not enabled.\n" - " first occurrence: %B: Thumb call to ARM"), - sym_sec->owner, name, input_bfd); + (_("%pB(%s): warning: interworking not enabled;" + " first occurrence: %pB: %s call to %s"), + sym_sec->owner, name, input_bfd, "Thumb", "ARM"); return FALSE; } @@ -8893,9 +8900,9 @@ elf32_arm_create_thumb_stub (struct bfd_link_info * info, && !INTERWORK_FLAG (sym_sec->owner)) { _bfd_error_handler - (_("%B(%s): warning: interworking not enabled.\n" - " first occurrence: %B: arm call to thumb"), - sym_sec->owner, name, input_bfd); + (_("%pB(%s): warning: interworking not enabled;" + " first occurrence: %pB: %s call to %s"), + sym_sec->owner, name, input_bfd, "ARM", "Thumb"); } --my_offset; @@ -9455,7 +9462,7 @@ elf32_arm_populate_plt_entry (bfd *output_bfd, struct bfd_link_info *info, { /* FIXME: We ought to be able to generate thumb-1 PLT instructions... */ - _bfd_error_handler (_("%B: Warning: thumb-1 mode PLT generation not currently supported"), + _bfd_error_handler (_("%pB: warning: thumb-1 mode PLT generation not currently supported"), output_bfd); return FALSE; } @@ -9720,8 +9727,10 @@ elf32_arm_tls_relax (struct elf32_arm_link_hash_table *globals, | bfd_get_16 (input_bfd, contents + rel->r_offset + 2); _bfd_error_handler /* xgettext:c-format */ - (_("%B(%A+%#Lx): unexpected Thumb instruction '%#lx' in TLS trampoline"), - input_bfd, input_sec, rel->r_offset, insn); + (_("%pB(%pA+%#" PRIx64 "): " + "unexpected %s instruction '%#lx' in TLS trampoline"), + input_bfd, input_sec, (uint64_t) rel->r_offset, + "Thumb", insn); return bfd_reloc_notsupported; } break; @@ -9760,8 +9769,10 @@ elf32_arm_tls_relax (struct elf32_arm_link_hash_table *globals, { _bfd_error_handler /* xgettext:c-format */ - (_("%B(%A+%#Lx): unexpected ARM instruction '%#lx' in TLS trampoline"), - input_bfd, input_sec, rel->r_offset, insn); + (_("%pB(%pA+%#" PRIx64 "): " + "unexpected %s instruction '%#lx' in TLS trampoline"), + input_bfd, input_sec, (uint64_t) rel->r_offset, + "ARM", insn); return bfd_reloc_notsupported; } break; @@ -10106,7 +10117,7 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, v = _("PIE executable"); _bfd_error_handler - (_("%B: relocation %s against external or undefined symbol `%s'" + (_("%pB: relocation %s against external or undefined symbol `%s'" " can not be used when making a %s; recompile with -fPIC"), input_bfd, elf32_arm_howto_table_1[r_type].name, h->root.root.string, v); return bfd_reloc_notsupported; @@ -10237,9 +10248,10 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, instruction instead ? */ if (branch_type != ST_BRANCH_TO_THUMB) _bfd_error_handler - (_("\%B: Warning: Arm BLX instruction targets Arm function '%s'."), - input_bfd, - h ? h->root.root.string : "(local)"); + (_("\%pB: warning: %s BLX instruction targets" + " %s function '%s'"), + input_bfd, "ARM", + "ARM", h ? h->root.root.string : "(local)"); } else if (r_type == R_ARM_PC24) { @@ -10663,9 +10675,10 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, instruction instead ? */ if (branch_type == ST_BRANCH_TO_THUMB) _bfd_error_handler - (_("%B: Warning: Thumb BLX instruction targets thumb function '%s'."), - input_bfd, - h ? h->root.root.string : "(local)"); + (_("%pB: warning: %s BLX instruction targets" + " %s function '%s'"), + input_bfd, "Thumb", + "Thumb", h ? h->root.root.string : "(local)"); } else { @@ -11531,8 +11544,11 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, { _bfd_error_handler /* xgettext:c-format */ - (_("%B(%A+%#Lx): unexpected Thumb instruction '%#lx' referenced by TLS_GOTDESC"), - input_bfd, input_section, rel->r_offset, insn); + (_("%pB(%pA+%#" PRIx64 "): " + "unexpected %s instruction '%#lx' " + "referenced by TLS_GOTDESC"), + input_bfd, input_section, (uint64_t) rel->r_offset, + "Thumb", insn); return bfd_reloc_notsupported; } } @@ -11554,8 +11570,11 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, default: _bfd_error_handler /* xgettext:c-format */ - (_("%B(%A+%#Lx): unexpected ARM instruction '%#lx' referenced by TLS_GOTDESC"), - input_bfd, input_section, rel->r_offset, insn); + (_("%pB(%pA+%#" PRIx64 "): " + "unexpected %s instruction '%#lx' " + "referenced by TLS_GOTDESC"), + input_bfd, input_section, (uint64_t) rel->r_offset, + "ARM", insn); return bfd_reloc_notsupported; } } @@ -11583,8 +11602,9 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, { _bfd_error_handler /* xgettext:c-format */ - (_("%B(%A+%#Lx): %s relocation not permitted in shared object"), - input_bfd, input_section, rel->r_offset, howto->name); + (_("%pB(%pA+%#" PRIx64 "): %s relocation not permitted " + "in shared object"), + input_bfd, input_section, (uint64_t) rel->r_offset, howto->name); return bfd_reloc_notsupported; } else @@ -11796,8 +11816,9 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, { _bfd_error_handler /* xgettext:c-format */ - (_("%B(%A+%#Lx): Only ADD or SUB instructions are allowed for ALU group relocations"), - input_bfd, input_section, rel->r_offset); + (_("%pB(%pA+%#" PRIx64 "): only ADD or SUB instructions " + "are allowed for ALU group relocations"), + input_bfd, input_section, (uint64_t) rel->r_offset); return bfd_reloc_overflow; } @@ -11836,9 +11857,11 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, { _bfd_error_handler /* xgettext:c-format */ - (_("%B(%A+%#Lx): Overflow whilst splitting %#Lx for group relocation %s"), - input_bfd, input_section, rel->r_offset, - signed_value < 0 ? -signed_value : signed_value, howto->name); + (_("%pB(%pA+%#" PRIx64 "): overflow whilst " + "splitting %#" PRIx64 " for group relocation %s"), + input_bfd, input_section, (uint64_t) rel->r_offset, + (uint64_t) (signed_value < 0 ? -signed_value : signed_value), + howto->name); return bfd_reloc_overflow; } @@ -11926,9 +11949,11 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, { _bfd_error_handler /* xgettext:c-format */ - (_("%B(%A+%#Lx): Overflow whilst splitting %#Lx for group relocation %s"), - input_bfd, input_section, rel->r_offset, - signed_value < 0 ? -signed_value : signed_value, howto->name); + (_("%pB(%pA+%#" PRIx64 "): overflow whilst " + "splitting %#" PRIx64 " for group relocation %s"), + input_bfd, input_section, (uint64_t) rel->r_offset, + (uint64_t) (signed_value < 0 ? -signed_value : signed_value), + howto->name); return bfd_reloc_overflow; } @@ -12012,9 +12037,11 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, { _bfd_error_handler /* xgettext:c-format */ - (_("%B(%A+%#Lx): Overflow whilst splitting %#Lx for group relocation %s"), - input_bfd, input_section, rel->r_offset, - signed_value < 0 ? -signed_value : signed_value, howto->name); + (_("%pB(%pA+%#" PRIx64 "): overflow whilst " + "splitting %#" PRIx64 " for group relocation %s"), + input_bfd, input_section, (uint64_t) rel->r_offset, + (uint64_t) (signed_value < 0 ? -signed_value : signed_value), + howto->name); return bfd_reloc_overflow; } @@ -12100,9 +12127,11 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, { _bfd_error_handler /* xgettext:c-format */ - (_("%B(%A+%#Lx): Overflow whilst splitting %#Lx for group relocation %s"), - input_bfd, input_section, rel->r_offset, - signed_value < 0 ? -signed_value : signed_value, howto->name); + (_("%pB(%pA+%#" PRIx64 "): overflow whilst " + "splitting %#" PRIx64 " for group relocation %s"), + input_bfd, input_section, (uint64_t) rel->r_offset, + (uint64_t) (signed_value < 0 ? -signed_value : signed_value), + howto->name); return bfd_reloc_overflow; } @@ -12366,9 +12395,10 @@ elf32_arm_relocate_section (bfd * output_bfd, { _bfd_error_handler /* xgettext:c-format */ - (_("%B(%A+%#Lx): %s relocation against SEC_MERGE section"), + (_("%pB(%pA+%#" PRIx64 "): " + "%s relocation against SEC_MERGE section"), input_bfd, input_section, - rel->r_offset, howto->name); + (uint64_t) rel->r_offset, howto->name); return FALSE; } @@ -12478,12 +12508,12 @@ elf32_arm_relocate_section (bfd * output_bfd, _bfd_error_handler ((sym_type == STT_TLS /* xgettext:c-format */ - ? _("%B(%A+%#Lx): %s used with TLS symbol %s") + ? _("%pB(%pA+%#" PRIx64 "): %s used with TLS symbol %s") /* xgettext:c-format */ - : _("%B(%A+%#Lx): %s used with non-TLS symbol %s")), + : _("%pB(%pA+%#" PRIx64 "): %s used with non-TLS symbol %s")), input_bfd, input_section, - rel->r_offset, + (uint64_t) rel->r_offset, howto->name, name); } @@ -12533,10 +12563,11 @@ elf32_arm_relocate_section (bfd * output_bfd, { _bfd_error_handler /* xgettext:c-format */ - (_("%B(%A+%#Lx): unresolvable %s relocation against symbol `%s'"), + (_("%pB(%pA+%#" PRIx64 "): " + "unresolvable %s relocation against symbol `%s'"), input_bfd, input_section, - rel->r_offset, + (uint64_t) rel->r_offset, howto->name, h->root.root.string); return FALSE; @@ -13018,11 +13049,11 @@ elf32_arm_set_private_flags (bfd *abfd, flagword flags) { if (flags & EF_ARM_INTERWORK) _bfd_error_handler - (_("Warning: Not setting interworking flag of %B since it has already been specified as non-interworking"), + (_("warning: not setting interworking flag of %pB since it has already been specified as non-interworking"), abfd); else _bfd_error_handler - (_("Warning: Clearing the interworking flag of %B due to outside request"), + (_("warning: clearing the interworking flag of %pB due to outside request"), abfd); } } @@ -13067,7 +13098,7 @@ elf32_arm_copy_private_bfd_data (bfd *ibfd, bfd *obfd) { if (out_flags & EF_ARM_INTERWORK) _bfd_error_handler - (_("Warning: Clearing the interworking flag of %B because non-interworking code in %B has been linked with it"), + (_("warning: clearing the interworking flag of %pB because non-interworking code in %pB has been linked with it"), obfd, ibfd); in_flags &= ~EF_ARM_INTERWORK; @@ -13154,7 +13185,7 @@ elf32_arm_obj_attrs_handle_unknown (bfd *abfd, int tag) if ((tag & 127) < 64) { _bfd_error_handler - (_("%B: Unknown mandatory EABI object attribute %d"), + (_("%pB: unknown mandatory EABI object attribute %d"), abfd, tag); bfd_set_error (bfd_error_bad_value); return FALSE; @@ -13162,7 +13193,7 @@ elf32_arm_obj_attrs_handle_unknown (bfd *abfd, int tag) else { _bfd_error_handler - (_("Warning: %B: Unknown EABI object attribute %d"), + (_("warning: %pB: unknown EABI object attribute %d"), abfd, tag); return TRUE; } @@ -13429,7 +13460,7 @@ tag_cpu_arch_combine (bfd *ibfd, int oldtag, int *secondary_compat_out, if (oldtag > MAX_TAG_CPU_ARCH || newtag > MAX_TAG_CPU_ARCH) { - _bfd_error_handler (_("error: %B: Unknown CPU architecture"), ibfd); + _bfd_error_handler (_("error: %pB: unknown CPU architecture"), ibfd); return -1; } @@ -13467,7 +13498,7 @@ tag_cpu_arch_combine (bfd *ibfd, int oldtag, int *secondary_compat_out, if (result == -1) { - _bfd_error_handler (_("error: %B: Conflicting CPU architectures %d/%d"), + _bfd_error_handler (_("error: %pB: conflicting CPU architectures %d/%d"), ibfd, oldtag, newtag); return -1; } @@ -13564,7 +13595,7 @@ elf32_arm_merge_eabi_attributes (bfd *ibfd, struct bfd_link_info *info) != out_attr[Tag_MPextension_use].i) { _bfd_error_handler - (_("Error: %B has both the current and legacy " + (_("Error: %pB has both the current and legacy " "Tag_MPextension_use attributes"), ibfd); result = FALSE; } @@ -13593,7 +13624,7 @@ elf32_arm_merge_eabi_attributes (bfd *ibfd, struct bfd_link_info *info) && in_attr[Tag_ABI_VFP_args].i != AEABI_VFP_args_compatible) { _bfd_error_handler - (_("error: %B uses VFP register arguments, %B does not"), + (_("error: %pB uses VFP register arguments, %pB does not"), in_attr[Tag_ABI_VFP_args].i ? ibfd : obfd, in_attr[Tag_ABI_VFP_args].i ? obfd : ibfd); result = FALSE; @@ -13722,7 +13753,7 @@ elf32_arm_merge_eabi_attributes (bfd *ibfd, struct bfd_link_info *info) binaries in the toolchain have had the attributes set properly. _bfd_error_handler - (_("error: %B: 8-byte data alignment conflicts with %B"), + (_("error: %pB: 8-byte data alignment conflicts with %pB"), obfd, ibfd); result = FALSE; */ } @@ -13751,8 +13782,8 @@ elf32_arm_merge_eabi_attributes (bfd *ibfd, struct bfd_link_info *info) else { _bfd_error_handler - (_("error: %B: unable to merge virtualization attributes " - "with %B"), + (_("error: %pB: unable to merge virtualization attributes " + "with %pB"), obfd, ibfd); result = FALSE; } @@ -13777,7 +13808,7 @@ elf32_arm_merge_eabi_attributes (bfd *ibfd, struct bfd_link_info *info) else { _bfd_error_handler - (_("error: %B: Conflicting architecture profiles %c/%c"), + (_("error: %pB: conflicting architecture profiles %c/%c"), ibfd, in_attr[i].i ? in_attr[i].i : '0', out_attr[i].i ? out_attr[i].i : '0'); @@ -13916,7 +13947,7 @@ elf32_arm_merge_eabi_attributes (bfd *ibfd, struct bfd_link_info *info) /* It's sometimes ok to mix different configs, so this is only a warning. */ _bfd_error_handler - (_("Warning: %B: Conflicting platform configuration"), ibfd); + (_("warning: %pB: conflicting platform configuration"), ibfd); } break; case Tag_ABI_PCS_R9_use: @@ -13925,7 +13956,7 @@ elf32_arm_merge_eabi_attributes (bfd *ibfd, struct bfd_link_info *info) && in_attr[i].i != AEABI_R9_unused) { _bfd_error_handler - (_("error: %B: Conflicting use of R9"), ibfd); + (_("error: %pB: conflicting use of R9"), ibfd); result = FALSE; } if (out_attr[i].i == AEABI_R9_unused) @@ -13937,7 +13968,7 @@ elf32_arm_merge_eabi_attributes (bfd *ibfd, struct bfd_link_info *info) && out_attr[Tag_ABI_PCS_R9_use].i != AEABI_R9_unused) { _bfd_error_handler - (_("error: %B: SB relative addressing conflicts with use of R9"), + (_("error: %pB: SB relative addressing conflicts with use of R9"), ibfd); result = FALSE; } @@ -13950,7 +13981,7 @@ elf32_arm_merge_eabi_attributes (bfd *ibfd, struct bfd_link_info *info) && !elf_arm_tdata (obfd)->no_wchar_size_warning) { _bfd_error_handler - (_("warning: %B uses %u-byte wchar_t yet the output is to use %u-byte wchar_t; use of wchar_t values across objects may fail"), + (_("warning: %pB uses %u-byte wchar_t yet the output is to use %u-byte wchar_t; use of wchar_t values across objects may fail"), ibfd, in_attr[i].i, out_attr[i].i); } else if (in_attr[i].i && !out_attr[i].i) @@ -13981,7 +14012,7 @@ elf32_arm_merge_eabi_attributes (bfd *ibfd, struct bfd_link_info *info) ? aeabi_enum_names[out_attr[i].i] : ""; _bfd_error_handler - (_("warning: %B uses %s enums yet the output is to use %s enums; use of enum values across objects may fail"), + (_("warning: %pB uses %s enums yet the output is to use %s enums; use of enum values across objects may fail"), ibfd, in_name, out_name); } } @@ -13993,7 +14024,7 @@ elf32_arm_merge_eabi_attributes (bfd *ibfd, struct bfd_link_info *info) if (in_attr[i].i != out_attr[i].i) { _bfd_error_handler - (_("error: %B uses iWMMXt register arguments, %B does not"), + (_("error: %pB uses iWMMXt register arguments, %pB does not"), ibfd, obfd); result = FALSE; } @@ -14010,7 +14041,7 @@ elf32_arm_merge_eabi_attributes (bfd *ibfd, struct bfd_link_info *info) if (in_attr[i].i != out_attr[i].i) { _bfd_error_handler - (_("error: fp16 format mismatch between %B and %B"), + (_("error: fp16 format mismatch between %pB and %pB"), ibfd, obfd); result = FALSE; } @@ -14046,7 +14077,7 @@ elf32_arm_merge_eabi_attributes (bfd *ibfd, struct bfd_link_info *info) if (in_attr[Tag_MPextension_use].i != in_attr[i].i) { _bfd_error_handler - (_("%B has both the current and legacy " + (_("%pB has both the current and legacy " "Tag_MPextension_use attributes"), ibfd); result = FALSE; @@ -14365,7 +14396,7 @@ elf32_arm_check_relocs (bfd *abfd, struct bfd_link_info *info, object file containing relocations but no symbol table. */ && (r_symndx > STN_UNDEF || nsyms > 0)) { - _bfd_error_handler (_("%B: bad symbol index: %d"), abfd, + _bfd_error_handler (_("%pB: bad symbol index: %d"), abfd, r_symndx); return FALSE; } @@ -14518,7 +14549,7 @@ elf32_arm_check_relocs (bfd *abfd, struct bfd_link_info *info, if (bfd_link_pic (info)) { _bfd_error_handler - (_("%B: relocation %s against `%s' can not be used when making a shared object; recompile with -fPIC"), + (_("%pB: relocation %s against `%s' can not be used when making a shared object; recompile with -fPIC"), abfd, elf32_arm_howto_table_1[r_type].name, (h) ? h->root.root.string : "a local symbol"); bfd_set_error (bfd_error_bad_value); @@ -15633,7 +15664,7 @@ maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) info->flags |= DF_TEXTREL; info->callbacks->minfo - (_("%B: dynamic relocation against `%T' in read-only section `%A'\n"), + (_("%pB: dynamic relocation against `%pT' in read-only section `%pA'\n"), sec->owner, h->root.root.string, sec); /* Not an error, just cut short the traversal. */ @@ -15878,7 +15909,7 @@ elf32_arm_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED, if (!bfd_elf32_arm_process_before_allocation (ibfd, info) || !bfd_elf32_arm_vfp11_erratum_scan (ibfd, info) || !bfd_elf32_arm_stm32l4xx_erratum_scan (ibfd, info)) - _bfd_error_handler (_("Errors encountered processing file %B"), ibfd); + _bfd_error_handler (_("errors encountered processing file %pB"), ibfd); } /* Allocate space for the glue sections now that we've sized them. */ @@ -17491,7 +17522,7 @@ make_branch_to_a8_stub (struct bfd_hash_entry *gen_entry, This check is just to be on the safe side... */ if ((veneered_insn_loc & ~0xfff) == (veneer_entry_loc & ~0xfff)) { - _bfd_error_handler (_("%B: error: Cortex-A8 erratum stub is " + _bfd_error_handler (_("%pB: error: Cortex-A8 erratum stub is " "allocated in unsafe location"), abfd); return FALSE; } @@ -17518,7 +17549,7 @@ make_branch_to_a8_stub (struct bfd_hash_entry *gen_entry, { /* There's not much we can do apart from complain if this happens. */ - _bfd_error_handler (_("%B: error: Cortex-A8 erratum stub out " + _bfd_error_handler (_("%pB: error: Cortex-A8 erratum stub out " "of range (input file too large)"), abfd); return FALSE; } @@ -18345,7 +18376,7 @@ elf32_arm_write_section (bfd *output_bfd, if ((signed) branch_to_veneer < -(1 << 25) || (signed) branch_to_veneer >= (1 << 25)) - _bfd_error_handler (_("%B: error: VFP11 veneer out of " + _bfd_error_handler (_("%pB: error: VFP11 veneer out of " "range"), output_bfd); insn |= (branch_to_veneer >> 2) & 0xffffff; @@ -18367,7 +18398,7 @@ elf32_arm_write_section (bfd *output_bfd, if ((signed) branch_from_veneer < -(1 << 25) || (signed) branch_from_veneer >= (1 << 25)) - _bfd_error_handler (_("%B: error: VFP11 veneer out of " + _bfd_error_handler (_("%pB: error: VFP11 veneer out of " "range"), output_bfd); /* Original instruction. */ @@ -18418,12 +18449,13 @@ elf32_arm_write_section (bfd *output_bfd, branch_to_veneer - (1 << 24) : 0; _bfd_error_handler - (_("%B(%#Lx): error: Cannot create STM32L4XX veneer. " - "Jump out of range by %Ld bytes. " - "Cannot encode branch instruction. "), + (_("%pB(%#" PRIx64 "): error: " + "cannot create STM32L4XX veneer; " + "jump out of range by %" PRId64 " bytes; " + "cannot encode branch instruction"), output_bfd, - stm32l4xx_errnode->vma - 4, - out_of_range); + (uint64_t) (stm32l4xx_errnode->vma - 4), + (int64_t) out_of_range); continue; } @@ -18456,8 +18488,8 @@ elf32_arm_write_section (bfd *output_bfd, STM32L4XX_ERRATUM_LDM_VENEER_SIZE) < -(1 << 24) || (signed) (veneer_r - veneer) >= (1 << 24)) { - _bfd_error_handler (_("%B: error: Cannot create STM32L4XX " - "veneer."), output_bfd); + _bfd_error_handler (_("%pB: error: cannot create STM32L4XX " + "veneer"), output_bfd); continue; } @@ -19478,7 +19510,7 @@ elf32_arm_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) && !(ibfd->flags & DYNAMIC) && (in_flags & EF_ARM_BE8)) { - _bfd_error_handler (_("error: %B is already in final BE8 format"), + _bfd_error_handler (_("error: %pB is already in final BE8 format"), ibfd); return FALSE; } @@ -19554,7 +19586,7 @@ elf32_arm_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) EF_ARM_EABI_VERSION (out_flags))) { _bfd_error_handler - (_("error: Source object %B has EABI version %d, but target %B has EABI version %d"), + (_("error: source object %pB has EABI version %d, but target %pB has EABI version %d"), ibfd, (in_flags & EF_ARM_EABIMASK) >> 24, obfd, (out_flags & EF_ARM_EABIMASK) >> 24); return FALSE; @@ -19569,7 +19601,7 @@ elf32_arm_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) if ((in_flags & EF_ARM_APCS_26) != (out_flags & EF_ARM_APCS_26)) { _bfd_error_handler - (_("error: %B is compiled for APCS-%d, whereas target %B uses APCS-%d"), + (_("error: %pB is compiled for APCS-%d, whereas target %pB uses APCS-%d"), ibfd, in_flags & EF_ARM_APCS_26 ? 26 : 32, obfd, out_flags & EF_ARM_APCS_26 ? 26 : 32); flags_compatible = FALSE; @@ -19579,11 +19611,11 @@ elf32_arm_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) { if (in_flags & EF_ARM_APCS_FLOAT) _bfd_error_handler - (_("error: %B passes floats in float registers, whereas %B passes them in integer registers"), + (_("error: %pB passes floats in float registers, whereas %pB passes them in integer registers"), ibfd, obfd); else _bfd_error_handler - (_("error: %B passes floats in integer registers, whereas %B passes them in float registers"), + (_("error: %pB passes floats in integer registers, whereas %pB passes them in float registers"), ibfd, obfd); flags_compatible = FALSE; @@ -19593,12 +19625,12 @@ elf32_arm_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) { if (in_flags & EF_ARM_VFP_FLOAT) _bfd_error_handler - (_("error: %B uses VFP instructions, whereas %B does not"), - ibfd, obfd); + (_("error: %pB uses %s instructions, whereas %pB does not"), + ibfd, "VFP", obfd); else _bfd_error_handler - (_("error: %B uses FPA instructions, whereas %B does not"), - ibfd, obfd); + (_("error: %pB uses %s instructions, whereas %pB does not"), + ibfd, "FPA", obfd); flags_compatible = FALSE; } @@ -19607,12 +19639,12 @@ elf32_arm_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) { if (in_flags & EF_ARM_MAVERICK_FLOAT) _bfd_error_handler - (_("error: %B uses Maverick instructions, whereas %B does not"), - ibfd, obfd); + (_("error: %pB uses %s instructions, whereas %pB does not"), + ibfd, "Maverick", obfd); else _bfd_error_handler - (_("error: %B does not use Maverick instructions, whereas %B does"), - ibfd, obfd); + (_("error: %pB does not use %s instructions, whereas %pB does"), + ibfd, "Maverick", obfd); flags_compatible = FALSE; } @@ -19630,11 +19662,11 @@ elf32_arm_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) { if (in_flags & EF_ARM_SOFT_FLOAT) _bfd_error_handler - (_("error: %B uses software FP, whereas %B uses hardware FP"), + (_("error: %pB uses software FP, whereas %pB uses hardware FP"), ibfd, obfd); else _bfd_error_handler - (_("error: %B uses hardware FP, whereas %B uses software FP"), + (_("error: %pB uses hardware FP, whereas %pB uses software FP"), ibfd, obfd); flags_compatible = FALSE; @@ -19648,13 +19680,13 @@ elf32_arm_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) if (in_flags & EF_ARM_INTERWORK) { _bfd_error_handler - (_("Warning: %B supports interworking, whereas %B does not"), + (_("warning: %pB supports interworking, whereas %pB does not"), ibfd, obfd); } else { _bfd_error_handler - (_("Warning: %B does not support interworking, whereas %B does"), + (_("warning: %pB does not support interworking, whereas %pB does"), ibfd, obfd); } } diff --git a/bfd/elf32-avr.c b/bfd/elf32-avr.c index 46e15ec..7087606 100644 --- a/bfd/elf32-avr.c +++ b/bfd/elf32-avr.c @@ -945,8 +945,8 @@ bfd_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, /* Set the howto pointer for an AVR ELF reloc. */ -static void -avr_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED, +static bfd_boolean +avr_info_to_howto_rela (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst) { @@ -956,10 +956,13 @@ avr_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED, if (r_type >= (unsigned int) R_AVR_max) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: invalid AVR reloc number: %d"), abfd, r_type); - r_type = 0; + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; } cache_ptr->howto = &elf_avr_howto_table[r_type]; + return TRUE; } static bfd_boolean diff --git a/bfd/elf32-bfin.c b/bfd/elf32-bfin.c index 478b8d4..ae83771 100644 --- a/bfd/elf32-bfin.c +++ b/bfd/elf32-bfin.c @@ -1040,8 +1040,8 @@ static const struct bfin_reloc_map bfin_reloc_map [] = }; -static void -bfin_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, +static bfd_boolean +bfin_info_to_howto (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst) { @@ -1056,7 +1056,15 @@ bfin_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, cache_ptr->howto = &bfin_gnuext_howto_table [r_type - BFIN_GNUEXT_RELOC_MIN]; else - cache_ptr->howto = (reloc_howto_type *) NULL; + { + /* xgettext:c-format */ + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; + } + + return TRUE; } /* Given a BFD reloc type, return the howto. */ @@ -1574,9 +1582,10 @@ bfin_relocate_section (bfd * output_bfd, { _bfd_error_handler /* xgettext:c-format */ - (_("%B(%A+%#Lx): unresolvable relocation against symbol `%s'"), - input_bfd, - input_section, rel->r_offset, h->root.root.string); + (_("%pB(%pA+%#" PRIx64 "): " + "unresolvable relocation against symbol `%s'"), + input_bfd, input_section, (uint64_t) rel->r_offset, + h->root.root.string); return FALSE; } @@ -1605,8 +1614,9 @@ bfin_relocate_section (bfd * output_bfd, { _bfd_error_handler /* xgettext:c-format */ - (_("%B(%A+%#Lx): reloc against `%s': error %d"), - input_bfd, input_section, rel->r_offset, name, (int) r); + (_("%pB(%pA+%#" PRIx64 "): reloc against `%s': error %d"), + input_bfd, input_section, (uint64_t) rel->r_offset, + name, (int) r); return FALSE; } } @@ -2625,8 +2635,9 @@ bfinfdpic_relocate_section (bfd * output_bfd, { _bfd_error_handler /* xgettext:c-format */ - (_("%B: relocation at `%A+%#Lx' references symbol `%s' with nonzero addend"), - input_bfd, input_section, rel->r_offset, name); + (_("%pB: relocation at `%pA+%#" PRIx64 "' " + "references symbol `%s' with nonzero addend"), + input_bfd, input_section, (uint64_t) rel->r_offset, name); return FALSE; } @@ -4684,7 +4695,7 @@ bfinfdpic_check_relocs (bfd *abfd, struct bfd_link_info *info, bad_reloc: _bfd_error_handler /* xgettext:c-format */ - (_("%B: unsupported relocation type %d"), + (_("%pB: unsupported relocation type %#x"), abfd, (int) ELF32_R_TYPE (rel->r_info)); return FALSE; } @@ -4759,7 +4770,7 @@ elf32_bfin_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) if (0) #endif _bfd_error_handler - ("old_flags = 0x%.8x, new_flags = 0x%.8x, init = %s, filename = %B", + ("old_flags = 0x%.8x, new_flags = 0x%.8x, init = %s, filename = %pB", old_flags, new_flags, elf_flags_init (obfd) ? "yes" : "no", ibfd); if (!elf_flags_init (obfd)) /* First call, no flags set. */ @@ -4773,11 +4784,11 @@ elf32_bfin_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) error = TRUE; if (IS_FDPIC (obfd)) _bfd_error_handler - (_("%B: cannot link non-fdpic object file into fdpic executable"), + (_("%pB: cannot link non-fdpic object file into fdpic executable"), ibfd); else _bfd_error_handler - (_("%B: cannot link fdpic object file into non-fdpic executable"), + (_("%pB: cannot link fdpic object file into non-fdpic executable"), ibfd); } @@ -5337,7 +5348,7 @@ bfd_bfin_elf32_create_embedded_relocs (bfd *abfd, /* We can only relocate absolute longword relocs at run time. */ if (ELF32_R_TYPE (irel->r_info) != (int) R_BFIN_BYTE4_DATA) { - *errmsg = _("unsupported reloc type"); + *errmsg = _("unsupported relocation type"); bfd_set_error (bfd_error_bad_value); goto error_return; } @@ -5421,7 +5432,7 @@ struct bfd_elf_special_section const elf32_bfin_special_sections[] = #define bfd_elf32_bfd_reloc_name_lookup \ bfin_bfd_reloc_name_lookup #define elf_info_to_howto bfin_info_to_howto -#define elf_info_to_howto_rel 0 +#define elf_info_to_howto_rel NULL #define elf_backend_object_p elf32_bfin_object_p #define bfd_elf32_bfd_is_local_label_name \ diff --git a/bfd/elf32-cr16.c b/bfd/elf32-cr16.c index 7bb67a7..7756ef5 100644 --- a/bfd/elf32-cr16.c +++ b/bfd/elf32-cr16.c @@ -641,7 +641,7 @@ _bfd_cr16_elf_create_got_section (bfd * abfd, struct bfd_link_info * info) /* Retrieve a howto ptr using a BFD reloc_code. */ static reloc_howto_type * -elf_cr16_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED, +elf_cr16_reloc_type_lookup (bfd *abfd, bfd_reloc_code_real_type code) { unsigned int i; @@ -650,7 +650,8 @@ elf_cr16_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED, if (code == cr16_reloc_map[i].bfd_reloc_enum) return &cr16_elf_howto_table[cr16_reloc_map[i].cr16_reloc_type]; - _bfd_error_handler (_("Unsupported CR16 relocation type: 0x%x\n"), code); + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, code); return NULL; } @@ -670,8 +671,8 @@ elf_cr16_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, /* Retrieve a howto ptr using an internal relocation entry. */ -static void -elf_cr16_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, arelent *cache_ptr, +static bfd_boolean +elf_cr16_info_to_howto (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst) { unsigned int r_type = ELF32_R_TYPE (dst->r_info); @@ -679,12 +680,13 @@ elf_cr16_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, arelent *cache_ptr, if (r_type >= R_CR16_MAX) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: unrecognised CR16 reloc number: %d"), + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), abfd, r_type); bfd_set_error (bfd_error_bad_value); - r_type = R_CR16_NONE; + return FALSE; } cache_ptr->howto = cr16_elf_howto_table + r_type; + return TRUE; } /* Look through the relocs for a section during the first phase. @@ -2798,7 +2800,7 @@ bfd_cr16_elf32_create_embedded_relocs (bfd *abfd, if (!((ELF32_R_TYPE (irel->r_info) == (int) R_CR16_NUM32a) || (ELF32_R_TYPE (irel->r_info) == (int) R_CR16_NUM32))) { - *errmsg = _("unsupported reloc type"); + *errmsg = _("unsupported relocation type"); bfd_set_error (bfd_error_bad_value); goto error_return; } @@ -2894,7 +2896,7 @@ _bfd_cr16_elf_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSE #define bfd_elf32_bfd_reloc_type_lookup elf_cr16_reloc_type_lookup #define bfd_elf32_bfd_reloc_name_lookup elf_cr16_reloc_name_lookup #define elf_info_to_howto elf_cr16_info_to_howto -#define elf_info_to_howto_rel 0 +#define elf_info_to_howto_rel NULL #define elf_backend_relocate_section elf32_cr16_relocate_section #define bfd_elf32_bfd_relax_section elf32_cr16_relax_section #define bfd_elf32_bfd_get_relocated_section_contents \ @@ -2921,8 +2923,7 @@ _bfd_cr16_elf_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSE _bfd_cr16_elf_adjust_dynamic_symbol #define elf_backend_size_dynamic_sections \ _bfd_cr16_elf_size_dynamic_sections -#define elf_backend_omit_section_dynsym \ - ((bfd_boolean (*) (bfd *, struct bfd_link_info *, asection *)) bfd_true) +#define elf_backend_omit_section_dynsym _bfd_elf_omit_section_dynsym_all #define elf_backend_finish_dynamic_symbol \ _bfd_cr16_elf_finish_dynamic_symbol #define elf_backend_finish_dynamic_sections \ diff --git a/bfd/elf32-cr16c.c b/bfd/elf32-cr16c.c index ec2948d..40ec759 100644 --- a/bfd/elf32-cr16c.c +++ b/bfd/elf32-cr16c.c @@ -165,15 +165,15 @@ elf_cr16c_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, return NULL; } -static void +static bfd_boolean elf_cr16c_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, arelent *cache_ptr ATTRIBUTE_UNUSED, Elf_Internal_Rela *dst ATTRIBUTE_UNUSED) { - abort (); + return FALSE; } -static void +static bfd_boolean elf_cr16c_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED, arelent *cache_ptr, Elf_Internal_Rela *dst) @@ -183,10 +183,13 @@ elf_cr16c_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED, if (r_type >= RINDEX_16C_MAX) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: invalid CR16C reloc number: %d"), abfd, r_type); - r_type = 0; + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; } cache_ptr->howto = &elf_howto_table[r_type]; + return TRUE; } /* Perform a relocation as part of a final link. */ diff --git a/bfd/elf32-cris.c b/bfd/elf32-cris.c index 4cbe4c5..1c367c4 100644 --- a/bfd/elf32-cris.c +++ b/bfd/elf32-cris.c @@ -453,7 +453,7 @@ cris_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, const char *r_name) /* Set the howto pointer for an CRIS ELF reloc. */ -static void +static bfd_boolean cris_info_to_howto_rela (bfd * abfd ATTRIBUTE_UNUSED, arelent * cache_ptr, Elf_Internal_Rela * dst) @@ -464,10 +464,13 @@ cris_info_to_howto_rela (bfd * abfd ATTRIBUTE_UNUSED, if (r_type >= R_CRIS_max) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: invalid CRIS reloc number: %d"), abfd, r_type); - r_type = 0; + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; } cache_ptr->howto = & cris_elf_howto_table [r_type]; + return TRUE; } bfd_reloc_status_type @@ -1113,7 +1116,7 @@ cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, { _bfd_error_handler /* xgettext:c-format */ - (_("%B, section %A: unresolvable relocation %s against symbol `%s'"), + (_("%pB, section %pA: unresolvable relocation %s against symbol `%s'"), input_bfd, input_section, cris_elf_howto_table[r_type].name, @@ -1178,10 +1181,10 @@ cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, _bfd_error_handler ((h->got.offset == (bfd_vma) -1) /* xgettext:c-format */ - ? _("%B, section %A: No PLT nor GOT for relocation %s" + ? _("%pB, section %pA: no PLT nor GOT for relocation %s" " against symbol `%s'") /* xgettext:c-format */ - : _("%B, section %A: No PLT for relocation %s" + : _("%pB, section %pA: no PLT for relocation %s" " against symbol `%s'"), input_bfd, input_section, @@ -1305,21 +1308,21 @@ cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, if (h == NULL) _bfd_error_handler /* xgettext:c-format */ - (_("%B, section %A: relocation %s with non-zero addend %Ld" - " against local symbol"), + (_("%pB, section %pA: relocation %s with non-zero addend" + " %" PRId64 " against local symbol"), input_bfd, input_section, cris_elf_howto_table[r_type].name, - rel->r_addend); + (int64_t) rel->r_addend); else _bfd_error_handler /* xgettext:c-format */ - (_("%B, section %A: relocation %s with non-zero addend %Ld" - " against symbol `%s'"), + (_("%pB, section %pA: relocation %s with non-zero addend" + " %" PRId64 " against symbol `%s'"), input_bfd, input_section, cris_elf_howto_table[r_type].name, - rel->r_addend, + (int64_t) rel->r_addend, symname[0] != '\0' ? symname : _("[whose name is lost]")); bfd_set_error (bfd_error_bad_value); @@ -1341,7 +1344,7 @@ cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, { _bfd_error_handler /* xgettext:c-format */ - (_("%B, section %A: relocation %s is" + (_("%pB, section %pA: relocation %s is" " not allowed for global symbol: `%s'"), input_bfd, input_section, @@ -1358,7 +1361,7 @@ cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, { _bfd_error_handler /* xgettext:c-format */ - (_("%B, section %A: relocation %s with no GOT created"), + (_("%pB, section %pA: relocation %s with no GOT created"), input_bfd, input_section, cris_elf_howto_table[r_type].name); @@ -1575,10 +1578,10 @@ cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, ((h->root.type == bfd_link_hash_undefined) /* We shouldn't get here for GCC-emitted code. */ /* xgettext:c-format */ - ? _("%B, section %A: relocation %s has an undefined" + ? _("%pB, section %pA: relocation %s has an undefined" " reference to `%s', perhaps a declaration mixup?") /* xgettext:c-format */ - : _("%B, section %A: relocation %s is" + : _("%pB, section %pA: relocation %s is" " not allowed for `%s', a global symbol with default" " visibility, perhaps a declaration mixup?"), input_bfd, @@ -1662,12 +1665,12 @@ cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, to pass us these kinds of things. */ _bfd_error_handler /* xgettext:c-format */ - (_("%B, section %A: relocation %s with non-zero addend %Ld" - " against symbol `%s'"), + (_("%pB, section %pA: relocation %s with non-zero addend" + " %" PRId64 " against symbol `%s'"), input_bfd, input_section, cris_elf_howto_table[r_type].name, - rel->r_addend, + (int64_t) rel->r_addend, symname[0] != '\0' ? symname : _("[whose name is lost]")); bfd_set_error (bfd_error_bad_value); @@ -1815,12 +1818,12 @@ cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, things. */ _bfd_error_handler /* xgettext:c-format */ - (_("%B, section %A: relocation %s with non-zero addend %Ld" - " against symbol `%s'"), + (_("%pB, section %pA: relocation %s with non-zero addend" + " %" PRId64 " against symbol `%s'"), input_bfd, input_section, cris_elf_howto_table[r_type].name, - rel->r_addend, + (int64_t) rel->r_addend, symname[0] != '\0' ? symname : _("[whose name is lost]")); bfd_set_error (bfd_error_bad_value); return FALSE; @@ -1949,7 +1952,7 @@ cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, { _bfd_error_handler /* xgettext:c-format */ - (_("%B, section %A: relocation %s is" + (_("%pB, section %pA: relocation %s is" " not allowed for symbol: `%s'" " which is defined outside the program," " perhaps a declaration mixup?"), @@ -3044,7 +3047,7 @@ cris_elf_check_relocs (bfd *abfd, { _bfd_error_handler /* xgettext:c-format */ - (_("%B, section %A:\n v10/v32 compatible object" + (_("%pB, section %pA: v10/v32 compatible object" " must not contain a PIC relocation"), abfd, sec); return FALSE; @@ -3098,7 +3101,7 @@ cris_elf_check_relocs (bfd *abfd, { _bfd_error_handler /* xgettext:c-format */ - (_("%B, section %A:\n relocation %s not valid" + (_("%pB, section %pA:\n relocation %s not valid" " in a shared object;" " typically an option mixup, recompile with -fPIC"), abfd, @@ -3316,7 +3319,7 @@ cris_elf_check_relocs (bfd *abfd, /* FIXME: How do we make this optionally a warning only? */ _bfd_error_handler /* xgettext:c-format */ - (_("%B, section %A:\n relocation %s should not" + (_("%pB, section %pA: relocation %s should not" " be used in a shared object; recompile with -fPIC"), abfd, sec, @@ -3741,8 +3744,8 @@ elf_cris_discard_excess_dso_dynamics (struct elf_cris_link_hash_entry *h, /* FIXME: How do we make this optionally a warning only? */ _bfd_error_handler /* xgettext:c-format */ - (_("%B, section `%A', to symbol `%s':\n" - " relocation %s should not be used" + (_("%pB, section `%pA', to symbol `%s':" + " relocation %s should not be used" " in a shared object; recompile with -fPIC"), s->section->owner, s->section, @@ -3854,7 +3857,7 @@ cris_elf_final_write_processing (bfd *abfd, default: _bfd_abort (__FILE__, __LINE__, - _("Unexpected machine number")); + _("unexpected machine number")); } elf_elfheader (abfd)->e_flags = e_flags; @@ -3955,8 +3958,8 @@ cris_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) { _bfd_error_handler (bfd_get_symbol_leading_char (ibfd) == '_' - ? _("%B: uses _-prefixed symbols, but writing file with non-prefixed symbols") - : _("%B: uses non-prefixed symbols, but writing file with _-prefixed symbols"), + ? _("%pB: uses _-prefixed symbols, but writing file with non-prefixed symbols") + : _("%pB: uses non-prefixed symbols, but writing file with _-prefixed symbols"), ibfd); bfd_set_error (bfd_error_bad_value); return FALSE; @@ -3975,9 +3978,9 @@ cris_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) { _bfd_error_handler ((imach == bfd_mach_cris_v32) - ? _("%B contains CRIS v32 code, incompatible" + ? _("%pB contains CRIS v32 code, incompatible" " with previous objects") - : _("%B contains non-CRIS-v32 code, incompatible" + : _("%pB contains non-CRIS-v32 code, incompatible" " with previous objects"), ibfd); bfd_set_error (bfd_error_bad_value); diff --git a/bfd/elf32-crx.c b/bfd/elf32-crx.c index d8a3862..fde3a58 100644 --- a/bfd/elf32-crx.c +++ b/bfd/elf32-crx.c @@ -28,7 +28,7 @@ static reloc_howto_type *elf_crx_reloc_type_lookup (bfd *, bfd_reloc_code_real_type); -static void elf_crx_info_to_howto +static bfd_boolean elf_crx_info_to_howto (bfd *, arelent *, Elf_Internal_Rela *); static bfd_boolean elf32_crx_relax_delete_bytes (struct bfd_link_info *, bfd *, asection *, bfd_vma, int); @@ -418,20 +418,21 @@ elf_crx_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, /* Retrieve a howto ptr using an internal relocation entry. */ -static void -elf_crx_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, arelent *cache_ptr, +static bfd_boolean +elf_crx_info_to_howto (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst) { unsigned int r_type = ELF32_R_TYPE (dst->r_info); if (r_type >= R_CRX_MAX) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: unrecognised CRX reloc number: %d"), + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), abfd, r_type); bfd_set_error (bfd_error_bad_value); - r_type = R_CRX_NONE; + return FALSE; } cache_ptr->howto = &crx_elf_howto_table[r_type]; + return TRUE; } /* Perform a relocation as part of a final link. */ @@ -1320,7 +1321,7 @@ elf32_crx_relax_section (bfd *abfd, asection *sec, #define bfd_elf32_bfd_reloc_name_lookup \ elf_crx_reloc_name_lookup #define elf_info_to_howto elf_crx_info_to_howto -#define elf_info_to_howto_rel 0 +#define elf_info_to_howto_rel NULL #define elf_backend_relocate_section elf32_crx_relocate_section #define bfd_elf32_bfd_relax_section elf32_crx_relax_section #define bfd_elf32_bfd_get_relocated_section_contents \ diff --git a/bfd/elf32-d10v.c b/bfd/elf32-d10v.c index 0d1453c..c901595 100644 --- a/bfd/elf32-d10v.c +++ b/bfd/elf32-d10v.c @@ -220,8 +220,8 @@ bfd_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, /* Set the howto pointer for an D10V ELF reloc. */ -static void -d10v_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED, +static bfd_boolean +d10v_info_to_howto_rel (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst) { @@ -231,10 +231,13 @@ d10v_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED, if (r_type >= (unsigned int) R_D10V_max) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: invalid D10V reloc number: %d"), abfd, r_type); - r_type = 0; + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; } cache_ptr->howto = &elf_d10v_howto_table[r_type]; + return TRUE; } static asection * @@ -539,7 +542,7 @@ elf32_d10v_relocate_section (bfd *output_bfd, #define TARGET_BIG_SYM d10v_elf32_vec #define TARGET_BIG_NAME "elf32-d10v" -#define elf_info_to_howto 0 +#define elf_info_to_howto NULL #define elf_info_to_howto_rel d10v_info_to_howto_rel #define elf_backend_object_p 0 #define elf_backend_final_write_processing 0 diff --git a/bfd/elf32-d30v.c b/bfd/elf32-d30v.c index 51d9b88..7620a73 100644 --- a/bfd/elf32-d30v.c +++ b/bfd/elf32-d30v.c @@ -508,8 +508,8 @@ bfd_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, /* Set the howto pointer for an D30V ELF reloc (type REL). */ -static void -d30v_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED, +static bfd_boolean +d30v_info_to_howto_rel (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst) { @@ -519,16 +519,19 @@ d30v_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED, if (r_type >= (unsigned int) R_D30V_max) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: invalid D30V reloc number: %d"), abfd, r_type); - r_type = 0; + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; } cache_ptr->howto = &elf_d30v_howto_table[r_type]; + return TRUE; } /* Set the howto pointer for an D30V ELF reloc (type RELA). */ -static void -d30v_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED, +static bfd_boolean +d30v_info_to_howto_rela (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst) { @@ -538,10 +541,13 @@ d30v_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED, if (r_type >= (unsigned int) R_D30V_max) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: invalid D30V reloc number: %d"), abfd, r_type); - r_type = 0; + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; } cache_ptr->howto = &elf_d30v_howto_table[r_type]; + return TRUE; } #define ELF_ARCH bfd_arch_d30v diff --git a/bfd/elf32-dlx.c b/bfd/elf32-dlx.c index 468e6cb..d82d3ea 100644 --- a/bfd/elf32-dlx.c +++ b/bfd/elf32-dlx.c @@ -138,7 +138,7 @@ elf32_dlx_relocate16 (bfd *abfd, if (strcmp (input_section->name, symbol->section->output_section->name) != 0) { _bfd_error_handler - (_("BFD Link Error: branch (PC rel16) to section (%s) not supported"), + (_("branch (PC rel16) to section (%s) not supported"), symbol->section->output_section->name); return bfd_reloc_undefined; } @@ -201,7 +201,7 @@ elf32_dlx_relocate26 (bfd *abfd, if (strcmp (input_section->name, symbol->section->output_section->name) != 0) { _bfd_error_handler - (_("BFD Link Error: jump (PC rel26) to section (%s) not supported"), + (_("jump (PC rel26) to section (%s) not supported"), symbol->section->output_section->name); return bfd_reloc_undefined; } @@ -530,7 +530,7 @@ elf32_dlx_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, } static reloc_howto_type * -dlx_rtype_to_howto (unsigned int r_type) +dlx_rtype_to_howto (bfd *abfd, unsigned int r_type) { switch (r_type) { @@ -545,31 +545,33 @@ dlx_rtype_to_howto (unsigned int r_type) default: if (r_type >= (unsigned int) R_DLX_max) { - _bfd_error_handler (_("Invalid DLX reloc number: %d"), r_type); - r_type = 0; + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return NULL; } return & dlx_elf_howto_table[r_type]; } } -static void +static bfd_boolean elf32_dlx_info_to_howto (bfd * abfd ATTRIBUTE_UNUSED, arelent * cache_ptr ATTRIBUTE_UNUSED, Elf_Internal_Rela * dst ATTRIBUTE_UNUSED) { - abort (); + return FALSE; } -static void -elf32_dlx_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED, +static bfd_boolean +elf32_dlx_info_to_howto_rel (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst) { unsigned int r_type; r_type = ELF32_R_TYPE (dst->r_info); - cache_ptr->howto = dlx_rtype_to_howto (r_type); - return; + cache_ptr->howto = dlx_rtype_to_howto (abfd, r_type); + return cache_ptr->howto != NULL; } #define TARGET_BIG_SYM dlx_elf32_be_vec diff --git a/bfd/elf32-epiphany.c b/bfd/elf32-epiphany.c index 1ad1184..efbd67b 100644 --- a/bfd/elf32-epiphany.c +++ b/bfd/elf32-epiphany.c @@ -362,8 +362,8 @@ epiphany_elf_relax_section (bfd *abfd, asection *sec, /* Set the howto pointer for a EPIPHANY ELF reloc. */ -static void -epiphany_info_to_howto_rela (bfd * abfd ATTRIBUTE_UNUSED, +static bfd_boolean +epiphany_info_to_howto_rela (bfd * abfd, arelent * cache_ptr, Elf_Internal_Rela * dst) { @@ -373,10 +373,13 @@ epiphany_info_to_howto_rela (bfd * abfd ATTRIBUTE_UNUSED, if (r_type >= (unsigned int) R_EPIPHANY_max) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: invalid Epiphany reloc number: %d"), abfd, r_type); - r_type = 0; + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; } cache_ptr->howto = & epiphany_elf_howto_table [r_type]; + return TRUE; } /* Perform a single relocation. diff --git a/bfd/elf32-fr30.c b/bfd/elf32-fr30.c index 679322a..7b0fc88 100644 --- a/bfd/elf32-fr30.c +++ b/bfd/elf32-fr30.c @@ -367,7 +367,7 @@ fr30_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, const char *r_name) /* Set the howto pointer for an FR30 ELF reloc. */ -static void +static bfd_boolean fr30_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED, arelent *cache_ptr, Elf_Internal_Rela *dst) @@ -378,10 +378,13 @@ fr30_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED, if (r_type >= (unsigned int) R_FR30_max) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: invalid FR30 reloc number: %d"), abfd, r_type); - r_type = 0; + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; } cache_ptr->howto = & fr30_elf_howto_table [r_type]; + return TRUE; } /* Perform a single relocation. By default we use the standard BFD diff --git a/bfd/elf32-frv.c b/bfd/elf32-frv.c index b8d0338..7831aff 100644 --- a/bfd/elf32-frv.c +++ b/bfd/elf32-frv.c @@ -2532,7 +2532,7 @@ frv_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, const char *r_name) /* Set the howto pointer for an FRV ELF reloc. */ -static void +static bfd_boolean frv_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED, arelent *cache_ptr, Elf_Internal_Rela *dst) @@ -2554,16 +2554,20 @@ frv_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED, if (r_type >= (unsigned int) R_FRV_max) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: invalid FRV reloc number: %d"), abfd, r_type); - r_type = 0; + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; } cache_ptr->howto = & elf32_frv_howto_table [r_type]; break; } + return TRUE; } /* Set the howto pointer for an FRV ELF REL reloc. */ -static void + +static bfd_boolean frvfdpic_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED, arelent *cache_ptr, Elf_Internal_Rela *dst) { @@ -2594,8 +2598,9 @@ frvfdpic_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED, default: cache_ptr->howto = NULL; - break; + return FALSE; } + return TRUE; } /* Perform a single relocation. By default we use the standard BFD @@ -3529,9 +3534,10 @@ elf32_frv_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, if (addend) { info->callbacks->einfo - (_("%H: R_FRV_FUNCDESC references dynamic symbol" + (_("%H: %s references dynamic symbol" " with nonzero addend\n"), - input_bfd, input_section, rel->r_offset); + input_bfd, input_section, rel->r_offset, + "R_FRV_FUNCDESC"); return FALSE; } dynindx = h->dynindx; @@ -3650,9 +3656,10 @@ elf32_frv_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, if (addend && r_type == R_FRV_FUNCDESC_VALUE) { info->callbacks->einfo - (_("%H: R_FRV_FUNCDESC_VALUE" - " references dynamic symbol with nonzero addend\n"), - input_bfd, input_section, rel->r_offset); + (_("%H: %s references dynamic symbol" + " with nonzero addend\n"), + input_bfd, input_section, rel->r_offset, + "R_FRV_FUNCDESC_VALUE"); return FALSE; } dynindx = h->dynindx; @@ -6250,10 +6257,9 @@ elf32_frv_check_relocs (bfd *abfd, default: bad_reloc: - info->callbacks->einfo - /* xgettext:c-format */ - (_("%B: unsupported relocation type %i\n"), - abfd, ELF32_R_TYPE (rel->r_info)); + /* xgettext:c-format */ + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, (unsigned int) ELF32_R_TYPE (rel->r_info)); return FALSE; } } @@ -6504,7 +6510,7 @@ frv_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) error = TRUE; _bfd_error_handler /* xgettext:c-format */ - (_("%B: compiled with %s and linked with modules" + (_("%pB: compiled with %s and linked with modules" " that use non-pic relocations"), ibfd, (new_flags & EF_FRV_BIGPIC) ? "-fPIC" : "-fpic"); #endif @@ -6558,7 +6564,7 @@ frv_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) error = TRUE; _bfd_error_handler /* xgettext:c-format */ - (_("%B: compiled with %s and linked with modules compiled with %s"), + (_("%pB: compiled with %s and linked with modules compiled with %s"), ibfd, new_opt, old_opt); } @@ -6571,7 +6577,7 @@ frv_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) error = TRUE; _bfd_error_handler /* xgettext:c-format */ - (_("%B: uses different unknown e_flags (%#x) fields" + (_("%pB: uses different unknown e_flags (%#x) fields" " than previous modules (%#x)"), ibfd, new_partial, old_partial); } @@ -6593,11 +6599,11 @@ frv_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) error = TRUE; if (IS_FDPIC (obfd)) _bfd_error_handler - (_("%B: cannot link non-fdpic object file into fdpic executable"), + (_("%pB: cannot link non-fdpic object file into fdpic executable"), ibfd); else _bfd_error_handler - (_("%B: cannot link fdpic object file into non-fdpic executable"), + (_("%pB: cannot link fdpic object file into non-fdpic executable"), ibfd); } diff --git a/bfd/elf32-ft32.c b/bfd/elf32-ft32.c index 86157d8..7c4e1ae 100644 --- a/bfd/elf32-ft32.c +++ b/bfd/elf32-ft32.c @@ -292,16 +292,25 @@ ft32_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, const char *r_name) /* Set the howto pointer for an FT32 ELF reloc. */ -static void -ft32_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED, +static bfd_boolean +ft32_info_to_howto_rela (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst) { unsigned int r_type; r_type = ELF32_R_TYPE (dst->r_info); - BFD_ASSERT (r_type < (unsigned int) R_FT32_max); + if (r_type >= (unsigned int) R_FT32_max) + { + /* xgettext:c-format */ + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; + } + cache_ptr->howto = & ft32_elf_howto_table [r_type]; + return cache_ptr->howto != NULL; } /* Relocate an FT32 ELF section. diff --git a/bfd/elf32-gen.c b/bfd/elf32-gen.c index 9ffaf59..1d907a0 100644 --- a/bfd/elf32-gen.c +++ b/bfd/elf32-gen.c @@ -41,20 +41,22 @@ static reloc_howto_type dummy = 0, /* dst_mask */ FALSE); /* pcrel_offset */ -static void +static bfd_boolean elf_generic_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, arelent *bfd_reloc, Elf_Internal_Rela *elf_reloc ATTRIBUTE_UNUSED) { bfd_reloc->howto = &dummy; + return TRUE; } -static void +static bfd_boolean elf_generic_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED, arelent *bfd_reloc, Elf_Internal_Rela *elf_reloc ATTRIBUTE_UNUSED) { bfd_reloc->howto = &dummy; + return TRUE; } static void @@ -66,7 +68,7 @@ check_for_relocs (bfd * abfd, asection * o, void * failed) ehdrp = elf_elfheader (abfd); /* xgettext:c-format */ - _bfd_error_handler (_("%B: Relocations in generic ELF (EM: %d)"), + _bfd_error_handler (_("%pB: relocations in generic ELF (EM: %d)"), abfd, ehdrp->e_machine); bfd_set_error (bfd_error_wrong_format); diff --git a/bfd/elf32-h8300.c b/bfd/elf32-h8300.c index 0412424..a41ae63 100644 --- a/bfd/elf32-h8300.c +++ b/bfd/elf32-h8300.c @@ -26,9 +26,9 @@ static reloc_howto_type *elf32_h8_reloc_type_lookup (bfd *abfd, bfd_reloc_code_real_type code); -static void elf32_h8_info_to_howto +static bfd_boolean elf32_h8_info_to_howto (bfd *, arelent *, Elf_Internal_Rela *); -static void elf32_h8_info_to_howto_rel +static bfd_boolean elf32_h8_info_to_howto_rel (bfd *, arelent *, Elf_Internal_Rela *); static unsigned long elf32_h8_mach (flagword); static void elf32_h8_final_write_processing (bfd *, bfd_boolean); @@ -284,7 +284,7 @@ elf32_h8_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, return NULL; } -static void +static bfd_boolean elf32_h8_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, arelent *bfd_reloc, Elf_Internal_Rela *elf_reloc) { @@ -296,20 +296,20 @@ elf32_h8_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, arelent *bfd_reloc, if (h8_elf_howto_table[i].type == r) { bfd_reloc->howto = &h8_elf_howto_table[i]; - return; + return TRUE; } - abort (); + /* xgettext:c-format */ + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), abfd, r); + bfd_set_error (bfd_error_bad_value); + return FALSE; } -static void -elf32_h8_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED, arelent *bfd_reloc, +static bfd_boolean +elf32_h8_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED, + arelent *bfd_reloc ATTRIBUTE_UNUSED, Elf_Internal_Rela *elf_reloc ATTRIBUTE_UNUSED) { - unsigned int r; - - abort (); - r = ELF32_R_TYPE (elf_reloc->r_info); - bfd_reloc->howto = &h8_elf_howto_table[r]; + return FALSE; } /* Special handling for H8/300 relocs. @@ -453,7 +453,8 @@ elf32_h8_relocate_section (bfd *output_bfd, struct bfd_link_info *info, arelent bfd_reloc; reloc_howto_type *howto; - elf32_h8_info_to_howto (input_bfd, &bfd_reloc, rel); + if (! elf32_h8_info_to_howto (input_bfd, &bfd_reloc, rel)) + continue; howto = bfd_reloc.howto; r_symndx = ELF32_R_SYM (rel->r_info); @@ -733,7 +734,8 @@ elf32_h8_relax_section (bfd *abfd, asection *sec, { arelent bfd_reloc; - elf32_h8_info_to_howto (abfd, &bfd_reloc, irel); + if (! elf32_h8_info_to_howto (abfd, &bfd_reloc, irel)) + continue; } /* Keep track of the previous reloc so that we can delete some long jumps created by the compiler. */ @@ -1249,7 +1251,8 @@ elf32_h8_relax_section (bfd *abfd, asection *sec, reloc_howto_type *h; bfd_vma last_reloc_size; - elf32_h8_info_to_howto (abfd, &bfd_reloc, last_reloc); + if (! elf32_h8_info_to_howto (abfd, &bfd_reloc, last_reloc)) + break; h = bfd_reloc.howto; last_reloc_size = 1 << h->size; if (last_reloc->r_offset + last_reloc_size @@ -1267,7 +1270,8 @@ elf32_h8_relax_section (bfd *abfd, asection *sec, reloc_howto_type *h; bfd_vma next_reloc_size; - elf32_h8_info_to_howto (abfd, &bfd_reloc, next_reloc); + if (! elf32_h8_info_to_howto (abfd, &bfd_reloc, next_reloc)) + break; h = bfd_reloc.howto; next_reloc_size = 1 << h->size; if (next_reloc->r_offset + next_reloc_size diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c index 7454f48..3ce3807 100644 --- a/bfd/elf32-hppa.c +++ b/bfd/elf32-hppa.c @@ -574,7 +574,7 @@ hppa_add_stub (const char *stub_name, if (hsh == NULL) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: cannot create stub entry %s"), + _bfd_error_handler (_("%pB: cannot create stub entry %s"), section->owner, stub_name); return NULL; } @@ -826,10 +826,11 @@ hppa_build_one_stub (struct bfd_hash_entry *bh, void *in_arg) { _bfd_error_handler /* xgettext:c-format */ - (_("%B(%A+%#Lx): cannot reach %s, recompile with -ffunction-sections"), + (_("%pB(%pA+%#" PRIx64 "): " + "cannot reach %s, recompile with -ffunction-sections"), hsh->target_section->owner, stub_sec, - hsh->stub_offset, + (uint64_t) hsh->stub_offset, hsh->bh_root.string); bfd_set_error (bfd_error_bad_value); return FALSE; @@ -1239,7 +1240,7 @@ elf32_hppa_check_relocs (bfd *abfd, { _bfd_error_handler /* xgettext:c-format */ - (_("%B: relocation %s can not be used when making a shared object; recompile with -fPIC"), + (_("%pB: relocation %s can not be used when making a shared object; recompile with -fPIC"), abfd, elf_hppa_howto_table[r_type].name); bfd_set_error (bfd_error_bad_value); @@ -2079,7 +2080,7 @@ maybe_set_textrel (struct elf_link_hash_entry *eh, void *inf) info->flags |= DF_TEXTREL; info->callbacks->minfo - (_("%B: dynamic relocation against `%T' in read-only section `%A'\n"), + (_("%pB: dynamic relocation against `%pT' in read-only section `%pA'\n"), sec->owner, eh->root.root.string, sec); /* Not an error, just cut short the traversal. */ @@ -2677,7 +2678,7 @@ get_local_syms (bfd *output_bfd, bfd *input_bfd, struct bfd_link_info *info) else { /* xgettext:c-format */ - _bfd_error_handler (_("%B: duplicate export stub %s"), + _bfd_error_handler (_("%pB: duplicate export stub %s"), input_bfd, stub_name); } } @@ -3330,10 +3331,11 @@ final_link_relocate (asection *input_section, error. */ _bfd_error_handler /* xgettext:c-format */ - (_("%B(%A+%#Lx): %s fixup for insn %#x is not supported in a non-shared link"), + (_("%pB(%pA+%#" PRIx64 "): %s fixup for insn %#x " + "is not supported in a non-shared link"), input_bfd, input_section, - offset, + (uint64_t) offset, howto->name, insn); } @@ -3496,10 +3498,11 @@ final_link_relocate (asection *input_section, { _bfd_error_handler /* xgettext:c-format */ - (_("%B(%A+%#Lx): cannot reach %s, recompile with -ffunction-sections"), + (_("%pB(%pA+%#" PRIx64 "): cannot reach %s, " + "recompile with -ffunction-sections"), input_bfd, input_section, - offset, + (uint64_t) offset, hsh->bh_root.string); bfd_set_error (bfd_error_bad_value); return bfd_reloc_notsupported; @@ -4139,7 +4142,7 @@ elf32_hppa_relocate_section (bfd *output_bfd, if (*sym_name == '\0') sym_name = bfd_section_name (input_bfd, sym_sec); _bfd_error_handler - (_("%B:%s has both normal and TLS relocs"), + (_("%pB:%s has both normal and TLS relocs"), input_bfd, sym_name); } bfd_set_error (bfd_error_bad_value); @@ -4198,10 +4201,10 @@ elf32_hppa_relocate_section (bfd *output_bfd, { _bfd_error_handler /* xgettext:c-format */ - (_("%B(%A+%#Lx): cannot handle %s for %s"), + (_("%pB(%pA+%#" PRIx64 "): cannot handle %s for %s"), input_bfd, input_section, - rela->r_offset, + (uint64_t) rela->r_offset, howto->name, sym_name); bfd_set_error (bfd_error_bad_value); diff --git a/bfd/elf32-i370.c b/bfd/elf32-i370.c index 88be84b..2c6a30d 100644 --- a/bfd/elf32-i370.c +++ b/bfd/elf32-i370.c @@ -289,8 +289,8 @@ i370_elf_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, /* Set the howto pointer for an i370 ELF reloc. */ -static void -i370_elf_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, +static bfd_boolean +i370_elf_info_to_howto (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst) { @@ -304,12 +304,13 @@ i370_elf_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, if (r_type >= R_I370_max) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: unrecognised I370 reloc number: %d"), + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), abfd, r_type); bfd_set_error (bfd_error_bad_value); - r_type = R_I370_NONE; + return FALSE; } cache_ptr->howto = i370_elf_howto_table[r_type]; + return TRUE; } /* Hack alert -- the following several routines look generic to me ... @@ -356,7 +357,7 @@ i370_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) { _bfd_error_handler /* xgettext:c-format */ - (_("%B: uses different e_flags (%#x) fields than previous modules (%#x)"), + (_("%pB: uses different e_flags (%#x) fields than previous modules (%#x)"), ibfd, new_flags, old_flags); bfd_set_error (bfd_error_bad_value); @@ -811,7 +812,7 @@ i370_elf_check_relocs (bfd *abfd, return TRUE; #ifdef DEBUG - _bfd_error_handler ("i370_elf_check_relocs called for section %A in %B", + _bfd_error_handler ("i370_elf_check_relocs called for section %pA in %pB", sec, abfd); #endif @@ -1049,7 +1050,7 @@ i370_elf_relocate_section (bfd *output_bfd, bfd_boolean ret = TRUE; #ifdef DEBUG - _bfd_error_handler ("i370_elf_relocate_section called for %B section %A, %u relocations%s", + _bfd_error_handler ("i370_elf_relocate_section called for %pB section %pA, %u relocations%s", input_bfd, input_section, input_section->reloc_count, (bfd_link_relocatable (info)) ? " (relocatable)" : ""); @@ -1068,7 +1069,6 @@ i370_elf_relocate_section (bfd *output_bfd, Elf_Internal_Sym *sym = NULL; asection *sec = NULL; struct elf_link_hash_entry * h = NULL; - const char *sym_name = NULL; reloc_howto_type *howto; unsigned long r_symndx; bfd_vma relocation; @@ -1078,7 +1078,7 @@ i370_elf_relocate_section (bfd *output_bfd, || !i370_elf_howto_table[(int)r_type]) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: unknown relocation type %d"), + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), input_bfd, (int) r_type); bfd_set_error (bfd_error_bad_value); @@ -1094,7 +1094,6 @@ i370_elf_relocate_section (bfd *output_bfd, { sym = local_syms + r_symndx; sec = local_sections[r_symndx]; - sym_name = ""; relocation = _bfd_elf_rela_local_sym (output_bfd, sym, & sec, rel); addend = rel->r_addend; @@ -1111,7 +1110,6 @@ i370_elf_relocate_section (bfd *output_bfd, while (h->root.type == bfd_link_hash_indirect || h->root.type == bfd_link_hash_warning) h = (struct elf_link_hash_entry *) h->root.u.i.link; - sym_name = h->root.root.string; if (h->root.type == bfd_link_hash_defined || h->root.type == bfd_link_hash_defweak) { @@ -1161,8 +1159,8 @@ i370_elf_relocate_section (bfd *output_bfd, { default: _bfd_error_handler - (_("%B: unknown relocation type %d for symbol %s"), - input_bfd, (int) r_type, sym_name); + (_("%pB: unsupported relocation type %#x"), + input_bfd, (int) r_type); bfd_set_error (bfd_error_bad_value); ret = FALSE; @@ -1301,28 +1299,15 @@ i370_elf_relocate_section (bfd *output_bfd, case (int) R_I370_COPY: case (int) R_I370_RELATIVE: - _bfd_error_handler - /* xgettext:c-format */ - (_("%B: Relocation %s is not yet supported for symbol %s."), - input_bfd, - i370_elf_howto_table[(int) r_type]->name, - sym_name); - + /* xgettext:c-format */ + _bfd_error_handler (_("%pB: %s unsupported"), + input_bfd, + i370_elf_howto_table[(int) r_type]->name); bfd_set_error (bfd_error_invalid_operation); ret = FALSE; continue; } -#ifdef DEBUG - fprintf (stderr, "\ttype = %s (%d), name = %s, symbol index = %ld, offset = %ld, addend = %ld\n", - howto->name, - (int)r_type, - sym_name, - r_symndx, - (long) offset, - (long) addend); -#endif - r = _bfd_final_link_relocate (howto, input_bfd, input_section, contents, offset, relocation, addend); @@ -1405,10 +1390,10 @@ i370_elf_relocate_section (bfd *output_bfd, #define elf_backend_adjust_dynamic_symbol i370_elf_adjust_dynamic_symbol #define elf_backend_check_relocs i370_elf_check_relocs -static int -i370_noop (void) +static bfd_boolean +i370_noop (bfd * abfd ATTRIBUTE_UNUSED, ...) { - return 1; + return TRUE; } #define elf_backend_finish_dynamic_symbol \ diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index 1f380db..61a1409 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -194,7 +194,7 @@ static reloc_howto_type elf_howto_table[]= #endif static reloc_howto_type * -elf_i386_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED, +elf_i386_reloc_type_lookup (bfd *abfd, bfd_reloc_code_real_type code) { switch (code) @@ -346,11 +346,13 @@ elf_i386_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED, return &elf_howto_table[R_386_GNU_VTENTRY - R_386_vt_offset]; default: - break; + TRACE ("Unknown"); + /* xgettext:c-format */ + _bfd_error_handler (_("%pB: unsupported relocation type: %#x"), + abfd, (int) code); + bfd_set_error (bfd_error_bad_value); + return NULL; } - - TRACE ("Unknown"); - return 0; } static reloc_howto_type * @@ -368,7 +370,7 @@ elf_i386_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, } static reloc_howto_type * -elf_i386_rtype_to_howto (bfd *abfd, unsigned r_type) +elf_i386_rtype_to_howto (bfd *abfd ATTRIBUTE_UNUSED, unsigned r_type) { unsigned int indx; @@ -379,25 +381,30 @@ elf_i386_rtype_to_howto (bfd *abfd, unsigned r_type) >= R_386_ext2 - R_386_ext) && ((indx = r_type - R_386_vt_offset) - R_386_ext2 >= R_386_vt - R_386_ext2)) - { - /* xgettext:c-format */ - _bfd_error_handler (_("%B: invalid relocation type %d"), - abfd, (int) r_type); - indx = R_386_NONE; - } + return NULL; /* PR 17512: file: 0f67f69d. */ if (elf_howto_table [indx].type != r_type) return NULL; return &elf_howto_table[indx]; } -static void -elf_i386_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED, +static bfd_boolean +elf_i386_info_to_howto_rel (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst) { unsigned int r_type = ELF32_R_TYPE (dst->r_info); - cache_ptr->howto = elf_i386_rtype_to_howto (abfd, r_type); + + if ((cache_ptr->howto = elf_i386_rtype_to_howto (abfd, r_type)) == NULL) + { + /* xgettext:c-format */ + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; + } + + return TRUE; } /* Return whether a symbol name implies a local label. The UnixWare @@ -1156,10 +1163,10 @@ elf_i386_tls_transition (struct bfd_link_info *info, bfd *abfd, _bfd_error_handler /* xgettext:c-format */ - (_("%B: TLS transition from %s to %s against `%s' at %#Lx " - "in section `%A' failed"), + (_("%pB: TLS transition from %s to %s against `%s'" + " at %#" PRIx64 " in section `%pA' failed"), abfd, from->name, to->name, name, - rel->r_offset, sec); + (uint64_t) rel->r_offset, sec); bfd_set_error (bfd_error_bad_value); return FALSE; } @@ -1247,7 +1254,7 @@ elf_i386_convert_load_reloc (bfd *abfd, Elf_Internal_Shdr *symtab_hdr, _bfd_error_handler /* xgettext:c-format */ - (_("%B: direct GOT relocation R_386_GOT32X against `%s' without base" + (_("%pB: direct GOT relocation R_386_GOT32X against `%s' without base" " register can not be used when making a shared object"), abfd, name); return FALSE; @@ -1507,7 +1514,7 @@ elf_i386_check_relocs (bfd *abfd, if (r_symndx >= NUM_SHDR_ENTRIES (symtab_hdr)) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: bad symbol index: %d"), + _bfd_error_handler (_("%pB: bad symbol index: %d"), abfd, r_symndx); goto error_return; } @@ -1578,6 +1585,10 @@ elf_i386_check_relocs (bfd *abfd, rel, rel_end, h, r_symndx, FALSE)) goto error_return; + /* Check if _GLOBAL_OFFSET_TABLE_ is referenced. */ + if (h == htab->elf.hgot) + htab->got_referenced = TRUE; + switch (r_type) { case R_386_TLS_LDM: @@ -1700,7 +1711,7 @@ elf_i386_check_relocs (bfd *abfd, NULL); _bfd_error_handler /* xgettext:c-format */ - (_("%B: `%s' accessed both as normal and " + (_("%pB: `%s' accessed both as normal and " "thread local symbol"), abfd, name); bfd_set_error (bfd_error_bad_value); @@ -1720,11 +1731,19 @@ elf_i386_check_relocs (bfd *abfd, case R_386_GOTOFF: case R_386_GOTPC: - create_got: +create_got: if (r_type != R_386_TLS_IE) { if (eh != NULL) - eh->zero_undefweak &= 0x2; + { + eh->zero_undefweak &= 0x2; + + /* Need GOT to resolve undefined weak symbol to 0. */ + if (r_type == R_386_GOTOFF + && h->root.type == bfd_link_hash_undefweak + && bfd_link_executable (info)) + htab->got_referenced = TRUE; + } break; } /* Fall through */ @@ -1764,7 +1783,7 @@ do_relocation: { _bfd_error_handler /* xgettext:c-format */ - (_("%B: unsupported non-PIC call to IFUNC `%s'"), + (_("%pB: unsupported non-PIC call to IFUNC `%s'"), abfd, h->root.root.string); bfd_set_error (bfd_error_bad_value); goto error_return; @@ -1800,7 +1819,7 @@ do_relocation: size_reloc = FALSE; do_size: - if (NEED_DYNAMIC_RELOCATION_P (info, h, sec, r_type, + if (NEED_DYNAMIC_RELOCATION_P (info, FALSE, h, sec, r_type, R_386_32)) { struct elf_dyn_relocs *p; @@ -2342,7 +2361,7 @@ bad_ifunc_reloc: NULL); _bfd_error_handler /* xgettext:c-format */ - (_("%B: relocation %s against STT_GNU_IFUNC " + (_("%pB: relocation %s against STT_GNU_IFUNC " "symbol `%s' isn't supported"), input_bfd, howto->name, name); bfd_set_error (bfd_error_bad_value); @@ -2375,7 +2394,7 @@ do_ifunc_pointer: if (POINTER_LOCAL_IFUNC_P (info, h)) { - info->callbacks->minfo (_("Local IFUNC function `%s' in %B\n"), + info->callbacks->minfo (_("Local IFUNC function `%s' in %pB\n"), h->root.root.string, h->root.u.def.section->owner); @@ -2590,7 +2609,7 @@ disallow_got32: _bfd_error_handler /* xgettext:c-format */ - (_("%B: direct GOT relocation %s against `%s'" + (_("%pB: direct GOT relocation %s against `%s'" " without base register can not be used" " when making a shared object"), input_bfd, howto->name, name); @@ -2640,7 +2659,7 @@ disallow_got32: _bfd_error_handler /* xgettext:c-format */ - (_("%B: relocation R_386_GOTOFF against undefined %s" + (_("%pB: relocation R_386_GOTOFF against undefined %s" " `%s' can not be used when making a shared object"), input_bfd, v, h->root.root.string); bfd_set_error (bfd_error_bad_value); @@ -2653,7 +2672,7 @@ disallow_got32: { _bfd_error_handler /* xgettext:c-format */ - (_("%B: relocation R_386_GOTOFF against protected %s" + (_("%pB: relocation R_386_GOTOFF against protected %s" " `%s' can not be used when making a shared object"), input_bfd, h->type == STT_FUNC ? "function" : "data", @@ -3430,10 +3449,10 @@ disallow_got32: { _bfd_error_handler /* xgettext:c-format */ - (_("%B(%A+%#Lx): unresolvable %s relocation against symbol `%s'"), + (_("%pB(%pA+%#" PRIx64 "): unresolvable %s relocation against symbol `%s'"), input_bfd, input_section, - rel->r_offset, + (uint64_t) rel->r_offset, howto->name, h->root.root.string); return FALSE; @@ -3470,9 +3489,9 @@ check_relocation_error: { _bfd_error_handler /* xgettext:c-format */ - (_("%B(%A+%#Lx): reloc against `%s': error %d"), + (_("%pB(%pA+%#" PRIx64 "): reloc against `%s': error %d"), input_bfd, input_section, - rel->r_offset, name, (int) r); + (uint64_t) rel->r_offset, name, (int) r); return FALSE; } } @@ -3681,7 +3700,7 @@ elf_i386_finish_dynamic_symbol (bfd *output_bfd, + got_offset); if (PLT_LOCAL_IFUNC_P (info, h)) { - info->callbacks->minfo (_("Local IFUNC function `%s' in %B\n"), + info->callbacks->minfo (_("Local IFUNC function `%s' in %pB\n"), h->root.root.string, h->root.u.def.section->owner); @@ -3820,7 +3839,7 @@ elf_i386_finish_dynamic_symbol (bfd *output_bfd, } if (SYMBOL_REFERENCES_LOCAL_P (info, h)) { - info->callbacks->minfo (_("Local IFUNC function `%s' in %B\n"), + info->callbacks->minfo (_("Local IFUNC function `%s' in %pB\n"), h->root.root.string, h->root.u.def.section->owner); @@ -4178,6 +4197,7 @@ elf_i386_get_synthetic_symtab (bfd *abfd, switch (get_elf_x86_backend_data (abfd)->target_os) { case is_normal: + case is_solaris: non_lazy_plt = &elf_i386_non_lazy_plt; lazy_ibt_plt = &elf_i386_lazy_ibt_plt; non_lazy_ibt_plt = &elf_i386_non_lazy_ibt_plt; @@ -4337,6 +4357,7 @@ elf_i386_link_setup_gnu_properties (struct bfd_link_info *info) switch (get_elf_x86_backend_data (info->output_bfd)->target_os) { case is_normal: + case is_solaris: init_table.plt0_pad_byte = 0x0; init_table.lazy_plt = &elf_i386_lazy_plt; init_table.non_lazy_plt = &elf_i386_non_lazy_plt; @@ -4454,6 +4475,14 @@ elf_i386_fbsd_post_process_headers (bfd *abfd, struct bfd_link_info *info) #undef TARGET_LITTLE_NAME #define TARGET_LITTLE_NAME "elf32-i386-sol2" +static const struct elf_x86_backend_data elf_i386_solaris_arch_bed = + { + is_solaris /* os */ + }; + +#undef elf_backend_arch_data +#define elf_backend_arch_data &elf_i386_solaris_arch_bed + #undef elf_backend_post_process_headers /* Restore default: we cannot use ELFOSABI_SOLARIS, otherwise ELFOSABI_NONE @@ -4580,6 +4609,9 @@ elf32_iamcu_elf_object_p (bfd *abfd) #undef ELF_MACHINE_CODE #define ELF_MACHINE_CODE EM_IAMCU +#undef elf_backend_arch_data +#define elf_backend_arch_data &elf_i386_arch_bed + #undef ELF_OSABI #undef elf32_bed diff --git a/bfd/elf32-i860.c b/bfd/elf32-i860.c index e34965c..737e7f5 100644 --- a/bfd/elf32-i860.c +++ b/bfd/elf32-i860.c @@ -761,10 +761,11 @@ lookup_howto (unsigned int rtype) elf_code_to_howto_index[elf32_i860_howto_table[i].type] = i; } - BFD_ASSERT (rtype <= R_860_max); + if (rtype > R_860_max) + return NULL; i = elf_code_to_howto_index[rtype]; if (i >= howto_tbl_size) - return 0; + return NULL; return elf32_i860_howto_table + i; } @@ -880,8 +881,7 @@ elf32_i860_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED, rtype = R_860_HIGOTOFF; break; default: - rtype = 0; - break; + return NULL; } return lookup_howto (rtype); } @@ -904,13 +904,15 @@ elf32_i860_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, } /* Given a ELF reloc, return the matching HOWTO structure. */ -static void + +static bfd_boolean elf32_i860_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED, arelent *bfd_reloc, Elf_Internal_Rela *elf_reloc) { bfd_reloc->howto = lookup_howto ((unsigned) ELF32_R_TYPE (elf_reloc->r_info)); + return bfd_reloc->howto != NULL; } /* Specialized relocation handler for R_860_SPLITn. These relocations diff --git a/bfd/elf32-i960.c b/bfd/elf32-i960.c index 61a7f9d..244e4ea 100644 --- a/bfd/elf32-i960.c +++ b/bfd/elf32-i960.c @@ -29,7 +29,7 @@ #define bfd_elf32_bfd_reloc_type_lookup elf32_i960_reloc_type_lookup #define bfd_elf32_bfd_reloc_name_lookup \ elf32_i960_reloc_name_lookup -#define elf_info_to_howto elf32_i960_info_to_howto +#define elf_info_to_howto NULL #define elf_info_to_howto_rel elf32_i960_info_to_howto_rel /* ELF relocs are against symbols. If we are producing relocatable @@ -116,15 +116,7 @@ elf32_i960_bfd_to_reloc_type (bfd_reloc_code_real_type code) } } -static void -elf32_i960_info_to_howto (bfd * abfd ATTRIBUTE_UNUSED, - arelent * cache_ptr ATTRIBUTE_UNUSED, - Elf_Internal_Rela * dst ATTRIBUTE_UNUSED) -{ - abort (); -} - -static void +static bfd_boolean elf32_i960_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED, arelent *cache_ptr, Elf_Internal_Rela *dst) @@ -137,11 +129,14 @@ elf32_i960_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED, if (type >= R_960_max) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: invalid i960 reloc number: %d"), abfd, type); - type = 0; + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, type); + bfd_set_error (bfd_error_bad_value); + return FALSE; } cache_ptr->howto = &elf_howto_table[(int) type]; + return TRUE; } static reloc_howto_type * diff --git a/bfd/elf32-ip2k.c b/bfd/elf32-ip2k.c index 3733ebb..1432f18 100644 --- a/bfd/elf32-ip2k.c +++ b/bfd/elf32-ip2k.c @@ -1231,8 +1231,8 @@ ip2k_elf_relax_section (bfd *abfd, /* Set the howto pointer for a IP2K ELF reloc. */ -static void -ip2k_info_to_howto_rela (bfd * abfd ATTRIBUTE_UNUSED, +static bfd_boolean +ip2k_info_to_howto_rela (bfd * abfd, arelent * cache_ptr, Elf_Internal_Rela * dst) { @@ -1242,10 +1242,13 @@ ip2k_info_to_howto_rela (bfd * abfd ATTRIBUTE_UNUSED, if (r_type >= (unsigned int) R_IP2K_max) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: invalid IP2K reloc number: %d"), abfd, r_type); - r_type = 0; + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; } cache_ptr->howto = & ip2k_elf_howto_table [r_type]; + return TRUE; } /* Perform a single relocation. @@ -1295,9 +1298,11 @@ ip2k_final_link_relocate (reloc_howto_type * howto, ip2k_nominal_page_bits (input_bfd, input_section, rel->r_offset, contents)) /* xgettext:c-format */ - _bfd_error_handler (_("ip2k linker: missing page instruction at %#Lx (dest = %#Lx)"), - BASEADDR (input_section) + rel->r_offset, - relocation + rel->r_addend); + _bfd_error_handler + (_("ip2k linker: missing page instruction " + "at %#" PRIx64 " (dest = %#" PRIx64 ")"), + (uint64_t) (BASEADDR (input_section) + rel->r_offset), + (uint64_t) (relocation + rel->r_addend)); } else if (ip2k_relaxed) { @@ -1312,9 +1317,11 @@ ip2k_final_link_relocate (reloc_howto_type * howto, ip2k_nominal_page_bits (input_bfd, input_section, rel->r_offset - 2, contents))) /* xgettext:c-format */ - _bfd_error_handler (_("ip2k linker: redundant page instruction at %#Lx (dest = %#Lx)"), - page_addr, - relocation + rel->r_addend); + _bfd_error_handler + (_("ip2k linker: redundant page instruction " + "at %#" PRIx64 " (dest = %#" PRIx64 ")"), + (uint64_t) page_addr, + (uint64_t) (relocation + rel->r_addend)); } if ((relocation & IP2K_INSN_MASK) == IP2K_INSN_VALUE) relocation &= ~IP2K_INSN_MASK; diff --git a/bfd/elf32-iq2000.c b/bfd/elf32-iq2000.c index b29b9cb..d1ce3c8 100644 --- a/bfd/elf32-iq2000.c +++ b/bfd/elf32-iq2000.c @@ -416,7 +416,7 @@ iq2000_final_link_relocate (reloc_howto_type * howto, /* Set the howto pointer for a IQ2000 ELF reloc. */ -static void +static bfd_boolean iq2000_info_to_howto_rela (bfd * abfd ATTRIBUTE_UNUSED, arelent * cache_ptr, Elf_Internal_Rela * dst) @@ -438,12 +438,15 @@ iq2000_info_to_howto_rela (bfd * abfd ATTRIBUTE_UNUSED, if (r_type >= (unsigned int) R_IQ2000_max) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: invalid IQ2000 reloc number: %d"), abfd, r_type); - r_type = 0; + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; } cache_ptr->howto = & iq2000_elf_howto_table [r_type]; break; } + return TRUE; } /* Look through the relocs for a section during the first phase. @@ -825,7 +828,7 @@ iq2000_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) error = TRUE; _bfd_error_handler /* xgettext:c-format */ - (_("%B: compiled with %s and linked with modules compiled with %s"), + (_("%pB: compiled with %s and linked with modules compiled with %s"), ibfd, new_opt, old_opt); } @@ -839,7 +842,7 @@ iq2000_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) _bfd_error_handler /* xgettext:c-format */ - (_("%B: uses different e_flags (%#x) fields than previous modules (%#x)"), + (_("%pB: uses different e_flags (%#x) fields than previous modules (%#x)"), ibfd, new_flags, old_flags); } } diff --git a/bfd/elf32-lm32.c b/bfd/elf32-lm32.c index 089ec84..027830b 100644 --- a/bfd/elf32-lm32.c +++ b/bfd/elf32-lm32.c @@ -525,8 +525,8 @@ lm32_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, /* Set the howto pointer for an Lattice Mico32 ELF reloc. */ -static void -lm32_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED, +static bfd_boolean +lm32_info_to_howto_rela (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst) { @@ -536,10 +536,13 @@ lm32_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED, if (r_type >= (unsigned int) R_LM32_max) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: invalid LM32 reloc number: %d"), abfd, r_type); - r_type = 0; + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; } cache_ptr->howto = &lm32_elf_howto_table[r_type]; + return TRUE; } /* Set the right machine number for an Lattice Mico32 ELF file. */ @@ -995,7 +998,9 @@ lm32_elf_relocate_section (bfd *output_bfd, /* Addend should be zero. */ if (rel->r_addend != 0) - _bfd_error_handler (_("internal error: addend should be zero for R_LM32_16_GOT")); + _bfd_error_handler + (_("internal error: addend should be zero for %s"), + "R_LM32_16_GOT"); r = _bfd_final_link_relocate (howto, input_bfd, @@ -1073,7 +1078,8 @@ lm32_elf_relocate_section (bfd *output_bfd, const char *msg = NULL; arelent bfd_reloc; - lm32_info_to_howto_rela (input_bfd, &bfd_reloc, rel); + if (! lm32_info_to_howto_rela (input_bfd, &bfd_reloc, rel)) + continue; howto = bfd_reloc.howto; if (h != NULL) @@ -1427,8 +1433,9 @@ lm32_elf_finish_dynamic_sections (bfd *output_bfd, != (lm32fdpic_fixup32_section (info)->reloc_count * 4)) { _bfd_error_handler - ("LINKER BUG: .rofixup section size mismatch: size/4 %Ld != relocs %d", - lm32fdpic_fixup32_section (info)->size/4, + ("LINKER BUG: .rofixup section size mismatch: size/4 %" PRId64 + " != relocs %d", + (int64_t) (lm32fdpic_fixup32_section (info)->size / 4), lm32fdpic_fixup32_section (info)->reloc_count); return FALSE; } @@ -1449,7 +1456,9 @@ lm32_elf_finish_dynamic_sections (bfd *output_bfd, if (hend->u.def.value != value) { _bfd_error_handler - ("LINKER BUG: .rofixup section hend->u.def.value != value: %Ld != %Ld", hend->u.def.value, value); + ("LINKER BUG: .rofixup section hend->u.def.value != value: %" + PRId64 " != %" PRId64, + (int64_t) hend->u.def.value, (int64_t) value); return FALSE; } } @@ -1986,7 +1995,7 @@ maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) info->flags |= DF_TEXTREL; info->callbacks->minfo - (_("%B: dynamic relocation against `%T' in read-only section `%A'\n"), + (_("%pB: dynamic relocation against `%pT' in read-only section `%pA'\n"), sec->owner, h->root.root.string, sec); /* Not an error, just cut short the traversal. */ @@ -2562,7 +2571,7 @@ lm32_elf_fdpic_copy_private_bfd_data (bfd *ibfd, bfd *obfd) #define bfd_elf32_bfd_reloc_type_lookup lm32_reloc_type_lookup #define bfd_elf32_bfd_reloc_name_lookup lm32_reloc_name_lookup #define elf_info_to_howto lm32_info_to_howto_rela -#define elf_info_to_howto_rel 0 +#define elf_info_to_howto_rel NULL #define elf_backend_rela_normal 1 #define elf_backend_object_p lm32_elf_object_p #define elf_backend_final_write_processing lm32_elf_final_write_processing @@ -2580,7 +2589,7 @@ lm32_elf_fdpic_copy_private_bfd_data (bfd *ibfd, bfd *obfd) #define elf_backend_reloc_type_class lm32_elf_reloc_type_class #define elf_backend_copy_indirect_symbol lm32_elf_copy_indirect_symbol #define elf_backend_size_dynamic_sections lm32_elf_size_dynamic_sections -#define elf_backend_omit_section_dynsym ((bfd_boolean (*) (bfd *, struct bfd_link_info *, asection *)) bfd_true) +#define elf_backend_omit_section_dynsym _bfd_elf_omit_section_dynsym_all #define elf_backend_create_dynamic_sections lm32_elf_create_dynamic_sections #define elf_backend_finish_dynamic_sections lm32_elf_finish_dynamic_sections #define elf_backend_adjust_dynamic_symbol lm32_elf_adjust_dynamic_symbol diff --git a/bfd/elf32-m32c.c b/bfd/elf32-m32c.c index dfb8a1e..613844a 100644 --- a/bfd/elf32-m32c.c +++ b/bfd/elf32-m32c.c @@ -28,7 +28,7 @@ /* Forward declarations. */ static reloc_howto_type * m32c_reloc_type_lookup (bfd *, bfd_reloc_code_real_type); -static void m32c_info_to_howto_rela +static bfd_boolean m32c_info_to_howto_rela (bfd *, arelent *, Elf_Internal_Rela *); static bfd_boolean m32c_elf_relocate_section (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, Elf_Internal_Rela *, Elf_Internal_Sym *, asection **); @@ -291,11 +291,10 @@ m32c_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, const char *r_name) /* Set the howto pointer for an M32C ELF reloc. */ -static void -m32c_info_to_howto_rela - (bfd * abfd ATTRIBUTE_UNUSED, - arelent * cache_ptr, - Elf_Internal_Rela * dst) +static bfd_boolean +m32c_info_to_howto_rela (bfd * abfd, + arelent * cache_ptr, + Elf_Internal_Rela * dst) { unsigned int r_type; @@ -303,10 +302,13 @@ m32c_info_to_howto_rela if (r_type >= (unsigned int) R_M32C_max) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: invalid M32C reloc number: %d"), abfd, r_type); - r_type = 0; + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; } cache_ptr->howto = & m32c_elf_howto_table [r_type]; + return TRUE; } @@ -871,7 +873,7 @@ m32c_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) error = TRUE; _bfd_error_handler /* xgettext:c-format */ - (_("%B: compiled with %s and linked with modules compiled with %s"), + (_("%pB: compiled with %s and linked with modules compiled with %s"), ibfd, new_opt, old_opt); } @@ -884,7 +886,7 @@ m32c_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) error = TRUE; _bfd_error_handler /* xgettext:c-format */ - (_("%B: uses different e_flags (%#x) fields" + (_("%pB: uses different e_flags (%#x) fields" " than previous modules (%#x)"), ibfd, new_flags, old_flags); } diff --git a/bfd/elf32-m32r.c b/bfd/elf32-m32r.c index 78d5e39..94a4bc9 100644 --- a/bfd/elf32-m32r.c +++ b/bfd/elf32-m32r.c @@ -1272,7 +1272,7 @@ bfd_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, /* Set the howto pointer for an M32R ELF reloc. */ -static void +static bfd_boolean m32r_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED, arelent *cache_ptr, Elf_Internal_Rela *dst) @@ -1283,21 +1283,34 @@ m32r_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED, if (r_type > (unsigned int) R_M32R_GNU_VTENTRY) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: invalid M32R reloc number: %d"), abfd, r_type); - r_type = 0; + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; } cache_ptr->howto = &m32r_elf_howto_table[r_type]; + return TRUE; } -static void +static bfd_boolean m32r_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, arelent *cache_ptr, Elf_Internal_Rela *dst) { - BFD_ASSERT ((ELF32_R_TYPE(dst->r_info) == (unsigned int) R_M32R_NONE) - || ((ELF32_R_TYPE(dst->r_info) > (unsigned int) R_M32R_GNU_VTENTRY) - && (ELF32_R_TYPE(dst->r_info) < (unsigned int) R_M32R_max))); - cache_ptr->howto = &m32r_elf_howto_table[ELF32_R_TYPE(dst->r_info)]; + unsigned int r_type = ELF32_R_TYPE (dst->r_info); + + if (r_type == (unsigned int) R_M32R_NONE + || ((r_type > (unsigned int) R_M32R_GNU_VTENTRY) + && (r_type < (unsigned int) R_M32R_max))) + { + cache_ptr->howto = &m32r_elf_howto_table[r_type]; + return TRUE; + } + + /* xgettext:c-format */ + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; } @@ -2094,7 +2107,7 @@ maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) info->flags |= DF_TEXTREL; info->callbacks->minfo - (_("%B: dynamic relocation against `%T' in read-only section `%A'\n"), + (_("%pB: dynamic relocation against `%pT' in read-only section `%pA'\n"), sec->owner, h->root.root.string, sec); /* Not an error, just cut short the traversal. */ @@ -2401,7 +2414,7 @@ m32r_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, if (r_type < 0 || r_type >= (int) R_M32R_max) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: unknown relocation type %d"), + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), input_bfd, (int) r_type); bfd_set_error (bfd_error_bad_value); ret = FALSE; @@ -2523,11 +2536,11 @@ m32r_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, { _bfd_error_handler /* xgettext:c-format */ - (_("%B(%A+%#Lx): unresolvable %s relocation " + (_("%pB(%pA+%#" PRIx64 "): unresolvable %s relocation " "against symbol `%s'"), input_bfd, input_section, - rel->r_offset, + (uint64_t) rel->r_offset, howto->name, h->root.root.string); } @@ -2968,7 +2981,8 @@ m32r_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, { _bfd_error_handler /* xgettext:c-format */ - (_("%B: The target (%s) of an %s relocation is in the wrong section (%A)"), + (_("%pB: the target (%s) of an %s relocation" + " is in the wrong section (%pA)"), input_bfd, sym_name, m32r_elf_howto_table[(int) r_type].name, @@ -3470,7 +3484,7 @@ m32r_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) || ((in_flags & EF_M32R_ARCH) == E_M32R2_ARCH)) { _bfd_error_handler - (_("%B: Instruction set mismatch with previous modules"), ibfd); + (_("%pB: instruction set mismatch with previous modules"), ibfd); bfd_set_error (bfd_error_bad_value); return FALSE; @@ -3854,8 +3868,7 @@ m32r_elf_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED, #define elf_backend_create_dynamic_sections m32r_elf_create_dynamic_sections #define bfd_elf32_bfd_link_hash_table_create m32r_elf_link_hash_table_create #define elf_backend_size_dynamic_sections m32r_elf_size_dynamic_sections -#define elf_backend_omit_section_dynsym \ - ((bfd_boolean (*) (bfd *, struct bfd_link_info *, asection *)) bfd_true) +#define elf_backend_omit_section_dynsym _bfd_elf_omit_section_dynsym_all #define elf_backend_finish_dynamic_sections m32r_elf_finish_dynamic_sections #define elf_backend_adjust_dynamic_symbol m32r_elf_adjust_dynamic_symbol #define elf_backend_finish_dynamic_symbol m32r_elf_finish_dynamic_symbol diff --git a/bfd/elf32-m68hc11.c b/bfd/elf32-m68hc11.c index 0283e93..95d271f 100644 --- a/bfd/elf32-m68hc11.c +++ b/bfd/elf32-m68hc11.c @@ -32,7 +32,7 @@ /* Relocation functions. */ static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup (bfd *, bfd_reloc_code_real_type); -static void m68hc11_info_to_howto_rel +static bfd_boolean m68hc11_info_to_howto_rel (bfd *, arelent *, Elf_Internal_Rela *); /* Trampoline generation. */ @@ -377,8 +377,8 @@ bfd_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, /* Set the howto pointer for an M68HC11 ELF reloc. */ -static void -m68hc11_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED, +static bfd_boolean +m68hc11_info_to_howto_rel (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst) { unsigned int r_type; @@ -387,10 +387,13 @@ m68hc11_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED, if (r_type >= (unsigned int) R_M68HC11_max) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: invalid M68HC11 reloc number: %d"), abfd, r_type); - r_type = 0; + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; } cache_ptr->howto = &elf_m68hc11_howto_table[r_type]; + return TRUE; } @@ -1296,7 +1299,7 @@ static const struct bfd_elf_special_section elf32_m68hc11_special_sections[] = #define TARGET_BIG_SYM m68hc11_elf32_vec #define TARGET_BIG_NAME "elf32-m68hc11" -#define elf_info_to_howto 0 +#define elf_info_to_howto NULL #define elf_info_to_howto_rel m68hc11_info_to_howto_rel #define bfd_elf32_bfd_relax_section m68hc11_elf_relax_section #define elf_backend_check_relocs elf32_m68hc11_check_relocs diff --git a/bfd/elf32-m68hc12.c b/bfd/elf32-m68hc12.c index 3fec993..0b53674 100644 --- a/bfd/elf32-m68hc12.c +++ b/bfd/elf32-m68hc12.c @@ -32,7 +32,7 @@ /* Relocation functions. */ static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup (bfd *, bfd_reloc_code_real_type); -static void m68hc11_info_to_howto_rel +static bfd_boolean m68hc11_info_to_howto_rel (bfd *, arelent *, Elf_Internal_Rela *); /* Trampoline generation. */ @@ -497,8 +497,8 @@ bfd_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, /* Set the howto pointer for an M68HC11 ELF reloc. */ -static void -m68hc11_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED, +static bfd_boolean +m68hc11_info_to_howto_rel (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst) { unsigned int r_type; @@ -507,10 +507,13 @@ m68hc11_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED, if (r_type >= (unsigned int) R_M68HC11_max) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: invalid M68HC12 reloc number: %d"), abfd, r_type); - r_type = 0; + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; } cache_ptr->howto = &elf_m68hc11_howto_table[r_type]; + return TRUE; } @@ -646,7 +649,7 @@ static const struct bfd_elf_special_section elf32_m68hc12_special_sections[] = #define TARGET_BIG_SYM m68hc12_elf32_vec #define TARGET_BIG_NAME "elf32-m68hc12" -#define elf_info_to_howto 0 +#define elf_info_to_howto NULL #define elf_info_to_howto_rel m68hc11_info_to_howto_rel #define elf_backend_check_relocs elf32_m68hc11_check_relocs #define elf_backend_relocate_section elf32_m68hc11_relocate_section diff --git a/bfd/elf32-m68hc1x.c b/bfd/elf32-m68hc1x.c index dcdc357..35152ee 100644 --- a/bfd/elf32-m68hc1x.c +++ b/bfd/elf32-m68hc1x.c @@ -162,7 +162,7 @@ m68hc12_add_stub (const char *stub_name, asection *section, if (stub_entry == NULL) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: cannot create stub entry %s"), + _bfd_error_handler (_("%pB: cannot create stub entry %s"), section->owner, stub_name); return NULL; } @@ -963,7 +963,8 @@ elf32_m68hc11_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, || r_type == R_M68HC11_GNU_VTINHERIT) continue; - (*ebd->elf_info_to_howto_rel) (input_bfd, &arel, rel); + if (! (*ebd->elf_info_to_howto_rel) (input_bfd, &arel, rel)) + continue; howto = arel.howto; h = NULL; @@ -1112,7 +1113,7 @@ elf32_m68hc11_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, /* Get virtual address of instruction having the relocation. */ if (is_far) { - msg = _("Reference to the far symbol `%s' using a wrong " + msg = _("reference to the far symbol `%s' using a wrong " "relocation may result in incorrect execution"); buf = xmalloc (strlen (msg) + strlen (name) + 10); sprintf (buf, msg, name); @@ -1348,14 +1349,14 @@ _bfd_m68hc11_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) if ((new_flags & E_M68HC11_I32) != (old_flags & E_M68HC11_I32)) { _bfd_error_handler - (_("%B: linking files compiled for 16-bit integers (-mshort) " + (_("%pB: linking files compiled for 16-bit integers (-mshort) " "and others for 32-bit integers"), ibfd); ok = FALSE; } if ((new_flags & E_M68HC11_F64) != (old_flags & E_M68HC11_F64)) { _bfd_error_handler - (_("%B: linking files compiled for 32-bit double (-fshort-double) " + (_("%pB: linking files compiled for 32-bit double (-fshort-double) " "and others for 64-bit double"), ibfd); ok = FALSE; } @@ -1364,7 +1365,7 @@ _bfd_m68hc11_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) if (!EF_M68HC11_CAN_MERGE_MACH (new_flags, old_flags)) { _bfd_error_handler - (_("%B: linking files compiled for HCS12 with " + (_("%pB: linking files compiled for HCS12 with " "others compiled for HC12"), ibfd); ok = FALSE; } @@ -1381,7 +1382,7 @@ _bfd_m68hc11_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) { _bfd_error_handler /* xgettext:c-format */ - (_("%B: uses different e_flags (%#x) fields than previous modules (%#x)"), + (_("%pB: uses different e_flags (%#x) fields than previous modules (%#x)"), ibfd, new_flags, old_flags); ok = FALSE; } diff --git a/bfd/elf32-m68k.c b/bfd/elf32-m68k.c index 112067b..8680504 100644 --- a/bfd/elf32-m68k.c +++ b/bfd/elf32-m68k.c @@ -341,7 +341,7 @@ static reloc_howto_type howto_table[] = FALSE), /* pcrel_offset */ }; -static void +static bfd_boolean rtype_to_howto (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst) { unsigned int indx = ELF32_R_TYPE (dst->r_info); @@ -349,11 +349,13 @@ rtype_to_howto (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst) if (indx >= (unsigned int) R_68K_max) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: invalid relocation type %d"), - abfd, (int) indx); - indx = R_68K_NONE; + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, indx); + bfd_set_error (bfd_error_bad_value); + return FALSE; } cache_ptr->howto = &howto_table[indx]; + return TRUE; } #define elf_info_to_howto rtype_to_howto @@ -1655,15 +1657,15 @@ elf_m68k_add_entry_to_got (struct elf_m68k_got *got, { if (got->n_slots[R_8] > ELF_M68K_R_8_MAX_N_SLOTS_IN_GOT (info)) /* xgettext:c-format */ - _bfd_error_handler (_("%B: GOT overflow: " - "Number of relocations with 8-bit " + _bfd_error_handler (_("%pB: GOT overflow: " + "number of relocations with 8-bit " "offset > %d"), abfd, ELF_M68K_R_8_MAX_N_SLOTS_IN_GOT (info)); else /* xgettext:c-format */ - _bfd_error_handler (_("%B: GOT overflow: " - "Number of relocations with 8- or 16-bit " + _bfd_error_handler (_("%pB: GOT overflow: " + "number of relocations with 8- or 16-bit " "offset > %d"), abfd, ELF_M68K_R_8_16_MAX_N_SLOTS_IN_GOT (info)); @@ -3698,8 +3700,10 @@ elf_m68k_relocate_section (bfd *output_bfd, { _bfd_error_handler /* xgettext:c-format */ - (_("%B(%A+%#Lx): %s relocation not permitted in shared object"), - input_bfd, input_section, rel->r_offset, howto->name); + (_("%pB(%pA+%#" PRIx64 "): " + "%s relocation not permitted in shared object"), + input_bfd, input_section, (uint64_t) rel->r_offset, + howto->name); return FALSE; } @@ -3892,10 +3896,11 @@ elf_m68k_relocate_section (bfd *output_bfd, { _bfd_error_handler /* xgettext:c-format */ - (_("%B(%A+%#Lx): unresolvable %s relocation against symbol `%s'"), + (_("%pB(%pA+%#" PRIx64 "): " + "unresolvable %s relocation against symbol `%s'"), input_bfd, input_section, - rel->r_offset, + (uint64_t) rel->r_offset, howto->name, h->root.root.string); return FALSE; @@ -3928,12 +3933,12 @@ elf_m68k_relocate_section (bfd *output_bfd, _bfd_error_handler ((sym_type == STT_TLS /* xgettext:c-format */ - ? _("%B(%A+%#Lx): %s used with TLS symbol %s") + ? _("%pB(%pA+%#" PRIx64 "): %s used with TLS symbol %s") /* xgettext:c-format */ - : _("%B(%A+%#Lx): %s used with non-TLS symbol %s")), + : _("%pB(%pA+%#" PRIx64 "): %s used with non-TLS symbol %s")), input_bfd, input_section, - rel->r_offset, + (uint64_t) rel->r_offset, howto->name, name); } @@ -3968,9 +3973,9 @@ elf_m68k_relocate_section (bfd *output_bfd, { _bfd_error_handler /* xgettext:c-format */ - (_("%B(%A+%#Lx): reloc against `%s': error %d"), + (_("%pB(%pA+%#" PRIx64 "): reloc against `%s': error %d"), input_bfd, input_section, - rel->r_offset, name, (int) r); + (uint64_t) rel->r_offset, name, (int) r); return FALSE; } } @@ -4382,7 +4387,7 @@ bfd_m68k_elf32_create_embedded_relocs (bfd *abfd, struct bfd_link_info *info, /* We can only relocate absolute longword relocs at run time. */ if (ELF32_R_TYPE (irel->r_info) != (int) R_68K_32) { - *errmsg = _("unsupported reloc type"); + *errmsg = _("unsupported relocation type"); bfd_set_error (bfd_error_bad_value); goto error_return; } diff --git a/bfd/elf32-mcore.c b/bfd/elf32-mcore.c index 9334b1d..a88acae 100644 --- a/bfd/elf32-mcore.c +++ b/bfd/elf32-mcore.c @@ -97,10 +97,9 @@ mcore_elf_unsupported_reloc (bfd * abfd, BFD_ASSERT (reloc_entry->howto != (reloc_howto_type *)0); /* xgettext:c-format */ - _bfd_error_handler (_("%B: Relocation %s (%d) is not currently supported.\n"), + _bfd_error_handler (_("%pB: %s unsupported"), abfd, - reloc_entry->howto->name, - reloc_entry->howto->type); + reloc_entry->howto->name); return bfd_reloc_notsupported; } @@ -337,8 +336,8 @@ mcore_elf_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, /* Set the howto pointer for a RCE ELF reloc. */ -static void -mcore_elf_info_to_howto (bfd * abfd ATTRIBUTE_UNUSED, +static bfd_boolean +mcore_elf_info_to_howto (bfd * abfd, arelent * cache_ptr, Elf_Internal_Rela * dst) { @@ -352,13 +351,14 @@ mcore_elf_info_to_howto (bfd * abfd ATTRIBUTE_UNUSED, if (r_type >= R_MCORE_max) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: unrecognised MCore reloc number: %d"), + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), abfd, r_type); bfd_set_error (bfd_error_bad_value); - r_type = R_MCORE_NONE; + return FALSE; } cache_ptr->howto = mcore_elf_howto_table [r_type]; + return TRUE; } /* The RELOCATE_SECTION function is called by the ELF backend linker @@ -408,7 +408,7 @@ mcore_elf_relocate_section (bfd * output_bfd, #ifdef DEBUG _bfd_error_handler - ("mcore_elf_relocate_section called for %B section %A, %u relocations%s", + ("mcore_elf_relocate_section called for %pB section %pA, %u relocations%s", input_bfd, input_section, input_section->reloc_count, @@ -437,7 +437,7 @@ mcore_elf_relocate_section (bfd * output_bfd, || ! mcore_elf_howto_table [(int)r_type]) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: Unknown relocation type %d\n"), + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), input_bfd, (int) r_type); bfd_set_error (bfd_error_bad_value); @@ -452,10 +452,9 @@ mcore_elf_relocate_section (bfd * output_bfd, if (howto->special_function == mcore_elf_unsupported_reloc) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: Relocation %s (%d) is not currently supported.\n"), + _bfd_error_handler (_("%pB: %s unsupported"), input_bfd, - howto->name, - (int)r_type); + howto->name); bfd_set_error (bfd_error_bad_value); ret = FALSE; diff --git a/bfd/elf32-mep.c b/bfd/elf32-mep.c index d9d457b..5224d9a 100644 --- a/bfd/elf32-mep.c +++ b/bfd/elf32-mep.c @@ -375,11 +375,10 @@ mep_final_link_relocate /* Set the howto pointer for a MEP ELF reloc. */ -static void -mep_info_to_howto_rela - (bfd * abfd ATTRIBUTE_UNUSED, - arelent * cache_ptr, - Elf_Internal_Rela * dst) +static bfd_boolean +mep_info_to_howto_rela (bfd * abfd, + arelent * cache_ptr, + Elf_Internal_Rela * dst) { unsigned int r_type; @@ -387,10 +386,13 @@ mep_info_to_howto_rela if (r_type >= R_MEP_max) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: invalid MEP reloc number: %d"), abfd, r_type); - r_type = 0; + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; } cache_ptr->howto = & mep_elf_howto_table [r_type]; + return TRUE; } /* Relocate a MEP ELF section. @@ -585,7 +587,7 @@ mep_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) old_flags = elf_elfheader (obfd)->e_flags; #ifdef DEBUG - _bfd_error_handler ("%B: old_flags = 0x%.8x, new_flags = 0x%.8x, init = %s", + _bfd_error_handler ("%pB: old_flags = 0x%.8x, new_flags = 0x%.8x, init = %s", ibfd, old_flags, new_flags, elf_flags_init (obfd) ? "yes" : "no"); #endif @@ -617,7 +619,7 @@ mep_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) else { /* xgettext:c-format */ - _bfd_error_handler (_("%B and %B are for different cores"), + _bfd_error_handler (_("%pB and %pB are for different cores"), last_ibfd, ibfd); bfd_set_error (bfd_error_invalid_target); return FALSE; @@ -636,7 +638,7 @@ mep_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) else { /* xgettext:c-format */ - _bfd_error_handler (_("%B and %B are for different configurations"), + _bfd_error_handler (_("%pB and %pB are for different configurations"), last_ibfd, ibfd); bfd_set_error (bfd_error_invalid_target); return FALSE; diff --git a/bfd/elf32-metag.c b/bfd/elf32-metag.c index b985fc0..efe95bd 100644 --- a/bfd/elf32-metag.c +++ b/bfd/elf32-metag.c @@ -864,8 +864,8 @@ tpoff (struct bfd_link_info *info, bfd_vma address) elf_hash_table (info)->tls_sec->alignment_power)); } -static void -metag_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED, +static bfd_boolean +metag_info_to_howto_rela (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst) { @@ -875,10 +875,13 @@ metag_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED, if (r_type >= (unsigned int) R_METAG_MAX) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: invalid METAG reloc number: %d"), abfd, r_type); - r_type = 0; + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; } cache_ptr->howto = & elf_metag_howto_table [r_type]; + return TRUE; } static reloc_howto_type * @@ -1180,7 +1183,7 @@ metag_add_stub (const char *stub_name, if (hsh == NULL) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: cannot create stub entry %s"), + _bfd_error_handler (_("%pB: cannot create stub entry %s"), section->owner, stub_name); return NULL; } @@ -1857,10 +1860,10 @@ elf_metag_relocate_section (bfd *output_bfd, /* We don't support changing the TLS model. */ /* PR 20675 */ if (bfd_link_pic (info)) - _bfd_error_handler (_("%B(%A): multiple TLS models are not supported"), + _bfd_error_handler (_("%pB(%pA): multiple TLS models are not supported"), input_bfd, input_section); else - _bfd_error_handler (_("%B(%A): shared library symbol %s encountered whilst performing a static link"), + _bfd_error_handler (_("%pB(%pA): shared library symbol %s encountered whilst performing a static link"), input_bfd, input_section, name); return FALSE; } @@ -1913,8 +1916,10 @@ elf_metag_relocate_section (bfd *output_bfd, { _bfd_error_handler /* xgettext:c-format */ - (_("%B(%A+%#Lx): %s relocation not permitted in shared object"), - input_bfd, input_section, rel->r_offset, howto->name); + (_("%pB(%pA+%#" PRIx64 "): " + "%s relocation not permitted in shared object"), + input_bfd, input_section, (uint64_t) rel->r_offset, + howto->name); return FALSE; } else @@ -2249,7 +2254,7 @@ elf_metag_check_relocs (bfd *abfd, name = bfd_elf_sym_name (abfd, symtab_hdr, isym, NULL); _bfd_error_handler /* xgettext:c-format */ - (_("%B: relocation %s against `%s' can not be used when making a shared object; recompile with -fPIC"), + (_("%pB: relocation %s against `%s' can not be used when making a shared object; recompile with -fPIC"), abfd, elf_metag_howto_table[r_type].name, name); bfd_set_error (bfd_error_bad_value); return FALSE; @@ -2789,7 +2794,7 @@ maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) info->flags |= DF_TEXTREL; info->callbacks->minfo - (_("%B: dynamic relocation against `%T' in read-only section `%A'\n"), + (_("%pB: dynamic relocation against `%pT' in read-only section `%pA'\n"), sec->owner, h->root.root.string, sec); /* Not an error, just cut short the traversal. */ @@ -4141,7 +4146,7 @@ elf_metag_plt_sym_val (bfd_vma i, const asection *plt, #define elf_backend_finish_dynamic_sections elf_metag_finish_dynamic_sections #define elf_backend_size_dynamic_sections elf_metag_size_dynamic_sections #define elf_backend_omit_section_dynsym \ - ((bfd_boolean (*) (bfd *, struct bfd_link_info *, asection *)) bfd_true) + _bfd_elf_omit_section_dynsym_all #define elf_backend_post_process_headers elf_metag_post_process_headers #define elf_backend_reloc_type_class elf_metag_reloc_type_class #define elf_backend_copy_indirect_symbol elf_metag_copy_indirect_symbol diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c index f1808bc..3acf93a 100644 --- a/bfd/elf32-microblaze.c +++ b/bfd/elf32-microblaze.c @@ -638,8 +638,8 @@ microblaze_elf_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, /* Set the howto pointer for a RCE ELF reloc. */ -static void -microblaze_elf_info_to_howto (bfd * abfd ATTRIBUTE_UNUSED, +static bfd_boolean +microblaze_elf_info_to_howto (bfd * abfd, arelent * cache_ptr, Elf_Internal_Rela * dst) { @@ -653,13 +653,14 @@ microblaze_elf_info_to_howto (bfd * abfd ATTRIBUTE_UNUSED, if (r_type >= R_MICROBLAZE_max) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: unrecognised MicroBlaze reloc number: %d"), + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), abfd, r_type); bfd_set_error (bfd_error_bad_value); - r_type = R_MICROBLAZE_NONE; + return FALSE; } cache_ptr->howto = microblaze_elf_howto_table [r_type]; + return TRUE; } /* Microblaze ELF local labels start with 'L.' or '$L', not '.L'. */ @@ -929,7 +930,7 @@ microblaze_elf_relocate_section (bfd *output_bfd, if (r_type < 0 || r_type >= (int) R_MICROBLAZE_max) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: unknown relocation type %d"), + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), input_bfd, (int) r_type); bfd_set_error (bfd_error_bad_value); ret = FALSE; @@ -1061,8 +1062,8 @@ microblaze_elf_relocate_section (bfd *output_bfd, { _bfd_error_handler /* xgettext:c-format */ - (_("%B: The target (%s) of an %s relocation" - " is in the wrong section (%A)"), + (_("%pB: the target (%s) of an %s relocation" + " is in the wrong section (%pA)"), input_bfd, sym_name, microblaze_elf_howto_table[(int) r_type]->name, @@ -1109,8 +1110,8 @@ microblaze_elf_relocate_section (bfd *output_bfd, { _bfd_error_handler /* xgettext:c-format */ - (_("%B: The target (%s) of an %s relocation" - " is in the wrong section (%A)"), + (_("%pB: the target (%s) of an %s relocation" + " is in the wrong section (%pA)"), input_bfd, sym_name, microblaze_elf_howto_table[(int) r_type]->name, @@ -1479,7 +1480,7 @@ microblaze_elf_relocate_section (bfd *output_bfd, { BFD_FAIL (); _bfd_error_handler - (_("%B: probably compiled without -fPIC?"), + (_("%pB: probably compiled without -fPIC?"), input_bfd); bfd_set_error (bfd_error_bad_value); return FALSE; diff --git a/bfd/elf32-mips.c b/bfd/elf32-mips.c index fa0cc15..d6005ff 100644 --- a/bfd/elf32-mips.c +++ b/bfd/elf32-mips.c @@ -57,11 +57,9 @@ static bfd_reloc_status_type mips32_64bit_reloc (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup (bfd *, bfd_reloc_code_real_type); -static reloc_howto_type *mips_elf32_rtype_to_howto - (unsigned int, bfd_boolean); -static void mips_info_to_howto_rel +static bfd_boolean mips_info_to_howto_rel (bfd *, arelent *, Elf_Internal_Rela *); -static void mips_info_to_howto_rela +static bfd_boolean mips_info_to_howto_rela (bfd *, arelent *, Elf_Internal_Rela *); static bfd_boolean mips_elf_sym_is_global (bfd *, asymbol *); @@ -2196,7 +2194,8 @@ bfd_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, /* Given a MIPS Elf_Internal_Rel, fill in an arelent structure. */ static reloc_howto_type * -mips_elf32_rtype_to_howto (unsigned int r_type, +mips_elf32_rtype_to_howto (bfd *abfd, + unsigned int r_type, bfd_boolean rela_p ATTRIBUTE_UNUSED) { switch (r_type) @@ -2222,9 +2221,10 @@ mips_elf32_rtype_to_howto (unsigned int r_type, return &elf_mips16_howto_table_rel[r_type - R_MIPS16_min]; if (r_type >= (unsigned int) R_MIPS_max) { - _bfd_error_handler (_("Unrecognised MIPS reloc number: %d"), r_type); + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); bfd_set_error (bfd_error_bad_value); - r_type = R_MIPS_NONE; + return NULL; } return &elf_mips_howto_table_rel[r_type]; } @@ -2232,7 +2232,7 @@ mips_elf32_rtype_to_howto (unsigned int r_type, /* Given a MIPS Elf_Internal_Rel, fill in an arelent structure. */ -static void +static bfd_boolean mips_info_to_howto_rel (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst) { const struct elf_backend_data *bed; @@ -2240,7 +2240,14 @@ mips_info_to_howto_rel (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst) r_type = ELF32_R_TYPE (dst->r_info); bed = get_elf_backend_data (abfd); - cache_ptr->howto = bed->elf_backend_mips_rtype_to_howto (r_type, FALSE); + cache_ptr->howto = bed->elf_backend_mips_rtype_to_howto (abfd, r_type, FALSE); + if (cache_ptr->howto == NULL) + { + /* xgettext:c-format */ + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; + } /* The addend for a GPREL16 or LITERAL relocation comes from the GP value for the object file. We get the addend now, rather than @@ -2249,14 +2256,16 @@ mips_info_to_howto_rel (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst) if (((*cache_ptr->sym_ptr_ptr)->flags & BSF_SECTION_SYM) != 0 && (gprel16_reloc_p (r_type) || literal_reloc_p (r_type))) cache_ptr->addend = elf_gp (abfd); + + return TRUE; } /* Given a MIPS Elf_Internal_Rela, fill in an arelent structure. */ -static void +static bfd_boolean mips_info_to_howto_rela (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst) { - mips_info_to_howto_rel (abfd, cache_ptr, dst); + return mips_info_to_howto_rel (abfd, cache_ptr, dst); /* If we ever need to do any extra processing with dst->r_addend (the field omitted in an Elf_Internal_Rel) we can do it here. */ diff --git a/bfd/elf32-moxie.c b/bfd/elf32-moxie.c index 8c7a378..d8b549d 100644 --- a/bfd/elf32-moxie.c +++ b/bfd/elf32-moxie.c @@ -123,8 +123,8 @@ moxie_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, const char *r_name) /* Set the howto pointer for an MOXIE ELF reloc. */ -static void -moxie_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED, +static bfd_boolean +moxie_info_to_howto_rela (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst) { @@ -134,10 +134,13 @@ moxie_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED, if (r_type >= (unsigned int) R_MOXIE_max) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: invalid Moxie reloc number: %d"), abfd, r_type); - r_type = 0; + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; } cache_ptr->howto = & moxie_elf_howto_table [r_type]; + return TRUE; } /* Perform a single relocation. By default we use the standard BFD diff --git a/bfd/elf32-msp430.c b/bfd/elf32-msp430.c index 5ee32c4..2d351d3 100644 --- a/bfd/elf32-msp430.c +++ b/bfd/elf32-msp430.c @@ -631,8 +631,8 @@ bfd_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, /* Set the howto pointer for an MSP430 ELF reloc. */ -static void -msp430_info_to_howto_rela (bfd * abfd ATTRIBUTE_UNUSED, +static bfd_boolean +msp430_info_to_howto_rela (bfd * abfd, arelent * cache_ptr, Elf_Internal_Rela * dst) { @@ -645,20 +645,25 @@ msp430_info_to_howto_rela (bfd * abfd ATTRIBUTE_UNUSED, if (r_type >= (unsigned int) R_MSP430x_max) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: invalid MSP430X reloc number: %d"), abfd, r_type); - r_type = 0; + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; } cache_ptr->howto = elf_msp430x_howto_table + r_type; - return; } - - if (r_type >= (unsigned int) R_MSP430_max) + else if (r_type >= (unsigned int) R_MSP430_max) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: invalid MSP430 reloc number: %d"), abfd, r_type); - r_type = 0; + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; } - cache_ptr->howto = &elf_msp430_howto_table[r_type]; + else + cache_ptr->howto = &elf_msp430_howto_table[r_type]; + + return TRUE; } /* Look through the relocs for a section during the first phase. @@ -829,7 +834,7 @@ msp430_final_link_relocate (reloc_howto_type * howto, { info->callbacks->warning (info, - _("Try enabling relaxation to avoid relocation truncations"), + _("try enabling relaxation to avoid relocation truncations"), NULL, input_bfd, input_section, relocation); warned = TRUE; } @@ -1143,7 +1148,7 @@ msp430_final_link_relocate (reloc_howto_type * howto, { info->callbacks->warning (info, - _("Try enabling relaxation to avoid relocation truncations"), + _("try enabling relaxation to avoid relocation truncations"), NULL, input_bfd, input_section, relocation); warned = TRUE; } @@ -2349,7 +2354,7 @@ elf32_msp430_obj_attrs_handle_unknown (bfd *abfd, int tag) { _bfd_error_handler /* xgettext:c-format */ - (_("Warning: %B: Unknown MSPABI object attribute %d"), + (_("warning: %pB: unknown MSPABI object attribute %d"), abfd, tag); return TRUE; } @@ -2442,7 +2447,7 @@ elf32_msp430_merge_mspabi_attributes (bfd *ibfd, struct bfd_link_info *info) { _bfd_error_handler /* xgettext:c-format */ - (_("error: %B uses %s instructions but %B uses %s"), + (_("error: %pB uses %s instructions but %pB uses %s"), ibfd, isa_type (in_attr[OFBA_MSPABI_Tag_ISA].i), first_input_bfd, isa_type (out_attr[OFBA_MSPABI_Tag_ISA].i)); result = FALSE; @@ -2454,7 +2459,7 @@ elf32_msp430_merge_mspabi_attributes (bfd *ibfd, struct bfd_link_info *info) { _bfd_error_handler /* xgettext:c-format */ - (_("error: %B uses the %s code model whereas %B uses the %s code model"), + (_("error: %pB uses the %s code model whereas %pB uses the %s code model"), ibfd, code_model (in_attr[OFBA_MSPABI_Tag_Code_Model].i), first_input_bfd, code_model (out_attr[OFBA_MSPABI_Tag_Code_Model].i)); result = FALSE; @@ -2466,7 +2471,7 @@ elf32_msp430_merge_mspabi_attributes (bfd *ibfd, struct bfd_link_info *info) { _bfd_error_handler /* xgettext:c-format */ - (_("error: %B uses the large code model but %B uses MSP430 instructions"), + (_("error: %pB uses the large code model but %pB uses MSP430 instructions"), ibfd, first_input_bfd); result = FALSE; } @@ -2477,7 +2482,7 @@ elf32_msp430_merge_mspabi_attributes (bfd *ibfd, struct bfd_link_info *info) { _bfd_error_handler /* xgettext:c-format */ - (_("error: %B uses the %s data model whereas %B uses the %s data model"), + (_("error: %pB uses the %s data model whereas %pB uses the %s data model"), ibfd, data_model (in_attr[OFBA_MSPABI_Tag_Data_Model].i), first_input_bfd, data_model (out_attr[OFBA_MSPABI_Tag_Data_Model].i)); result = FALSE; @@ -2489,7 +2494,7 @@ elf32_msp430_merge_mspabi_attributes (bfd *ibfd, struct bfd_link_info *info) { _bfd_error_handler /* xgettext:c-format */ - (_("error: %B uses the small code model but %B uses the %s data model"), + (_("error: %pB uses the small code model but %pB uses the %s data model"), ibfd, first_input_bfd, data_model (out_attr[OFBA_MSPABI_Tag_Data_Model].i)); result = FALSE; @@ -2501,7 +2506,7 @@ elf32_msp430_merge_mspabi_attributes (bfd *ibfd, struct bfd_link_info *info) { _bfd_error_handler /* xgettext:c-format */ - (_("error: %B uses the %s data model but %B only uses MSP430 instructions"), + (_("error: %pB uses the %s data model but %pB only uses MSP430 instructions"), ibfd, data_model (in_attr[OFBA_MSPABI_Tag_Data_Model].i), first_input_bfd); result = FALSE; diff --git a/bfd/elf32-mt.c b/bfd/elf32-mt.c index b58394f..94c2fac 100644 --- a/bfd/elf32-mt.c +++ b/bfd/elf32-mt.c @@ -28,7 +28,7 @@ static reloc_howto_type * mt_reloc_type_lookup (bfd *, bfd_reloc_code_real_type); -static void mt_info_to_howto_rela +static bfd_boolean mt_info_to_howto_rela (bfd *, arelent *, Elf_Internal_Rela *); static bfd_reloc_status_type mt_elf_relocate_hi16 @@ -227,11 +227,10 @@ mt_elf_relocate_hi16 /* Set the howto pointer for a MT ELF reloc. */ -static void -mt_info_to_howto_rela - (bfd * abfd ATTRIBUTE_UNUSED, - arelent * cache_ptr, - Elf_Internal_Rela * dst) +static bfd_boolean +mt_info_to_howto_rela (bfd * abfd, + arelent * cache_ptr, + Elf_Internal_Rela * dst) { unsigned int r_type; @@ -239,10 +238,13 @@ mt_info_to_howto_rela if (r_type >= (unsigned int) R_MT_max) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: invalid MT reloc number: %d"), abfd, r_type); - r_type = 0; + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; } cache_ptr->howto = & mt_elf_howto_table [r_type]; + return TRUE; } /* Perform a single relocation. By default we use the standard BFD @@ -520,7 +522,7 @@ mt_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) old_flags = elf_elfheader (obfd)->e_flags; #ifdef DEBUG - _bfd_error_handler ("%B: old_flags = 0x%.8x, new_flags = 0x%.8x, init = %s", + _bfd_error_handler ("%pB: old_flags = 0x%.8x, new_flags = 0x%.8x, init = %s", ibfd, old_flags, new_flags, elf_flags_init (obfd) ? "yes" : "no"); #endif diff --git a/bfd/elf32-nds32.c b/bfd/elf32-nds32.c index 5ceb0a0..fad1379 100644 --- a/bfd/elf32-nds32.c +++ b/bfd/elf32-nds32.c @@ -20,6 +20,8 @@ 02110-1301, USA. */ +#pragma GCC diagnostic ignored "-Wstack-usage=" + #include "sysdep.h" #include "bfd.h" #include "bfd_stdint.h" @@ -33,6 +35,7 @@ #include "elf32-nds32.h" #include "opcode/cgen.h" #include "../opcodes/nds32-opc.h" +#include /* Relocation HOWTO functions. */ static bfd_reloc_status_type nds32_elf_ignore_reloc @@ -56,36 +59,72 @@ static bfd_reloc_status_type nds32_elf_sda15_reloc static bfd_reloc_status_type nds32_elf_do_9_pcrel_reloc (bfd *, reloc_howto_type *, asection *, bfd_byte *, bfd_vma, asection *, bfd_vma, bfd_vma); +static void nds32_elf_relocate_hi20 + (bfd *, int, Elf_Internal_Rela *, Elf_Internal_Rela *, bfd_byte *, bfd_vma); +static reloc_howto_type *bfd_elf32_bfd_reloc_type_table_lookup + (enum elf_nds32_reloc_type); +static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup + (bfd *, bfd_reloc_code_real_type); + +/* Target hooks. */ +static bfd_boolean nds32_info_to_howto_rel + (bfd *, arelent *, Elf_Internal_Rela *); +static bfd_boolean nds32_info_to_howto + (bfd *, arelent *, Elf_Internal_Rela *); +static bfd_boolean nds32_elf_add_symbol_hook + (bfd *, struct bfd_link_info *, Elf_Internal_Sym *, const char **, + flagword *, asection **, bfd_vma *); +static bfd_boolean nds32_elf_relocate_section + (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, + Elf_Internal_Rela *, Elf_Internal_Sym *, asection **); +static bfd_boolean nds32_elf_object_p (bfd *); +static void nds32_elf_final_write_processing (bfd *, bfd_boolean); +static bfd_boolean nds32_elf_set_private_flags (bfd *, flagword); +static bfd_boolean nds32_elf_merge_private_bfd_data (bfd *, struct bfd_link_info *); +static bfd_boolean nds32_elf_print_private_bfd_data (bfd *, void *); +static bfd_boolean nds32_elf_check_relocs + (bfd *, struct bfd_link_info *, asection *, const Elf_Internal_Rela *); +static asection *nds32_elf_gc_mark_hook + (asection *, struct bfd_link_info *, Elf_Internal_Rela *, + struct elf_link_hash_entry *, Elf_Internal_Sym *); +static bfd_boolean nds32_elf_adjust_dynamic_symbol + (struct bfd_link_info *, struct elf_link_hash_entry *); +static bfd_boolean nds32_elf_size_dynamic_sections + (bfd *, struct bfd_link_info *); +static bfd_boolean nds32_elf_create_dynamic_sections + (bfd *, struct bfd_link_info *); +static bfd_boolean nds32_elf_finish_dynamic_sections + (bfd *, struct bfd_link_info *info); +static bfd_boolean nds32_elf_finish_dynamic_symbol + (bfd *, struct bfd_link_info *, struct elf_link_hash_entry *, + Elf_Internal_Sym *); +static bfd_boolean nds32_elf_mkobject (bfd *); /* Nds32 helper functions. */ +static bfd_reloc_status_type nds32_elf_final_sda_base + (bfd *, struct bfd_link_info *, bfd_vma *, bfd_boolean); +static bfd_boolean allocate_dynrelocs (struct elf_link_hash_entry *, void *); +static bfd_boolean readonly_dynrelocs (struct elf_link_hash_entry *, void *); +static Elf_Internal_Rela *find_relocs_at_address + (Elf_Internal_Rela *, Elf_Internal_Rela *, + Elf_Internal_Rela *, enum elf_nds32_reloc_type); static bfd_vma calculate_memory_address -(bfd *, Elf_Internal_Rela *, Elf_Internal_Sym *, Elf_Internal_Shdr *); + (bfd *, Elf_Internal_Rela *, Elf_Internal_Sym *, Elf_Internal_Shdr *); static int nds32_get_section_contents (bfd *, asection *, bfd_byte **, bfd_boolean); -static bfd_boolean nds32_elf_ex9_build_hash_table -(bfd *, asection *, struct bfd_link_info *); -static bfd_boolean nds32_elf_ex9_itb_base (struct bfd_link_info *); -static void nds32_elf_ex9_import_table (struct bfd_link_info *); -static void nds32_elf_ex9_finish (struct bfd_link_info *); -static void nds32_elf_ex9_reloc_jmp (struct bfd_link_info *); -static void nds32_elf_get_insn_with_reg - (Elf_Internal_Rela *, uint32_t, uint32_t *); static int nds32_get_local_syms (bfd *, asection *ATTRIBUTE_UNUSED, Elf_Internal_Sym **); -static bfd_boolean nds32_elf_ex9_replace_instruction - (struct bfd_link_info *, bfd *, asection *); -static bfd_boolean nds32_elf_ifc_calc (struct bfd_link_info *, bfd *, - asection *); -static bfd_boolean nds32_elf_ifc_finish (struct bfd_link_info *); -static bfd_boolean nds32_elf_ifc_replace (struct bfd_link_info *); -static bfd_boolean nds32_elf_ifc_reloc (void); -static bfd_boolean nds32_relax_fp_as_gp - (struct bfd_link_info *link_info, bfd *abfd, asection *sec, - Elf_Internal_Rela *internal_relocs, Elf_Internal_Rela *irelend, - Elf_Internal_Sym *isymbuf); +static bfd_boolean nds32_relax_fp_as_gp + (struct bfd_link_info *, bfd *, asection *, Elf_Internal_Rela *, + Elf_Internal_Rela *, Elf_Internal_Sym *); static bfd_boolean nds32_fag_remove_unused_fpbase - (bfd *abfd, asection *sec, Elf_Internal_Rela *internal_relocs, - Elf_Internal_Rela *irelend); + (bfd *, asection *, Elf_Internal_Rela *, Elf_Internal_Rela *); +static bfd_byte *nds32_elf_get_relocated_section_contents + (bfd *, struct bfd_link_info *, struct bfd_link_order *, bfd_byte *, + bfd_boolean, asymbol **); +static void nds32_elf_ict_hash_init (void); +static void nds32_elf_ict_relocate (bfd *, struct bfd_link_info *); +static asection* nds32_elf_get_target_section (struct bfd_link_info *, char *); enum { @@ -95,13 +134,24 @@ enum MACH_V3M = bfd_mach_n1h_v3m }; +/* If ABI is set by the option --mabi, without + checking the ABI compatible. */ +static char *output_abi; + #define MIN(a, b) ((a) > (b) ? (b) : (a)) #define MAX(a, b) ((a) > (b) ? (a) : (b)) +/* True if insn is 4byte. */ +#define INSN_32BIT(insn) ((((insn) & 0x80000000) == 0 ? (TRUE) : (FALSE))) + /* The name of the dynamic interpreter. This is put in the .interp section. */ #define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so.1" +#define NDS32_GUARD_SEC_P(flags) ((flags) & SEC_ALLOC \ + && (flags) & SEC_LOAD \ + && (flags) & SEC_READONLY) + /* The nop opcode we use. */ #define NDS32_NOP32 0x40000009 #define NDS32_NOP16 0x9200 @@ -113,32 +163,32 @@ enum /* The first entry in a procedure linkage table are reserved, and the initial contents are unimportant (we zero them out). Subsequent entries look like this. */ -#define PLT0_ENTRY_WORD0 0x46f00000 /* sethi r15, HI20(.got+4) */ -#define PLT0_ENTRY_WORD1 0x58f78000 /* ori r15, r25, LO12(.got+4) */ -#define PLT0_ENTRY_WORD2 0x05178000 /* lwi r17, [r15+0] */ -#define PLT0_ENTRY_WORD3 0x04f78001 /* lwi r15, [r15+4] */ -#define PLT0_ENTRY_WORD4 0x4a003c00 /* jr r15 */ +#define PLT0_ENTRY_WORD0 0x46f00000 /* sethi r15, HI20(.got+4) */ +#define PLT0_ENTRY_WORD1 0x58f78000 /* ori r15, r25, LO12(.got+4) */ +#define PLT0_ENTRY_WORD2 0x05178000 /* lwi r17, [r15+0] */ +#define PLT0_ENTRY_WORD3 0x04f78001 /* lwi r15, [r15+4] */ +#define PLT0_ENTRY_WORD4 0x4a003c00 /* jr r15 */ /* $ta is change to $r15 (from $r25). */ #define PLT0_PIC_ENTRY_WORD0 0x46f00000 /* sethi r15, HI20(got[1]@GOT) */ -#define PLT0_PIC_ENTRY_WORD1 0x58f78000 /* ori r15, r15, LO12(got[1]@GOT) */ -#define PLT0_PIC_ENTRY_WORD2 0x40f7f400 /* add r15, gp, r15 */ -#define PLT0_PIC_ENTRY_WORD3 0x05178000 /* lwi r17, [r15+0] */ -#define PLT0_PIC_ENTRY_WORD4 0x04f78001 /* lwi r15, [r15+4] */ -#define PLT0_PIC_ENTRY_WORD5 0x4a003c00 /* jr r15 */ - -#define PLT_ENTRY_WORD0 0x46f00000 /* sethi r15, HI20(&got[n+3]) */ -#define PLT_ENTRY_WORD1 0x04f78000 /* lwi r15, r15, LO12(&got[n+3]) */ -#define PLT_ENTRY_WORD2 0x4a003c00 /* jr r15 */ -#define PLT_ENTRY_WORD3 0x45000000 /* movi r16, sizeof(RELA) * n */ -#define PLT_ENTRY_WORD4 0x48000000 /* j .plt0. */ - -#define PLT_PIC_ENTRY_WORD0 0x46f00000 /* sethi r15, HI20(got[n+3]@GOT) */ -#define PLT_PIC_ENTRY_WORD1 0x58f78000 /* ori r15, r15, LO12(got[n+3]@GOT) */ -#define PLT_PIC_ENTRY_WORD2 0x38febc02 /* lw r15, [gp+r15] */ -#define PLT_PIC_ENTRY_WORD3 0x4a003c00 /* jr r15 */ -#define PLT_PIC_ENTRY_WORD4 0x45000000 /* movi r16, sizeof(RELA) * n */ -#define PLT_PIC_ENTRY_WORD5 0x48000000 /* j .plt0 */ +#define PLT0_PIC_ENTRY_WORD1 0x58f78000 /* ori r15, r15, LO12(got[1]@GOT) */ +#define PLT0_PIC_ENTRY_WORD2 0x40f7f400 /* add r15, gp, r15 */ +#define PLT0_PIC_ENTRY_WORD3 0x05178000 /* lwi r17, [r15+0] */ +#define PLT0_PIC_ENTRY_WORD4 0x04f78001 /* lwi r15, [r15+4] */ +#define PLT0_PIC_ENTRY_WORD5 0x4a003c00 /* jr r15 */ + +#define PLT_ENTRY_WORD0 0x46f00000 /* sethi r15, HI20(&got[n+3]) */ +#define PLT_ENTRY_WORD1 0x04f78000 /* lwi r15, r15, LO12(&got[n+3]) */ +#define PLT_ENTRY_WORD2 0x4a003c00 /* jr r15 */ +#define PLT_ENTRY_WORD3 0x45000000 /* movi r16, sizeof(RELA) * n */ +#define PLT_ENTRY_WORD4 0x48000000 /* j .plt0 */ + +#define PLT_PIC_ENTRY_WORD0 0x46f00000 /* sethi r15, HI20(got[n+3]@GOT) */ +#define PLT_PIC_ENTRY_WORD1 0x58f78000 /* ori r15, r15, LO12(got[n+3]@GOT) */ +#define PLT_PIC_ENTRY_WORD2 0x38febc02 /* lw r15, [gp+r15] */ +#define PLT_PIC_ENTRY_WORD3 0x4a003c00 /* jr r15 */ +#define PLT_PIC_ENTRY_WORD4 0x45000000 /* movi r16, sizeof(RELA) * n */ +#define PLT_PIC_ENTRY_WORD5 0x48000000 /* j .plt0 */ /* These are macros used to get the relocation accurate value. */ #define ACCURATE_8BIT_S1 (0x100) @@ -160,10 +210,11 @@ enum #define CONSERVATIVE_19BIT (0x40000 - 0x1000) #define CONSERVATIVE_20BIT (0x80000 - 0x1000) +#define NDS32_ICT_SECTION ".nds32.ict" + /* Size of small data/bss sections, used to calculate SDA_BASE. */ static long got_size = 0; static int is_SDA_BASE_set = 0; -static int is_ITB_BASE_set = 0; /* Convert ELF-VER in eflags to string for debugging purpose. */ static const char *const nds32_elfver_strtab[] = @@ -192,37 +243,108 @@ struct elf_nds32_pcrel_relocs_copied bfd_size_type count; }; +/* The sh linker needs to keep track of the number of relocs that it + decides to copy as dynamic relocs in check_relocs for each symbol. + This is so that it can later discard them if they are found to be + unnecessary. We store the information in a field extending the + regular ELF linker hash table. */ + +struct elf_nds32_dyn_relocs +{ + struct elf_nds32_dyn_relocs *next; + + /* The input section of the reloc. */ + asection *sec; + + /* Total number of relocs copied for the input section. */ + bfd_size_type count; + + /* Number of pc-relative relocs copied for the input section. */ + bfd_size_type pc_count; +}; + /* Nds32 ELF linker hash entry. */ +enum elf_nds32_tls_type +{ + GOT_UNKNOWN = (0), + GOT_NORMAL = (1 << 0), + GOT_TLS_LE = (1 << 1), + GOT_TLS_IE = (1 << 2), + GOT_TLS_IEGP = (1 << 3), + GOT_TLS_LD = (1 << 4), + GOT_TLS_GD = (1 << 5), + GOT_TLS_DESC = (1 << 6), +}; + struct elf_nds32_link_hash_entry { struct elf_link_hash_entry root; /* Track dynamic relocs copied for this symbol. */ - struct elf_dyn_relocs *dyn_relocs; + struct elf_nds32_dyn_relocs *dyn_relocs; /* For checking relocation type. */ -#define GOT_UNKNOWN 0 -#define GOT_NORMAL 1 -#define GOT_TLS_IE 2 - unsigned int tls_type; + enum elf_nds32_tls_type tls_type; + + int offset_to_gp; + + /* For saving function attribute indirect_call and entry address. */ + bfd_boolean indirect_call; }; /* Get the nds32 ELF linker hash table from a link_info structure. */ #define FP_BASE_NAME "_FP_BASE_" static int check_start_export_sym = 0; -static size_t ex9_relax_size = 0; /* Save ex9 predicted reducing size. */ +/* File for exporting indirect call table. */ +static FILE *ict_file = NULL; +/* Save object ict model. */ +static unsigned int ict_model = 0; +/* True if _INDIRECT_CALL_TABLE_BASE_ is defined. */ +static bfd_boolean ignore_indirect_call = FALSE; +/* Be used to set ifc bit in elf header. */ +static bfd_boolean ifc_flag = FALSE; + +/* Rom-patch symbol hash table. */ +struct elf_nds32_ict_hash_entry +{ + struct bfd_hash_entry root; + struct elf_link_hash_entry *h; + unsigned int order; +}; + +/* Rom-patch hash table. */ +static struct bfd_hash_table indirect_call_table; /* The offset for executable tls relaxation. */ #define TP_OFFSET 0x0 +typedef struct +{ + int min_id; + int max_id; + int count; + int bias; + int init; +} elf32_nds32_relax_group_t; + struct elf_nds32_obj_tdata { struct elf_obj_tdata root; /* tls_type for each local got entry. */ char *local_got_tls_type; + + unsigned int hdr_size; + + /* GOTPLT entries for TLS descriptors. */ + bfd_vma *local_tlsdesc_gotent; + + int* offset_to_gp; + + /* for R_NDS32_RELAX_GROUP handling. */ + elf32_nds32_relax_group_t relax_group; }; #define elf_nds32_tdata(bfd) \ @@ -231,6 +353,12 @@ struct elf_nds32_obj_tdata #define elf32_nds32_local_got_tls_type(bfd) \ (elf_nds32_tdata (bfd)->local_got_tls_type) +#define elf32_nds32_local_gp_offset(bfd) \ + (elf_nds32_tdata (bfd)->offset_to_gp) + +#define elf32_nds32_relax_group_ptr(bfd) \ + &(elf_nds32_tdata (bfd)->relax_group) + #define elf32_nds32_hash_entry(ent) ((struct elf_nds32_link_hash_entry *)(ent)) static bfd_boolean @@ -240,68 +368,75 @@ nds32_elf_mkobject (bfd *abfd) NDS32_ELF_DATA); } + /* Relocations used for relocation. */ -static reloc_howto_type nds32_elf_howto_table[] = -{ +/* NOTE! + the index order must be the same with elf_nds32_reloc_type in + include/elf/nds32.h + */ +#define HOWTO2(C, R, S, B, P, BI, O, SF, NAME, INPLACE, MASKSRC, MASKDST, PC) \ + [C] = HOWTO(C, R, S, B, P, BI, O, SF, NAME, INPLACE, MASKSRC, MASKDST, PC) + +static reloc_howto_type nds32_elf_howto_table[] = { /* This reloc does nothing. */ - HOWTO (R_NDS32_NONE, /* type */ - 0, /* rightshift */ - 3, /* size (0 = byte, 1 = short, 2 = long) */ - 0, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_NONE", /* name */ - FALSE, /* partial_inplace */ - 0, /* src_mask */ - 0, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_NONE, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_bitfield,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_NONE", /* name */ + FALSE, /* partial_inplace */ + 0, /* src_mask */ + 0, /* dst_mask */ + FALSE), /* pcrel_offset */ /* A 16 bit absolute relocation. */ - HOWTO (R_NDS32_16, /* type */ - 0, /* rightshift */ - 1, /* size (0 = byte, 1 = short, 2 = long) */ - 16, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_bitfield, /* complain_on_overflow */ - nds32_elf_generic_reloc, /* special_function */ - "R_NDS32_16", /* name */ - FALSE, /* partial_inplace */ - 0xffff, /* src_mask */ - 0xffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_16, /* type */ + 0, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_bitfield,/* complain_on_overflow */ + nds32_elf_generic_reloc,/* special_function */ + "R_NDS32_16", /* name */ + FALSE, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* A 32 bit absolute relocation. */ - HOWTO (R_NDS32_32, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_bitfield, /* complain_on_overflow */ - nds32_elf_generic_reloc, /* special_function */ - "R_NDS32_32", /* name */ - FALSE, /* partial_inplace */ - 0xffffffff, /* src_mask */ - 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_32, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_bitfield,/* complain_on_overflow */ + nds32_elf_generic_reloc,/* special_function */ + "R_NDS32_32", /* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* A 20 bit address. */ - HOWTO (R_NDS32_20, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 20, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_unsigned, /* complain_on_overflow */ - nds32_elf_generic_reloc, /* special_function */ - "R_NDS32_20", /* name */ - FALSE, /* partial_inplace */ - 0xfffff, /* src_mask */ - 0xfffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_20, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 20, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_unsigned,/* complain_on_overflow */ + nds32_elf_generic_reloc,/* special_function */ + "R_NDS32_20", /* name */ + FALSE, /* partial_inplace */ + 0xfffff, /* src_mask */ + 0xfffff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* An PC Relative 9-bit relocation, shifted by 2. This reloc is complicated because relocations are relative to pc & -4. @@ -311,1910 +446,2264 @@ static reloc_howto_type nds32_elf_howto_table[] = Branch relaxing in the assembler can store the addend in the insn, and if bfd_install_relocation gets called the addend may get added again. */ - HOWTO (R_NDS32_9_PCREL, /* type */ - 1, /* rightshift */ - 1, /* size (0 = byte, 1 = short, 2 = long) */ - 8, /* bitsize */ - TRUE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_signed, /* complain_on_overflow */ - nds32_elf_9_pcrel_reloc, /* special_function */ - "R_NDS32_9_PCREL", /* name */ - FALSE, /* partial_inplace */ - 0xff, /* src_mask */ - 0xff, /* dst_mask */ - TRUE), /* pcrel_offset */ + HOWTO2 (R_NDS32_9_PCREL, /* type */ + 1, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 8, /* bitsize */ + TRUE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed,/* complain_on_overflow */ + nds32_elf_9_pcrel_reloc,/* special_function */ + "R_NDS32_9_PCREL", /* name */ + FALSE, /* partial_inplace */ + 0xff, /* src_mask */ + 0xff, /* dst_mask */ + TRUE), /* pcrel_offset */ /* A relative 15 bit relocation, right shifted by 1. */ - HOWTO (R_NDS32_15_PCREL, /* type */ - 1, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 14, /* bitsize */ - TRUE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_15_PCREL", /* name */ - FALSE, /* partial_inplace */ - 0x3fff, /* src_mask */ - 0x3fff, /* dst_mask */ - TRUE), /* pcrel_offset */ + HOWTO2 (R_NDS32_15_PCREL, /* type */ + 1, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 14, /* bitsize */ + TRUE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_15_PCREL", /* name */ + FALSE, /* partial_inplace */ + 0x3fff, /* src_mask */ + 0x3fff, /* dst_mask */ + TRUE), /* pcrel_offset */ /* A relative 17 bit relocation, right shifted by 1. */ - HOWTO (R_NDS32_17_PCREL, /* type */ - 1, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 16, /* bitsize */ - TRUE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_17_PCREL", /* name */ - FALSE, /* partial_inplace */ - 0xffff, /* src_mask */ - 0xffff, /* dst_mask */ - TRUE), /* pcrel_offset */ + HOWTO2 (R_NDS32_17_PCREL, /* type */ + 1, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + TRUE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_17_PCREL", /* name */ + FALSE, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + TRUE), /* pcrel_offset */ /* A relative 25 bit relocation, right shifted by 1. */ /* ??? It's not clear whether this should have partial_inplace set or not. Branch relaxing in the assembler can store the addend in the insn, and if bfd_install_relocation gets called the addend may get added again. */ - HOWTO (R_NDS32_25_PCREL, /* type */ - 1, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 24, /* bitsize */ - TRUE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_25_PCREL", /* name */ - FALSE, /* partial_inplace */ - 0xffffff, /* src_mask */ - 0xffffff, /* dst_mask */ - TRUE), /* pcrel_offset */ + HOWTO2 (R_NDS32_25_PCREL, /* type */ + 1, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 24, /* bitsize */ + TRUE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_25_PCREL", /* name */ + FALSE, /* partial_inplace */ + 0xffffff, /* src_mask */ + 0xffffff, /* dst_mask */ + TRUE), /* pcrel_offset */ /* High 20 bits of address when lower 12 is or'd in. */ - HOWTO (R_NDS32_HI20, /* type */ - 12, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 20, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - nds32_elf_hi20_reloc, /* special_function */ - "R_NDS32_HI20", /* name */ - FALSE, /* partial_inplace */ - 0x000fffff, /* src_mask */ - 0x000fffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_HI20, /* type */ + 12, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 20, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_hi20_reloc, /* special_function */ + "R_NDS32_HI20", /* name */ + FALSE, /* partial_inplace */ + 0x000fffff, /* src_mask */ + 0x000fffff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Lower 12 bits of address. */ - HOWTO (R_NDS32_LO12S3, /* type */ - 3, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 9, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - nds32_elf_lo12_reloc, /* special_function */ - "R_NDS32_LO12S3", /* name */ - FALSE, /* partial_inplace */ - 0x000001ff, /* src_mask */ - 0x000001ff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_LO12S3, /* type */ + 3, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 9, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_lo12_reloc, /* special_function */ + "R_NDS32_LO12S3", /* name */ + FALSE, /* partial_inplace */ + 0x000001ff, /* src_mask */ + 0x000001ff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Lower 12 bits of address. */ - HOWTO (R_NDS32_LO12S2, /* type */ - 2, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 10, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - nds32_elf_lo12_reloc, /* special_function */ - "R_NDS32_LO12S2", /* name */ - FALSE, /* partial_inplace */ - 0x000003ff, /* src_mask */ - 0x000003ff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_LO12S2, /* type */ + 2, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 10, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_lo12_reloc, /* special_function */ + "R_NDS32_LO12S2", /* name */ + FALSE, /* partial_inplace */ + 0x000003ff, /* src_mask */ + 0x000003ff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Lower 12 bits of address. */ - HOWTO (R_NDS32_LO12S1, /* type */ - 1, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 11, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - nds32_elf_lo12_reloc, /* special_function */ - "R_NDS32_LO12S1", /* name */ - FALSE, /* partial_inplace */ - 0x000007ff, /* src_mask */ - 0x000007ff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_LO12S1, /* type */ + 1, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 11, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_lo12_reloc, /* special_function */ + "R_NDS32_LO12S1", /* name */ + FALSE, /* partial_inplace */ + 0x000007ff, /* src_mask */ + 0x000007ff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Lower 12 bits of address. */ - HOWTO (R_NDS32_LO12S0, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 12, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - nds32_elf_lo12_reloc, /* special_function */ - "R_NDS32_LO12S0", /* name */ - FALSE, /* partial_inplace */ - 0x00000fff, /* src_mask */ - 0x00000fff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_LO12S0, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 12, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_lo12_reloc, /* special_function */ + "R_NDS32_LO12S0", /* name */ + FALSE, /* partial_inplace */ + 0x00000fff, /* src_mask */ + 0x00000fff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Small data area 15 bits offset. */ - HOWTO (R_NDS32_SDA15S3, /* type */ - 3, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 15, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_signed, /* complain_on_overflow */ - nds32_elf_sda15_reloc, /* special_function */ - "R_NDS32_SDA15S3", /* name */ - FALSE, /* partial_inplace */ - 0x00007fff, /* src_mask */ - 0x00007fff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_SDA15S3, /* type */ + 3, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 15, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed,/* complain_on_overflow */ + nds32_elf_sda15_reloc, /* special_function */ + "R_NDS32_SDA15S3", /* name */ + FALSE, /* partial_inplace */ + 0x00007fff, /* src_mask */ + 0x00007fff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Small data area 15 bits offset. */ - HOWTO (R_NDS32_SDA15S2, /* type */ - 2, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 15, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_signed, /* complain_on_overflow */ - nds32_elf_sda15_reloc, /* special_function */ - "R_NDS32_SDA15S2", /* name */ - FALSE, /* partial_inplace */ - 0x00007fff, /* src_mask */ - 0x00007fff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_SDA15S2, /* type */ + 2, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 15, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed,/* complain_on_overflow */ + nds32_elf_sda15_reloc, /* special_function */ + "R_NDS32_SDA15S2", /* name */ + FALSE, /* partial_inplace */ + 0x00007fff, /* src_mask */ + 0x00007fff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Small data area 15 bits offset. */ - HOWTO (R_NDS32_SDA15S1, /* type */ - 1, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 15, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_signed, /* complain_on_overflow */ - nds32_elf_sda15_reloc, /* special_function */ - "R_NDS32_SDA15S1", /* name */ - FALSE, /* partial_inplace */ - 0x00007fff, /* src_mask */ - 0x00007fff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_SDA15S1, /* type */ + 1, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 15, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed,/* complain_on_overflow */ + nds32_elf_sda15_reloc, /* special_function */ + "R_NDS32_SDA15S1", /* name */ + FALSE, /* partial_inplace */ + 0x00007fff, /* src_mask */ + 0x00007fff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Small data area 15 bits offset. */ - HOWTO (R_NDS32_SDA15S0, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 15, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_signed, /* complain_on_overflow */ - nds32_elf_sda15_reloc, /* special_function */ - "R_NDS32_SDA15S0", /* name */ - FALSE, /* partial_inplace */ - 0x00007fff, /* src_mask */ - 0x00007fff, /* dst_mask */ - FALSE), /* pcrel_offset */ - - /* GNU extension to record C++ vtable hierarchy */ - HOWTO (R_NDS32_GNU_VTINHERIT, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 0, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - NULL, /* special_function */ - "R_NDS32_GNU_VTINHERIT", /* name */ - FALSE, /* partial_inplace */ - 0, /* src_mask */ - 0, /* dst_mask */ - FALSE), /* pcrel_offset */ - - /* GNU extension to record C++ vtable member usage */ - HOWTO (R_NDS32_GNU_VTENTRY, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 0, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - _bfd_elf_rel_vtable_reloc_fn, /* special_function */ - "R_NDS32_GNU_VTENTRY", /* name */ - FALSE, /* partial_inplace */ - 0, /* src_mask */ - 0, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_SDA15S0, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 15, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed,/* complain_on_overflow */ + nds32_elf_sda15_reloc, /* special_function */ + "R_NDS32_SDA15S0", /* name */ + FALSE, /* partial_inplace */ + 0x00007fff, /* src_mask */ + 0x00007fff, /* dst_mask */ + FALSE), /* pcrel_offset */ + + /* GNU extension to record C++ vtable hierarchy */ + HOWTO2 (R_NDS32_GNU_VTINHERIT,/* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 0, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + NULL, /* special_function */ + "R_NDS32_GNU_VTINHERIT",/* name */ + FALSE, /* partial_inplace */ + 0, /* src_mask */ + 0, /* dst_mask */ + FALSE), /* pcrel_offset */ + + /* GNU extension to record C++ vtable member usage */ + HOWTO2 (R_NDS32_GNU_VTENTRY, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 0, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + _bfd_elf_rel_vtable_reloc_fn,/* special_function */ + "R_NDS32_GNU_VTENTRY", /* name */ + FALSE, /* partial_inplace */ + 0, /* src_mask */ + 0, /* dst_mask */ + FALSE), /* pcrel_offset */ /* A 16 bit absolute relocation. */ - HOWTO (R_NDS32_16_RELA, /* type */ - 0, /* rightshift */ - 1, /* size (0 = byte, 1 = short, 2 = long) */ - 16, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_bitfield, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_16_RELA", /* name */ - FALSE, /* partial_inplace */ - 0xffff, /* src_mask */ - 0xffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_16_RELA, /* type */ + 0, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_bitfield,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_16_RELA", /* name */ + FALSE, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* A 32 bit absolute relocation. */ - HOWTO (R_NDS32_32_RELA, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_bitfield, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_32_RELA", /* name */ - FALSE, /* partial_inplace */ - 0xffffffff, /* src_mask */ - 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_32_RELA, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_bitfield,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_32_RELA", /* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* A 20 bit address. */ - HOWTO (R_NDS32_20_RELA, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 20, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_20_RELA", /* name */ - FALSE, /* partial_inplace */ - 0xfffff, /* src_mask */ - 0xfffff, /* dst_mask */ - FALSE), /* pcrel_offset */ - - HOWTO (R_NDS32_9_PCREL_RELA, /* type */ - 1, /* rightshift */ - 1, /* size (0 = byte, 1 = short, 2 = long) */ - 8, /* bitsize */ - TRUE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_9_PCREL_RELA",/* name */ - FALSE, /* partial_inplace */ - 0xff, /* src_mask */ - 0xff, /* dst_mask */ - TRUE), /* pcrel_offset */ + HOWTO2 (R_NDS32_20_RELA, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 20, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_20_RELA", /* name */ + FALSE, /* partial_inplace */ + 0xfffff, /* src_mask */ + 0xfffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + + HOWTO2 (R_NDS32_9_PCREL_RELA, /* type */ + 1, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 8, /* bitsize */ + TRUE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_9_PCREL_RELA",/* name */ + FALSE, /* partial_inplace */ + 0xff, /* src_mask */ + 0xff, /* dst_mask */ + TRUE), /* pcrel_offset */ /* A relative 15 bit relocation, right shifted by 1. */ - HOWTO (R_NDS32_15_PCREL_RELA, /* type */ - 1, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 14, /* bitsize */ - TRUE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_15_PCREL_RELA", /* name */ - FALSE, /* partial_inplace */ - 0x3fff, /* src_mask */ - 0x3fff, /* dst_mask */ - TRUE), /* pcrel_offset */ + HOWTO2 (R_NDS32_15_PCREL_RELA,/* type */ + 1, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 14, /* bitsize */ + TRUE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_15_PCREL_RELA",/* name */ + FALSE, /* partial_inplace */ + 0x3fff, /* src_mask */ + 0x3fff, /* dst_mask */ + TRUE), /* pcrel_offset */ /* A relative 17 bit relocation, right shifted by 1. */ - HOWTO (R_NDS32_17_PCREL_RELA, /* type */ - 1, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 16, /* bitsize */ - TRUE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_17_PCREL_RELA", /* name */ - FALSE, /* partial_inplace */ - 0xffff, /* src_mask */ - 0xffff, /* dst_mask */ - TRUE), /* pcrel_offset */ + HOWTO2 (R_NDS32_17_PCREL_RELA,/* type */ + 1, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + TRUE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_17_PCREL_RELA",/* name */ + FALSE, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + TRUE), /* pcrel_offset */ /* A relative 25 bit relocation, right shifted by 2. */ - HOWTO (R_NDS32_25_PCREL_RELA, /* type */ - 1, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 24, /* bitsize */ - TRUE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_25_PCREL_RELA", /* name */ - FALSE, /* partial_inplace */ - 0xffffff, /* src_mask */ - 0xffffff, /* dst_mask */ - TRUE), /* pcrel_offset */ + HOWTO2 (R_NDS32_25_PCREL_RELA,/* type */ + 1, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 24, /* bitsize */ + TRUE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_25_PCREL_RELA",/* name */ + FALSE, /* partial_inplace */ + 0xffffff, /* src_mask */ + 0xffffff, /* dst_mask */ + TRUE), /* pcrel_offset */ /* High 20 bits of address when lower 16 is or'd in. */ - HOWTO (R_NDS32_HI20_RELA, /* type */ - 12, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 20, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_HI20_RELA", /* name */ - FALSE, /* partial_inplace */ - 0x000fffff, /* src_mask */ - 0x000fffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_HI20_RELA, /* type */ + 12, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 20, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_HI20_RELA", /* name */ + FALSE, /* partial_inplace */ + 0x000fffff, /* src_mask */ + 0x000fffff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Lower 12 bits of address. */ - HOWTO (R_NDS32_LO12S3_RELA, /* type */ - 3, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 9, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_LO12S3_RELA", /* name */ - FALSE, /* partial_inplace */ - 0x000001ff, /* src_mask */ - 0x000001ff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_LO12S3_RELA, /* type */ + 3, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 9, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_LO12S3_RELA", /* name */ + FALSE, /* partial_inplace */ + 0x000001ff, /* src_mask */ + 0x000001ff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Lower 12 bits of address. */ - HOWTO (R_NDS32_LO12S2_RELA, /* type */ - 2, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 10, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_LO12S2_RELA", /* name */ - FALSE, /* partial_inplace */ - 0x000003ff, /* src_mask */ - 0x000003ff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_LO12S2_RELA, /* type */ + 2, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 10, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_LO12S2_RELA", /* name */ + FALSE, /* partial_inplace */ + 0x000003ff, /* src_mask */ + 0x000003ff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Lower 12 bits of address. */ - HOWTO (R_NDS32_LO12S1_RELA, /* type */ - 1, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 11, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_LO12S1_RELA", /* name */ - FALSE, /* partial_inplace */ - 0x000007ff, /* src_mask */ - 0x000007ff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_LO12S1_RELA, /* type */ + 1, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 11, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_LO12S1_RELA", /* name */ + FALSE, /* partial_inplace */ + 0x000007ff, /* src_mask */ + 0x000007ff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Lower 12 bits of address. */ - HOWTO (R_NDS32_LO12S0_RELA, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 12, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_LO12S0_RELA", /* name */ - FALSE, /* partial_inplace */ - 0x00000fff, /* src_mask */ - 0x00000fff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_LO12S0_RELA, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 12, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_LO12S0_RELA", /* name */ + FALSE, /* partial_inplace */ + 0x00000fff, /* src_mask */ + 0x00000fff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Small data area 15 bits offset. */ - HOWTO (R_NDS32_SDA15S3_RELA, /* type */ - 3, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 15, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_SDA15S3_RELA",/* name */ - FALSE, /* partial_inplace */ - 0x00007fff, /* src_mask */ - 0x00007fff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_SDA15S3_RELA, /* type */ + 3, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 15, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_SDA15S3_RELA",/* name */ + FALSE, /* partial_inplace */ + 0x00007fff, /* src_mask */ + 0x00007fff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Small data area 15 bits offset. */ - HOWTO (R_NDS32_SDA15S2_RELA, /* type */ - 2, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 15, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_SDA15S2_RELA",/* name */ - FALSE, /* partial_inplace */ - 0x00007fff, /* src_mask */ - 0x00007fff, /* dst_mask */ - FALSE), /* pcrel_offset */ - - HOWTO (R_NDS32_SDA15S1_RELA, /* type */ - 1, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 15, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_SDA15S1_RELA",/* name */ - FALSE, /* partial_inplace */ - 0x00007fff, /* src_mask */ - 0x00007fff, /* dst_mask */ - FALSE), /* pcrel_offset */ - - HOWTO (R_NDS32_SDA15S0_RELA, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 15, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_SDA15S0_RELA",/* name */ - FALSE, /* partial_inplace */ - 0x00007fff, /* src_mask */ - 0x00007fff, /* dst_mask */ - FALSE), /* pcrel_offset */ - - /* GNU extension to record C++ vtable hierarchy */ - HOWTO (R_NDS32_RELA_GNU_VTINHERIT, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 0, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - NULL, /* special_function */ - "R_NDS32_RELA_GNU_VTINHERIT", /* name */ - FALSE, /* partial_inplace */ - 0, /* src_mask */ - 0, /* dst_mask */ - FALSE), /* pcrel_offset */ - - /* GNU extension to record C++ vtable member usage */ - HOWTO (R_NDS32_RELA_GNU_VTENTRY, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 0, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - _bfd_elf_rel_vtable_reloc_fn, /* special_function */ - "R_NDS32_RELA_GNU_VTENTRY", /* name */ - FALSE, /* partial_inplace */ - 0, /* src_mask */ - 0, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_SDA15S2_RELA, /* type */ + 2, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 15, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_SDA15S2_RELA",/* name */ + FALSE, /* partial_inplace */ + 0x00007fff, /* src_mask */ + 0x00007fff, /* dst_mask */ + FALSE), /* pcrel_offset */ + + HOWTO2 (R_NDS32_SDA15S1_RELA, /* type */ + 1, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 15, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_SDA15S1_RELA",/* name */ + FALSE, /* partial_inplace */ + 0x00007fff, /* src_mask */ + 0x00007fff, /* dst_mask */ + FALSE), /* pcrel_offset */ + + HOWTO2 (R_NDS32_SDA15S0_RELA, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 15, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_SDA15S0_RELA",/* name */ + FALSE, /* partial_inplace */ + 0x00007fff, /* src_mask */ + 0x00007fff, /* dst_mask */ + FALSE), /* pcrel_offset */ + + /* GNU extension to record C++ vtable hierarchy */ + HOWTO2 (R_NDS32_RELA_GNU_VTINHERIT,/* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 0, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + NULL, /* special_function */ + "R_NDS32_RELA_GNU_VTINHERIT",/* name */ + FALSE, /* partial_inplace */ + 0, /* src_mask */ + 0, /* dst_mask */ + FALSE), /* pcrel_offset */ + + /* GNU extension to record C++ vtable member usage */ + HOWTO2 (R_NDS32_RELA_GNU_VTENTRY,/* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 0, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + _bfd_elf_rel_vtable_reloc_fn,/* special_function */ + "R_NDS32_RELA_GNU_VTENTRY",/* name */ + FALSE, /* partial_inplace */ + 0, /* src_mask */ + 0, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Like R_NDS32_20, but referring to the GOT table entry for the symbol. */ - HOWTO (R_NDS32_GOT20, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 20, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_GOT20", /* name */ - FALSE, /* partial_inplace */ - 0xfffff, /* src_mask */ - 0xfffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_GOT20, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 20, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_GOT20", /* name */ + FALSE, /* partial_inplace */ + 0xfffff, /* src_mask */ + 0xfffff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Like R_NDS32_PCREL, but referring to the procedure linkage table entry for the symbol. */ - HOWTO (R_NDS32_25_PLTREL, /* type */ - 1, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 24, /* bitsize */ - TRUE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_25_PLTREL", /* name */ - FALSE, /* partial_inplace */ - 0xffffff, /* src_mask */ - 0xffffff, /* dst_mask */ - TRUE), /* pcrel_offset */ + HOWTO2 (R_NDS32_25_PLTREL, /* type */ + 1, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 24, /* bitsize */ + TRUE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_25_PLTREL", /* name */ + FALSE, /* partial_inplace */ + 0xffffff, /* src_mask */ + 0xffffff, /* dst_mask */ + TRUE), /* pcrel_offset */ /* This is used only by the dynamic linker. The symbol should exist both in the object being run and in some shared library. The dynamic linker copies the data addressed by the symbol from the shared library into the object, because the object being run has to have the data at some particular address. */ - HOWTO (R_NDS32_COPY, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_bitfield, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_COPY", /* name */ - FALSE, /* partial_inplace */ - 0xffffffff, /* src_mask */ - 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_COPY, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_bitfield,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_COPY", /* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Like R_NDS32_20, but used when setting global offset table entries. */ - HOWTO (R_NDS32_GLOB_DAT, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_bitfield, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_GLOB_DAT", /* name */ - FALSE, /* partial_inplace */ - 0xffffffff, /* src_mask */ - 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_GLOB_DAT, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_bitfield,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_GLOB_DAT", /* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Marks a procedure linkage table entry for a symbol. */ - HOWTO (R_NDS32_JMP_SLOT, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_bitfield, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_JMP_SLOT", /* name */ - FALSE, /* partial_inplace */ - 0xffffffff, /* src_mask */ - 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_JMP_SLOT, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_bitfield,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_JMP_SLOT", /* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Used only by the dynamic linker. When the object is run, this longword is set to the load address of the object, plus the addend. */ - HOWTO (R_NDS32_RELATIVE, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_bitfield, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_RELATIVE", /* name */ - FALSE, /* partial_inplace */ - 0xffffffff, /* src_mask */ - 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ - - HOWTO (R_NDS32_GOTOFF, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 20, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_GOTOFF", /* name */ - FALSE, /* partial_inplace */ - 0xfffff, /* src_mask */ - 0xfffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_RELATIVE, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_bitfield,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_RELATIVE", /* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + + HOWTO2 (R_NDS32_GOTOFF, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 20, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_GOTOFF", /* name */ + FALSE, /* partial_inplace */ + 0xfffff, /* src_mask */ + 0xfffff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* An PC Relative 20-bit relocation used when setting PIC offset table register. */ - HOWTO (R_NDS32_GOTPC20, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 20, /* bitsize */ - TRUE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_GOTPC20", /* name */ - FALSE, /* partial_inplace */ - 0xfffff, /* src_mask */ - 0xfffff, /* dst_mask */ - TRUE), /* pcrel_offset */ + HOWTO2 (R_NDS32_GOTPC20, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 20, /* bitsize */ + TRUE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_GOTPC20", /* name */ + FALSE, /* partial_inplace */ + 0xfffff, /* src_mask */ + 0xfffff, /* dst_mask */ + TRUE), /* pcrel_offset */ /* Like R_NDS32_HI20, but referring to the GOT table entry for the symbol. */ - HOWTO (R_NDS32_GOT_HI20, /* type */ - 12, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 20, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_GOT_HI20", /* name */ - FALSE, /* partial_inplace */ - 0x000fffff, /* src_mask */ - 0x000fffff, /* dst_mask */ - FALSE), /* pcrel_offset */ - HOWTO (R_NDS32_GOT_LO12, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 12, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_GOT_LO12", /* name */ - FALSE, /* partial_inplace */ - 0x00000fff, /* src_mask */ - 0x00000fff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_GOT_HI20, /* type */ + 12, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 20, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_GOT_HI20", /* name */ + FALSE, /* partial_inplace */ + 0x000fffff, /* src_mask */ + 0x000fffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_GOT_LO12, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 12, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_GOT_LO12", /* name */ + FALSE, /* partial_inplace */ + 0x00000fff, /* src_mask */ + 0x00000fff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* An PC Relative relocation used when setting PIC offset table register. Like R_NDS32_HI20, but referring to the GOT table entry for the symbol. */ - HOWTO (R_NDS32_GOTPC_HI20, /* type */ - 12, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 20, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_GOTPC_HI20", /* name */ - FALSE, /* partial_inplace */ - 0x000fffff, /* src_mask */ - 0x000fffff, /* dst_mask */ - TRUE), /* pcrel_offset */ - HOWTO (R_NDS32_GOTPC_LO12, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 12, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_GOTPC_LO12", /* name */ - FALSE, /* partial_inplace */ - 0x00000fff, /* src_mask */ - 0x00000fff, /* dst_mask */ - TRUE), /* pcrel_offset */ - - HOWTO (R_NDS32_GOTOFF_HI20, /* type */ - 12, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 20, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_GOTOFF_HI20", /* name */ - FALSE, /* partial_inplace */ - 0x000fffff, /* src_mask */ - 0x000fffff, /* dst_mask */ - FALSE), /* pcrel_offset */ - HOWTO (R_NDS32_GOTOFF_LO12, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 12, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_GOTOFF_LO12", /* name */ - FALSE, /* partial_inplace */ - 0x00000fff, /* src_mask */ - 0x00000fff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_GOTPC_HI20, /* type */ + 12, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 20, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_GOTPC_HI20", /* name */ + FALSE, /* partial_inplace */ + 0x000fffff, /* src_mask */ + 0x000fffff, /* dst_mask */ + TRUE), /* pcrel_offset */ + HOWTO2 (R_NDS32_GOTPC_LO12, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 12, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_GOTPC_LO12", /* name */ + FALSE, /* partial_inplace */ + 0x00000fff, /* src_mask */ + 0x00000fff, /* dst_mask */ + TRUE), /* pcrel_offset */ + + HOWTO2 (R_NDS32_GOTOFF_HI20, /* type */ + 12, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 20, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_GOTOFF_HI20", /* name */ + FALSE, /* partial_inplace */ + 0x000fffff, /* src_mask */ + 0x000fffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_GOTOFF_LO12, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 12, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_GOTOFF_LO12", /* name */ + FALSE, /* partial_inplace */ + 0x00000fff, /* src_mask */ + 0x00000fff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Alignment hint for relaxable instruction. This is used with R_NDS32_LABEL as a pair. Relax this instruction from 4 bytes to 2 in order to make next label aligned on word boundary. */ - HOWTO (R_NDS32_INSN16, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - nds32_elf_ignore_reloc,/* special_function */ - "R_NDS32_INSN16", /* name */ - FALSE, /* partial_inplace */ - 0x00000fff, /* src_mask */ - 0x00000fff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_INSN16, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_INSN16", /* name */ + FALSE, /* partial_inplace */ + 0x00000fff, /* src_mask */ + 0x00000fff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Alignment hint for label. */ - HOWTO (R_NDS32_LABEL, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - nds32_elf_ignore_reloc,/* special_function */ - "R_NDS32_LABEL", /* name */ - FALSE, /* partial_inplace */ - 0xffffffff, /* src_mask */ - 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_LABEL, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_LABEL", /* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Relax hint for unconditional call sequence */ - HOWTO (R_NDS32_LONGCALL1, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - nds32_elf_ignore_reloc,/* special_function */ - "R_NDS32_LONGCALL1", /* name */ - FALSE, /* partial_inplace */ - 0xffffffff, /* src_mask */ - 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_LONGCALL1, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_LONGCALL1", /* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Relax hint for conditional call sequence. */ - HOWTO (R_NDS32_LONGCALL2, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - nds32_elf_ignore_reloc,/* special_function */ - "R_NDS32_LONGCALL2", /* name */ - FALSE, /* partial_inplace */ - 0xffffffff, /* src_mask */ - 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_LONGCALL2, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_LONGCALL2", /* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Relax hint for conditional call sequence. */ - HOWTO (R_NDS32_LONGCALL3, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - nds32_elf_ignore_reloc,/* special_function */ - "R_NDS32_LONGCALL3", /* name */ - FALSE, /* partial_inplace */ - 0xffffffff, /* src_mask */ - 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_LONGCALL3, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_LONGCALL3", /* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Relax hint for unconditional branch sequence. */ - HOWTO (R_NDS32_LONGJUMP1, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - nds32_elf_ignore_reloc,/* special_function */ - "R_NDS32_LONGJUMP1", /* name */ - FALSE, /* partial_inplace */ - 0xffffffff, /* src_mask */ - 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_LONGJUMP1, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_LONGJUMP1", /* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Relax hint for conditional branch sequence. */ - HOWTO (R_NDS32_LONGJUMP2, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - nds32_elf_ignore_reloc,/* special_function */ - "R_NDS32_LONGJUMP2", /* name */ - FALSE, /* partial_inplace */ - 0xffffffff, /* src_mask */ - 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_LONGJUMP2, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_LONGJUMP2", /* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Relax hint for conditional branch sequence. */ - HOWTO (R_NDS32_LONGJUMP3, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - nds32_elf_ignore_reloc,/* special_function */ - "R_NDS32_LONGJUMP3", /* name */ - FALSE, /* partial_inplace */ - 0xffffffff, /* src_mask */ - 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_LONGJUMP3, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_LONGJUMP3", /* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Relax hint for load/store sequence. */ - HOWTO (R_NDS32_LOADSTORE, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - nds32_elf_ignore_reloc,/* special_function */ - "R_NDS32_LOADSTORE", /* name */ - FALSE, /* partial_inplace */ - 0xffffffff, /* src_mask */ - 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_LOADSTORE, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_LOADSTORE", /* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Relax hint for load/store sequence. */ - HOWTO (R_NDS32_9_FIXED_RELA, /* type */ - 0, /* rightshift */ - 1, /* size (0 = byte, 1 = short, 2 = long) */ - 16, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - nds32_elf_ignore_reloc,/* special_function */ - "R_NDS32_9_FIXED_RELA",/* name */ - FALSE, /* partial_inplace */ - 0x000000ff, /* src_mask */ - 0x000000ff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_9_FIXED_RELA, /* type */ + 0, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_9_FIXED_RELA",/* name */ + FALSE, /* partial_inplace */ + 0x000000ff, /* src_mask */ + 0x000000ff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Relax hint for load/store sequence. */ - HOWTO (R_NDS32_15_FIXED_RELA, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - nds32_elf_ignore_reloc,/* special_function */ - "R_NDS32_15_FIXED_RELA", /* name */ - FALSE, /* partial_inplace */ - 0x00003fff, /* src_mask */ - 0x00003fff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_15_FIXED_RELA,/* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_15_FIXED_RELA",/* name */ + FALSE, /* partial_inplace */ + 0x00003fff, /* src_mask */ + 0x00003fff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Relax hint for load/store sequence. */ - HOWTO (R_NDS32_17_FIXED_RELA, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - nds32_elf_ignore_reloc,/* special_function */ - "R_NDS32_17_FIXED_RELA", /* name */ - FALSE, /* partial_inplace */ - 0x0000ffff, /* src_mask */ - 0x0000ffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_17_FIXED_RELA,/* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_17_FIXED_RELA",/* name */ + FALSE, /* partial_inplace */ + 0x0000ffff, /* src_mask */ + 0x0000ffff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Relax hint for load/store sequence. */ - HOWTO (R_NDS32_25_FIXED_RELA, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - nds32_elf_ignore_reloc,/* special_function */ - "R_NDS32_25_FIXED_RELA", /* name */ - FALSE, /* partial_inplace */ - 0x00ffffff, /* src_mask */ - 0x00ffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_25_FIXED_RELA,/* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_25_FIXED_RELA",/* name */ + FALSE, /* partial_inplace */ + 0x00ffffff, /* src_mask */ + 0x00ffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* High 20 bits of PLT symbol offset relative to PC. */ - HOWTO (R_NDS32_PLTREL_HI20, /* type */ - 12, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 20, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_PLTREL_HI20", /* name */ - FALSE, /* partial_inplace */ - 0x000fffff, /* src_mask */ - 0x000fffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_PLTREL_HI20, /* type */ + 12, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 20, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_PLTREL_HI20", /* name */ + FALSE, /* partial_inplace */ + 0x000fffff, /* src_mask */ + 0x000fffff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Low 12 bits of PLT symbol offset relative to PC. */ - HOWTO (R_NDS32_PLTREL_LO12, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 12, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_PLTREL_LO12", /* name */ - FALSE, /* partial_inplace */ - 0x00000fff, /* src_mask */ - 0x00000fff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_PLTREL_LO12, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 12, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_PLTREL_LO12", /* name */ + FALSE, /* partial_inplace */ + 0x00000fff, /* src_mask */ + 0x00000fff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* High 20 bits of PLT symbol offset relative to GOT (GP). */ - HOWTO (R_NDS32_PLT_GOTREL_HI20, /* type */ - 12, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 20, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_PLT_GOTREL_HI20", /* name */ - FALSE, /* partial_inplace */ - 0x000fffff, /* src_mask */ - 0x000fffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_PLT_GOTREL_HI20, /* type */ + 12, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 20, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_PLT_GOTREL_HI20",/* name */ + FALSE, /* partial_inplace */ + 0x000fffff, /* src_mask */ + 0x000fffff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Low 12 bits of PLT symbol offset relative to GOT (GP). */ - HOWTO (R_NDS32_PLT_GOTREL_LO12, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 12, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_PLT_GOTREL_LO12", /* name */ - FALSE, /* partial_inplace */ - 0x00000fff, /* src_mask */ - 0x00000fff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_PLT_GOTREL_LO12,/* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 12, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_PLT_GOTREL_LO12",/* name */ + FALSE, /* partial_inplace */ + 0x00000fff, /* src_mask */ + 0x00000fff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Small data area 12 bits offset. */ - HOWTO (R_NDS32_SDA12S2_DP_RELA, /* type */ - 2, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 12, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_SDA12S2_DP_RELA", /* name */ - FALSE, /* partial_inplace */ - 0x00000fff, /* src_mask */ - 0x00000fff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_SDA12S2_DP_RELA,/* type */ + 2, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 12, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_SDA12S2_DP_RELA",/* name */ + FALSE, /* partial_inplace */ + 0x00000fff, /* src_mask */ + 0x00000fff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Small data area 12 bits offset. */ - HOWTO (R_NDS32_SDA12S2_SP_RELA, /* type */ - 2, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 12, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_SDA12S2_SP_RELA", /* name */ - FALSE, /* partial_inplace */ - 0x00000fff, /* src_mask */ - 0x00000fff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_SDA12S2_SP_RELA,/* type */ + 2, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 12, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_SDA12S2_SP_RELA",/* name */ + FALSE, /* partial_inplace */ + 0x00000fff, /* src_mask */ + 0x00000fff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Lower 12 bits of address. */ - HOWTO (R_NDS32_LO12S2_DP_RELA, /* type */ - 2, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 10, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_LO12S2_DP_RELA", /* name */ - FALSE, /* partial_inplace */ - 0x000003ff, /* src_mask */ - 0x000003ff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_LO12S2_DP_RELA, /* type */ + 2, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 10, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_LO12S2_DP_RELA",/* name */ + FALSE, /* partial_inplace */ + 0x000003ff, /* src_mask */ + 0x000003ff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Lower 12 bits of address. */ - HOWTO (R_NDS32_LO12S2_SP_RELA,/* type */ - 2, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 10, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_LO12S2_SP_RELA", /* name */ - FALSE, /* partial_inplace */ - 0x000003ff, /* src_mask */ - 0x000003ff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_LO12S2_SP_RELA,/* type */ + 2, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 10, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_LO12S2_SP_RELA",/* name */ + FALSE, /* partial_inplace */ + 0x000003ff, /* src_mask */ + 0x000003ff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Lower 12 bits of address. Special identity for or case. */ - HOWTO (R_NDS32_LO12S0_ORI_RELA, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 12, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_LO12S0_ORI_RELA", /* name */ - FALSE, /* partial_inplace */ - 0x00000fff, /* src_mask */ - 0x00000fff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_LO12S0_ORI_RELA,/* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 12, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_LO12S0_ORI_RELA",/* name */ + FALSE, /* partial_inplace */ + 0x00000fff, /* src_mask */ + 0x00000fff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Small data area 19 bits offset. */ - HOWTO (R_NDS32_SDA16S3_RELA, /* type */ - 3, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 16, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_SDA16S3_RELA",/* name */ - FALSE, /* partial_inplace */ - 0x0000ffff, /* src_mask */ - 0x0000ffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_SDA16S3_RELA, /* type */ + 3, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_SDA16S3_RELA",/* name */ + FALSE, /* partial_inplace */ + 0x0000ffff, /* src_mask */ + 0x0000ffff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Small data area 15 bits offset. */ - HOWTO (R_NDS32_SDA17S2_RELA, /* type */ - 2, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 17, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_SDA17S2_RELA",/* name */ - FALSE, /* partial_inplace */ - 0x0001ffff, /* src_mask */ - 0x0001ffff, /* dst_mask */ - FALSE), /* pcrel_offset */ - - HOWTO (R_NDS32_SDA18S1_RELA, /* type */ - 1, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 18, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_SDA18S1_RELA",/* name */ - FALSE, /* partial_inplace */ - 0x0003ffff, /* src_mask */ - 0x0003ffff, /* dst_mask */ - FALSE), /* pcrel_offset */ - - HOWTO (R_NDS32_SDA19S0_RELA, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 19, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_SDA19S0_RELA",/* name */ - FALSE, /* partial_inplace */ - 0x0007ffff, /* src_mask */ - 0x0007ffff, /* dst_mask */ - FALSE), /* pcrel_offset */ - HOWTO (R_NDS32_DWARF2_OP1_RELA, /* type */ - 0, /* rightshift */ - 0, /* size (0 = byte, 1 = short, 2 = long) */ - 8, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - nds32_elf_ignore_reloc,/* special_function */ - "R_NDS32_DWARF2_OP1_RELA", /* name */ - FALSE, /* partial_inplace */ - 0xff, /* src_mask */ - 0xff, /* dst_mask */ - FALSE), /* pcrel_offset */ - HOWTO (R_NDS32_DWARF2_OP2_RELA, /* type */ - 0, /* rightshift */ - 1, /* size (0 = byte, 1 = short, 2 = long) */ - 16, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - nds32_elf_ignore_reloc,/* special_function */ - "R_NDS32_DWARF2_OP2_RELA", /* name */ - FALSE, /* partial_inplace */ - 0xffff, /* src_mask */ - 0xffff, /* dst_mask */ - FALSE), /* pcrel_offset */ - HOWTO (R_NDS32_DWARF2_LEB_RELA, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - nds32_elf_ignore_reloc,/* special_function */ - "R_NDS32_DWARF2_LEB_RELA", /* name */ - FALSE, /* partial_inplace */ - 0xffffffff, /* src_mask */ - 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ - HOWTO (R_NDS32_UPDATE_TA_RELA,/* type */ - 0, /* rightshift */ - 1, /* size (0 = byte, 1 = short, 2 = long) */ - 16, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - nds32_elf_ignore_reloc,/* special_function */ - "R_NDS32_UPDATE_TA_RELA", /* name */ - FALSE, /* partial_inplace */ - 0xffff, /* src_mask */ - 0xffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_SDA17S2_RELA, /* type */ + 2, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 17, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_SDA17S2_RELA",/* name */ + FALSE, /* partial_inplace */ + 0x0001ffff, /* src_mask */ + 0x0001ffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + + HOWTO2 (R_NDS32_SDA18S1_RELA, /* type */ + 1, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 18, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_SDA18S1_RELA",/* name */ + FALSE, /* partial_inplace */ + 0x0003ffff, /* src_mask */ + 0x0003ffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + + HOWTO2 (R_NDS32_SDA19S0_RELA, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 19, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_SDA19S0_RELA",/* name */ + FALSE, /* partial_inplace */ + 0x0007ffff, /* src_mask */ + 0x0007ffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_DWARF2_OP1_RELA,/* type */ + 0, /* rightshift */ + 0, /* size (0 = byte, 1 = short, 2 = long) */ + 8, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_DWARF2_OP1_RELA",/* name */ + FALSE, /* partial_inplace */ + 0xff, /* src_mask */ + 0xff, /* dst_mask */ + FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_DWARF2_OP2_RELA,/* type */ + 0, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_DWARF2_OP2_RELA",/* name */ + FALSE, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_DWARF2_LEB_RELA,/* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_DWARF2_LEB_RELA",/* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_UPDATE_TA_RELA,/* type */ + 0, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_UPDATE_TA_RELA",/* name */ + FALSE, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Like R_NDS32_PCREL, but referring to the procedure linkage table entry for the symbol. */ - HOWTO (R_NDS32_9_PLTREL, /* type */ - 1, /* rightshift */ - 1, /* size (0 = byte, 1 = short, 2 = long) */ - 8, /* bitsize */ - TRUE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_9_PLTREL", /* name */ - FALSE, /* partial_inplace */ - 0xff, /* src_mask */ - 0xff, /* dst_mask */ - TRUE), /* pcrel_offset */ + HOWTO2 (R_NDS32_9_PLTREL, /* type */ + 1, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 8, /* bitsize */ + TRUE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_9_PLTREL", /* name */ + FALSE, /* partial_inplace */ + 0xff, /* src_mask */ + 0xff, /* dst_mask */ + TRUE), /* pcrel_offset */ /* Low 20 bits of PLT symbol offset relative to GOT (GP). */ - HOWTO (R_NDS32_PLT_GOTREL_LO20, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 20, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_PLT_GOTREL_LO20", /* name */ - FALSE, /* partial_inplace */ - 0x000fffff, /* src_mask */ - 0x000fffff, /* dst_mask */ - FALSE), /* pcrel_offset */ - /* low 15 bits of PLT symbol offset relative to GOT (GP) */ - HOWTO (R_NDS32_PLT_GOTREL_LO15, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 15, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_PLT_GOTREL_LO15", /* name */ - FALSE, /* partial_inplace */ - 0x00007fff, /* src_mask */ - 0x00007fff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_PLT_GOTREL_LO20,/* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 20, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_PLT_GOTREL_LO20",/* name */ + FALSE, /* partial_inplace */ + 0x000fffff, /* src_mask */ + 0x000fffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + /* low 15 bits of PLT symbol offset relative to GOT (GP) */ + HOWTO2 (R_NDS32_PLT_GOTREL_LO15,/* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 15, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_PLT_GOTREL_LO15",/* name */ + FALSE, /* partial_inplace */ + 0x00007fff, /* src_mask */ + 0x00007fff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Low 19 bits of PLT symbol offset relative to GOT (GP). */ - HOWTO (R_NDS32_PLT_GOTREL_LO19, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 19, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_PLT_GOTREL_LO19", /* name */ - FALSE, /* partial_inplace */ - 0x0007ffff, /* src_mask */ - 0x0007ffff, /* dst_mask */ - FALSE), /* pcrel_offset */ - HOWTO (R_NDS32_GOT_LO15, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 15, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_GOT_LO15", /* name */ - FALSE, /* partial_inplace */ - 0x00007fff, /* src_mask */ - 0x00007fff, /* dst_mask */ - FALSE), /* pcrel_offset */ - HOWTO (R_NDS32_GOT_LO19, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 19, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_GOT_LO19", /* name */ - FALSE, /* partial_inplace */ - 0x0007ffff, /* src_mask */ - 0x0007ffff, /* dst_mask */ - FALSE), /* pcrel_offset */ - HOWTO (R_NDS32_GOTOFF_LO15, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 15, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_GOTOFF_LO15", /* name */ - FALSE, /* partial_inplace */ - 0x00007fff, /* src_mask */ - 0x00007fff, /* dst_mask */ - FALSE), /* pcrel_offset */ - HOWTO (R_NDS32_GOTOFF_LO19, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 19, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_GOTOFF_LO19", /* name */ - FALSE, /* partial_inplace */ - 0x0007ffff, /* src_mask */ - 0x0007ffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_PLT_GOTREL_LO19,/* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 19, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_PLT_GOTREL_LO19",/* name */ + FALSE, /* partial_inplace */ + 0x0007ffff, /* src_mask */ + 0x0007ffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_GOT_LO15, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 15, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_GOT_LO15", /* name */ + FALSE, /* partial_inplace */ + 0x00007fff, /* src_mask */ + 0x00007fff, /* dst_mask */ + FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_GOT_LO19, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 19, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_GOT_LO19", /* name */ + FALSE, /* partial_inplace */ + 0x0007ffff, /* src_mask */ + 0x0007ffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_GOTOFF_LO15, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 15, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_GOTOFF_LO15", /* name */ + FALSE, /* partial_inplace */ + 0x00007fff, /* src_mask */ + 0x00007fff, /* dst_mask */ + FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_GOTOFF_LO19, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 19, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_GOTOFF_LO19", /* name */ + FALSE, /* partial_inplace */ + 0x0007ffff, /* src_mask */ + 0x0007ffff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* GOT 15 bits offset. */ - HOWTO (R_NDS32_GOT15S2_RELA, /* type */ - 2, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 15, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_GOT15S2_RELA",/* name */ - FALSE, /* partial_inplace */ - 0x00007fff, /* src_mask */ - 0x00007fff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_GOT15S2_RELA, /* type */ + 2, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 15, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_GOT15S2_RELA",/* name */ + FALSE, /* partial_inplace */ + 0x00007fff, /* src_mask */ + 0x00007fff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* GOT 17 bits offset. */ - HOWTO (R_NDS32_GOT17S2_RELA, /* type */ - 2, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 17, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_GOT17S2_RELA",/* name */ - FALSE, /* partial_inplace */ - 0x0001ffff, /* src_mask */ - 0x0001ffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_GOT17S2_RELA, /* type */ + 2, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 17, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_GOT17S2_RELA",/* name */ + FALSE, /* partial_inplace */ + 0x0001ffff, /* src_mask */ + 0x0001ffff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* A 5 bit address. */ - HOWTO (R_NDS32_5_RELA, /* type */ - 0, /* rightshift */ - 1, /* size (0 = byte, 1 = short, 2 = long) */ - 5, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_5_RELA", /* name */ - FALSE, /* partial_inplace */ - 0x1f, /* src_mask */ - 0x1f, /* dst_mask */ - FALSE), /* pcrel_offset */ - HOWTO (R_NDS32_10_UPCREL_RELA,/* type */ - 1, /* rightshift */ - 1, /* size (0 = byte, 1 = short, 2 = long) */ - 9, /* bitsize */ - TRUE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_unsigned, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_10_UPCREL_RELA", /* name */ - FALSE, /* partial_inplace */ - 0x1ff, /* src_mask */ - 0x1ff, /* dst_mask */ - TRUE), /* pcrel_offset */ - HOWTO (R_NDS32_SDA_FP7U2_RELA,/* type */ - 2, /* rightshift */ - 1, /* size (0 = byte, 1 = short, 2 = long) */ - 7, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_unsigned, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_SDA_FP7U2_RELA", /* name */ - FALSE, /* partial_inplace */ - 0x0000007f, /* src_mask */ - 0x0000007f, /* dst_mask */ - FALSE), /* pcrel_offset */ - HOWTO (R_NDS32_WORD_9_PCREL_RELA, /* type */ - 1, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 8, /* bitsize */ - TRUE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_WORD_9_PCREL_RELA", /* name */ - FALSE, /* partial_inplace */ - 0xff, /* src_mask */ - 0xff, /* dst_mask */ - TRUE), /* pcrel_offset */ - HOWTO (R_NDS32_25_ABS_RELA, /* type */ - 1, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 24, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_25_ABS_RELA", /* name */ - FALSE, /* partial_inplace */ - 0xffffff, /* src_mask */ - 0xffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_5_RELA, /* type */ + 0, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 5, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_5_RELA", /* name */ + FALSE, /* partial_inplace */ + 0x1f, /* src_mask */ + 0x1f, /* dst_mask */ + FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_10_UPCREL_RELA,/* type */ + 1, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 9, /* bitsize */ + TRUE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_unsigned,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_10_UPCREL_RELA",/* name */ + FALSE, /* partial_inplace */ + 0x1ff, /* src_mask */ + 0x1ff, /* dst_mask */ + TRUE), /* pcrel_offset */ + HOWTO2 (R_NDS32_SDA_FP7U2_RELA,/* type */ + 2, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 7, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_unsigned,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_SDA_FP7U2_RELA",/* name */ + FALSE, /* partial_inplace */ + 0x0000007f, /* src_mask */ + 0x0000007f, /* dst_mask */ + FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_WORD_9_PCREL_RELA,/* type */ + 1, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 8, /* bitsize */ + TRUE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_WORD_9_PCREL_RELA",/* name */ + FALSE, /* partial_inplace */ + 0xff, /* src_mask */ + 0xff, /* dst_mask */ + TRUE), /* pcrel_offset */ + HOWTO2 (R_NDS32_25_ABS_RELA, /* type */ + 1, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 24, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_25_ABS_RELA", /* name */ + FALSE, /* partial_inplace */ + 0xffffff, /* src_mask */ + 0xffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* A relative 17 bit relocation for ifc, right shifted by 1. */ - HOWTO (R_NDS32_17IFC_PCREL_RELA, /* type */ - 1, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 16, /* bitsize */ - TRUE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_17IFC_PCREL_RELA", /* name */ - FALSE, /* partial_inplace */ - 0xffff, /* src_mask */ - 0xffff, /* dst_mask */ - TRUE), /* pcrel_offset */ + HOWTO2 (R_NDS32_17IFC_PCREL_RELA,/* type */ + 1, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + TRUE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_17IFC_PCREL_RELA",/* name */ + FALSE, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + TRUE), /* pcrel_offset */ /* A relative unsigned 10 bit relocation for ifc, right shifted by 1. */ - HOWTO (R_NDS32_10IFCU_PCREL_RELA, /* type */ - 1, /* rightshift */ - 1, /* size (0 = byte, 1 = short, 2 = long) */ - 9, /* bitsize */ - TRUE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_unsigned, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_10IFCU_PCREL_RELA", /* name */ - FALSE, /* partial_inplace */ - 0x1ff, /* src_mask */ - 0x1ff, /* dst_mask */ - TRUE), /* pcrel_offset */ - - /* Like R_NDS32_HI20, but referring to the TLS entry for the symbol. */ - HOWTO (R_NDS32_TLS_LE_HI20, /* type */ - 12, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 20, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_TLS_LE_HI20", /* name */ - FALSE, /* partial_inplace */ - 0x000fffff, /* src_mask */ - 0x000fffff, /* dst_mask */ - FALSE), /* pcrel_offset */ - HOWTO (R_NDS32_TLS_LE_LO12, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 12, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_TLS_LE_LO12", /* name */ - FALSE, /* partial_inplace */ - 0x00000fff, /* src_mask */ - 0x00000fff, /* dst_mask */ - FALSE), /* pcrel_offset */ - - /* Like R_NDS32_HI20, but referring to the TLS entry for the symbol. */ - HOWTO (R_NDS32_TLS_IE_HI20, /* type */ - 12, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 20, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_TLS_IE_HI20", /* name */ - FALSE, /* partial_inplace */ - 0x000fffff, /* src_mask */ - 0x000fffff, /* dst_mask */ - FALSE), /* pcrel_offset */ - HOWTO (R_NDS32_TLS_IE_LO12S2, /* type */ - 2, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 10, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_TLS_IE_LO12S2", /* name */ - FALSE, /* partial_inplace */ - 0x000003ff, /* src_mask */ - 0x000003ff, /* dst_mask */ - FALSE), /* pcrel_offset */ - /* Mark a TLS IE entry in GOT. */ - HOWTO (R_NDS32_TLS_TPOFF, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_bitfield, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_TLS_TPOFF", /* name */ - FALSE, /* partial_inplace */ - 0xffffffff, /* src_mask */ - 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ - /* A 20 bit address. */ - HOWTO (R_NDS32_TLS_LE_20, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 20, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_TLS_LE_20", /* name */ - FALSE, /* partial_inplace */ - 0xfffff, /* src_mask */ - 0xfffff, /* dst_mask */ - FALSE), /* pcrel_offset */ - HOWTO (R_NDS32_TLS_LE_15S0, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 15, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_TLS_LE_15S0", /* name */ - FALSE, /* partial_inplace */ - 0x7fff, /* src_mask */ - 0x7fff, /* dst_mask */ - FALSE), /* pcrel_offset */ - HOWTO (R_NDS32_TLS_LE_15S1, /* type */ - 1, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 15, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_TLS_LE_15S1", /* name */ - FALSE, /* partial_inplace */ - 0x7fff, /* src_mask */ - 0x7fff, /* dst_mask */ - FALSE), /* pcrel_offset */ - HOWTO (R_NDS32_TLS_LE_15S2, /* type */ - 2, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 15, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ - "R_NDS32_TLS_LE_15S2", /* name */ - FALSE, /* partial_inplace */ - 0x7fff, /* src_mask */ - 0x7fff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_10IFCU_PCREL_RELA,/* type */ + 1, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 9, /* bitsize */ + TRUE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_unsigned,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_10IFCU_PCREL_RELA",/* name */ + FALSE, /* partial_inplace */ + 0x1ff, /* src_mask */ + 0x1ff, /* dst_mask */ + TRUE), /* pcrel_offset */ /* Relax hint for unconditional call sequence */ - HOWTO (R_NDS32_LONGCALL4, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont, /* complain_on_overflow */ - nds32_elf_ignore_reloc, /* special_function */ - "R_NDS32_LONGCALL4", /* name */ - FALSE, /* partial_inplace */ - 0xffffffff, /* src_mask */ - 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_LONGCALL4, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_LONGCALL4", /* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Relax hint for conditional call sequence. */ - HOWTO (R_NDS32_LONGCALL5, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont, /* complain_on_overflow */ - nds32_elf_ignore_reloc, /* special_function */ - "R_NDS32_LONGCALL5", /* name */ - FALSE, /* partial_inplace */ - 0xffffffff, /* src_mask */ - 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_LONGCALL5, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_LONGCALL5", /* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Relax hint for conditional call sequence. */ - HOWTO (R_NDS32_LONGCALL6, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont, /* complain_on_overflow */ - nds32_elf_ignore_reloc, /* special_function */ - "R_NDS32_LONGCALL6", /* name */ - FALSE, /* partial_inplace */ - 0xffffffff, /* src_mask */ - 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_LONGCALL6, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_LONGCALL6", /* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Relax hint for unconditional branch sequence. */ - HOWTO (R_NDS32_LONGJUMP4, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont, /* complain_on_overflow */ - nds32_elf_ignore_reloc, /* special_function */ - "R_NDS32_LONGJUMP4", /* name */ - FALSE, /* partial_inplace */ - 0xffffffff, /* src_mask */ - 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_LONGJUMP4, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_LONGJUMP4", /* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Relax hint for conditional branch sequence. */ - HOWTO (R_NDS32_LONGJUMP5, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont, /* complain_on_overflow */ - nds32_elf_ignore_reloc, /* special_function */ - "R_NDS32_LONGJUMP5", /* name */ - FALSE, /* partial_inplace */ - 0xffffffff, /* src_mask */ - 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_LONGJUMP5, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_LONGJUMP5", /* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Relax hint for conditional branch sequence. */ - HOWTO (R_NDS32_LONGJUMP6, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont, /* complain_on_overflow */ - nds32_elf_ignore_reloc, /* special_function */ - "R_NDS32_LONGJUMP6", /* name */ - FALSE, /* partial_inplace */ - 0xffffffff, /* src_mask */ - 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_LONGJUMP6, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_LONGJUMP6", /* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Relax hint for conditional branch sequence. */ - HOWTO (R_NDS32_LONGJUMP7, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont, /* complain_on_overflow */ - nds32_elf_ignore_reloc, /* special_function */ - "R_NDS32_LONGJUMP7", /* name */ - FALSE, /* partial_inplace */ - 0xffffffff, /* src_mask */ - 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_LONGJUMP7, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_LONGJUMP7", /* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + + /* Check sum value for security. */ + HOWTO2 (R_NDS32_SECURITY_16, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + FALSE, /* pc_relative */ + 5, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_SECURITY_16", /* name */ + FALSE, /* partial_inplace */ + 0x1fffe0, /* src_mask */ + 0x1fffe0, /* dst_mask */ + TRUE), /* pcrel_offset */ + + /* TLS LE TP offset relocation */ + HOWTO2 (R_NDS32_TLS_TPOFF, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_bitfield,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_TLS_TPOFF", /* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + + /* Like R_NDS32_HI20, but referring to the TLS LE entry for the symbol. */ + HOWTO2 (R_NDS32_TLS_LE_HI20, /* type */ + 12, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 20, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_TLS_LE_HI20", /* name */ + FALSE, /* partial_inplace */ + 0x000fffff, /* src_mask */ + 0x000fffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_TLS_LE_LO12, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 12, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_TLS_LE_LO12", /* name */ + FALSE, /* partial_inplace */ + 0x00000fff, /* src_mask */ + 0x00000fff, /* dst_mask */ + FALSE), /* pcrel_offset */ + + /* A 20 bit address. */ + HOWTO2 (R_NDS32_TLS_LE_20, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 20, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_TLS_LE_20", /* name */ + FALSE, /* partial_inplace */ + 0xfffff, /* src_mask */ + 0xfffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_TLS_LE_15S0, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 15, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_TLS_LE_15S0", /* name */ + FALSE, /* partial_inplace */ + 0x7fff, /* src_mask */ + 0x7fff, /* dst_mask */ + FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_TLS_LE_15S1, /* type */ + 1, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 15, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_TLS_LE_15S1", /* name */ + FALSE, /* partial_inplace */ + 0x7fff, /* src_mask */ + 0x7fff, /* dst_mask */ + FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_TLS_LE_15S2, /* type */ + 2, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 15, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_TLS_LE_15S2", /* name */ + FALSE, /* partial_inplace */ + 0x7fff, /* src_mask */ + 0x7fff, /* dst_mask */ + FALSE), /* pcrel_offset */ + + /* Like R_NDS32_HI20, but referring to the TLS IE entry for the symbol. */ + HOWTO2 (R_NDS32_TLS_IE_HI20, /* type */ + 12, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 20, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_TLS_IE_HI20", /* name */ + FALSE, /* partial_inplace */ + 0x000fffff, /* src_mask */ + 0x000fffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_TLS_IE_LO12, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 12, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_TLS_IE_LO12", /* name */ + FALSE, /* partial_inplace */ + 0x00000fff, /* src_mask */ + 0x00000fff, /* dst_mask */ + FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_TLS_IE_LO12S2,/* type */ + 2, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 10, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_TLS_IE_LO12S2",/* name */ + FALSE, /* partial_inplace */ + 0x000003ff, /* src_mask */ + 0x000003ff, /* dst_mask */ + FALSE), /* pcrel_offset */ + + /* Like R_NDS32_HI20, but referring to the TLS IE (PIE) entry for the symbol. */ + HOWTO2 (R_NDS32_TLS_IEGP_HI20,/* type */ + 12, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 20, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_TLS_IEGP_HI20",/* name */ + FALSE, /* partial_inplace */ + 0x000fffff, /* src_mask */ + 0x000fffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + + HOWTO2 (R_NDS32_TLS_IEGP_LO12,/* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 12, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_TLS_IEGP_LO12",/* name */ + FALSE, /* partial_inplace */ + 0x00000fff, /* src_mask */ + 0x00000fff, /* dst_mask */ + FALSE), /* pcrel_offset */ + + HOWTO2 (R_NDS32_TLS_IEGP_LO12S2,/* type */ + 2, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 10, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_TLS_IEGP_LO12S2",/* name */ + FALSE, /* partial_inplace */ + 0x000003ff, /* src_mask */ + 0x000003ff, /* dst_mask */ + FALSE), /* pcrel_offset */ + + /* TLS description relocation */ + HOWTO2 (R_NDS32_TLS_DESC, /* type */ + 12, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 20, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_hi20_reloc, /* special_function */ + "R_NDS32_TLS_DESC_HI20",/* name */ + FALSE, /* partial_inplace */ + 0x000fffff, /* src_mask */ + 0x000fffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + + /* TLS GD/LD description offset high part. */ + HOWTO2 (R_NDS32_TLS_DESC_HI20,/* type */ + 12, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 20, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_hi20_reloc, /* special_function */ + "R_NDS32_TLS_DESC_HI20",/* name */ + FALSE, /* partial_inplace */ + 0x000fffff, /* src_mask */ + 0x000fffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + /* TLS GD/LD description offset low part. */ + HOWTO2 (R_NDS32_TLS_DESC_LO12,/* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 12, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_lo12_reloc, /* special_function */ + "R_NDS32_TLS_DESC_LO12",/* name */ + FALSE, /* partial_inplace */ + 0x00000fff, /* src_mask */ + 0x00000fff, /* dst_mask */ + FALSE), /* pcrel_offset */ + + /* TLS GD/LD description offset set (movi). */ + HOWTO2 (R_NDS32_TLS_DESC_20, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 20, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_TLS_DESC_20", /* name */ + FALSE, /* partial_inplace */ + 0x000fffff, /* src_mask */ + 0x000fffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + + /* TLS GD/LD description offset set (lwi.gp). */ + HOWTO2 (R_NDS32_TLS_DESC_SDA17S2,/* type */ + 2, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 17, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_TLS_DESC_SDA17S2",/* name */ + FALSE, /* partial_inplace */ + 0x0001ffff, /* src_mask */ + 0x0001ffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + + /* Jump-patch table relocations. */ + /* High 20 bits of jump-patch table address. */ + HOWTO2 (R_NDS32_ICT_HI20, /* type */ + 12, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 20, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_ICT_HI20", /* name */ + FALSE, /* partial_inplace */ + 0x000fffff, /* src_mask */ + 0x000fffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + /* Lower 12 bits of jump-patch table address. */ + HOWTO2 (R_NDS32_ICT_LO12,/* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 12, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_ICT_LO12",/* name */ + FALSE, /* partial_inplace */ + 0x00000fff, /* src_mask */ + 0x00000fff, /* dst_mask */ + FALSE), /* pcrel_offset */ + HOWTO2 (R_NDS32_ICT_LO12S2,/* type */ + 2, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 10, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_ICT_LO12S2",/* name */ + FALSE, /* partial_inplace */ + 0x000003ff, /* src_mask */ + 0x000003ff, /* dst_mask */ + FALSE), /* pcrel_offset */ + + /* A relative 25 bit relocation, right shifted by 2. */ + HOWTO2 (R_NDS32_ICT_25PC,/* type */ + 1, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 24, /* bitsize */ + TRUE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed,/* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_NDS32_ICT_25PC",/* name */ + FALSE, /* partial_inplace */ + 0xffffff, /* src_mask */ + 0xffffff, /* dst_mask */ + TRUE), /* pcrel_offset */ }; /* Relocations used for relaxation. */ -static reloc_howto_type nds32_elf_relax_howto_table[] = -{ - HOWTO (R_NDS32_RELAX_ENTRY, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - nds32_elf_ignore_reloc,/* special_function */ - "R_NDS32_RELAX_ENTRY", /* name */ - FALSE, /* partial_inplace */ - 0xffffffff, /* src_mask */ - 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ - HOWTO (R_NDS32_GOT_SUFF, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - nds32_elf_ignore_reloc,/* special_function */ - "R_NDS32_GOT_SUFF", /* name */ - FALSE, /* partial_inplace */ - 0xffffffff, /* src_mask */ - 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ - HOWTO (R_NDS32_GOTOFF_SUFF, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_bitfield, /* complain_on_overflow */ - nds32_elf_ignore_reloc,/* special_function */ - "R_NDS32_GOTOFF_SUFF", /* name */ - FALSE, /* partial_inplace */ - 0xffffffff, /* src_mask */ - 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ - HOWTO (R_NDS32_PLT_GOT_SUFF, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - nds32_elf_ignore_reloc,/* special_function */ - "R_NDS32_PLT_GOT_SUFF",/* name */ - FALSE, /* partial_inplace */ - 0xffffffff, /* src_mask */ - 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ - HOWTO (R_NDS32_MULCALL_SUFF, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - nds32_elf_ignore_reloc,/* special_function */ - "R_NDS32_MULCALL_SUFF",/* name */ - FALSE, /* partial_inplace */ - 0xffffffff, /* src_mask */ - 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ - HOWTO (R_NDS32_PTR, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - nds32_elf_ignore_reloc,/* special_function */ - "R_NDS32_PTR", /* name */ - FALSE, /* partial_inplace */ - 0xffffffff, /* src_mask */ - 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ - HOWTO (R_NDS32_PTR_COUNT, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - nds32_elf_ignore_reloc,/* special_function */ - "R_NDS32_PTR_COUNT", /* name */ - FALSE, /* partial_inplace */ - 0xffffffff, /* src_mask */ - 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ - HOWTO (R_NDS32_PTR_RESOLVED, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - nds32_elf_ignore_reloc,/* special_function */ - "R_NDS32_PTR_RESOLVED",/* name */ - FALSE, /* partial_inplace */ - 0xffffffff, /* src_mask */ - 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ - HOWTO (R_NDS32_PLTBLOCK, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - nds32_elf_ignore_reloc,/* special_function */ - "R_NDS32_PLTBLOCK", /* name */ - FALSE, /* partial_inplace */ - 0xffffffff, /* src_mask */ - 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ - HOWTO (R_NDS32_RELAX_REGION_BEGIN, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - nds32_elf_ignore_reloc,/* special_function */ - "R_NDS32_RELAX_REGION_BEGIN", /* name */ - FALSE, /* partial_inplace */ - 0xffffffff, /* src_mask */ - 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ - HOWTO (R_NDS32_RELAX_REGION_END, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - nds32_elf_ignore_reloc,/* special_function */ - "R_NDS32_RELAX_REGION_END", /* name */ - FALSE, /* partial_inplace */ - 0xffffffff, /* src_mask */ - 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ - HOWTO (R_NDS32_MINUEND, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - nds32_elf_ignore_reloc,/* special_function */ - "R_NDS32_MINUEND", /* name */ - FALSE, /* partial_inplace */ - 0xffffffff, /* src_mask */ - 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ - HOWTO (R_NDS32_SUBTRAHEND, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - nds32_elf_ignore_reloc,/* special_function */ - "R_NDS32_SUBTRAHEND", /* name */ - FALSE, /* partial_inplace */ - 0xffffffff, /* src_mask */ - 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ - HOWTO (R_NDS32_DIFF8, /* type */ - 0, /* rightshift */ - 0, /* size (0 = byte, 1 = short, 2 = long) */ - 8, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - nds32_elf_ignore_reloc,/* special_function */ - "R_NDS32_DIFF8", /* name */ - FALSE, /* partial_inplace */ - 0x000000ff, /* src_mask */ - 0x000000ff, /* dst_mask */ - FALSE), /* pcrel_offset */ - HOWTO (R_NDS32_DIFF16, /* type */ - 0, /* rightshift */ - 1, /* size (0 = byte, 1 = short, 2 = long) */ - 16, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - nds32_elf_ignore_reloc,/* special_function */ - "R_NDS32_DIFF16", /* name */ - FALSE, /* partial_inplace */ - 0x0000ffff, /* src_mask */ - 0x0000ffff, /* dst_mask */ - FALSE), /* pcrel_offset */ - HOWTO (R_NDS32_DIFF32, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - nds32_elf_ignore_reloc,/* special_function */ - "R_NDS32_DIFF32", /* name */ - FALSE, /* partial_inplace */ - 0xffffffff, /* src_mask */ - 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ - HOWTO (R_NDS32_DIFF_ULEB128, /* type */ - 0, /* rightshift */ - 0, /* size (0 = byte, 1 = short, 2 = long) */ - 0, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - nds32_elf_ignore_reloc,/* special_function */ - "R_NDS32_DIFF_ULEB128",/* name */ - FALSE, /* partial_inplace */ - 0xffffffff, /* src_mask */ - 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ - HOWTO (R_NDS32_DATA, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - nds32_elf_ignore_reloc,/* special_function */ - "R_NDS32_DATA", /* name */ - FALSE, /* partial_inplace */ - 0xffffffff, /* src_mask */ - 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ - HOWTO (R_NDS32_TRAN, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont,/* complain_on_overflow */ - nds32_elf_ignore_reloc,/* special_function */ - "R_NDS32_TRAN", /* name */ - FALSE, /* partial_inplace */ - 0xffffffff, /* src_mask */ - 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ - HOWTO (R_NDS32_TLS_LE_ADD, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont, /* complain_on_overflow */ - nds32_elf_ignore_reloc, /* special_function */ - "R_NDS32_TLS_LE_ADD", /* name */ - FALSE, /* partial_inplace */ - 0xffffffff, /* src_mask */ - 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ - HOWTO (R_NDS32_TLS_LE_LS, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont, /* complain_on_overflow */ - nds32_elf_ignore_reloc, /* special_function */ - "R_NDS32_TLS_LE_LS", /* name */ - FALSE, /* partial_inplace */ - 0xffffffff, /* src_mask */ - 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ - HOWTO (R_NDS32_EMPTY, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont, /* complain_on_overflow */ - nds32_elf_ignore_reloc, /* special_function */ - "R_NDS32_EMPTY", /* name */ - FALSE, /* partial_inplace */ - 0xffffffff, /* src_mask */ - 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ +#define HOWTO3(C, R, S, B, P, BI, O, SF, NAME, INPLACE, MASKSRC, MASKDST, PC) \ + [C-R_NDS32_RELAX_ENTRY] = HOWTO(C, R, S, B, P, BI, O, SF, NAME, INPLACE, MASKSRC, MASKDST, PC) + +static reloc_howto_type nds32_elf_relax_howto_table[] = { + HOWTO3 (R_NDS32_RELAX_ENTRY, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_RELAX_ENTRY", /* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + HOWTO3 (R_NDS32_GOT_SUFF, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_GOT_SUFF", /* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + HOWTO3 (R_NDS32_GOTOFF_SUFF, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_bitfield,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_GOTOFF_SUFF", /* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + HOWTO3 (R_NDS32_PLT_GOT_SUFF, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_PLT_GOT_SUFF",/* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + HOWTO3 (R_NDS32_MULCALL_SUFF, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_MULCALL_SUFF",/* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + HOWTO3 (R_NDS32_PTR, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_PTR", /* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + HOWTO3 (R_NDS32_PTR_COUNT, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_PTR_COUNT", /* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + HOWTO3 (R_NDS32_PTR_RESOLVED, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_PTR_RESOLVED",/* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + HOWTO3 (R_NDS32_PLTBLOCK, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_PLTBLOCK", /* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + HOWTO3 (R_NDS32_RELAX_REGION_BEGIN,/* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_RELAX_REGION_BEGIN",/* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + HOWTO3 (R_NDS32_RELAX_REGION_END,/* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_RELAX_REGION_END",/* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + HOWTO3 (R_NDS32_MINUEND, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_MINUEND", /* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + HOWTO3 (R_NDS32_SUBTRAHEND, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_SUBTRAHEND", /* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + HOWTO3 (R_NDS32_DIFF8, /* type */ + 0, /* rightshift */ + 0, /* size (0 = byte, 1 = short, 2 = long) */ + 8, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_DIFF8", /* name */ + FALSE, /* partial_inplace */ + 0x000000ff, /* src_mask */ + 0x000000ff, /* dst_mask */ + FALSE), /* pcrel_offset */ + HOWTO3 (R_NDS32_DIFF16, /* type */ + 0, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_DIFF16", /* name */ + FALSE, /* partial_inplace */ + 0x0000ffff, /* src_mask */ + 0x0000ffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + HOWTO3 (R_NDS32_DIFF32, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_DIFF32", /* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + HOWTO3 (R_NDS32_DIFF_ULEB128, /* type */ + 0, /* rightshift */ + 0, /* size (0 = byte, 1 = short, 2 = long) */ + 0, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_DIFF_ULEB128",/* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + HOWTO3 (R_NDS32_DATA, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_DATA", /* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + HOWTO3 (R_NDS32_TRAN, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_TRAN", /* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + HOWTO3 (R_NDS32_EMPTY, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_EMPTY", /* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + + HOWTO3 (R_NDS32_TLS_LE_ADD, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_TLS_LE_ADD", /* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + HOWTO3 (R_NDS32_TLS_LE_LS, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_TLS_LE_LS", /* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + + HOWTO3 (R_NDS32_TLS_IEGP_LW, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_TLS_IEGP_LW", /* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + + /* TLS GD/LD description address base addition. */ + HOWTO3 (R_NDS32_TLS_DESC_ADD, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_TLS_DESC_ADD",/* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + + /* TLS GD/LD description function load. */ + HOWTO3 (R_NDS32_TLS_DESC_FUNC,/* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_TLS_DESC_FUNC",/* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + + /* TLS DESC resolve function call. */ + HOWTO3 (R_NDS32_TLS_DESC_CALL,/* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_TLS_DESC_CALL",/* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + + /* TLS DESC variable access. */ + HOWTO3 (R_NDS32_TLS_DESC_MEM, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_TLS_DESC_MEM",/* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + + /* TLS GD/LD description mark (@tlsdec). */ + HOWTO3 (R_NDS32_RELAX_REMOVE, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_REMOVE", /* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + + /* TLS GD/LD description mark (@tlsdec). */ + HOWTO3 (R_NDS32_RELAX_GROUP, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_GROUP", /* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + + /* LA and FLSI relaxation. */ + HOWTO3 (R_NDS32_LSI, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont,/* complain_on_overflow */ + nds32_elf_ignore_reloc,/* special_function */ + "R_NDS32_LSI", /* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ }; - + +static unsigned long dl_tlsdesc_lazy_trampoline[] = +{ + 0x46200000, /* sethi $r2,#0x0 */ + 0x58210000, /* ori $r2,$r2,#0x0 */ + 0x40217400, /* add $r2,$r2,$gp */ + 0x04210000, /* lwi $r2,[$r2+#0x0] */ + 0x46300000, /* sethi $r3,#0x0 */ + 0x58318000, /* ori $r3,$r3,#0x0 */ + 0x4031f400, /* add $r3,$r3,$gp */ + 0x4a000800, /* jr $r2 */ +}; + +/* === code === */ + +static void +nds32_put_trampoline (void *contents, const unsigned long *template, + unsigned count) +{ + unsigned ix; + + for (ix = 0; ix != count; ix++) + { + unsigned long insn = template[ix]; + bfd_putb32 (insn, (char *) contents + ix * 4); + } +} + /* nds32_insertion_sort sorts an array with nmemb elements of size size. This prototype is the same as qsort (). */ @@ -2224,7 +2713,7 @@ nds32_insertion_sort (void *base, size_t nmemb, size_t size, { char *ptr = (char *) base; int i, j; - char *tmp = xmalloc (size); + char *tmp = alloca (size); /* If i is less than j, i is inserted before j. @@ -2248,7 +2737,6 @@ nds32_insertion_sort (void *base, size_t nmemb, size_t size, memmove (ptr + (j + 1) * size, ptr + j * size, (i - j) * size); memcpy (ptr + j * size, tmp, size); } - free (tmp); } /* Sort relocation by r_offset. @@ -2277,14 +2765,13 @@ compar_reloc (const void *lhs, const void *rhs) } /* Functions listed below are only used for old relocs. - * nds32_elf_9_pcrel_reloc - * nds32_elf_do_9_pcrel_reloc - * nds32_elf_hi20_reloc - * nds32_elf_relocate_hi20 - * nds32_elf_lo12_reloc - * nds32_elf_sda15_reloc - * nds32_elf_generic_reloc - */ + nds32_elf_9_pcrel_reloc + nds32_elf_do_9_pcrel_reloc + nds32_elf_hi20_reloc + nds32_elf_relocate_hi20 + nds32_elf_lo12_reloc + nds32_elf_sda15_reloc + nds32_elf_generic_reloc */ /* Handle the R_NDS32_9_PCREL & R_NDS32_9_PCREL_RELA reloc. */ @@ -2705,8 +3192,7 @@ struct nds32_reloc_map_entry unsigned char elf_reloc_val; }; -static const struct nds32_reloc_map_entry nds32_reloc_map[] = -{ +static const struct nds32_reloc_map_entry nds32_reloc_map[] = { {BFD_RELOC_NONE, R_NDS32_NONE}, {BFD_RELOC_16, R_NDS32_16_RELA}, {BFD_RELOC_32, R_NDS32_32_RELA}, @@ -2765,6 +3251,7 @@ static const struct nds32_reloc_map_entry nds32_reloc_map[] = {BFD_RELOC_NDS32_LONGJUMP5, R_NDS32_LONGJUMP5}, {BFD_RELOC_NDS32_LONGJUMP6, R_NDS32_LONGJUMP6}, {BFD_RELOC_NDS32_LONGJUMP7, R_NDS32_LONGJUMP7}, + {BFD_RELOC_NDS32_SECURITY_16, R_NDS32_SECURITY_16}, {BFD_RELOC_NDS32_LOADSTORE, R_NDS32_LOADSTORE}, {BFD_RELOC_NDS32_9_FIXED, R_NDS32_9_FIXED_RELA}, {BFD_RELOC_NDS32_15_FIXED, R_NDS32_15_FIXED_RELA}, @@ -2822,15 +3309,52 @@ static const struct nds32_reloc_map_entry nds32_reloc_map[] = {BFD_RELOC_NDS32_TLS_LE_LS, R_NDS32_TLS_LE_LS}, {BFD_RELOC_NDS32_TLS_IE_HI20, R_NDS32_TLS_IE_HI20}, {BFD_RELOC_NDS32_TLS_IE_LO12S2, R_NDS32_TLS_IE_LO12S2}, - {BFD_RELOC_NDS32_TLS_TPOFF, R_NDS32_TLS_TPOFF}, {BFD_RELOC_NDS32_TLS_LE_20, R_NDS32_TLS_LE_20}, {BFD_RELOC_NDS32_TLS_LE_15S0, R_NDS32_TLS_LE_15S0}, {BFD_RELOC_NDS32_TLS_LE_15S1, R_NDS32_TLS_LE_15S1}, {BFD_RELOC_NDS32_TLS_LE_15S2, R_NDS32_TLS_LE_15S2}, + + {BFD_RELOC_NDS32_TLS_DESC, R_NDS32_TLS_DESC}, + {BFD_RELOC_NDS32_TLS_DESC_HI20, R_NDS32_TLS_DESC_HI20}, + {BFD_RELOC_NDS32_TLS_DESC_LO12, R_NDS32_TLS_DESC_LO12}, + {BFD_RELOC_NDS32_TLS_DESC_ADD, R_NDS32_TLS_DESC_ADD}, + {BFD_RELOC_NDS32_TLS_DESC_FUNC, R_NDS32_TLS_DESC_FUNC}, + {BFD_RELOC_NDS32_TLS_DESC_CALL, R_NDS32_TLS_DESC_CALL}, + {BFD_RELOC_NDS32_TLS_DESC_MEM, R_NDS32_TLS_DESC_MEM}, + {BFD_RELOC_NDS32_TLS_DESC_20, R_NDS32_TLS_DESC_20}, + {BFD_RELOC_NDS32_TLS_DESC_SDA17S2, R_NDS32_TLS_DESC_SDA17S2}, + {BFD_RELOC_NDS32_TLS_IE_LO12, R_NDS32_TLS_IE_LO12}, + {BFD_RELOC_NDS32_TLS_IEGP_HI20, R_NDS32_TLS_IEGP_HI20}, + {BFD_RELOC_NDS32_TLS_IEGP_LO12, R_NDS32_TLS_IEGP_LO12}, + {BFD_RELOC_NDS32_TLS_IEGP_LO12S2, R_NDS32_TLS_IEGP_LO12S2}, + {BFD_RELOC_NDS32_TLS_IEGP_LW, R_NDS32_TLS_IEGP_LW}, + + {BFD_RELOC_NDS32_REMOVE, R_NDS32_RELAX_REMOVE}, + {BFD_RELOC_NDS32_GROUP, R_NDS32_RELAX_GROUP}, + + {BFD_RELOC_NDS32_ICT_HI20, R_NDS32_ICT_HI20}, + {BFD_RELOC_NDS32_ICT_LO12, R_NDS32_ICT_LO12}, + {BFD_RELOC_NDS32_ICT_25PC, R_NDS32_ICT_25PC}, + {BFD_RELOC_NDS32_ICT_LO12S2, R_NDS32_ICT_LO12S2}, + + {BFD_RELOC_NDS32_LSI, R_NDS32_LSI}, }; /* Patch tag. */ +/* Reserve space for COUNT dynamic relocations in relocation selection + SRELOC. */ + +static inline void +elf32_nds32_allocate_dynrelocs (struct bfd_link_info *info, asection *sreloc, + bfd_size_type count) +{ + BFD_ASSERT (elf_hash_table (info)->dynamic_sections_created); + if (sreloc == NULL) + abort (); + sreloc->size += sizeof (Elf32_External_Rela) * count; +} + static reloc_howto_type * bfd_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, const char *r_name) @@ -2860,6 +3384,13 @@ bfd_elf32_bfd_reloc_type_table_lookup (enum elf_nds32_reloc_type code) } else { + if ((size_t) (code - R_NDS32_RELAX_ENTRY) >= + ARRAY_SIZE (nds32_elf_relax_howto_table)) + { + int i = code; + i += 1; + } + BFD_ASSERT ((size_t) (code - R_NDS32_RELAX_ENTRY) < ARRAY_SIZE (nds32_elf_relax_howto_table)); return &nds32_elf_relax_howto_table[code - R_NDS32_RELAX_ENTRY]; @@ -2876,7 +3407,7 @@ bfd_elf32_bfd_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED, { if (nds32_reloc_map[i].bfd_reloc_val == code) return bfd_elf32_bfd_reloc_type_table_lookup - (nds32_reloc_map[i].elf_reloc_val); + (nds32_reloc_map[i].elf_reloc_val); } return NULL; @@ -2884,7 +3415,7 @@ bfd_elf32_bfd_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED, /* Set the howto pointer for an NDS32 ELF reloc. */ -static void +static bfd_boolean nds32_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED, arelent *cache_ptr, Elf_Internal_Rela *dst) { @@ -2894,20 +3425,35 @@ nds32_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED, arelent *cache_ptr, if (r_type > R_NDS32_GNU_VTENTRY) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: invalid NDS32 reloc number: %d"), abfd, r_type); - r_type = 0; + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; } + + BFD_ASSERT (ELF32_R_TYPE (dst->r_info) <= R_NDS32_GNU_VTENTRY); cache_ptr->howto = bfd_elf32_bfd_reloc_type_table_lookup (r_type); + return TRUE; } -static void +static bfd_boolean nds32_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, arelent *cache_ptr, Elf_Internal_Rela *dst) { - BFD_ASSERT ((ELF32_R_TYPE (dst->r_info) == R_NDS32_NONE) - || ((ELF32_R_TYPE (dst->r_info) > R_NDS32_GNU_VTENTRY) - && (ELF32_R_TYPE (dst->r_info) < R_NDS32_max))); - cache_ptr->howto = bfd_elf32_bfd_reloc_type_table_lookup (ELF32_R_TYPE (dst->r_info)); + unsigned int r_type = ELF32_R_TYPE (dst->r_info); + + if ((r_type == R_NDS32_NONE) + || ((r_type > R_NDS32_GNU_VTENTRY) + && (r_type < R_NDS32_max))) + { + cache_ptr->howto = bfd_elf32_bfd_reloc_type_table_lookup (r_type); + return TRUE; + } + + /* xgettext:c-format */ + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; } /* Support for core dump NOTE sections. @@ -2922,29 +3468,29 @@ nds32_elf_grok_prstatus (bfd *abfd, Elf_Internal_Note *note) switch (note->descsz) { case 0x114: - /* Linux/NDS32 32-bit, ABI1 */ + /* Linux/NDS32 32-bit, ABI1 */ - /* pr_cursig */ + /* pr_cursig */ elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12); - /* pr_pid */ + /* pr_pid */ elf_tdata (abfd)->core->pid = bfd_get_32 (abfd, note->descdata + 24); - /* pr_reg */ + /* pr_reg */ offset = 72; size = 200; break; case 0xfc: - /* Linux/NDS32 32-bit */ + /* Linux/NDS32 32-bit */ - /* pr_cursig */ + /* pr_cursig */ elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12); - /* pr_pid */ + /* pr_pid */ elf_tdata (abfd)->core->pid = bfd_get_32 (abfd, note->descdata + 24); - /* pr_reg */ + /* pr_reg */ offset = 72; size = 176; break; @@ -2964,7 +3510,7 @@ nds32_elf_grok_psinfo (bfd *abfd, Elf_Internal_Note *note) switch (note->descsz) { case 124: - /* Linux/NDS32 */ + /* Linux/NDS32 */ /* __kernel_uid_t, __kernel_gid_t are short on NDS32 platform. */ elf_tdata (abfd)->core->program = @@ -3097,20 +3643,20 @@ nds32_elf_final_sda_base (bfd *output_bfd, struct bfd_link_info *info, struct elf_nds32_link_hash_table *table; struct bfd_link_hash_entry *h, *h2; long unsigned int total = 0; + asection *first = NULL, *final = NULL, *temp; + bfd_vma sda_base = 0; h = bfd_link_hash_lookup (info->hash, "_SDA_BASE_", FALSE, FALSE, TRUE); if (!h || (h->type != bfd_link_hash_defined && h->type != bfd_link_hash_defweak)) { - asection *first = NULL, *final = NULL, *temp; - bfd_vma sda_base; /* The first section must be 4-byte aligned to promise _SDA_BASE_ being 4 byte-aligned. Therefore, it has to set the first section ".data" 4 byte-aligned. */ static const char sec_name[SDA_SECTION_NUM][10] = - { - ".data", ".got", ".sdata_d", ".sdata_w", ".sdata_h", ".sdata_b", - ".sbss_b", ".sbss_h", ".sbss_w", ".sbss_d" - }; + { + ".data", ".got", ".sdata_d", ".sdata_w", ".sdata_h", ".sdata_b", + ".sbss_b", ".sbss_h", ".sbss_w", ".sbss_d" + }; size_t i = 0; if (output_bfd->sections == NULL) @@ -3120,7 +3666,7 @@ nds32_elf_final_sda_base (bfd *output_bfd, struct bfd_link_info *info, } /* Get the first and final section. */ - while (i < sizeof (sec_name) / sizeof (sec_name [0])) + while (i < ARRAY_SIZE (sec_name)) { temp = bfd_get_section_by_name (output_bfd, sec_name[i]); if (temp && !first && (temp->size != 0 || temp->rawsize != 0)) @@ -3162,7 +3708,7 @@ nds32_elf_final_sda_base (bfd *output_bfd, struct bfd_link_info *info, /* Find the section sda_base located. */ i = 0; - while (i < sizeof (sec_name) / sizeof (sec_name [0])) + while (i < ARRAY_SIZE (sec_name)) { final = bfd_get_section_by_name (output_bfd, sec_name[i]); if (final && (final->size != 0 || final->rawsize != 0) @@ -3177,17 +3723,44 @@ nds32_elf_final_sda_base (bfd *output_bfd, struct bfd_link_info *info, } else { - /* There is not any data section in output bfd, and set _SDA_BASE_ in - first output section. */ - first = output_bfd->sections; - while (first && first->size == 0 && first->rawsize == 0) - first = first->next; + /* If there is not any default data section in output bfd, try to find + the first data section. If no data section be found, just simplily + choose the first output section. */ + temp = output_bfd->sections; + while (temp) + { + if (temp->flags & SEC_ALLOC + && (((temp->flags & SEC_DATA) + && ((temp->flags & SEC_READONLY) == 0)) + || (temp->flags & SEC_LOAD) == 0) + && (temp->size != 0 || temp->rawsize != 0)) + { + if (!first) + first = temp; + final = temp; + } + temp = temp->next; + } + + /* There is no data or bss section. */ + if (!first || (first->size == 0 && first->rawsize == 0)) + { + first = output_bfd->sections; + while (first && first->size == 0 && first->rawsize == 0) + first = first->next; + } + + /* There is no concrete section. */ if (!first) { *psb = elf_gp (output_bfd); return bfd_reloc_ok; } - sda_base = first->vma + first->rawsize; + + if (final && (final->vma + final->rawsize - first->vma) <= 0x4000) + sda_base = final->vma / 2 + final->rawsize / 2 + first->vma / 2; + else + sda_base = first->vma + 0x2000; } sda_base -= first->vma; @@ -3201,24 +3774,34 @@ nds32_elf_final_sda_base (bfd *output_bfd, struct bfd_link_info *info, sda_rela_sec = first; - table = nds32_elf_hash_table (info); - relax_fp_as_gp = table->relax_fp_as_gp; - if (relax_fp_as_gp) - { - h2 = bfd_link_hash_lookup (info->hash, FP_BASE_NAME, - FALSE, FALSE, FALSE); - /* Define a weak FP_BASE_NAME here to prevent the undefined symbol. - And set FP equal to SDA_BASE to do relaxation for - la $fp, _FP_BASE_. */ - if (!_bfd_generic_link_add_one_symbol - (info, output_bfd, FP_BASE_NAME, BSF_GLOBAL | BSF_WEAK, - first, (bfd_vma) sda_base, (const char *) NULL, - FALSE, get_elf_backend_data (output_bfd)->collect, &h2)) - return FALSE; - } } - if (add_symbol) + /* Set _FP_BASE_ to _SDA_BASE_. */ + table = nds32_elf_hash_table (info); + relax_fp_as_gp = table->relax_fp_as_gp; + h2 = bfd_link_hash_lookup (info->hash, FP_BASE_NAME, FALSE, FALSE, FALSE); + /* _SDA_BASE_ is difined in linker script. */ + if (!first) + { + first = h->u.def.section; + sda_base = h->u.def.value; + } + + if (relax_fp_as_gp && h2 + && (h2->type == bfd_link_hash_undefweak + || h2->type == bfd_link_hash_undefined)) + { + /* Define a weak FP_BASE_NAME here to prevent the undefined symbol. + And set FP equal to SDA_BASE to do relaxation for + la $fp, _FP_BASE_. */ + if (!_bfd_generic_link_add_one_symbol + (info, output_bfd, FP_BASE_NAME, BSF_GLOBAL | BSF_WEAK, + first, sda_base, (const char *) NULL, + FALSE, get_elf_backend_data (output_bfd)->collect, &h2)) + return FALSE; + } + + if (add_symbol == TRUE) { if (h) { @@ -3229,7 +3812,7 @@ nds32_elf_final_sda_base (bfd *output_bfd, struct bfd_link_info *info, } else { - _bfd_error_handler (_("error: Can't find symbol: _SDA_BASE_.")); + _bfd_error_handler (_("error: can't find symbol: %s"), "_SDA_BASE_"); return bfd_reloc_dangerous; } } @@ -3275,6 +3858,8 @@ nds32_elf_link_hash_newfunc (struct bfd_hash_entry *entry, eh = (struct elf_nds32_link_hash_entry *) ret; eh->dyn_relocs = NULL; eh->tls_type = GOT_UNKNOWN; + eh->offset_to_gp = 0; + eh->indirect_call = FALSE; } return (struct bfd_hash_entry *) ret; @@ -3303,22 +3888,61 @@ nds32_elf_link_hash_table_create (bfd *abfd) return NULL; } + ret->sdynbss = NULL; + ret->srelbss = NULL; + ret->sym_ld_script = NULL; + return &ret->root.root; } +/* Create .got, .gotplt, and .rela.got sections in DYNOBJ, and set up + shortcuts to them in our hash table. */ + +static bfd_boolean +create_got_section (bfd *dynobj, struct bfd_link_info *info) +{ + struct elf_link_hash_table *ehtab; + + if (!_bfd_elf_create_got_section (dynobj, info)) + return FALSE; + + ehtab = elf_hash_table (info); + ehtab->sgot = bfd_get_section_by_name (dynobj, ".got"); + ehtab->sgotplt = bfd_get_section_by_name (dynobj, ".got.plt"); + if (!ehtab->sgot || !ehtab->sgotplt) + abort (); + + /* _bfd_elf_create_got_section will create it for us. */ + ehtab->srelgot = bfd_get_section_by_name (dynobj, ".rela.got"); + if (ehtab->srelgot == NULL + || !bfd_set_section_flags (dynobj, ehtab->srelgot, + (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS + | SEC_IN_MEMORY | SEC_LINKER_CREATED + | SEC_READONLY)) + || !bfd_set_section_alignment (dynobj, ehtab->srelgot, 2)) + return FALSE; + + return TRUE; +} + /* Create dynamic sections when linking against a dynamic object. */ static bfd_boolean nds32_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) { + struct elf_link_hash_table *ehtab; struct elf_nds32_link_hash_table *htab; flagword flags, pltflags; register asection *s; const struct elf_backend_data *bed; int ptralign = 2; /* 32-bit */ + const char *secname; + char *relname; + flagword secflags; + asection *sec; bed = get_elf_backend_data (abfd); - + ehtab = elf_hash_table (info); htab = nds32_elf_hash_table (info); /* We need to create .plt, .rel[a].plt, .got, .got.plt, .dynbss, and @@ -3335,7 +3959,7 @@ nds32_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) pltflags |= SEC_READONLY; s = bfd_make_section (abfd, ".plt"); - htab->root.splt = s; + ehtab->splt = s; if (s == NULL || !bfd_set_section_flags (abfd, s, pltflags) || !bfd_set_section_alignment (abfd, s, bed->plt_alignment)) @@ -3364,40 +3988,33 @@ nds32_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) s = bfd_make_section (abfd, bed->default_use_rela_p ? ".rela.plt" : ".rel.plt"); - htab->root.srelplt = s; + ehtab->srelplt = s; if (s == NULL || !bfd_set_section_flags (abfd, s, flags | SEC_READONLY) || !bfd_set_section_alignment (abfd, s, ptralign)) return FALSE; - if (htab->root.sgot == NULL && !_bfd_elf_create_got_section (abfd, info)) + if (ehtab->sgot == NULL && !create_got_section (abfd, info)) return FALSE; - { - const char *secname; - char *relname; - flagword secflags; - asection *sec; - - for (sec = abfd->sections; sec; sec = sec->next) - { - secflags = bfd_get_section_flags (abfd, sec); - if ((secflags & (SEC_DATA | SEC_LINKER_CREATED)) - || ((secflags & SEC_HAS_CONTENTS) != SEC_HAS_CONTENTS)) - continue; - secname = bfd_get_section_name (abfd, sec); - relname = (char *) bfd_malloc ((bfd_size_type) strlen (secname) + 6); - strcpy (relname, ".rela"); - strcat (relname, secname); - if (bfd_get_section_by_name (abfd, secname)) - continue; - s = bfd_make_section (abfd, relname); - if (s == NULL - || !bfd_set_section_flags (abfd, s, flags | SEC_READONLY) - || !bfd_set_section_alignment (abfd, s, ptralign)) - return FALSE; - } - } + for (sec = abfd->sections; sec; sec = sec->next) + { + secflags = bfd_get_section_flags (abfd, sec); + if ((secflags & (SEC_DATA | SEC_LINKER_CREATED)) + || ((secflags & SEC_HAS_CONTENTS) != SEC_HAS_CONTENTS)) + continue; + secname = bfd_get_section_name (abfd, sec); + relname = (char *) bfd_malloc ((bfd_size_type) strlen (secname) + 6); + strcpy (relname, ".rela"); + strcat (relname, secname); + if (bfd_get_section_by_name (abfd, secname)) + continue; + s = bfd_make_section (abfd, relname); + if (s == NULL + || !bfd_set_section_flags (abfd, s, flags | SEC_READONLY) + || !bfd_set_section_alignment (abfd, s, ptralign)) + return FALSE; + } if (bed->want_dynbss) { @@ -3453,8 +4070,8 @@ nds32_elf_copy_indirect_symbol (struct bfd_link_info *info, { if (edir->dyn_relocs != NULL) { - struct elf_dyn_relocs **pp; - struct elf_dyn_relocs *p; + struct elf_nds32_dyn_relocs **pp; + struct elf_nds32_dyn_relocs *p; if (ind->root.type == bfd_link_hash_indirect) abort (); @@ -3463,7 +4080,7 @@ nds32_elf_copy_indirect_symbol (struct bfd_link_info *info, list. Merge any entries against the same section. */ for (pp = &eind->dyn_relocs; (p = *pp) != NULL;) { - struct elf_dyn_relocs *q; + struct elf_nds32_dyn_relocs *q; for (q = edir->dyn_relocs; q != NULL; q = q->next) if (q->sec == p->sec) @@ -3483,25 +4100,18 @@ nds32_elf_copy_indirect_symbol (struct bfd_link_info *info, eind->dyn_relocs = NULL; } - _bfd_elf_link_hash_copy_indirect (info, dir, ind); -} - -/* Find dynamic relocs for H that apply to read-only sections. */ - -static asection * -readonly_dynrelocs (struct elf_link_hash_entry *h) -{ - struct elf_dyn_relocs *p; - - for (p = elf32_nds32_hash_entry (h)->dyn_relocs; p != NULL; p = p->next) + if (ind->root.type == bfd_link_hash_indirect) { - asection *s = p->sec->output_section; - - if (s != NULL && (s->flags & SEC_READONLY) != 0) - return p->sec; + if (dir->got.refcount <= 0) + { + edir->tls_type = eind->tls_type; + eind->tls_type = GOT_UNKNOWN; + } } - return NULL; + + _bfd_elf_link_hash_copy_indirect (info, dir, ind); } + /* Adjust a symbol defined by a dynamic object and referenced by a regular object. The current definition is in some section of the @@ -3514,6 +4124,8 @@ nds32_elf_adjust_dynamic_symbol (struct bfd_link_info *info, struct elf_link_hash_entry *h) { struct elf_nds32_link_hash_table *htab; + struct elf_nds32_link_hash_entry *eh; + struct elf_nds32_dyn_relocs *p; bfd *dynobj; asection *s; unsigned int power_of_two; @@ -3558,7 +4170,8 @@ nds32_elf_adjust_dynamic_symbol (struct bfd_link_info *info, if (h->is_weakalias) { struct elf_link_hash_entry *def = weakdef (h); - BFD_ASSERT (def->root.type == bfd_link_hash_defined); + BFD_ASSERT (def->root.type == bfd_link_hash_defined + || def->root.type == bfd_link_hash_defweak); h->root.u.def.section = def->root.u.def.section; h->root.u.def.value = def->root.u.def.value; return TRUE; @@ -3580,15 +4193,24 @@ nds32_elf_adjust_dynamic_symbol (struct bfd_link_info *info, return TRUE; /* If -z nocopyreloc was given, we won't generate them either. */ - if (0 && info->nocopyreloc) + if (info->nocopyreloc) { h->non_got_ref = 0; return TRUE; } - /* If we don't find any dynamic relocs in read-only sections, then - we'll be keeping the dynamic relocs and avoiding the copy reloc. */ - if (0 && !readonly_dynrelocs (h)) + eh = (struct elf_nds32_link_hash_entry *) h; + for (p = eh->dyn_relocs; p != NULL; p = p->next) + { + s = p->sec->output_section; + if (s != NULL && (s->flags & (SEC_READONLY | SEC_HAS_CONTENTS)) != 0) + break; + } + + /* If we didn't find any dynamic relocs in sections which needs the + copy reloc, then we'll be keeping the dynamic relocs and avoiding + the copy reloc. */ + if (p == NULL) { h->non_got_ref = 0; return TRUE; @@ -3653,25 +4275,31 @@ static bfd_boolean allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) { struct bfd_link_info *info; + struct elf_link_hash_table *ehtab; struct elf_nds32_link_hash_table *htab; struct elf_nds32_link_hash_entry *eh; - struct elf_dyn_relocs *p; + struct elf_nds32_dyn_relocs *p; if (h->root.type == bfd_link_hash_indirect) return TRUE; + /* When warning symbols are created, they **replace** the "real" + entry in the hash table, thus we never get to see the real + symbol in a hash traversal. So look at it now. */ if (h->root.type == bfd_link_hash_warning) - /* When warning symbols are created, they **replace** the "real" - entry in the hash table, thus we never get to see the real - symbol in a hash traversal. So look at it now. */ h = (struct elf_link_hash_entry *) h->root.u.i.link; + eh = (struct elf_nds32_link_hash_entry *) h; + info = (struct bfd_link_info *) inf; + ehtab = elf_hash_table (info); htab = nds32_elf_hash_table (info); + if (htab == NULL) + return FALSE; - eh = (struct elf_nds32_link_hash_entry *) h; - - if (htab->root.dynamic_sections_created && h->plt.refcount > 0) + if ((htab->root.dynamic_sections_created || h->type == STT_GNU_IFUNC) + && h->plt.refcount > 0 + && !(bfd_link_pie (info) && h->def_regular)) { /* Make sure this symbol is output as a dynamic symbol. Undefined weak syms won't yet be marked as dynamic. */ @@ -3683,7 +4311,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, bfd_link_pic (info), h)) { - asection *s = htab->root.splt; + asection *s = ehtab->splt; /* If this is the first .plt entry, make room for the special first entry. */ @@ -3708,10 +4336,12 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) /* We also need to make an entry in the .got.plt section, which will be placed in the .got section by the linker script. */ - htab->root.sgotplt->size += 4; + ehtab->sgotplt->size += 4; /* We also need to make an entry in the .rel.plt section. */ - htab->root.srelplt->size += sizeof (Elf32_External_Rela); + ehtab->srelplt->size += sizeof (Elf32_External_Rela); + if (htab->tls_desc_trampoline) + htab->next_tls_desc_index++; } else { @@ -3727,7 +4357,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) if (h->got.refcount > 0) { - asection *s; + asection *sgot; bfd_boolean dyn; int tls_type = elf32_nds32_hash_entry (h)->tls_type; @@ -3739,22 +4369,44 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) return FALSE; } - s = htab->root.sgot; - h->got.offset = s->size; + sgot = elf_hash_table (info)->sgot; + h->got.offset = sgot->size; if (tls_type == GOT_UNKNOWN) abort (); - else if (tls_type == GOT_NORMAL - || tls_type == GOT_TLS_IE) - /* Need a GOT slot. */ - s->size += 4; + + /* Non-TLS symbols, and TLS_IE need one GOT slot. */ + if (tls_type & (GOT_NORMAL | GOT_TLS_IE | GOT_TLS_IEGP)) + sgot->size += 4; + else + { + /* TLS_DESC, TLS_GD, and TLS_LD need 2 consecutive GOT slots. */ + if (tls_type & GOT_TLS_DESC) + sgot->size += 8; + } dyn = htab->root.dynamic_sections_created; + if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, bfd_link_pic (info), h)) - htab->root.srelgot->size += sizeof (Elf32_External_Rela); + { + if (tls_type == GOT_TLS_DESC && htab->tls_desc_trampoline) + { + /* TLS_DESC with trampoline needs a relocation slot + within .rela.plt. */ + htab->num_tls_desc++; + ehtab->srelplt->size += sizeof (Elf32_External_Rela); + htab->tls_trampoline = -1; + } + else + { + /* other relocations, including TLS_DESC without trampoline, need + a relocation slot within .rela.got. */ + ehtab->srelgot->size += sizeof (Elf32_External_Rela); + } + } } else - h->got.offset = (bfd_vma) - 1; + h->got.offset = (bfd_vma) -1; if (eh->dyn_relocs == NULL) return TRUE; @@ -3769,7 +4421,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) { if (h->def_regular && (h->forced_local || info->symbolic)) { - struct elf_dyn_relocs **pp; + struct elf_nds32_dyn_relocs **pp; for (pp = &eh->dyn_relocs; (p = *pp) != NULL;) { @@ -3810,7 +4462,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) eh->dyn_relocs = NULL; - keep:; +keep:; } /* Finally, allocate space. */ @@ -3823,29 +4475,50 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) return TRUE; } -/* Set DF_TEXTREL if we find any dynamic relocs that apply to - read-only sections. */ +/* Add relocation REL to the end of relocation section SRELOC. */ + +static void +elf32_nds32_add_dynreloc (bfd *output_bfd, + struct bfd_link_info *info ATTRIBUTE_UNUSED, + asection *sreloc, Elf_Internal_Rela *rel) +{ + bfd_byte *loc; + if (sreloc == NULL) + abort (); + + loc = sreloc->contents; + loc += sreloc->reloc_count++ * sizeof (Elf32_External_Rela); + if (sreloc->reloc_count * sizeof (Elf32_External_Rela) > sreloc->size) + abort (); + + bfd_elf32_swap_reloca_out (output_bfd, rel, loc); +} + +/* Find any dynamic relocs that apply to read-only sections. */ static bfd_boolean -maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) +readonly_dynrelocs (struct elf_link_hash_entry *h, void *inf) { - asection *sec; + struct elf_nds32_link_hash_entry *eh; + struct elf_nds32_dyn_relocs *p; - if (h->root.type == bfd_link_hash_indirect) - return TRUE; + if (h->root.type == bfd_link_hash_warning) + h = (struct elf_link_hash_entry *) h->root.u.i.link; - sec = readonly_dynrelocs (h); - if (sec != NULL) + eh = (struct elf_nds32_link_hash_entry *) h; + for (p = eh->dyn_relocs; p != NULL; p = p->next) { - struct bfd_link_info *info = (struct bfd_link_info *) info_p; + asection *s = p->sec->output_section; - info->flags |= DF_TEXTREL; - info->callbacks->minfo - (_("%B: dynamic relocation against `%T' in read-only section `%A'\n"), - sec->owner, h->root.root.string, sec); + if (s != NULL && (s->flags & SEC_READONLY) != 0) + { + struct bfd_link_info *info = (struct bfd_link_info *) inf; - /* Not an error, just cut short the traversal. */ - return FALSE; + info->flags |= DF_TEXTREL; + + /* Not an error, just cut short the traversal. */ + return FALSE; + } } return TRUE; } @@ -3856,20 +4529,24 @@ static bfd_boolean nds32_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, struct bfd_link_info *info) { - struct elf_nds32_link_hash_table *htab; bfd *dynobj; asection *s; + bfd_boolean plt; bfd_boolean relocs; bfd *ibfd; + struct elf_nds32_link_hash_table *htab; htab = nds32_elf_hash_table (info); - dynobj = htab->root.dynobj; + if (htab == NULL) + return FALSE; + + dynobj = elf_hash_table (info)->dynobj; BFD_ASSERT (dynobj != NULL); - if (htab->root.dynamic_sections_created) + if (elf_hash_table (info)->dynamic_sections_created) { /* Set the contents of the .interp section to the interpreter. */ - if (bfd_link_executable (info) && !info->nointerp) + if (bfd_link_executable (info)) { s = bfd_get_section_by_name (dynobj, ".interp"); BFD_ASSERT (s != NULL); @@ -3886,16 +4563,19 @@ nds32_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, bfd_signed_vma *end_local_got; bfd_size_type locsymcount; Elf_Internal_Shdr *symtab_hdr; - asection *srel; + asection *sgot; + char *local_tls_type; + unsigned long symndx; + bfd_vma *local_tlsdesc_gotent; if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour) continue; for (s = ibfd->sections; s != NULL; s = s->next) { - struct elf_dyn_relocs *p; + struct elf_nds32_dyn_relocs *p; - for (p = ((struct elf_dyn_relocs *) + for (p = ((struct elf_nds32_dyn_relocs *) elf_section_data (s)->local_dynrel); p != NULL; p = p->next) { @@ -3909,8 +4589,8 @@ nds32_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, } else if (p->count != 0) { - srel = elf_section_data (p->sec)->sreloc; - srel->size += p->count * sizeof (Elf32_External_Rela); + asection *sreloc = elf_section_data (p->sec)->sreloc; + sreloc->size += p->count * sizeof (Elf32_External_Rela); if ((p->sec->output_section->flags & SEC_READONLY) != 0) info->flags |= DF_TEXTREL; } @@ -3924,19 +4604,57 @@ nds32_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, symtab_hdr = &elf_tdata (ibfd)->symtab_hdr; locsymcount = symtab_hdr->sh_info; end_local_got = local_got + locsymcount; - s = htab->root.sgot; - srel = htab->root.srelgot; - for (; local_got < end_local_got; ++local_got) + sgot = elf_hash_table (info)->sgot; + local_tls_type = elf32_nds32_local_got_tls_type (ibfd); + local_tlsdesc_gotent = elf32_nds32_local_tlsdesc_gotent (ibfd); + for (symndx = 0; local_got < end_local_got; + ++local_got, ++local_tls_type, ++local_tlsdesc_gotent, ++symndx) { if (*local_got > 0) { - *local_got = s->size; - s->size += 4; - if (bfd_link_pic (info)) - srel->size += sizeof (Elf32_External_Rela); + int num_of_got_entry_needed = 0; + *local_got = sgot->size; + *local_tlsdesc_gotent = sgot->size; + + /* TLS_NORMAL, and TLS_IE need one slot in .got. */ + if (*local_tls_type & (GOT_NORMAL | GOT_TLS_IE | GOT_TLS_IEGP)) + num_of_got_entry_needed = 1; + /* TLS_GD, TLS_LD, and TLS_DESC need an 8-byte structure in the GOT. */ + else if (*local_tls_type & GOT_TLS_DESC) + num_of_got_entry_needed = 2; + + sgot->size += (num_of_got_entry_needed << 2); + + /* non-relax-able TLS_DESCs need a slot in .rela.plt. + others need a slot in .rela.got. */ + if (*local_tls_type == GOT_TLS_DESC) + { + if (bfd_link_pic (info)) + { + if (htab->tls_desc_trampoline) + { + htab->num_tls_desc++; + htab->root.srelplt->size += sizeof (Elf32_External_Rela); + htab->tls_trampoline = -1; + } + else + htab->root.srelgot->size += sizeof (Elf32_External_Rela); + } + else + { + /* TLS_DESC -> TLS_LE */ + } + } + else + { + htab->root.srelgot->size += sizeof (Elf32_External_Rela); + } } else - *local_got = (bfd_vma) - 1; + { + *local_got = (bfd_vma) -1; + *local_tlsdesc_gotent = (bfd_vma) -1; + } } } @@ -3944,8 +4662,36 @@ nds32_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, sym dynamic relocs. */ elf_link_hash_traverse (&htab->root, allocate_dynrelocs, (void *) info); + /* For every jump slot reserved in the sgotplt, reloc_count is + incremented. However, when we reserve space for TLS descriptors, + it's not incremented, so in order to compute the space reserved + for them, it suffices to multiply the reloc count by the jump + slot size. */ + if (htab->tls_desc_trampoline && htab->root.srelplt) + htab->sgotplt_jump_table_size = elf32_nds32_compute_jump_table_size (htab); + + if (htab->tls_trampoline) + { + htab->tls_trampoline = htab->root.splt->size; + + /* If we're not using lazy TLS relocations, don't generate the + PLT and GOT entries they require. */ + if (!(info->flags & DF_BIND_NOW)) + { + htab->dt_tlsdesc_got = htab->root.sgot->size; + htab->root.sgot->size += 4; + + htab->dt_tlsdesc_plt = htab->root.splt->size; + htab->root.splt->size += 4 * ARRAY_SIZE (dl_tlsdesc_lazy_trampoline); + } + } + /* We now have determined the sizes of the various dynamic sections. Allocate memory for them. */ + /* The check_relocs and adjust_dynamic_symbol entry points have + determined the sizes of the various dynamic sections. Allocate + memory for them. */ + plt = FALSE; relocs = FALSE; for (s = dynobj->sections; s != NULL; s = s->next) { @@ -3956,18 +4702,19 @@ nds32_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, { /* Strip this section if we don't need it; see the comment below. */ + plt = s->size != 0; } - else if (s == htab->root.sgot) + else if (s == elf_hash_table (info)->sgot) { got_size += s->size; } - else if (s == htab->root.sgotplt) + else if (s == elf_hash_table (info)->sgotplt) { got_size += s->size; } else if (strncmp (bfd_get_section_name (dynobj, s), ".rela", 5) == 0) { - if (s->size != 0 && s != htab->root.srelplt) + if (s->size != 0 && s != elf_hash_table (info)->srelplt) relocs = TRUE; /* We use the reloc_count field as a counter if we need @@ -4013,16 +4760,15 @@ nds32_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, must add the entries now so that we get the correct size for the .dynamic section. The DT_DEBUG entry is filled in by the dynamic linker and used by the debugger. */ -#define add_dynamic_entry(TAG, VAL) \ - _bfd_elf_add_dynamic_entry (info, TAG, VAL) +#define add_dynamic_entry(TAG, VAL) _bfd_elf_add_dynamic_entry (info, TAG, VAL) - if (!bfd_link_pic (info)) + if (bfd_link_executable (info)) { if (!add_dynamic_entry (DT_DEBUG, 0)) return FALSE; } - if (htab->root.splt->size != 0) + if (elf_hash_table (info)->splt->size != 0) { if (!add_dynamic_entry (DT_PLTGOT, 0) || !add_dynamic_entry (DT_PLTRELSZ, 0) @@ -4031,6 +4777,14 @@ nds32_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, return FALSE; } + if (htab->tls_desc_trampoline && plt) + { + if (htab->dt_tlsdesc_plt + && (!add_dynamic_entry (DT_TLSDESC_PLT, 0) + || !add_dynamic_entry (DT_TLSDESC_GOT, 0))) + return FALSE; + } + if (relocs) { if (!add_dynamic_entry (DT_RELA, 0) @@ -4041,7 +4795,7 @@ nds32_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, /* If any dynamic relocs apply to a read-only section, then we need a DT_TEXTREL entry. */ if ((info->flags & DF_TEXTREL) == 0) - elf_link_hash_traverse (&htab->root, maybe_set_textrel, + elf_link_hash_traverse (&htab->root, readonly_dynrelocs, (void *) info); if ((info->flags & DF_TEXTREL) != 0) @@ -4076,10 +4830,11 @@ nds32_relocate_contents (reloc_howto_type *howto, bfd *input_bfd, switch (size) { default: + case 0: + case 1: + case 8: abort (); break; - case 0: - return bfd_reloc_ok; case 2: x = bfd_getb16 (location); break; @@ -4297,9 +5052,9 @@ nds32_elf_output_symbol_hook (struct bfd_link_info *info, else source = input_sec->owner->filename; - fprintf (sym_ld_script, "\t%s = 0x%08lx;\t /* %s */\n", + fprintf (sym_ld_script, "\t%s = 0x%08lx;\t /* %s */\n", h->root.root.string, - (long) (h->root.u.def.value + (h->root.u.def.value + h->root.u.def.section->output_section->vma + h->root.u.def.section->output_offset), source); } @@ -4340,52 +5095,243 @@ nds32_elf_output_symbol_hook (struct bfd_link_info *info, section, which means that the addend must be adjusted accordingly. */ +/* Return the base VMA address which should be subtracted from real addresses + when resolving @dtpoff relocation. + This is PT_TLS segment p_vaddr. */ + +/* Return the relocation value for @tpoff relocation + if STT_TLS virtual address is ADDRESS. */ + +/* Return the relocation value for @gottpoff relocation + if STT_TLS virtual address is ADDRESS. */ static bfd_vma -dtpoff_base (struct bfd_link_info *info) +gottpoff (struct bfd_link_info *info, bfd_vma address) { + bfd_vma tp_base; + bfd_vma tp_offset; + /* If tls_sec is NULL, we should have signalled an error already. */ if (elf_hash_table (info)->tls_sec == NULL) return 0; - return elf_hash_table (info)->tls_sec->vma; + + tp_base = elf_hash_table (info)->tls_sec->vma; + tp_offset = address - tp_base; + + return tp_offset; } -static bfd_boolean -nds32_elf_relocate_section (bfd * output_bfd ATTRIBUTE_UNUSED, - struct bfd_link_info * info, - bfd * input_bfd, - asection * input_section, - bfd_byte * contents, - Elf_Internal_Rela * relocs, - Elf_Internal_Sym * local_syms, - asection ** local_sections) +/* Move all SECURITY_16 to the final one for each instruction. */ + +static void +nds32_elf_crc_adjust_reloc (Elf_Internal_Rela *relocs, + Elf_Internal_Rela *relend) { - Elf_Internal_Shdr *symtab_hdr; - struct elf_link_hash_entry **sym_hashes; - Elf_Internal_Rela *rel, *relend; - bfd_boolean ret = TRUE; /* Assume success. */ - int align = 0; - bfd_reloc_status_type r; - const char *errmsg = NULL; - bfd_vma gp; - struct elf_nds32_link_hash_table *htab; - bfd *dynobj; - bfd_vma *local_got_offsets; + Elf_Internal_Rela *rel, *crc_rel = NULL; + Elf_Internal_Rela rel_temp; + + for (rel = relocs; rel < relend; rel++) + { + if (crc_rel && crc_rel->r_offset == rel->r_offset) + { + memcpy (&rel_temp, rel, sizeof (Elf_Internal_Rela)); + memcpy (rel, crc_rel, sizeof (Elf_Internal_Rela)); + memcpy (crc_rel, &rel_temp, sizeof (Elf_Internal_Rela)); + crc_rel = rel; + } + else if (ELF32_R_TYPE (rel->r_info) == R_NDS32_SECURITY_16) + { + crc_rel = rel; + continue; + } + } +} + +static bfd_boolean +patch_tls_desc_to_ie (bfd_byte *contents, Elf_Internal_Rela *rel, bfd *ibfd) +{ + /* TLS_GD/TLS_LD model #1 + 46 00 00 00 sethi $r0,#0x0 + 58 00 00 00 ori $r0,$r0,#0x0 + 40 00 74 00 add $r0,$r0,$gp + 04 10 00 00 lwi $r1,[$r0+#0x0] + 4b e0 04 01 jral $lp,$r1 */ + + /* TLS_GD/TLS_LD model #2 + 46 00 00 00 sethi $r0,#0x0 + 58 00 00 00 ori $r0,$r0,#0x0 + 38 10 74 02 lw $r1,[$r0+($gp<<#0x0)] <= TODO: not necessary $r1 register allocation + 40 00 74 00 add $r0,$r0,$gp + 4b e0 04 01 jral $lp,$r1 */ + + /* TLS_IE model (non-PIC) + 46 00 00 00 sethi $r0,#0x0 + 04 00 00 00 lwi $r0,[$r0+#0x0] + 38 00 64 02 lw $r0,[$r0+($r25<<#0x0)] */ + + /* TLS_IE model (PIC) + 46 00 00 00 sethi $r0,#0x0 + 58 00 00 00 ori $r0,$r0,#0x0 + 38 00 74 02 lw $r0,[$r0+($gp<<#0x0)] + 38 00 64 02 lw $r0,[$r0+($r25<<#0x0)] */ + + /* TLS_GD_TO_IE model + 46 00 00 00 sethi $r0,#0x0 + 58 00 00 00 ori $r0,$r0,#0x0 + 40 00 74 00 add $r0,$rM,$gp + 04 00 00 01 lwi $r0,[$r0+#0x4] + 40 00 64 00 add $r0,$r0,$r25 */ + + bfd_boolean rz = FALSE; + + typedef struct + { + uint32_t opcode; + uint32_t mask; + } pat_t; + + uint32_t patch[3] = + { + 0x40007400, /* add $r0,$rM,$gp */ + 0x04000001, /* lwi $r0,[$r0+#0x4] */ + 0x40006400, /* add $r0,$r0,$r25 */ + }; + + pat_t mode0[3] = + { + { 0x40000000, 0xfe0003ff }, + { 0x04000000, 0xfe000000 }, + { 0x4be00001, 0xffff83ff }, + }; + + pat_t mode1[3] = + { + { 0x38007402, 0xfe007fff }, + { 0x40007400, 0xfe007fff }, + { 0x4be00001, 0xffff83ff }, + }; + + unsigned char *p = contents + rel->r_offset; + + uint32_t insn; + uint32_t regidx = 0; + insn = bfd_getb32 (p); + if (INSN_SETHI == (0xfe0fffffu & insn)) + { + regidx = 0x1f & (insn >> 20); + p += 4; + } + + insn = bfd_getb32 (p); + if (INSN_ORI == (0xfe007fffu & insn)) + { + regidx = 0x1f & (insn >> 20); + p += 4; + } + + if (patch[2] == bfd_getb32 (p + 8)) /* character instruction */ + { + /* already patched? */ + if ((patch[0] == (0xfff07fffu & bfd_getb32 (p + 0))) && + (patch[1] == bfd_getb32 (p + 4))) + rz = TRUE; + } + else if (mode0[0].opcode == (mode0[0].mask & bfd_getb32 (p + 0))) + { + if ((mode0[1].opcode == (mode0[1].mask & bfd_getb32 (p + 4))) && + (mode0[2].opcode == (mode0[2].mask & bfd_getb32 (p + 8)))) + { + bfd_putb32 (patch[0] | (regidx << 15), p + 0); + bfd_putb32 (patch[1], p + 4); + bfd_putb32 (patch[2], p + 8); + rz = TRUE; + } + } + else if (mode1[0].opcode == (mode1[0].mask & bfd_getb32 (p + 0))) + { + if ((mode1[1].opcode == (mode1[1].mask & bfd_getb32 (p + 4))) && + (mode1[2].opcode == (mode1[2].mask & bfd_getb32 (p + 8)))) + { + bfd_putb32 (patch[0] | (regidx << 15), p + 0); + bfd_putb32 (patch[1], p + 4); + bfd_putb32 (patch[2], p + 8); + rz = TRUE; + } + } + + if (!rz) + { + printf ("%s: %s @ 0x%08x\n", __func__, ibfd->filename, + (int) rel->r_offset); + BFD_ASSERT(0); /* unsupported pattern */ + } + + return rz; +} + +static enum elf_nds32_tls_type +get_tls_type (enum elf_nds32_reloc_type r_type, struct elf_link_hash_entry *h); + +static unsigned int +ones32 (register unsigned int x) +{ + /* 32-bit recursive reduction using SWAR... + but first step is mapping 2-bit values + into sum of 2 1-bit values in sneaky way. */ + x -= ((x >> 1) & 0x55555555); + x = (((x >> 2) & 0x33333333) + (x & 0x33333333)); + x = (((x >> 4) + x) & 0x0f0f0f0f); + x += (x >> 8); + x += (x >> 16); + return (x & 0x0000003f); +} + +static unsigned int +fls (register unsigned int x) +{ + return ffs (x & (-x)); +} + +#define nds32_elf_local_tlsdesc_gotent(bfd) \ + (elf_nds32_tdata (bfd)->local_tlsdesc_gotent) + +static bfd_boolean +nds32_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, + struct bfd_link_info *info, bfd *input_bfd, + asection *input_section, bfd_byte *contents, + Elf_Internal_Rela *relocs, + Elf_Internal_Sym *local_syms, + asection **local_sections) +{ + Elf_Internal_Shdr *symtab_hdr; + struct elf_link_hash_entry **sym_hashes; + Elf_Internal_Rela *rel, *relend; + bfd_boolean ret = TRUE; /* Assume success. */ + int align = 0; + bfd_reloc_status_type r; + const char *errmsg = NULL; + bfd_vma gp; + struct elf_link_hash_table *ehtab; + struct elf_nds32_link_hash_table *htab; + bfd *dynobj; + bfd_vma *local_got_offsets; asection *sgot, *splt, *sreloc; bfd_vma high_address; struct elf_nds32_link_hash_table *table; int eliminate_gc_relocs; bfd_vma fpbase_addr; + Elf_Internal_Rela *crc_rel = NULL; symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; sym_hashes = elf_sym_hashes (input_bfd); + ehtab = elf_hash_table (info); htab = nds32_elf_hash_table (info); high_address = bfd_get_section_limit (input_bfd, input_section); dynobj = htab->root.dynobj; local_got_offsets = elf_local_got_offsets (input_bfd); - sgot = htab->root.sgot; - splt = htab->root.splt; + sgot = ehtab->sgot; + splt = ehtab->splt; sreloc = NULL; rel = relocs; @@ -4393,6 +5339,8 @@ nds32_elf_relocate_section (bfd * output_bfd ATTRIBUTE_UNUSED, table = nds32_elf_hash_table (info); eliminate_gc_relocs = table->eliminate_gc_relocs; + + /* explain _SDA_BASE_ */ /* By this time, we can adjust the value of _SDA_BASE_. */ if ((!bfd_link_relocatable (info))) { @@ -4402,40 +5350,37 @@ nds32_elf_relocate_section (bfd * output_bfd ATTRIBUTE_UNUSED, return FALSE; } - if (is_ITB_BASE_set == 0) - { - /* Set the _ITB_BASE_. */ - if (!nds32_elf_ex9_itb_base (info)) - { - _bfd_error_handler (_("%B: error: Cannot set _ITB_BASE_"), - output_bfd); - bfd_set_error (bfd_error_bad_value); - } - } - - if (table->target_optimize & NDS32_RELAX_JUMP_IFC_ON) - if (!nds32_elf_ifc_reloc ()) - _bfd_error_handler (_("error: IFC relocation error.")); +#ifdef NDS32_LINUX_TOOLCHAIN + /* Do TLS model conversion once at first. */ + nds32_elf_unify_tls_model (input_bfd, input_section, contents, info); +#endif - /* Relocation for .ex9.itable. */ - if (table->target_optimize & NDS32_RELAX_EX9_ON - || (table->ex9_import_file && table->update_ex9_table)) - nds32_elf_ex9_reloc_jmp (info); + if (indirect_call_table.count > 0) + nds32_elf_ict_relocate (output_bfd, info); /* Use gp as fp to prevent truncated fit. Because in relaxation time the fp value is set as gp, and it has be reverted for instruction setting fp. */ fpbase_addr = elf_gp (output_bfd); + /* Move all SECURITY_16 to the final one for each instruction. */ + nds32_elf_crc_adjust_reloc (relocs, relend); + + /* Deal with (dynamic) relocations. */ for (rel = relocs; rel < relend; rel++) { enum elf_nds32_reloc_type r_type; reloc_howto_type *howto = NULL; unsigned long r_symndx; struct elf_link_hash_entry *h = NULL; + struct bfd_link_hash_entry *h2; Elf_Internal_Sym *sym = NULL; asection *sec; bfd_vma relocation; + struct elf_nds32_ict_hash_entry *entry; + bfd_vma relocation_sym = 0xdeadbeef; + Elf_Internal_Rela *lorel; + bfd_vma off; /* We can't modify r_addend here as elf_link_input_bfd has an assert to ensure it's zero (we use REL relocs, not RELA). Therefore this @@ -4449,7 +5394,7 @@ nds32_elf_relocate_section (bfd * output_bfd ATTRIBUTE_UNUSED, if (r_type >= R_NDS32_max) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: error: unknown relocation type %d."), + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), input_bfd, r_type); bfd_set_error (bfd_error_bad_value); ret = FALSE; @@ -4463,12 +5408,17 @@ nds32_elf_relocate_section (bfd * output_bfd ATTRIBUTE_UNUSED, || r_type == R_NDS32_RELA_GNU_VTINHERIT || (r_type >= R_NDS32_INSN16 && r_type <= R_NDS32_25_FIXED_RELA) || r_type == R_NDS32_DATA - || r_type == R_NDS32_TRAN - || (r_type >= R_NDS32_LONGCALL4 && r_type <= R_NDS32_LONGJUMP7)) + || r_type == R_NDS32_TRAN) continue; - /* If we enter the fp-as-gp region. Resolve the address - of best fp-base. */ + /* Save security beginning. */ + if (r_type == R_NDS32_SECURITY_16 && crc_rel == NULL) + { + crc_rel = rel; + continue; + } + + /* If we enter the fp-as-gp region. Resolve the address of best fp-base. */ if (ELF32_R_TYPE (rel->r_info) == R_NDS32_RELAX_REGION_BEGIN && (rel->r_addend & R_NDS32_RELAX_REGION_OMIT_FP_FLAG)) { @@ -4485,9 +5435,13 @@ nds32_elf_relocate_section (bfd * output_bfd ATTRIBUTE_UNUSED, fpbase_addr = elf_gp (output_bfd); } - if (((r_type >= R_NDS32_DWARF2_OP1_RELA - && r_type <= R_NDS32_DWARF2_LEB_RELA) - || r_type >= R_NDS32_RELAX_ENTRY) && !bfd_link_relocatable (info)) + /* Skip the relocations used for relaxation. */ + /* Fix ticket-11832, we have to update LONGCALL and LONGJUMP + relocations when generating the relocatable files. */ + if (!bfd_link_relocatable (info) + && (r_type >= R_NDS32_RELAX_ENTRY + || (r_type >= R_NDS32_LONGCALL4 + && r_type <= R_NDS32_LONGJUMP7))) continue; howto = bfd_elf32_bfd_reloc_type_table_lookup (r_type); @@ -4506,10 +5460,26 @@ nds32_elf_relocate_section (bfd * output_bfd ATTRIBUTE_UNUSED, relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel); addend = rel->r_addend; + + /* keep symbol location for static TLS_IE GOT entry */ + relocation_sym = relocation; + if (bfd_link_relocatable (info)) + { + /* This is a relocatable link. We don't have to change + anything, unless the reloc is against a section symbol, + in which case we have to adjust according to where the + section symbol winds up in the output section. */ + if (sym != NULL && ELF_ST_TYPE (sym->st_info) == STT_SECTION) + rel->r_addend += sec->output_offset + sym->st_value; + + continue; + } } else { /* External symbol. */ + if (bfd_link_relocatable (info)) + continue; bfd_boolean warned, ignored, unresolved_reloc; int symndx = r_symndx - symtab_hdr->sh_info; @@ -4518,10 +5488,27 @@ nds32_elf_relocate_section (bfd * output_bfd ATTRIBUTE_UNUSED, relocation, unresolved_reloc, warned, ignored); + /* keep symbol location for static TLS_IE GOT entry */ + relocation_sym = relocation; + /* la $fp, _FP_BASE_ is per-function (region). Handle it specially. */ switch ((int) r_type) { + case R_NDS32_HI20_RELA: + case R_NDS32_LO12S0_RELA: + if (strcmp (elf_sym_hashes (input_bfd)[symndx]->root.root.string, + FP_BASE_NAME) == 0) + { + if (!bfd_link_pie (info)) + { + _bfd_error_handler + ("%pB: warning: _FP_BASE_ setting insns relaxation failed.", + input_bfd); + } + relocation = fpbase_addr; + break; + } case R_NDS32_SDA19S0_RELA: case R_NDS32_SDA15S0_RELA: case R_NDS32_20_RELA: @@ -4532,19 +5519,6 @@ nds32_elf_relocate_section (bfd * output_bfd ATTRIBUTE_UNUSED, break; } } - - } - - if (bfd_link_relocatable (info)) - { - /* This is a relocatable link. We don't have to change - anything, unless the reloc is against a section symbol, - in which case we have to adjust according to where the - section symbol winds up in the output section. */ - if (sym != NULL && ELF_ST_TYPE (sym->st_info) == STT_SECTION) - rel->r_addend += sec->output_offset + sym->st_value; - - continue; } /* Sanity check the address. */ @@ -4554,16 +5528,14 @@ nds32_elf_relocate_section (bfd * output_bfd ATTRIBUTE_UNUSED, goto check_reloc; } - if ((r_type >= R_NDS32_DWARF2_OP1_RELA - && r_type <= R_NDS32_DWARF2_LEB_RELA) - || r_type >= R_NDS32_RELAX_ENTRY) + if (r_type >= R_NDS32_RELAX_ENTRY) continue; switch ((int) r_type) { case R_NDS32_GOTOFF: /* Relocation is relative to the start of the global offset - table (for ld24 rx, #uimm24), e.g. access at label+addend + table (for ld24 rx, #uimm24), e.g. access at label + addend ld24 rx. #label@GOTOFF + addend sub rx, r12. */ @@ -4605,12 +5577,18 @@ nds32_elf_relocate_section (bfd * output_bfd ATTRIBUTE_UNUSED, case R_NDS32_PLT_GOTREL_LO15: case R_NDS32_PLT_GOTREL_LO19: case R_NDS32_PLT_GOTREL_LO20: - if (h == NULL || h->forced_local || h->plt.offset == (bfd_vma) - 1) + if (h == NULL + || h->forced_local + || h->plt.offset == (bfd_vma) -1 + || (bfd_link_pie (info) && h->def_regular)) { + /* TODO: find better checking to optimize PIE PLT relocations. */ /* We didn't make a PLT entry for this symbol. This happens when statically linking PIC code, or when using -Bsymbolic. */ - relocation -= elf_gp (output_bfd); + if (h) + h->plt.offset = (bfd_vma) -1; /* cancel PLT trampoline. */ + relocation -= elf_gp(output_bfd); break; } @@ -4661,21 +5639,18 @@ nds32_elf_relocate_section (bfd * output_bfd ATTRIBUTE_UNUSED, case R_NDS32_GOTPC_HI20: case R_NDS32_GOTPC_LO12: - { - /* .got(_GLOBAL_OFFSET_TABLE_) - pc relocation - bl .+4 - seth rx,#high(_GLOBAL_OFFSET_TABLE_) - or3 rx,rx,#low(_GLOBAL_OFFSET_TABLE_ +4) - or - bl .+4 - seth rx,#shigh(_GLOBAL_OFFSET_TABLE_) - add3 rx,rx,#low(_GLOBAL_OFFSET_TABLE_ +4) - */ - relocation = elf_gp (output_bfd); - relocation -= (input_section->output_section->vma - + input_section->output_offset + rel->r_offset); - break; - } + /* .got(_GLOBAL_OFFSET_TABLE_) - pc relocation + bl .+4 + seth rx,#high(_GLOBAL_OFFSET_TABLE_) + or3 rx,rx,#low(_GLOBAL_OFFSET_TABLE_ +4) + or + bl .+4 + seth rx,#shigh(_GLOBAL_OFFSET_TABLE_) + add3 rx,rx,#low(_GLOBAL_OFFSET_TABLE_ +4) */ + relocation = elf_gp (output_bfd); + relocation -= (input_section->output_section->vma + + input_section->output_offset + rel->r_offset); + break; case R_NDS32_GOT20: /* Fall through. */ @@ -4687,17 +5662,14 @@ nds32_elf_relocate_section (bfd * output_bfd ATTRIBUTE_UNUSED, offset table. */ BFD_ASSERT (sgot != NULL); - if (h != NULL) + if (h != NULL) /* External symbol */ { bfd_boolean dyn; - bfd_vma off; off = h->got.offset; BFD_ASSERT (off != (bfd_vma) - 1); dyn = htab->root.dynamic_sections_created; - if (!WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, - bfd_link_pic (info), - h) + if (!WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, bfd_link_pic (info), h) || (bfd_link_pic (info) && (info->symbolic || h->dynindx == -1 @@ -4707,28 +5679,27 @@ nds32_elf_relocate_section (bfd * output_bfd ATTRIBUTE_UNUSED, -Bsymbolic link and the symbol is defined locally, or the symbol was forced to be local because of a version file. We must initialize - this entry in the global offset table. Since the + this entry in the global offset table. Since the offset must always be a multiple of 4, we use the least significant bit to record whether we have initialized it already. When doing a dynamic link, we create a .rela.got - relocation entry to initialize the value. This + relocation entry to initialize the value. This is done in the finish_dynamic_symbol routine. */ - if ((off & 1) != 0) + if ((off & 1) != 0) /* clear LSB */ off &= ~1; else { bfd_put_32 (output_bfd, relocation, sgot->contents + off); - h->got.offset |= 1; + h->got.offset |= 1; /* mark initialized */ } } relocation = sgot->output_section->vma + sgot->output_offset + off - - elf_gp (output_bfd); + - elf_gp (output_bfd); } - else + else /* Local symbol */ { - bfd_vma off; bfd_byte *loc; BFD_ASSERT (local_got_offsets != NULL @@ -4736,10 +5707,10 @@ nds32_elf_relocate_section (bfd * output_bfd ATTRIBUTE_UNUSED, off = local_got_offsets[r_symndx]; - /* The offset must always be a multiple of 4. We use + /* The offset must always be a multiple of 4. We use the least significant bit to record whether we have already processed this entry. */ - if ((off & 1) != 0) + if ((off & 1) != 0) /* clear LSB */ off &= ~1; else { @@ -4752,7 +5723,7 @@ nds32_elf_relocate_section (bfd * output_bfd ATTRIBUTE_UNUSED, /* We need to generate a R_NDS32_RELATIVE reloc for the dynamic linker. */ - srelgot = htab->root.srelgot; + srelgot = bfd_get_section_by_name (dynobj, ".rela.got"); BFD_ASSERT (srelgot != NULL); outrel.r_offset = (elf_gp (output_bfd) @@ -4768,11 +5739,57 @@ nds32_elf_relocate_section (bfd * output_bfd ATTRIBUTE_UNUSED, local_got_offsets[r_symndx] |= 1; } relocation = sgot->output_section->vma + sgot->output_offset + off - - elf_gp (output_bfd); + - elf_gp (output_bfd); } break; + case R_NDS32_25_PCREL_RELA: + case R_NDS32_HI20_RELA: + case R_NDS32_LO12S0_RELA: + case R_NDS32_LO12S2_RELA: + /* Merge normal and indirect call functions. */ + if (!ignore_indirect_call && h + && elf32_nds32_hash_entry (h)->indirect_call) + { + if (ict_model == R_NDS32_RELAX_ENTRY_ICT_LARGE) + { + _bfd_error_handler + (_("%pB: Error: there are mixed indirect call function in" + " ICT large model\'%s\'\n"), + input_bfd, h->root.root.string); + bfd_set_error (bfd_error_bad_value); + return FALSE; + } + else + _bfd_error_handler + (_("%pB: Warning: there are mixed indirect call function" + " \'%s\'\n"), input_bfd, h->root.root.string); + + entry = (struct elf_nds32_ict_hash_entry*) + bfd_hash_lookup (&indirect_call_table, h->root.root.string, + FALSE, FALSE); + if (!entry) + { + _bfd_error_handler + (_("%pB %pA: internal error indirect call relocation " + "0x%lx without hash.\n"), + input_bfd, sec, rel->r_offset); + bfd_set_error (bfd_error_bad_value); + return FALSE; + } + + h2 = bfd_link_hash_lookup (info->hash, + "_INDIRECT_CALL_TABLE_BASE_", + FALSE, FALSE, FALSE); + relocation = ((h2->u.def.value + + h2->u.def.section->output_section->vma + + h2->u.def.section->output_offset) + + (entry->order * 4)); + break; + } + + /* Fall through. */ case R_NDS32_16_RELA: case R_NDS32_20_RELA: case R_NDS32_5_RELA: @@ -4782,14 +5799,10 @@ nds32_elf_relocate_section (bfd * output_bfd ATTRIBUTE_UNUSED, case R_NDS32_10_UPCREL_RELA: case R_NDS32_15_PCREL_RELA: case R_NDS32_17_PCREL_RELA: - case R_NDS32_25_PCREL_RELA: - case R_NDS32_HI20_RELA: case R_NDS32_LO12S3_RELA: - case R_NDS32_LO12S2_RELA: case R_NDS32_LO12S2_DP_RELA: case R_NDS32_LO12S2_SP_RELA: case R_NDS32_LO12S1_RELA: - case R_NDS32_LO12S0_RELA: case R_NDS32_LO12S0_ORI_RELA: if (bfd_link_pic (info) && r_symndx != 0 && (input_section->flags & SEC_ALLOC) != 0 @@ -4863,15 +5876,37 @@ nds32_elf_relocate_section (bfd * output_bfd ATTRIBUTE_UNUSED, become local. */ if (h == NULL || ((info->symbolic || h->dynindx == -1) - && h->def_regular)) + && h->def_regular) + || (bfd_link_pie (info) && h->def_regular)) { relocate = TRUE; outrel.r_info = ELF32_R_INFO (0, R_NDS32_RELATIVE); outrel.r_addend = relocation + rel->r_addend; + if (h) + { + h->plt.offset = (bfd_vma) -1; /* cancel PLT trampoline. */ + + BFD_ASSERT (sgot != NULL); + /* If we did not allocate got entry for the symbol, we can not + fill the nonexistent got entry. */ + if (h->got.offset != (bfd_vma) -1 && (h->got.offset & 1) == 0) + { + bfd_put_32 (output_bfd, outrel.r_addend, + sgot->contents + h->got.offset); + } + } } else { - BFD_ASSERT (h->dynindx != -1); + if (h->dynindx == -1) + { + _bfd_error_handler + (_("%pB: relocation %s against `%s' can not be used when" + "making a shared object; recompile with -fPIC"), + input_bfd, nds32_elf_howto_table[r_type].name, h->root.root.string); + bfd_set_error (bfd_error_bad_value); + return FALSE; + } outrel.r_info = ELF32_R_INFO (h->dynindx, r_type); outrel.r_addend = rel->r_addend; } @@ -4895,8 +5930,8 @@ nds32_elf_relocate_section (bfd * output_bfd ATTRIBUTE_UNUSED, if (bfd_link_pic (info)) { _bfd_error_handler - (_("%B: warning: cannot deal R_NDS32_25_ABS_RELA in shared " - "mode."), input_bfd); + (_("%s: warning: cannot deal R_NDS32_25_ABS_RELA in shared mode."), + bfd_get_filename (input_bfd)); return FALSE; } break; @@ -4908,128 +5943,120 @@ nds32_elf_relocate_section (bfd * output_bfd ATTRIBUTE_UNUSED, goto check_reloc; case R_NDS32_HI20: + /* We allow an arbitrary number of HI20 relocs before the + LO12 reloc. This permits GCC to emit the HI and LO relocs + itself. */ + for (lorel = rel + 1; + (lorel < relend + && ELF32_R_TYPE (lorel->r_info) == R_NDS32_HI20); lorel++) + continue; + if (lorel < relend + && (ELF32_R_TYPE (lorel->r_info) == R_NDS32_LO12S3 + || ELF32_R_TYPE (lorel->r_info) == R_NDS32_LO12S2 + || ELF32_R_TYPE (lorel->r_info) == R_NDS32_LO12S1 + || ELF32_R_TYPE (lorel->r_info) == R_NDS32_LO12S0)) { - Elf_Internal_Rela *lorel; - - /* We allow an arbitrary number of HI20 relocs before the - LO12 reloc. This permits gcc to emit the HI and LO relocs - itself. */ - for (lorel = rel + 1; - (lorel < relend - && ELF32_R_TYPE (lorel->r_info) == R_NDS32_HI20); lorel++) - continue; - if (lorel < relend - && (ELF32_R_TYPE (lorel->r_info) == R_NDS32_LO12S3 - || ELF32_R_TYPE (lorel->r_info) == R_NDS32_LO12S2 - || ELF32_R_TYPE (lorel->r_info) == R_NDS32_LO12S1 - || ELF32_R_TYPE (lorel->r_info) == R_NDS32_LO12S0)) - { - nds32_elf_relocate_hi20 (input_bfd, r_type, rel, lorel, - contents, relocation + addend); - r = bfd_reloc_ok; - } - else - r = _bfd_final_link_relocate (howto, input_bfd, input_section, - contents, offset, relocation, - addend); + nds32_elf_relocate_hi20 (input_bfd, r_type, rel, lorel, + contents, relocation + addend); + r = bfd_reloc_ok; } + else + r = _bfd_final_link_relocate (howto, input_bfd, input_section, + contents, offset, relocation, + addend); goto check_reloc; case R_NDS32_GOT17S2_RELA: case R_NDS32_GOT15S2_RELA: + BFD_ASSERT (sgot != NULL); + + if (h != NULL) { - bfd_vma off; + bfd_boolean dyn; - BFD_ASSERT (sgot != NULL); + off = h->got.offset; + BFD_ASSERT (off != (bfd_vma) - 1); - if (h != NULL) + dyn = htab->root.dynamic_sections_created; + if (!WILL_CALL_FINISH_DYNAMIC_SYMBOL + (dyn, bfd_link_pic (info), h) || (bfd_link_pic (info) + && (info->symbolic + || h->dynindx == -1 + || h->forced_local) + && h->def_regular)) { - bfd_boolean dyn; - - off = h->got.offset; - BFD_ASSERT (off != (bfd_vma) - 1); - - dyn = htab->root.dynamic_sections_created; - if (!WILL_CALL_FINISH_DYNAMIC_SYMBOL - (dyn, bfd_link_pic (info), h) - || (bfd_link_pic (info) - && (info->symbolic - || h->dynindx == -1 - || h->forced_local) - && h->def_regular)) + /* This is actually a static link, or it is a + -Bsymbolic link and the symbol is defined + locally, or the symbol was forced to be local + because of a version file. We must initialize + this entry in the global offset table. Since the + offset must always be a multiple of 4, we use the + least significant bit to record whether we have + initialized it already. + + When doing a dynamic link, we create a .rela.got + relocation entry to initialize the value. This + is done in the finish_dynamic_symbol routine. */ + if ((off & 1) != 0) + off &= ~1; + else { - /* This is actually a static link, or it is a - -Bsymbolic link and the symbol is defined - locally, or the symbol was forced to be local - because of a version file. We must initialize - this entry in the global offset table. Since the - offset must always be a multiple of 4, we use the - least significant bit to record whether we have - initialized it already. - - When doing a dynamic link, we create a .rela.got - relocation entry to initialize the value. This - is done in the finish_dynamic_symbol routine. */ - if ((off & 1) != 0) - off &= ~1; - else - { - bfd_put_32 (output_bfd, relocation, - sgot->contents + off); - h->got.offset |= 1; - } + bfd_put_32 (output_bfd, relocation, + sgot->contents + off); + h->got.offset |= 1; } } - else - { - bfd_byte *loc; + } + else + { + bfd_byte *loc; + + BFD_ASSERT (local_got_offsets != NULL + && local_got_offsets[r_symndx] != (bfd_vma) - 1); - BFD_ASSERT (local_got_offsets != NULL - && local_got_offsets[r_symndx] != (bfd_vma) - 1); + off = local_got_offsets[r_symndx]; - off = local_got_offsets[r_symndx]; + /* The offset must always be a multiple of 4. We use + the least significant bit to record whether we have + already processed this entry. */ + if ((off & 1) != 0) + off &= ~1; + else + { + bfd_put_32 (output_bfd, relocation, sgot->contents + off); - /* The offset must always be a multiple of 4. We use - the least significant bit to record whether we have - already processed this entry. */ - if ((off & 1) != 0) - off &= ~1; - else + if (bfd_link_pic (info)) { - bfd_put_32 (output_bfd, relocation, sgot->contents + off); + asection *srelgot; + Elf_Internal_Rela outrel; - if (bfd_link_pic (info)) - { - asection *srelgot; - Elf_Internal_Rela outrel; - - /* We need to generate a R_NDS32_RELATIVE reloc - for the dynamic linker. */ - srelgot = htab->root.srelgot; - BFD_ASSERT (srelgot != NULL); - - outrel.r_offset = (elf_gp (output_bfd) - + sgot->output_offset + off); - outrel.r_info = ELF32_R_INFO (0, R_NDS32_RELATIVE); - outrel.r_addend = relocation; - loc = srelgot->contents; - loc += - srelgot->reloc_count * sizeof (Elf32_External_Rela); - bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc); - ++srelgot->reloc_count; - } - local_got_offsets[r_symndx] |= 1; + /* We need to generate a R_NDS32_RELATIVE reloc + for the dynamic linker. */ + srelgot = bfd_get_section_by_name (dynobj, ".rela.got"); + BFD_ASSERT (srelgot != NULL); + + outrel.r_offset = (elf_gp (output_bfd) + + sgot->output_offset + off); + outrel.r_info = ELF32_R_INFO (0, R_NDS32_RELATIVE); + outrel.r_addend = relocation; + loc = srelgot->contents; + loc += + srelgot->reloc_count * sizeof (Elf32_External_Rela); + bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc); + ++srelgot->reloc_count; } + local_got_offsets[r_symndx] |= 1; } - relocation = sgot->output_section->vma + sgot->output_offset + off - - elf_gp (output_bfd); } + relocation = sgot->output_section->vma + sgot->output_offset + off + - elf_gp (output_bfd); + if (relocation & align) { /* Incorrect alignment. */ _bfd_error_handler - (_("%B: warning: unaligned access to GOT entry."), input_bfd); + (_("%pB: warning: unaligned access to GOT entry."), input_bfd); ret = FALSE; r = bfd_reloc_dangerous; goto check_reloc; @@ -5060,50 +6087,48 @@ nds32_elf_relocate_section (bfd * output_bfd ATTRIBUTE_UNUSED, case R_NDS32_SDA19S0_RELA: case R_NDS32_SDA15S0_RELA: case R_NDS32_SDA15S0: - { - align = 0x0; + align = 0x0; handle_sda: - BFD_ASSERT (sec != NULL); + BFD_ASSERT (sec != NULL); - /* If the symbol is in the abs section, the out_bfd will be null. - This happens when the relocation has a symbol@GOTOFF. */ - r = nds32_elf_final_sda_base (output_bfd, info, &gp, FALSE); - if (r != bfd_reloc_ok) - { - _bfd_error_handler - (_("%B: warning: relocate SDA_BASE failed."), input_bfd); - ret = FALSE; - goto check_reloc; - } + /* If the symbol is in the abs section, the out_bfd will be null. + This happens when the relocation has a symbol@GOTOFF. */ + r = nds32_elf_final_sda_base (output_bfd, info, &gp, FALSE); + if (r != bfd_reloc_ok) + { + _bfd_error_handler + (_("%pB: warning: relocate SDA_BASE failed."), input_bfd); + ret = FALSE; + goto check_reloc; + } - /* At this point `relocation' contains the object's - address. */ - if (r_type == R_NDS32_SDA_FP7U2_RELA) - { - relocation -= fpbase_addr; - } - else - relocation -= gp; - /* Now it contains the offset from _SDA_BASE_. */ + /* At this point `relocation' contains the object's + address. */ + if (r_type == R_NDS32_SDA_FP7U2_RELA) + { + relocation -= fpbase_addr; + } + else + relocation -= gp; + /* Now it contains the offset from _SDA_BASE_. */ - /* Make sure alignment is correct. */ + /* Make sure alignment is correct. */ - if (relocation & align) - { - /* Incorrect alignment. */ - _bfd_error_handler - /* xgettext:c-format */ - (_("%B(%A): warning: unaligned small data access of type %d."), - input_bfd, input_section, r_type); - ret = FALSE; - goto check_reloc; - } + if (relocation & align) + { + /* Incorrect alignment. */ + _bfd_error_handler + (_("%pB(%pA): warning: unaligned small data access of type %d."), + input_bfd, input_section, r_type); + ret = FALSE; + goto check_reloc; } break; case R_NDS32_17IFC_PCREL_RELA: case R_NDS32_10IFCU_PCREL_RELA: - /* do nothing */ + ifc_flag = TRUE; + /* do nothing */ break; case R_NDS32_TLS_LE_HI20: @@ -5112,28 +6137,38 @@ handle_sda: case R_NDS32_TLS_LE_15S0: case R_NDS32_TLS_LE_15S1: case R_NDS32_TLS_LE_15S2: + /* TODO: we do not have garbage collection for got entries. + IE to LE may have one empty entry, and DESC to LE may + have two. */ if (elf_hash_table (info)->tls_sec != NULL) relocation -= (elf_hash_table (info)->tls_sec->vma + TP_OFFSET); break; case R_NDS32_TLS_IE_HI20: case R_NDS32_TLS_IE_LO12S2: + case R_NDS32_TLS_DESC_HI20: + case R_NDS32_TLS_DESC_LO12: + case R_NDS32_TLS_IE_LO12: + case R_NDS32_TLS_IEGP_HI20: + case R_NDS32_TLS_IEGP_LO12: + case R_NDS32_TLS_IEGP_LO12S2: { /* Relocation is to the entry for this symbol in the global offset table. */ - unsigned int tls_type; + enum elf_nds32_tls_type tls_type, org_tls_type, eff_tls_type; asection *srelgot; Elf_Internal_Rela outrel; - bfd_vma off; bfd_byte *loc; int indx = 0; + eff_tls_type = org_tls_type = get_tls_type (r_type, h); + BFD_ASSERT (sgot != NULL); if (h != NULL) { bfd_boolean dyn; off = h->got.offset; - BFD_ASSERT (off != (bfd_vma) - 1); + BFD_ASSERT (off != (bfd_vma) -1); dyn = htab->root.dynamic_sections_created; tls_type = ((struct elf_nds32_link_hash_entry *) h)->tls_type; if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, bfd_link_pic (info), h) @@ -5143,64 +6178,184 @@ handle_sda: } else { - /* Never happen currently. */ BFD_ASSERT (local_got_offsets != NULL && local_got_offsets[r_symndx] != (bfd_vma) - 1); off = local_got_offsets[r_symndx]; - tls_type = elf32_nds32_local_got_tls_type (input_bfd)[r_symndx]; } + relocation = sgot->output_section->vma + sgot->output_offset + off; - if (r_type == R_NDS32_TLS_IE_LO12S2) - break; + if (1 < ones32 (tls_type)) + { + eff_tls_type = 1 << (fls (tls_type) - 1); + /* TLS model shall be handled in nds32_elf_unify_tls_model () */ + + /* TLS model X -> LE is not implement yet! + * workaround here! */ + if (eff_tls_type == GOT_TLS_LE) + { + eff_tls_type = 1 << (fls (tls_type ^ eff_tls_type) - 1); + } + } /* The offset must always be a multiple of 4. We use the least significant bit to record whether we have already processed this entry. */ - if ((off & 1) != 0) - off &= ~1; + bfd_boolean need_relocs = FALSE; + srelgot = ehtab->srelgot; + if ((bfd_link_pic (info) || indx != 0) + && (h == NULL || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT + || h->root.type != bfd_link_hash_undefweak)) + { + need_relocs = TRUE; + BFD_ASSERT (srelgot != NULL); + } + + if (off & 1) + { + off &= ~1; + relocation &= ~1; + + if (eff_tls_type & GOT_TLS_DESC) + { + relocation -= elf_gp (output_bfd); + if ((R_NDS32_TLS_DESC_HI20 == r_type) && (!need_relocs)) + { + /* TLS model shall be converted */ + BFD_ASSERT(0); + } + } + else if (eff_tls_type & GOT_TLS_IEGP) + { + relocation -= elf_gp (output_bfd); + } + } else { - bfd_boolean need_relocs = FALSE; - srelgot = htab->root.srelgot; - if ((bfd_link_pic (info) || indx != 0) - && (h == NULL - || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT - || h->root.type != bfd_link_hash_undefweak)) + if ((eff_tls_type & GOT_TLS_LE) && (tls_type ^ eff_tls_type)) { - need_relocs = TRUE; - BFD_ASSERT (srelgot != NULL); + /* TLS model workaround shall be applied */ + BFD_ASSERT(0); } - if (tls_type & GOT_TLS_IE) + else if (eff_tls_type & (GOT_TLS_IE | GOT_TLS_IEGP)) { + if (eff_tls_type & GOT_TLS_IEGP) + relocation -= elf_gp(output_bfd); + if (need_relocs) { - if (h->dynindx == 0) - outrel.r_addend = relocation - dtpoff_base (info); + if (indx == 0) + outrel.r_addend = gottpoff (info, relocation_sym); else outrel.r_addend = 0; outrel.r_offset = (sgot->output_section->vma - + sgot->output_offset - + off); - outrel.r_info = - ELF32_R_INFO (h->dynindx, R_NDS32_TLS_TPOFF); - - loc = srelgot->contents; - loc += - srelgot->reloc_count * sizeof (Elf32_External_Rela); - bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc); - ++srelgot->reloc_count; + + sgot->output_offset + off); + outrel.r_info = ELF32_R_INFO (indx, R_NDS32_TLS_TPOFF); + + elf32_nds32_add_dynreloc (output_bfd, info, srelgot, + &outrel); } else - bfd_put_32 (output_bfd, h->root.u.def.value - TP_OFFSET, - sgot->contents + off); + { + bfd_put_32 (output_bfd, gottpoff (info, relocation_sym), + sgot->contents + off); + } + } + else if (eff_tls_type & GOT_TLS_DESC) + { + relocation -= elf_gp (output_bfd); + if (need_relocs) + { + if (indx == 0) + outrel.r_addend = gottpoff (info, relocation_sym); + else + outrel.r_addend = 0; + outrel.r_offset = (sgot->output_section->vma + + sgot->output_offset + off); + outrel.r_info = ELF32_R_INFO (indx, R_NDS32_TLS_DESC); + + if (htab->tls_desc_trampoline) + { + asection *srelplt; + srelplt = ehtab->srelplt; + loc = srelplt->contents; + loc += htab->next_tls_desc_index++ * sizeof (Elf32_External_Rela); + BFD_ASSERT (loc + sizeof (Elf32_External_Rela) + <= srelplt->contents + srelplt->size); + + bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc); + } + else + { + loc = srelgot->contents; + loc += srelgot->reloc_count * sizeof (Elf32_External_Rela); + bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc); + ++srelgot->reloc_count; + } + } + else + { + /* feed me! */ + bfd_put_32 (output_bfd, 0xdeadbeef, + sgot->contents + off); + bfd_put_32 (output_bfd, gottpoff (info, relocation_sym), + sgot->contents + off + 4); + patch_tls_desc_to_ie (contents, rel, input_bfd); + BFD_ASSERT(0); + } + } + else + { + /* TLS model workaround shall be applied */ + BFD_ASSERT(0); } + + if (h != NULL) + h->got.offset |= 1; + else + local_got_offsets[r_symndx] |= 1; } } - break; + break; + + case R_NDS32_SECURITY_16: + relocation = 0; + crc_rel->r_addend = NDS32_SECURITY_NONE; + r = nds32_elf_final_link_relocate (howto, input_bfd, + input_section, contents, + crc_rel->r_offset, relocation, + crc_rel->r_addend); + crc_rel = NULL; + goto check_reloc; + break; + /* DON'T fall through. */ + case R_NDS32_ICT_HI20: + case R_NDS32_ICT_LO12: + case R_NDS32_ICT_25PC: + case R_NDS32_ICT_LO12S2: + entry = (struct elf_nds32_ict_hash_entry*) + bfd_hash_lookup (&indirect_call_table, h->root.root.string, + FALSE, FALSE); + if (!entry) + { + _bfd_error_handler + (_("%pB %pA: internal error indirect call relocation " + "0x%lx without hash.\n"), + input_bfd, sec, rel->r_offset); + bfd_set_error (bfd_error_bad_value); + return FALSE; + } + h2 = bfd_link_hash_lookup (info->hash, + "_INDIRECT_CALL_TABLE_BASE_", + FALSE, FALSE, FALSE); + relocation = ((h2->u.def.value + + h2->u.def.section->output_section->vma + + h2->u.def.section->output_offset) + + (entry->order * 4)); + break; /* DON'T fall through. */ default: @@ -5275,6 +6430,12 @@ handle_sda: case R_NDS32_TLS_LE_15S0: case R_NDS32_TLS_LE_15S1: case R_NDS32_TLS_LE_15S2: + case R_NDS32_TLS_DESC_HI20: + case R_NDS32_TLS_DESC_LO12: + case R_NDS32_TLS_IE_LO12: + case R_NDS32_TLS_IEGP_HI20: + case R_NDS32_TLS_IEGP_LO12: + case R_NDS32_TLS_IEGP_LO12S2: /* Instruction related relocs must handle endian properly. */ /* NOTE: PIC IS NOT HANDLE YET; DO IT LATER. */ r = nds32_elf_final_link_relocate (howto, input_bfd, @@ -5283,6 +6444,15 @@ handle_sda: rel->r_addend); break; + case R_NDS32_ICT_HI20: + case R_NDS32_ICT_LO12: + case R_NDS32_ICT_25PC: + case R_NDS32_ICT_LO12S2: + r = nds32_elf_final_link_relocate (howto, input_bfd, input_section, + contents, rel->r_offset, + relocation, 0); + break; + default: /* All other relocs can use default handler. */ r = _bfd_final_link_relocate (howto, input_bfd, input_section, @@ -5314,6 +6484,17 @@ check_reloc: switch (r) { case bfd_reloc_overflow: + if (r_type == R_NDS32_17IFC_PCREL_RELA) + { + _bfd_error_handler + (_("\n%pB: (%pA+0x%x): The IFC optimization range exceeded.\n" + "Please turn off the IFC optimization (-mno-ifc) when " + "compiling the file %s.\n"), + input_bfd, sec, (int) rel->r_offset, + h->root.u.def.section->owner->filename); + bfd_set_error (bfd_error_bad_value); + } + (*info->callbacks->reloc_overflow) (info, (h ? &h->root : NULL), name, howto->name, (bfd_vma) 0, input_bfd, input_section, offset); @@ -5340,14 +6521,18 @@ check_reloc: errmsg = _("internal error: unknown error"); /* Fall through. */ - common_error: - (*info->callbacks->warning) (info, errmsg, name, input_bfd, - input_section, offset); +common_error: + (*info->callbacks->warning) + (info, errmsg, name, input_bfd, input_section, offset); break; } } } + /* Resotre header size to avoid overflow load. */ + if (elf_nds32_tdata (input_bfd)->hdr_size != 0) + symtab_hdr->sh_size = elf_nds32_tdata (input_bfd)->hdr_size; + return ret; } @@ -5356,12 +6541,15 @@ check_reloc: static bfd_boolean nds32_elf_finish_dynamic_symbol (bfd *output_bfd, struct bfd_link_info *info, - struct elf_link_hash_entry *h, Elf_Internal_Sym *sym) + struct elf_link_hash_entry *h, + Elf_Internal_Sym *sym) { - struct elf_nds32_link_hash_table *htab; + struct elf_link_hash_table *ehtab; + struct elf_nds32_link_hash_entry *hent; bfd_byte *loc; - htab = nds32_elf_hash_table (info); + ehtab = elf_hash_table (info); + hent = (struct elf_nds32_link_hash_entry *) h; if (h->plt.offset != (bfd_vma) - 1) { @@ -5379,9 +6567,9 @@ nds32_elf_finish_dynamic_symbol (bfd *output_bfd, struct bfd_link_info *info, BFD_ASSERT (h->dynindx != -1); - splt = htab->root.splt; - sgot = htab->root.sgotplt; - srela = htab->root.srelplt; + splt = ehtab->splt; + sgot = ehtab->sgotplt; + srela = ehtab->srelplt; BFD_ASSERT (splt != NULL && sgot != NULL && srela != NULL); /* Get the index in the procedure linkage table which @@ -5417,7 +6605,7 @@ nds32_elf_finish_dynamic_symbol (bfd *output_bfd, struct bfd_link_info *info, bfd_putb32 (insn, splt->contents + h->plt.offset + 12); insn = PLT_ENTRY_WORD4 - + (((unsigned int) ((-(h->plt.offset + 16)) >> 1)) & 0xffffff); + + (((unsigned int) ((-(h->plt.offset + 16)) >> 1)) & 0xffffff); bfd_putb32 (insn, splt->contents + h->plt.offset + 16); local_plt_offset = 12; } @@ -5428,9 +6616,8 @@ nds32_elf_finish_dynamic_symbol (bfd *output_bfd, struct bfd_link_info *info, long offset; /* FIXME, sda_base is 65536, it will damage opcode. */ - /* insn = PLT_PIC_ENTRY_WORD0 + (((got_offset - sda_base) >> 2) & 0x7fff); */ offset = sgot->output_section->vma + sgot->output_offset + got_offset - - elf_gp (output_bfd); + - elf_gp (output_bfd); insn = PLT_PIC_ENTRY_WORD0 + ((offset >> 12) & 0xfffff); bfd_putb32 (insn, splt->contents + h->plt.offset); @@ -5479,18 +6666,18 @@ nds32_elf_finish_dynamic_symbol (bfd *output_bfd, struct bfd_link_info *info, } } - if (h->got.offset != (bfd_vma) - 1) + if ((h->got.offset != (bfd_vma) -1) && (hent->tls_type == GOT_NORMAL)) { asection *sgot; - asection *srela; + asection *srelagot; Elf_Internal_Rela rela; /* This symbol has an entry in the global offset table. Set it up. */ - sgot = htab->root.sgot; - srela = htab->root.srelgot; - BFD_ASSERT (sgot != NULL && srela != NULL); + sgot = ehtab->sgot; + srelagot = ehtab->srelgot; + BFD_ASSERT (sgot != NULL && srelagot != NULL); rela.r_offset = (sgot->output_section->vma + sgot->output_offset + (h->got.offset & ~1)); @@ -5500,14 +6687,24 @@ nds32_elf_finish_dynamic_symbol (bfd *output_bfd, struct bfd_link_info *info, the symbol was forced to be local because of a version file. The entry in the global offset table will already have been initialized in the relocate_section function. */ - if (bfd_link_pic (info) - && (info->symbolic - || h->dynindx == -1 || h->forced_local) && h->def_regular) + if ((bfd_link_pic (info) + && (info->symbolic || h->dynindx == -1 || h->forced_local) + && h->def_regular) + || (bfd_link_pie (info) && h->def_regular)) { rela.r_info = ELF32_R_INFO (0, R_NDS32_RELATIVE); rela.r_addend = (h->root.u.def.value - + h->root.u.def.section->output_section->vma - + h->root.u.def.section->output_offset); + + h->root.u.def.section->output_section->vma + + h->root.u.def.section->output_offset); + + /* FIXME: cancel PLT trampoline, too late ?? */ + /* h->plt.offset = (bfd_vma) -1; */ + + if ((h->got.offset & 1) == 0) + { + bfd_put_32 (output_bfd, rela.r_addend, + sgot->contents + h->got.offset); + } } else { @@ -5518,10 +6715,11 @@ nds32_elf_finish_dynamic_symbol (bfd *output_bfd, struct bfd_link_info *info, rela.r_addend = 0; } - loc = srela->contents; - loc += srela->reloc_count * sizeof (Elf32_External_Rela); + loc = srelagot->contents; + loc += srelagot->reloc_count * sizeof (Elf32_External_Rela); bfd_elf32_swap_reloca_out (output_bfd, &rela, loc); - ++srela->reloc_count; + ++srelagot->reloc_count; + BFD_ASSERT (loc < (srelagot->contents + srelagot->size)); } if (h->needs_copy) @@ -5563,23 +6761,32 @@ nds32_elf_finish_dynamic_symbol (bfd *output_bfd, struct bfd_link_info *info, static bfd_boolean nds32_elf_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) { - struct elf_nds32_link_hash_table *htab; bfd *dynobj; asection *sdyn; - asection *sgot; + asection *sgotplt; + struct elf_link_hash_table *ehtab; + struct elf_nds32_link_hash_table *htab; + ehtab = elf_hash_table (info); htab = nds32_elf_hash_table (info); - dynobj = htab->root.dynobj; + if (htab == NULL) + return FALSE; - sgot = htab->root.sgotplt; + dynobj = elf_hash_table (info)->dynobj; + + sgotplt = ehtab->sgotplt; + /* A broken linker script might have discarded the dynamic sections. + Catch this here so that we do not seg-fault later on. */ + if (sgotplt != NULL && bfd_is_abs_section (sgotplt->output_section)) + return FALSE; sdyn = bfd_get_section_by_name (dynobj, ".dynamic"); - if (htab->root.dynamic_sections_created) + if (elf_hash_table (info)->dynamic_sections_created) { asection *splt; Elf32_External_Dyn *dyncon, *dynconend; - BFD_ASSERT (sgot != NULL && sdyn != NULL); + BFD_ASSERT (sgotplt != NULL && sdyn != NULL); dyncon = (Elf32_External_Dyn *) sdyn->contents; dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->size); @@ -5597,25 +6804,60 @@ nds32_elf_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) break; case DT_PLTGOT: - s = htab->root.sgotplt; + /* name = ".got"; */ + s = ehtab->sgot->output_section; goto get_vma; case DT_JMPREL: - s = htab->root.srelplt; - get_vma: - dyn.d_un.d_ptr = s->output_section->vma + s->output_offset; + s = ehtab->srelplt->output_section; +get_vma: + BFD_ASSERT (s != NULL); + dyn.d_un.d_ptr = s->vma; bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); break; case DT_PLTRELSZ: - s = htab->root.srelplt; + s = ehtab->srelplt->output_section; + BFD_ASSERT (s != NULL); dyn.d_un.d_val = s->size; bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); break; + + case DT_RELASZ: + /* My reading of the SVR4 ABI indicates that the + procedure linkage table relocs (DT_JMPREL) should be + included in the overall relocs (DT_RELA). This is + what Solaris does. However, UnixWare can not handle + that case. Therefore, we override the DT_RELASZ entry + here to make it not include the JMPREL relocs. Since + the linker script arranges for .rela.plt to follow all + other relocation sections, we don't have to worry + about changing the DT_RELA entry. */ + if (ehtab->srelplt != NULL) + { + s = ehtab->srelplt->output_section; + dyn.d_un.d_val -= s->size; + } + bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); + break; + + case DT_TLSDESC_PLT: + s = htab->root.splt; + dyn.d_un.d_ptr = (s->output_section->vma + s->output_offset + + htab->dt_tlsdesc_plt); + bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); + break; + + case DT_TLSDESC_GOT: + s = htab->root.sgot; + dyn.d_un.d_ptr = (s->output_section->vma + s->output_offset + + htab->dt_tlsdesc_got); + bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); + break; } } /* Fill in the first entry in the procedure linkage table. */ - splt = htab->root.splt; + splt = ehtab->splt; if (splt && splt->size > 0) { if (bfd_link_pic (info)) @@ -5624,13 +6866,11 @@ nds32_elf_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) long offset; /* FIXME, sda_base is 65536, it will damage opcode. */ - /* insn = PLT_PIC_ENTRY_WORD0 + (((got_offset - sda_base) >> 2) & 0x7fff); */ - offset = sgot->output_section->vma + sgot->output_offset + 4 - - elf_gp (output_bfd); + offset = sgotplt->output_section->vma + sgotplt->output_offset + 4 + - elf_gp (output_bfd); insn = PLT0_PIC_ENTRY_WORD0 | ((offset >> 12) & 0xfffff); bfd_putb32 (insn, splt->contents); - /* insn = PLT0_PIC_ENTRY_WORD0 | (((8 - sda_base) >> 2) & 0x7fff) ; */ /* here has a typo? */ insn = PLT0_PIC_ENTRY_WORD1 | (offset & 0xfff); bfd_putb32 (insn, splt->contents + 4); @@ -5652,8 +6892,8 @@ nds32_elf_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) unsigned long insn; unsigned long addr; - /* addr = .got + 4 */ - addr = sgot->output_section->vma + sgot->output_offset + 4; + /* addr = .got + 4 */ + addr = sgotplt->output_section->vma + sgotplt->output_offset + 4; insn = PLT0_ENTRY_WORD0 | ((addr >> 12) & 0xfffff); bfd_putb32 (insn, splt->contents); @@ -5673,21 +6913,48 @@ nds32_elf_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) elf_section_data (splt->output_section)->this_hdr.sh_entsize = PLT_ENTRY_SIZE; } + + if (htab->dt_tlsdesc_plt) + { + /* Calculate addresses. */ + asection *sgot = sgot = ehtab->sgot; + bfd_vma pltgot = sgotplt->output_section->vma + + sgotplt->output_offset; + bfd_vma tlsdesc_got = sgot->output_section->vma + sgot->output_offset + + htab->dt_tlsdesc_got; + + /* Get GP offset. */ + pltgot -= elf_gp (output_bfd) - 4; /* PLTGOT[1] */ + tlsdesc_got -= elf_gp (output_bfd); + + /* Do relocation. */ + dl_tlsdesc_lazy_trampoline[0] += ((1 << 20) - 1) & (tlsdesc_got >> 12); + dl_tlsdesc_lazy_trampoline[1] += 0xfff & tlsdesc_got; + dl_tlsdesc_lazy_trampoline[4] += ((1 << 20) - 1) & (pltgot >> 12); + dl_tlsdesc_lazy_trampoline[5] += 0xfff & pltgot; + + /* TODO: relaxation. */ + + /* Insert .plt. */ + nds32_put_trampoline (splt->contents + htab->dt_tlsdesc_plt, + dl_tlsdesc_lazy_trampoline, + ARRAY_SIZE (dl_tlsdesc_lazy_trampoline)); + } } /* Fill in the first three entries in the global offset table. */ - if (sgot && sgot->size > 0) + if (sgotplt && sgotplt->size > 0) { if (sdyn == NULL) - bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents); + bfd_put_32 (output_bfd, (bfd_vma) 0, sgotplt->contents); else bfd_put_32 (output_bfd, sdyn->output_section->vma + sdyn->output_offset, - sgot->contents); - bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + 4); - bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + 8); + sgotplt->contents); + bfd_put_32 (output_bfd, (bfd_vma) 0, sgotplt->contents + 4); + bfd_put_32 (output_bfd, (bfd_vma) 0, sgotplt->contents + 8); - elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4; + elf_section_data (sgotplt->output_section)->this_hdr.sh_entsize = 4; } return TRUE; @@ -5738,6 +7005,7 @@ nds32_elf_final_write_processing (bfd *abfd, { unsigned long val; static unsigned int cur_mach = 0; + unsigned int i; if (bfd_mach_n1 != bfd_get_mach (abfd)) { @@ -5771,6 +7039,36 @@ nds32_elf_final_write_processing (bfd *abfd, elf_elfheader (abfd)->e_flags &= ~EF_NDS_ARCH; elf_elfheader (abfd)->e_flags |= val; + if (ifc_flag) + elf_elfheader (abfd)->e_flags |= E_NDS32_HAS_IFC_INST ; + + if (ict_file) + { + fprintf (ict_file, ".section " NDS32_ICT_SECTION ", \"ax\"\n"); + if (ict_model == R_NDS32_RELAX_ENTRY_ICT_LARGE) + fprintf (ict_file, ".ict_model\tlarge\n"); + else + fprintf (ict_file, ".ict_model\tsmall\n"); + fprintf (ict_file, ".globl _INDIRECT_CALL_TABLE_BASE_\n" + "_INDIRECT_CALL_TABLE_BASE_:\n"); + /* Output rom patch entries. */ + indirect_call_table.frozen = 1; + for (i = 0; i < indirect_call_table.size; i++) + { + struct bfd_hash_entry *p; + struct elf_nds32_ict_hash_entry *entry; + + for (p = indirect_call_table.table[i]; p != NULL; p = p->next) + { + entry = (struct elf_nds32_ict_hash_entry *) p; + if (ict_model == R_NDS32_RELAX_ENTRY_ICT_LARGE) + fprintf (ict_file, "\t.word\t%s\n", entry->root.string); + else + fprintf (ict_file, "\tj\t%s\n", entry->root.string); + } + } + indirect_call_table.frozen = 0; + } } /* Function to keep NDS32 specific file flags. */ @@ -5839,13 +7137,11 @@ nds32_check_vec_size (bfd *ibfd) nds32_vec_size = (flag_t & 0x3); else if (nds32_vec_size != (flag_t & 0x3)) { - _bfd_error_handler - /* xgettext:c-format */ - (_("%B: ISR vector size mismatch" - " with previous modules, previous %u-byte, current %u-byte"), - ibfd, - nds32_vec_size == 1 ? 4 : nds32_vec_size == 2 ? 16 : 0xffffffff, - (flag_t & 0x3) == 1 ? 4 : (flag_t & 0x3) == 2 ? 16 : 0xffffffff); + _bfd_error_handler (_("%pB: ISR vector size mismatch" + " with previous modules, previous %u-byte, current %u-byte"), + ibfd, + nds32_vec_size == 1 ? 4 : nds32_vec_size == 2 ? 16 : 0xffffffff, + (flag_t & 0x3) == 1 ? 4 : (flag_t & 0x3) == 2 ? 16 : 0xffffffff); return FALSE; } else @@ -5856,13 +7152,27 @@ nds32_check_vec_size (bfd *ibfd) return TRUE; } +static unsigned int +nds32_elf_force_to_set_output_abi (char *str) +{ + flagword flags; + + if (strcmp (str, "AABI") == 0) + flags = E_NDS_ABI_AABI; + else if (strcmp (str, "V2FP+") == 0) + flags = E_NDS_ABI_V2FP_PLUS; + else + flags = 0; + + return flags; +} + /* Merge backend specific data from an object file to the output object file when linking. */ static bfd_boolean nds32_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) { - bfd *obfd = info->output_bfd; flagword out_flags; flagword in_flags; flagword out_16regs; @@ -5873,6 +7183,7 @@ nds32_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) flagword in_version; flagword out_fpu_config; flagword in_fpu_config; + bfd *obfd = info->output_bfd; /* TODO: Revise to use object-attributes instead. */ if (!nds32_check_vec_size (ibfd)) @@ -5885,141 +7196,177 @@ nds32_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) if (bfd_little_endian (ibfd) != bfd_little_endian (obfd)) { _bfd_error_handler - (_("%B: warning: Endian mismatch with previous modules."), ibfd); + (_("%pB: warning: Endian mismatch with previous modules."), ibfd); bfd_set_error (bfd_error_bad_value); return FALSE; } - in_version = elf_elfheader (ibfd)->e_flags & EF_NDS32_ELF_VERSION; - if (in_version == E_NDS32_ELF_VER_1_2) - { - _bfd_error_handler - (_("%B: warning: Older version of object file encountered, " - "Please recompile with current tool chain."), ibfd); - } - - /* We may need to merge V1 and V2 arch object files to V2. */ - if ((elf_elfheader (ibfd)->e_flags & EF_NDS_ARCH) - != (elf_elfheader (obfd)->e_flags & EF_NDS_ARCH)) + /* [Bug 11585] [Ticket 7067] -B option in objcopy cannot work as expected. + e_flags = 0 shall be treat as generic one. + no checking, and no merging. */ + if (elf_elfheader (ibfd)->e_flags) { - /* Need to convert version. */ - if ((elf_elfheader (ibfd)->e_flags & EF_NDS_ARCH) - == E_NDS_ARCH_STAR_RESERVED) + in_version = elf_elfheader (ibfd)->e_flags & EF_NDS32_ELF_VERSION; + if (in_version == E_NDS32_ELF_VER_1_2) { - elf_elfheader (obfd)->e_flags = elf_elfheader (ibfd)->e_flags; + _bfd_error_handler + (_("%pB: warning: Older version of object file encountered, " + "Please recompile with current tool chain."), ibfd); } - else if ((elf_elfheader (obfd)->e_flags & EF_NDS_ARCH) == E_NDS_ARCH_STAR_V0_9 - || (elf_elfheader (ibfd)->e_flags & EF_NDS_ARCH) - > (elf_elfheader (obfd)->e_flags & EF_NDS_ARCH)) + + if (output_abi != NULL) { - elf_elfheader (obfd)->e_flags = - convert_e_flags (elf_elfheader (obfd)->e_flags, - (elf_elfheader (ibfd)->e_flags & EF_NDS_ARCH)); + elf_elfheader (ibfd)->e_flags &= ~(EF_NDS_ABI); + elf_elfheader (ibfd)->e_flags + |= nds32_elf_force_to_set_output_abi (output_abi); + elf_elfheader (obfd)->e_flags &= ~(EF_NDS_ABI); + elf_elfheader (obfd)->e_flags + |= nds32_elf_force_to_set_output_abi (output_abi); } - else + + /* We may need to merge V1 and V2 arch object files to V2. */ + if ((elf_elfheader (ibfd)->e_flags & EF_NDS_ARCH) + != (elf_elfheader (obfd)->e_flags & EF_NDS_ARCH)) { - elf_elfheader (ibfd)->e_flags = - convert_e_flags (elf_elfheader (ibfd)->e_flags, - (elf_elfheader (obfd)->e_flags & EF_NDS_ARCH)); - } - } - - /* Extract some flags. */ - in_flags = elf_elfheader (ibfd)->e_flags - & (~(E_NDS32_HAS_REDUCED_REGS | EF_NDS32_ELF_VERSION - | E_NDS32_HAS_NO_MAC_INST | E_NDS32_FPU_REG_CONF)); - - /* The following flags need special treatment. */ - in_16regs = elf_elfheader (ibfd)->e_flags & E_NDS32_HAS_REDUCED_REGS; - in_no_mac = elf_elfheader (ibfd)->e_flags & E_NDS32_HAS_NO_MAC_INST; - in_fpu_config = elf_elfheader (ibfd)->e_flags & E_NDS32_FPU_REG_CONF; - - /* Extract some flags. */ - out_flags = elf_elfheader (obfd)->e_flags - & (~(E_NDS32_HAS_REDUCED_REGS | EF_NDS32_ELF_VERSION - | E_NDS32_HAS_NO_MAC_INST | E_NDS32_FPU_REG_CONF)); - - /* The following flags need special treatment. */ - out_16regs = elf_elfheader (obfd)->e_flags & E_NDS32_HAS_REDUCED_REGS; - out_no_mac = elf_elfheader (obfd)->e_flags & E_NDS32_HAS_NO_MAC_INST; - out_fpu_config = elf_elfheader (obfd)->e_flags & E_NDS32_FPU_REG_CONF; - out_version = elf_elfheader (obfd)->e_flags & EF_NDS32_ELF_VERSION; - if (!elf_flags_init (obfd)) - { - /* If the input is the default architecture then do not - bother setting the flags for the output architecture, - instead allow future merges to do this. If no future - merges ever set these flags then they will retain their - unitialised values, which surprise surprise, correspond - to the default values. */ - if (bfd_get_arch_info (ibfd)->the_default) - return TRUE; + /* Need to convert version. */ + if ((elf_elfheader (ibfd)->e_flags & EF_NDS_ARCH) + == E_NDS_ARCH_STAR_RESERVED) + { + elf_elfheader (obfd)->e_flags = elf_elfheader (ibfd)->e_flags; + } + else if ((elf_elfheader (ibfd)->e_flags & EF_NDS_ARCH) + == E_NDS_ARCH_STAR_V3_M + && (elf_elfheader (obfd)->e_flags & EF_NDS_ARCH) + == E_NDS_ARCH_STAR_V3_0) + { + elf_elfheader (ibfd)->e_flags = + (elf_elfheader (ibfd)->e_flags & (~EF_NDS_ARCH)) + | E_NDS_ARCH_STAR_V3_0; + } + else if ((elf_elfheader (obfd)->e_flags & EF_NDS_ARCH) + == E_NDS_ARCH_STAR_V0_9 + || (elf_elfheader (ibfd)->e_flags & EF_NDS_ARCH) + > (elf_elfheader (obfd)->e_flags & EF_NDS_ARCH)) + { + elf_elfheader (obfd)->e_flags = + convert_e_flags (elf_elfheader (obfd)->e_flags, + (elf_elfheader (ibfd)->e_flags & EF_NDS_ARCH)); + } + else + { + elf_elfheader (ibfd)->e_flags = + convert_e_flags (elf_elfheader (ibfd)->e_flags, + (elf_elfheader (obfd)->e_flags & EF_NDS_ARCH)); + } + } - elf_flags_init (obfd) = TRUE; - elf_elfheader (obfd)->e_flags = elf_elfheader (ibfd)->e_flags; + /* Extract some flags. */ + in_flags = elf_elfheader (ibfd)->e_flags + & (~(E_NDS32_HAS_REDUCED_REGS | EF_NDS32_ELF_VERSION + | E_NDS32_HAS_NO_MAC_INST | E_NDS32_FPU_REG_CONF)); + + /* The following flags need special treatment. */ + in_16regs = elf_elfheader (ibfd)->e_flags & E_NDS32_HAS_REDUCED_REGS; + in_no_mac = elf_elfheader (ibfd)->e_flags & E_NDS32_HAS_NO_MAC_INST; + in_fpu_config = elf_elfheader (ibfd)->e_flags & E_NDS32_FPU_REG_CONF; + + /* Extract some flags. */ + out_flags = elf_elfheader (obfd)->e_flags + & (~(E_NDS32_HAS_REDUCED_REGS | EF_NDS32_ELF_VERSION + | E_NDS32_HAS_NO_MAC_INST | E_NDS32_FPU_REG_CONF)); + + /* The following flags need special treatment. */ + out_16regs = elf_elfheader (obfd)->e_flags & E_NDS32_HAS_REDUCED_REGS; + out_no_mac = elf_elfheader (obfd)->e_flags & E_NDS32_HAS_NO_MAC_INST; + out_fpu_config = elf_elfheader (obfd)->e_flags & E_NDS32_FPU_REG_CONF; + out_version = elf_elfheader (obfd)->e_flags & EF_NDS32_ELF_VERSION; + if (!elf_flags_init (obfd)) + { + /* If the input is the default architecture then do not + bother setting the flags for the output architecture, + instead allow future merges to do this. If no future + merges ever set these flags then they will retain their + unitialised values, which surprise surprise, correspond + to the default values. */ + if (bfd_get_arch_info (ibfd)->the_default) + return TRUE; - if (bfd_get_arch (obfd) == bfd_get_arch (ibfd) - && bfd_get_arch_info (obfd)->the_default) - { - return bfd_set_arch_mach (obfd, bfd_get_arch (ibfd), - bfd_get_mach (ibfd)); + elf_flags_init (obfd) = TRUE; + elf_elfheader (obfd)->e_flags = elf_elfheader (ibfd)->e_flags; + + if (bfd_get_arch (obfd) == bfd_get_arch (ibfd) + && bfd_get_arch_info (obfd)->the_default) + { + return bfd_set_arch_mach (obfd, bfd_get_arch (ibfd), + bfd_get_mach (ibfd)); + } + + return TRUE; } - return TRUE; - } + /* Check flag compatibility. */ + if ((in_flags & EF_NDS_ABI) != (out_flags & EF_NDS_ABI)) + { + asection *section = NULL; + bfd_byte *contents = NULL; + section = bfd_get_section_by_name (ibfd, ".note.v2abi_compatible"); + if (section) + bfd_get_full_section_contents (ibfd, section, &contents); - /* Check flag compatibility. */ - if ((in_flags & EF_NDS_ABI) != (out_flags & EF_NDS_ABI)) - { - _bfd_error_handler - (_("%B: error: ABI mismatch with previous modules."), ibfd); + /* Only enable v3f/v3s toolchain to link v2abi compatible objects. */ + if ((contents == NULL) + || bfd_getb32 (contents) != 1 + || (out_flags & EF_NDS_ABI) != E_NDS_ABI_V2FP_PLUS) + { + _bfd_error_handler + (_("%pB: error: ABI mismatch with previous modules."), ibfd); - bfd_set_error (bfd_error_bad_value); - return FALSE; - } + bfd_set_error (bfd_error_bad_value); + return FALSE; + } + } - if ((in_flags & EF_NDS_ARCH) != (out_flags & EF_NDS_ARCH)) - { - if (((in_flags & EF_NDS_ARCH) != E_N1_ARCH)) + if ((in_flags & EF_NDS_ARCH) != (out_flags & EF_NDS_ARCH)) { - _bfd_error_handler - (_("%B: error: Instruction set mismatch with previous modules."), ibfd); + if (((in_flags & EF_NDS_ARCH) != E_N1_ARCH)) + { + _bfd_error_handler + (_("%pB: error: Instruction set mismatch with previous modules."), ibfd); - bfd_set_error (bfd_error_bad_value); - return FALSE; + bfd_set_error (bfd_error_bad_value); + return FALSE; + } } - } - /* When linking with V1.2 and V1.3 objects together the output is V1.2. - and perf ext1 and DIV are mergerd to perf ext1. */ - if (in_version == E_NDS32_ELF_VER_1_2 || out_version == E_NDS32_ELF_VER_1_2) - { - elf_elfheader (obfd)->e_flags = - (in_flags & (~(E_NDS32_HAS_EXT_INST | E_NDS32_HAS_DIV_INST))) - | (out_flags & (~(E_NDS32_HAS_EXT_INST | E_NDS32_HAS_DIV_INST))) - | (((in_flags & (E_NDS32_HAS_EXT_INST | E_NDS32_HAS_DIV_INST))) - ? E_NDS32_HAS_EXT_INST : 0) - | (((out_flags & (E_NDS32_HAS_EXT_INST | E_NDS32_HAS_DIV_INST))) - ? E_NDS32_HAS_EXT_INST : 0) - | (in_16regs & out_16regs) | (in_no_mac & out_no_mac) - | ((in_version > out_version) ? out_version : in_version); - } - else - { - if (in_version != out_version) - _bfd_error_handler - /* xgettext:c-format */ - (_("%B: warning: Incompatible elf-versions %s and %s."), - ibfd, nds32_elfver_strtab[out_version], - nds32_elfver_strtab[in_version]); + /* When linking with V1.2 and V1.3 objects together the output is V1.2. + and perf ext1 and DIV are mergerd to perf ext1. */ + if (in_version == E_NDS32_ELF_VER_1_2 || out_version == E_NDS32_ELF_VER_1_2) + { + elf_elfheader (obfd)->e_flags = + (in_flags & (~(E_NDS32_HAS_EXT_INST | E_NDS32_HAS_DIV_INST))) + | (out_flags & (~(E_NDS32_HAS_EXT_INST | E_NDS32_HAS_DIV_INST))) + | (((in_flags & (E_NDS32_HAS_EXT_INST | E_NDS32_HAS_DIV_INST))) + ? E_NDS32_HAS_EXT_INST : 0) + | (((out_flags & (E_NDS32_HAS_EXT_INST | E_NDS32_HAS_DIV_INST))) + ? E_NDS32_HAS_EXT_INST : 0) + | (in_16regs & out_16regs) | (in_no_mac & out_no_mac) + | ((in_version > out_version) ? out_version : in_version); + } + else + { + if (in_version != out_version) + _bfd_error_handler + (_("%pB: warning: Incompatible elf-versions %s and %s."), ibfd, + nds32_elfver_strtab[out_version], + nds32_elfver_strtab[in_version]); - elf_elfheader (obfd)->e_flags = in_flags | out_flags - | (in_16regs & out_16regs) | (in_no_mac & out_no_mac) - | (in_fpu_config > out_fpu_config ? in_fpu_config : out_fpu_config) - | (in_version > out_version ? out_version : in_version); + elf_elfheader (obfd)->e_flags = in_flags | out_flags + | (in_16regs & out_16regs) | (in_no_mac & out_no_mac) + | (in_fpu_config > out_fpu_config ? in_fpu_config : out_fpu_config) + | (in_version > out_version ? out_version : in_version); + } } - return TRUE; } @@ -6081,6 +7428,79 @@ nds32_elf_gc_mark_hook (asection *sec, struct bfd_link_info *info, return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym); } +static enum elf_nds32_tls_type +get_tls_type (enum elf_nds32_reloc_type r_type, + struct elf_link_hash_entry *h ATTRIBUTE_UNUSED) +{ + enum elf_nds32_tls_type tls_type; + switch (r_type) + { + case R_NDS32_TLS_LE_HI20: + case R_NDS32_TLS_LE_LO12: + tls_type = GOT_TLS_LE; + break; + case R_NDS32_TLS_IE_HI20: + case R_NDS32_TLS_IE_LO12S2: + case R_NDS32_TLS_IE_LO12: + tls_type = GOT_TLS_IE; + break; + case R_NDS32_TLS_IEGP_HI20: + case R_NDS32_TLS_IEGP_LO12: + case R_NDS32_TLS_IEGP_LO12S2: + tls_type = GOT_TLS_IEGP; + break; + case R_NDS32_TLS_DESC_HI20: + case R_NDS32_TLS_DESC_LO12: + case R_NDS32_TLS_DESC_ADD: + case R_NDS32_TLS_DESC_FUNC: + case R_NDS32_TLS_DESC_CALL: + tls_type = GOT_TLS_DESC; + break; + default: + tls_type = GOT_NORMAL; + break; + } + return tls_type; +} + +/* Ensure that we have allocated bookkeeping structures for ABFD's local + symbols. */ + +static bfd_boolean +elf32_nds32_allocate_local_sym_info (bfd *abfd) +{ + if (elf_local_got_refcounts (abfd) == NULL) + { + bfd_size_type num_syms; + bfd_size_type size; + char *data; + + num_syms = elf_tdata (abfd)->symtab_hdr.sh_info; + /* This space is for got_refcounts, got_tls_type, tlsdesc_gotent, and + gp_offset. The details can refer to struct elf_nds32_obj_tdata. */ + size = num_syms * (sizeof (bfd_signed_vma) + sizeof (char) + + sizeof (bfd_vma) + sizeof (int) + + sizeof (bfd_boolean) + sizeof (bfd_vma)); + data = bfd_zalloc (abfd, size); + if (data == NULL) + return FALSE; + + elf_local_got_refcounts (abfd) = (bfd_signed_vma *) data; + data += num_syms * sizeof (bfd_signed_vma); + + elf32_nds32_local_got_tls_type (abfd) = (char *) data; + data += num_syms * sizeof (char); + + elf32_nds32_local_tlsdesc_gotent (abfd) = (bfd_vma *) data; + data += num_syms * sizeof (bfd_vma); + + elf32_nds32_local_gp_offset (abfd) = (int *) data; + data += num_syms * sizeof (int); + } + + return TRUE; +} + /* Look through the relocs for a section during the first phase. Since we don't do .gots or .plts, we just need to consider the virtual table relocs for gc. */ @@ -6093,21 +7513,17 @@ nds32_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, struct elf_link_hash_entry **sym_hashes, **sym_hashes_end; const Elf_Internal_Rela *rel; const Elf_Internal_Rela *rel_end; + struct elf_link_hash_table *ehtab; struct elf_nds32_link_hash_table *htab; bfd *dynobj; asection *sreloc = NULL; + /* No need for relocation if relocatable already. */ if (bfd_link_relocatable (info)) - return TRUE; - - /* Don't do anything special with non-loaded, non-alloced sections. - In particular, any relocs in such sections should not affect GOT - and PLT reference counting (ie. we don't allow them to create GOT - or PLT entries), there's no possibility or desire to optimize TLS - relocs, and there's not much point in propagating relocs to shared - libs that the dynamic linker won't relocate. */ - if ((sec->flags & SEC_ALLOC) == 0) - return TRUE; + { + elf32_nds32_check_relax_group (abfd, sec); + return TRUE; + } symtab_hdr = &elf_tdata (abfd)->symtab_hdr; sym_hashes = elf_sym_hashes (abfd); @@ -6116,6 +7532,7 @@ nds32_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, if (!elf_bad_symtab (abfd)) sym_hashes_end -= symtab_hdr->sh_info; + ehtab = elf_hash_table (info); htab = nds32_elf_hash_table (info); dynobj = htab->root.dynobj; @@ -6125,7 +7542,8 @@ nds32_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, enum elf_nds32_reloc_type r_type; struct elf_link_hash_entry *h; unsigned long r_symndx; - int tls_type, old_tls_type; + enum elf_nds32_tls_type tls_type, old_tls_type; + struct elf_nds32_ict_hash_entry *entry; r_symndx = ELF32_R_SYM (rel->r_info); r_type = ELF32_R_TYPE (rel->r_info); @@ -6139,10 +7557,11 @@ nds32_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, h = (struct elf_link_hash_entry *) h->root.u.i.link; } - /* Some relocs require a global offset table. We create - got section here, since these relocation need got section - and it is not created yet. */ - if (htab->root.sgot == NULL) + /* create .got section if necessary + Some relocs require a global offset table. We create + got section here, since these relocation need a got section + and if it is not created yet. */ + if (ehtab->sgot == NULL) { switch (r_type) { @@ -6162,10 +7581,16 @@ nds32_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, case R_NDS32_GOTPC_LO12: case R_NDS32_GOT20: case R_NDS32_TLS_IE_HI20: + case R_NDS32_TLS_IE_LO12: case R_NDS32_TLS_IE_LO12S2: + case R_NDS32_TLS_IEGP_HI20: + case R_NDS32_TLS_IEGP_LO12: + case R_NDS32_TLS_IEGP_LO12S2: + case R_NDS32_TLS_DESC_HI20: + case R_NDS32_TLS_DESC_LO12: if (dynobj == NULL) htab->root.dynobj = dynobj = abfd; - if (!_bfd_elf_create_got_section (dynobj, info)) + if (!create_got_section (dynobj, info)) return FALSE; break; @@ -6174,59 +7599,54 @@ nds32_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, } } + /* Check relocation type. */ switch ((int) r_type) { + case R_NDS32_TLS_LE_HI20: + case R_NDS32_TLS_LE_LO12: case R_NDS32_GOT_HI20: case R_NDS32_GOT_LO12: case R_NDS32_GOT_LO15: case R_NDS32_GOT_LO19: case R_NDS32_GOT20: case R_NDS32_TLS_IE_HI20: + case R_NDS32_TLS_IE_LO12: case R_NDS32_TLS_IE_LO12S2: - switch (r_type) - { - case R_NDS32_TLS_IE_HI20: - case R_NDS32_TLS_IE_LO12S2: - tls_type = GOT_TLS_IE; - break; - default: - tls_type = GOT_NORMAL; - break; - } - if (h != NULL) + case R_NDS32_TLS_IEGP_HI20: + case R_NDS32_TLS_IEGP_LO12: + case R_NDS32_TLS_IEGP_LO12S2: + case R_NDS32_TLS_DESC_HI20: + case R_NDS32_TLS_DESC_LO12: + tls_type = get_tls_type (r_type, h); + if (h) { + if (tls_type != GOT_TLS_LE) + h->got.refcount += 1; old_tls_type = elf32_nds32_hash_entry (h)->tls_type; - h->got.refcount += 1; } else { - bfd_signed_vma *local_got_refcounts; - - /* This is a global offset table entry for a local - symbol. */ - local_got_refcounts = elf_local_got_refcounts (abfd); - if (local_got_refcounts == NULL) - { - bfd_size_type size; + /* This is a global offset table entry for a local symbol. */ + if (!elf32_nds32_allocate_local_sym_info (abfd)) + return FALSE; - size = symtab_hdr->sh_info; - size *= sizeof (bfd_signed_vma); - local_got_refcounts = (bfd_signed_vma *) bfd_zalloc (abfd, size); - if (local_got_refcounts == NULL) - return FALSE; - elf_local_got_refcounts (abfd) = local_got_refcounts; - } - local_got_refcounts[r_symndx] += 1; + BFD_ASSERT (r_symndx < symtab_hdr->sh_info); + if (tls_type != GOT_TLS_LE) + elf_local_got_refcounts (abfd)[r_symndx] += 1; old_tls_type = elf32_nds32_local_got_tls_type (abfd)[r_symndx]; } - /* We will already have issued an error message if there + /* We would already issued an error message if there is a TLS/non-TLS mismatch, based on the symbol - type. So just combine any TLS types needed. */ + type. So just combine any TLS types needed. */ if (old_tls_type != GOT_UNKNOWN && old_tls_type != GOT_NORMAL && tls_type != GOT_NORMAL) tls_type |= old_tls_type; + /* DESC to IE/IEGP if link to executable */ + if ((tls_type & (GOT_TLS_DESC | GOT_TLS_IEGP)) && (bfd_link_executable (info))) + tls_type |= (bfd_link_pie (info) ? GOT_TLS_IEGP : GOT_TLS_IE); + if (old_tls_type != tls_type) { if (h != NULL) @@ -6235,6 +7655,7 @@ nds32_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, elf32_nds32_local_got_tls_type (abfd)[r_symndx] = tls_type; } break; + case R_NDS32_9_PLTREL: case R_NDS32_25_PLTREL: case R_NDS32_PLTREL_HI20: @@ -6244,19 +7665,20 @@ nds32_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, case R_NDS32_PLT_GOTREL_LO15: case R_NDS32_PLT_GOTREL_LO19: case R_NDS32_PLT_GOTREL_LO20: - - /* This symbol requires a procedure linkage table entry. We - actually build the entry in adjust_dynamic_symbol, + /* This symbol requires a procedure linkage table entry. + We actually build the entry in adjust_dynamic_symbol, because this might be a case of linking PIC code without linking in any dynamic objects, in which case we don't need to generate a procedure linkage table after all. */ /* If this is a local symbol, we resolve it directly without creating a procedure linkage table entry. */ + /* explain: continue v.s. break here following: */ if (h == NULL) continue; - if (h->forced_local) + if (h->forced_local + || (bfd_link_pie (info) && h->def_regular)) break; elf32_nds32_hash_entry (h)->tls_type = GOT_NORMAL; @@ -6330,8 +7752,8 @@ nds32_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, && (h->root.type == bfd_link_hash_defweak || !h->def_regular))) { - struct elf_dyn_relocs *p; - struct elf_dyn_relocs **head; + struct elf_nds32_dyn_relocs *p; + struct elf_nds32_dyn_relocs **head; if (dynobj == NULL) htab->root.dynobj = dynobj = abfd; @@ -6380,7 +7802,6 @@ nds32_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, else { asection *s; - void *vpp; Elf_Internal_Sym *isym; isym = bfd_sym_from_r_symndx (&htab->sym_cache, abfd, r_symndx); @@ -6392,15 +7813,15 @@ nds32_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, if (s == NULL) return FALSE; - vpp = &elf_section_data (s)->local_dynrel; - head = (struct elf_dyn_relocs **) vpp; + head = ((struct elf_nds32_dyn_relocs **) + &elf_section_data (s)->local_dynrel); } p = *head; if (p == NULL || p->sec != sec) { bfd_size_type amt = sizeof (*p); - p = (struct elf_dyn_relocs *) bfd_alloc (dynobj, amt); + p = (struct elf_nds32_dyn_relocs *) bfd_alloc (dynobj, amt); if (p == NULL) return FALSE; p->next = *head; @@ -6411,13 +7832,92 @@ nds32_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, } p->count += 1; + + /* FIXME: Since eh_frame is readonly, R_NDS32_32_RELA + reloc for eh_frame will cause shared library has + TEXTREL entry in the dynamic section. This lead glibc + testsuites to failure (bug-13092) and cause kernel fail + (bug-11819). I think the best solution is to replace + absolute reloc with pc relative reloc in the eh_frame. + To do that, we need to support the following issues: + + === For GCC === + * gcc/config/nds32/nds32.h: Define + ASM_PREFERRED_EH_DATA_FORMAT to encode DW_EH_PE_pcrel + and DW_EH_PE_sdata4 into DWARF exception header when + option have '-fpic'. + + === For binutils === + * bfd/: Define new reloc R_NDS32_32_PCREL_RELA. + * gas/config/tc-nds32.h: Define DIFF_EXPR_OK. This + may break our nds DIFF mechanism, therefore, we + must disable all linker relaxations to ensure + correctness. + * gas/config/tc-nds32.c (nds32_apply_fix): Replace + R_NDS32_32_RELA with R_NDS32_32_PCREL_RELA, and + do the necessary modification. + + Unfortunately, it still have some problems for nds32 + to support pc relative reloc in the eh_frame. So I use + another solution to fix this issue. + + However, I find that ld always emit TEXTREL marker for + R_NDS32_NONE relocs in rel.dyn. These none relocs are + correspond to R_NDS32_32_RELA for .eh_frame section. + It means that we always reserve redundant entries of rel.dyn + for these relocs which actually do nothing in dynamic linker. + + Therefore, we regard these relocs as pc relative relocs + here and increase the pc_count. */ if (ELF32_R_TYPE (rel->r_info) == R_NDS32_25_PCREL_RELA || ELF32_R_TYPE (rel->r_info) == R_NDS32_15_PCREL_RELA - || ELF32_R_TYPE (rel->r_info) == R_NDS32_17_PCREL_RELA) + || ELF32_R_TYPE (rel->r_info) == R_NDS32_17_PCREL_RELA + || (r_type == R_NDS32_32_RELA + && strcmp (sec->name, ".eh_frame") == 0)) p->pc_count += 1; } break; + /* Merge jump-patch table symbol here. */ + case R_NDS32_ICT_HI20: + case R_NDS32_ICT_LO12: + case R_NDS32_ICT_25PC: + if (rel->r_addend != 0) + { + _bfd_error_handler + (_("%pB %s: Error: Rom-patch relocation offset: 0x%lx " + "with addend 0x%lx\n"), + abfd, sec->name, rel->r_offset, rel->r_addend); + bfd_set_error (bfd_error_bad_value); + return FALSE; + } + + if (h) + { + elf32_nds32_hash_entry (h)->indirect_call = TRUE; + entry = (struct elf_nds32_ict_hash_entry *) + bfd_hash_lookup (&indirect_call_table, h->root.root.string, + TRUE, TRUE); + entry->h = h; + if (entry == NULL) + { + _bfd_error_handler + (_("%pB: failed creating indirect call %s hash table\n"), + abfd, h->root.root.string); + bfd_set_error (bfd_error_bad_value); + return FALSE; + } + } + else + { + /* Rom-patch functions cannot be local. */ + _bfd_error_handler + (_("%pB: indirect call relocation with local symbol.\n"), abfd); + bfd_set_error (bfd_error_bad_value); + return FALSE; + } + break; + /* This relocation describes the C++ object vtable hierarchy. Reconstruct it for later use during GC. */ case R_NDS32_RELA_GNU_VTINHERIT: @@ -6436,6 +7936,18 @@ nds32_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend)) return FALSE; break; + case R_NDS32_RELAX_ENTRY: + if (ict_model == 0) + ict_model = rel->r_addend & R_NDS32_RELAX_ENTRY_ICT_MASK; + else if (ict_model != (rel->r_addend & R_NDS32_RELAX_ENTRY_ICT_MASK) + && (rel->r_addend & R_NDS32_RELAX_ENTRY_ICT_MASK) != 0) + { + _bfd_error_handler + (_("%pB Error: mixed ict model objects.\n"), abfd); + bfd_set_error (bfd_error_bad_value); + return FALSE; + } + break; } } @@ -6464,8 +7976,7 @@ write_uleb128 (bfd_byte *p, unsigned int val) static bfd_signed_vma calculate_offset (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, - Elf_Internal_Sym *isymbuf, Elf_Internal_Shdr *symtab_hdr, - int *pic_ext_target) + Elf_Internal_Sym *isymbuf, Elf_Internal_Shdr *symtab_hdr) { bfd_signed_vma foff; bfd_vma symval, addend; @@ -6494,7 +8005,6 @@ calculate_offset (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, { unsigned long indx; struct elf_link_hash_entry *h; - bfd *owner; /* An external symbol. */ indx = ELF32_R_SYM (irel->r_info) - symtab_hdr->sh_info; @@ -6507,9 +8017,6 @@ calculate_offset (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, symbol. Just ignore it--it will be caught by the regular reloc processing. */ return 0; - owner = h->root.u.def.section->owner; - if (owner && (elf_elfheader (owner)->e_flags & E_NDS32_HAS_PIC)) - *pic_ext_target = 1; if (h->root.u.def.section->flags & SEC_MERGE) { @@ -6563,15 +8070,15 @@ calculate_plt_memory_address (bfd *abfd, struct bfd_link_info *link_info, { unsigned long indx; struct elf_link_hash_entry *h; - struct elf_nds32_link_hash_table *htab; + struct elf_link_hash_table *ehtab; asection *splt; /* An external symbol. */ indx = ELF32_R_SYM (irel->r_info) - symtab_hdr->sh_info; h = elf_sym_hashes (abfd)[indx]; BFD_ASSERT (h != NULL); - htab = nds32_elf_hash_table (link_info); - splt = htab->root.splt; + ehtab = elf_hash_table (link_info); + splt = ehtab->splt; while (h->root.type == bfd_link_hash_indirect || h->root.type == bfd_link_hash_warning) @@ -6582,8 +8089,8 @@ calculate_plt_memory_address (bfd *abfd, struct bfd_link_info *link_info, if (h->root.type != bfd_link_hash_defined && h->root.type != bfd_link_hash_defweak) /* This appears to be a reference to an undefined - * symbol. Just ignore it--it will be caught by the - * regular reloc processing. */ + symbol. Just ignore it--it will be caught by the + regular reloc processing. */ return 0; symval = (h->root.u.def.value + h->root.u.def.section->output_section->vma @@ -6620,7 +8127,7 @@ nds32_convert_32_to_16_alu1 (bfd *abfd, uint32_t insn, uint16_t *pinsn16, int *pinsn_type) { uint16_t insn16 = 0; - int insn_type = 0; + int insn_type; unsigned long mach = bfd_get_mach (abfd); if (N32_SH5 (insn) != 0) @@ -6919,8 +8426,7 @@ nds32_convert_32_to_16 (bfd *abfd, uint32_t insn, uint16_t *pinsn16, else if (N32_IS_RT4 (insn) && N32_RT5 (insn) == N32_RA5 (insn) && N32_IMM15S (insn) > -32) { - insn16 = N16_TYPE45 (SUBI45, N32_RT54 (insn), - 0 - N32_IMM15S (insn)); + insn16 = N16_TYPE45 (SUBI45, N32_RT54 (insn), 0 - N32_IMM15S (insn)); insn_type = NDS32_INSN_SUBI45; } else if (mach >= MACH_V2 && N32_RT5 (insn) == REG_SP @@ -6981,7 +8487,7 @@ nds32_convert_32_to_16 (bfd *abfd, uint32_t insn, uint16_t *pinsn16, if (__builtin_popcount (imm15u) == 1) { - /* BMSKI33 */ + /* BMSKI33 */ int imm3u = __builtin_ctz (imm15u); insn16 = N16_BFMI333 (BMSKI33, N32_RT5 (insn), imm3u); @@ -6989,7 +8495,7 @@ nds32_convert_32_to_16 (bfd *abfd, uint32_t insn, uint16_t *pinsn16, } else if (imm15u != 0 && __builtin_popcount (imm15u + 1) == 1) { - /* FEXTI33 */ + /* FEXTI33 */ int imm3u = __builtin_ctz (imm15u + 1) - 1; insn16 = N16_BFMI333 (FEXTI33, N32_RT5 (insn), imm3u); @@ -7150,7 +8656,7 @@ nds32_convert_32_to_16 (bfd *abfd, uint32_t insn, uint16_t *pinsn16, if ((insn & N32_BIT (14)) == 0) { - /* N32_BR1_BEQ */ + /* N32_BR1_BEQ */ if (N32_IS_RT3 (insn) && N32_RA5 (insn) == REG_R5 && N32_RT5 (insn) != REG_R5) insn16 = N16_TYPE38 (BEQS38, N32_RT5 (insn), N32_IMM14S (insn)); @@ -7162,7 +8668,7 @@ nds32_convert_32_to_16 (bfd *abfd, uint32_t insn, uint16_t *pinsn16, } else { - /* N32_BR1_BNE */ + /* N32_BR1_BNE */ if (N32_IS_RT3 (insn) && N32_RA5 (insn) == REG_R5 && N32_RT5 (insn) != REG_R5) insn16 = N16_TYPE38 (BNES38, N32_RT5 (insn), N32_IMM14S (insn)); @@ -7183,8 +8689,7 @@ nds32_convert_32_to_16 (bfd *abfd, uint32_t insn, uint16_t *pinsn16, insn16 = N16_TYPE38 (BEQZ38, N32_RT5 (insn), N32_IMM16S (insn)); insn_type = NDS32_INSN_BEQZ38; } - else if (N32_RT5 (insn) == REG_R15 - && IS_WITHIN_S (N32_IMM16S (insn), 8)) + else if (N32_RT5 (insn) == REG_R15 && IS_WITHIN_S (N32_IMM16S (insn), 8)) { insn16 = N16_TYPE8 (BEQZS8, N32_IMM16S (insn)); insn_type = NDS32_INSN_BEQZS8; @@ -7197,16 +8702,15 @@ nds32_convert_32_to_16 (bfd *abfd, uint32_t insn, uint16_t *pinsn16, insn16 = N16_TYPE38 (BNEZ38, N32_RT5 (insn), N32_IMM16S (insn)); insn_type = NDS32_INSN_BNEZ38; } - else if (N32_RT5 (insn) == REG_R15 - && IS_WITHIN_S (N32_IMM16S (insn), 8)) + else if (N32_RT5 (insn) == REG_R15 && IS_WITHIN_S (N32_IMM16S (insn), 8)) { insn16 = N16_TYPE8 (BNEZS8, N32_IMM16S (insn)); insn_type = NDS32_INSN_BNEZS8; } break; - case N32_BR2_IFCALL: - if (IS_WITHIN_U (N32_IMM16S (insn), 9)) + case N32_BR2_SOP0: + if (__GF (insn, 20, 5) == 0 && IS_WITHIN_U (N32_IMM16S (insn), 9)) { insn16 = N16_TYPE9 (IFCALL9, N32_IMM16S (insn)); insn_type = NDS32_INSN_IFCALL9; @@ -7218,7 +8722,7 @@ nds32_convert_32_to_16 (bfd *abfd, uint32_t insn, uint16_t *pinsn16, case N32_OP6_JI: if ((insn & N32_BIT (24)) == 0) { - /* N32_JI_J */ + /* N32_JI_J */ if (IS_WITHIN_S (N32_IMM24S (insn), 8)) { insn16 = N16_TYPE8 (J8, N32_IMM24S (insn)); @@ -7236,19 +8740,19 @@ nds32_convert_32_to_16 (bfd *abfd, uint32_t insn, uint16_t *pinsn16, case N32_JREG_JR: if (N32_JREG_HINT (insn) == 0) { - /* jr */ + /* jr */ insn16 = N16_TYPE5 (JR5, N32_RB5 (insn)); insn_type = NDS32_INSN_JR5; } else if (N32_JREG_HINT (insn) == 1) { - /* ret */ + /* ret */ insn16 = N16_TYPE5 (RET5, N32_RB5 (insn)); insn_type = NDS32_INSN_RET5; } else if (N32_JREG_HINT (insn) == 3) { - /* ifret = mov55 $sp, $sp */ + /* ifret = mov55 $sp, $sp */ insn16 = N16_TYPE55 (MOV55, REG_SP, REG_SP); insn_type = NDS32_INSN_IFRET; } @@ -7347,184 +8851,162 @@ nds32_convert_16_to_32 (bfd *abfd, uint16_t insn16, uint32_t *pinsn) switch (__GF (insn16, 9, 6)) { - case 0x4: /* add45 */ - insn = N32_ALU1 (ADD, N16_RT4 (insn16), N16_RT4 (insn16), - N16_RA5 (insn16)); + case 0x4: /* add45 */ + insn = N32_ALU1 (ADD, N16_RT4 (insn16), N16_RT4 (insn16), N16_RA5 (insn16)); goto done; - case 0x5: /* sub45 */ - insn = N32_ALU1 (SUB, N16_RT4 (insn16), N16_RT4 (insn16), - N16_RA5 (insn16)); + case 0x5: /* sub45 */ + insn = N32_ALU1 (SUB, N16_RT4 (insn16), N16_RT4 (insn16), N16_RA5 (insn16)); goto done; - case 0x6: /* addi45 */ - insn = N32_TYPE2 (ADDI, N16_RT4 (insn16), N16_RT4 (insn16), - N16_IMM5U (insn16)); + case 0x6: /* addi45 */ + insn = N32_TYPE2 (ADDI, N16_RT4 (insn16), N16_RT4 (insn16), N16_IMM5U (insn16)); goto done; - case 0x7: /* subi45 */ - insn = N32_TYPE2 (ADDI, N16_RT4 (insn16), N16_RT4 (insn16), - -N16_IMM5U (insn16)); + case 0x7: /* subi45 */ + insn = N32_TYPE2 (ADDI, N16_RT4 (insn16), N16_RT4 (insn16), -N16_IMM5U (insn16)); goto done; - case 0x8: /* srai45 */ - insn = N32_ALU1 (SRAI, N16_RT4 (insn16), N16_RT4 (insn16), - N16_IMM5U (insn16)); + case 0x8: /* srai45 */ + insn = N32_ALU1 (SRAI, N16_RT4 (insn16), N16_RT4 (insn16), N16_IMM5U (insn16)); goto done; - case 0x9: /* srli45 */ - insn = N32_ALU1 (SRLI, N16_RT4 (insn16), N16_RT4 (insn16), - N16_IMM5U (insn16)); + case 0x9: /* srli45 */ + insn = N32_ALU1 (SRLI, N16_RT4 (insn16), N16_RT4 (insn16), N16_IMM5U (insn16)); goto done; - case 0xa: /* slli333 */ - insn = N32_ALU1 (SLLI, N16_RT3 (insn16), N16_RA3 (insn16), - N16_IMM3U (insn16)); + + case 0xa: /* slli333 */ + insn = N32_ALU1 (SLLI, N16_RT3 (insn16), N16_RA3 (insn16), N16_IMM3U (insn16)); goto done; - case 0xc: /* add333 */ - insn = N32_ALU1 (ADD, N16_RT3 (insn16), N16_RA3 (insn16), - N16_RB3 (insn16)); + case 0xc: /* add333 */ + insn = N32_ALU1 (ADD, N16_RT3 (insn16), N16_RA3 (insn16), N16_RB3 (insn16)); goto done; - case 0xd: /* sub333 */ - insn = N32_ALU1 (SUB, N16_RT3 (insn16), N16_RA3 (insn16), - N16_RB3 (insn16)); + case 0xd: /* sub333 */ + insn = N32_ALU1 (SUB, N16_RT3 (insn16), N16_RA3 (insn16), N16_RB3 (insn16)); goto done; - case 0xe: /* addi333 */ - insn = N32_TYPE2 (ADDI, N16_RT3 (insn16), N16_RA3 (insn16), - N16_IMM3U (insn16)); + case 0xe: /* addi333 */ + insn = N32_TYPE2 (ADDI, N16_RT3 (insn16), N16_RA3 (insn16), N16_IMM3U (insn16)); goto done; - case 0xf: /* subi333 */ - insn = N32_TYPE2 (ADDI, N16_RT3 (insn16), N16_RA3 (insn16), - -N16_IMM3U (insn16)); + case 0xf: /* subi333 */ + insn = N32_TYPE2 (ADDI, N16_RT3 (insn16), N16_RA3 (insn16), -N16_IMM3U (insn16)); goto done; - case 0x10: /* lwi333 */ - insn = N32_TYPE2 (LWI, N16_RT3 (insn16), N16_RA3 (insn16), - N16_IMM3U (insn16)); + + case 0x10: /* lwi333 */ + insn = N32_TYPE2 (LWI, N16_RT3 (insn16), N16_RA3 (insn16), N16_IMM3U (insn16)); goto done; - case 0x12: /* lhi333 */ - insn = N32_TYPE2 (LHI, N16_RT3 (insn16), N16_RA3 (insn16), - N16_IMM3U (insn16)); + case 0x12: /* lhi333 */ + insn = N32_TYPE2 (LHI, N16_RT3 (insn16), N16_RA3 (insn16), N16_IMM3U (insn16)); goto done; - case 0x13: /* lbi333 */ - insn = N32_TYPE2 (LBI, N16_RT3 (insn16), N16_RA3 (insn16), - N16_IMM3U (insn16)); + case 0x13: /* lbi333 */ + insn = N32_TYPE2 (LBI, N16_RT3 (insn16), N16_RA3 (insn16), N16_IMM3U (insn16)); goto done; - case 0x11: /* lwi333.bi */ - insn = N32_TYPE2 (LWI_BI, N16_RT3 (insn16), N16_RA3 (insn16), - N16_IMM3U (insn16)); + case 0x11: /* lwi333.bi */ + insn = N32_TYPE2 (LWI_BI, N16_RT3 (insn16), N16_RA3 (insn16), N16_IMM3U (insn16)); goto done; - case 0x14: /* swi333 */ - insn = N32_TYPE2 (SWI, N16_RT3 (insn16), N16_RA3 (insn16), - N16_IMM3U (insn16)); + case 0x14: /* swi333 */ + insn = N32_TYPE2 (SWI, N16_RT3 (insn16), N16_RA3 (insn16), N16_IMM3U (insn16)); goto done; - case 0x16: /* shi333 */ - insn = N32_TYPE2 (SHI, N16_RT3 (insn16), N16_RA3 (insn16), - N16_IMM3U (insn16)); + case 0x16: /* shi333 */ + insn = N32_TYPE2 (SHI, N16_RT3 (insn16), N16_RA3 (insn16), N16_IMM3U (insn16)); goto done; - case 0x17: /* sbi333 */ - insn = N32_TYPE2 (SBI, N16_RT3 (insn16), N16_RA3 (insn16), - N16_IMM3U (insn16)); + case 0x17: /* sbi333 */ + insn = N32_TYPE2 (SBI, N16_RT3 (insn16), N16_RA3 (insn16), N16_IMM3U (insn16)); goto done; - case 0x15: /* swi333.bi */ - insn = N32_TYPE2 (SWI_BI, N16_RT3 (insn16), N16_RA3 (insn16), - N16_IMM3U (insn16)); + case 0x15: /* swi333.bi */ + insn = N32_TYPE2 (SWI_BI, N16_RT3 (insn16), N16_RA3 (insn16), N16_IMM3U (insn16)); goto done; - case 0x18: /* addri36.sp */ - insn = N32_TYPE2 (ADDI, N16_RT3 (insn16), REG_SP, - N16_IMM6U (insn16) << 2); + + case 0x18: /* addri36.sp */ + insn = N32_TYPE2 (ADDI, N16_RT3 (insn16), REG_SP, N16_IMM6U (insn16) << 2); goto done; - case 0x19: /* lwi45.fe */ - insn = N32_TYPE2 (LWI, N16_RT4 (insn16), REG_R8, - (N16_IMM5U (insn16) - 32)); + + case 0x19: /* lwi45.fe */ + insn = N32_TYPE2 (LWI, N16_RT4 (insn16), REG_R8, (N16_IMM5U (insn16) - 32)); goto done; - case 0x1a: /* lwi450 */ + case 0x1a: /* lwi450 */ insn = N32_TYPE2 (LWI, N16_RT4 (insn16), N16_RA5 (insn16), 0); goto done; - case 0x1b: /* swi450 */ + case 0x1b: /* swi450 */ insn = N32_TYPE2 (SWI, N16_RT4 (insn16), N16_RA5 (insn16), 0); goto done; - /* These are r15 implied instructions. */ - case 0x30: /* slts45 */ + /* These are r15 implied instructions. */ + case 0x30: /* slts45 */ insn = N32_ALU1 (SLTS, REG_TA, N16_RT4 (insn16), N16_RA5 (insn16)); goto done; - case 0x31: /* slt45 */ + case 0x31: /* slt45 */ insn = N32_ALU1 (SLT, REG_TA, N16_RT4 (insn16), N16_RA5 (insn16)); goto done; - case 0x32: /* sltsi45 */ + case 0x32: /* sltsi45 */ insn = N32_TYPE2 (SLTSI, REG_TA, N16_RT4 (insn16), N16_IMM5U (insn16)); goto done; - case 0x33: /* slti45 */ + case 0x33: /* slti45 */ insn = N32_TYPE2 (SLTI, REG_TA, N16_RT4 (insn16), N16_IMM5U (insn16)); goto done; - case 0x34: /* beqzs8, bnezs8 */ + case 0x34: /* beqzs8, bnezs8 */ if (insn16 & N32_BIT (8)) insn = N32_BR2 (BNEZ, REG_TA, N16_IMM8S (insn16)); else insn = N32_BR2 (BEQZ, REG_TA, N16_IMM8S (insn16)); goto done; - case 0x35: /* break16, ex9.it */ + case 0x35: /* break16, ex9.it */ /* Only consider range of v3 break16. */ insn = N32_TYPE0 (MISC, (N16_IMM5U (insn16) << 5) | N32_MISC_BREAK); goto done; - case 0x3c: /* ifcall9 */ - insn = N32_BR2 (IFCALL, 0, N16_IMM9U (insn16)); + case 0x3c: /* ifcall9 */ + insn = N32_BR2 (SOP0, 0, N16_IMM9U (insn16)); goto done; - case 0x3d: /* movpi45 */ + case 0x3d: /* movpi45 */ insn = N32_TYPE1 (MOVI, N16_RT4 (insn16), N16_IMM5U (insn16) + 16); goto done; - case 0x3f: /* MISC33 */ + case 0x3f: /* MISC33 */ switch (insn16 & 0x7) { - case 2: /* neg33 */ + case 2: /* neg33 */ insn = N32_TYPE2 (SUBRI, N16_RT3 (insn16), N16_RA3 (insn16), 0); break; - case 3: /* not33 */ - insn = N32_ALU1 (NOR, N16_RT3 (insn16), N16_RA3 (insn16), - N16_RA3 (insn16)); + case 3: /* not33 */ + insn = N32_ALU1 (NOR, N16_RT3 (insn16), N16_RA3 (insn16), N16_RA3 (insn16)); break; - case 4: /* mul33 */ - insn = N32_ALU2 (MUL, N16_RT3 (insn16), N16_RT3 (insn16), - N16_RA3 (insn16)); + case 4: /* mul33 */ + insn = N32_ALU2 (MUL, N16_RT3 (insn16), N16_RT3 (insn16), N16_RA3 (insn16)); break; - case 5: /* xor33 */ - insn = N32_ALU1 (XOR, N16_RT3 (insn16), N16_RT3 (insn16), - N16_RA3 (insn16)); + case 5: /* xor33 */ + insn = N32_ALU1 (XOR, N16_RT3 (insn16), N16_RT3 (insn16), N16_RA3 (insn16)); break; - case 6: /* and33 */ - insn = N32_ALU1 (AND, N16_RT3 (insn16), N16_RT3 (insn16), - N16_RA3 (insn16)); + case 6: /* and33 */ + insn = N32_ALU1 (AND, N16_RT3 (insn16), N16_RT3 (insn16), N16_RA3 (insn16)); break; - case 7: /* or33 */ - insn = N32_ALU1 (OR, N16_RT3 (insn16), N16_RT3 (insn16), - N16_RA3 (insn16)); + case 7: /* or33 */ + insn = N32_ALU1 (OR, N16_RT3 (insn16), N16_RT3 (insn16), N16_RA3 (insn16)); break; } goto done; - case 0xb: + case 0xb: /* ... */ switch (insn16 & 0x7) { - case 0: /* zeb33 */ + case 0: /* zeb33 */ insn = N32_TYPE2 (ANDI, N16_RT3 (insn16), N16_RA3 (insn16), 0xff); break; - case 1: /* zeh33 */ + case 1: /* zeh33 */ insn = N32_ALU1 (ZEH, N16_RT3 (insn16), N16_RA3 (insn16), 0); break; - case 2: /* seb33 */ + case 2: /* seb33 */ insn = N32_ALU1 (SEB, N16_RT3 (insn16), N16_RA3 (insn16), 0); break; - case 3: /* seh33 */ + case 3: /* seh33 */ insn = N32_ALU1 (SEH, N16_RT3 (insn16), N16_RA3 (insn16), 0); break; - case 4: /* xlsb33 */ + case 4: /* xlsb33 */ insn = N32_TYPE2 (ANDI, N16_RT3 (insn16), N16_RA3 (insn16), 1); break; - case 5: /* x11b33 */ + case 5: /* x11b33 */ insn = N32_TYPE2 (ANDI, N16_RT3 (insn16), N16_RA3 (insn16), 0x7ff); break; - case 6: /* bmski33 */ + case 6: /* bmski33 */ insn = N32_TYPE2 (ANDI, N16_RT3 (insn16), N16_RT3 (insn16), 1 << __GF (insn16, 3, 3)); break; - case 7: /* fexti33 */ + case 7: /* fexti33 */ insn = N32_TYPE2 (ANDI, N16_RT3 (insn16), N16_RT3 (insn16), (1 << (__GF (insn16, 3, 3) + 1)) - 1); break; @@ -7534,70 +9016,70 @@ nds32_convert_16_to_32 (bfd *abfd, uint16_t insn16, uint32_t *pinsn) switch (__GF (insn16, 10, 5)) { - case 0x0: /* mov55 or ifret16 */ + case 0x0: /* mov55 or ifret16 */ if (mach >= MACH_V3 && N16_RT5 (insn16) == REG_SP && N16_RT5 (insn16) == N16_RA5 (insn16)) - insn = N32_JREG (JR, 0, 0, 0, 3); + insn = N32_JREG (JR, 0, 0, 0, 3); else - insn = N32_TYPE2 (ADDI, N16_RT5 (insn16), N16_RA5 (insn16), 0); + insn = N32_TYPE2 (ADDI, N16_RT5 (insn16), N16_RA5 (insn16), 0); goto done; - case 0x1: /* movi55 */ + case 0x1: /* movi55 */ insn = N32_TYPE1 (MOVI, N16_RT5 (insn16), N16_IMM5S (insn16)); goto done; - case 0x1b: /* addi10s (V2) */ + case 0x1b: /* addi10s (V2) */ insn = N32_TYPE2 (ADDI, REG_SP, REG_SP, N16_IMM10S (insn16)); goto done; } switch (__GF (insn16, 11, 4)) { - case 0x7: /* lwi37.fp/swi37.fp */ - if (insn16 & N32_BIT (7)) /* swi37.fp */ + case 0x7: /* lwi37.fp/swi37.fp */ + if (insn16 & N32_BIT (7)) /* swi37.fp */ insn = N32_TYPE2 (SWI, N16_RT38 (insn16), REG_FP, N16_IMM7U (insn16)); - else /* lwi37.fp */ + else /* lwi37.fp */ insn = N32_TYPE2 (LWI, N16_RT38 (insn16), REG_FP, N16_IMM7U (insn16)); goto done; - case 0x8: /* beqz38 */ + case 0x8: /* beqz38 */ insn = N32_BR2 (BEQZ, N16_RT38 (insn16), N16_IMM8S (insn16)); goto done; - case 0x9: /* bnez38 */ + case 0x9: /* bnez38 */ insn = N32_BR2 (BNEZ, N16_RT38 (insn16), N16_IMM8S (insn16)); goto done; - case 0xa: /* beqs38/j8, implied r5 */ + case 0xa: /* beqs38/j8, implied r5 */ if (N16_RT38 (insn16) == 5) insn = N32_JI (J, N16_IMM8S (insn16)); else insn = N32_BR1 (BEQ, N16_RT38 (insn16), REG_R5, N16_IMM8S (insn16)); goto done; - case 0xb: /* bnes38 and others */ + case 0xb: /* bnes38 and others */ if (N16_RT38 (insn16) == 5) { switch (__GF (insn16, 5, 3)) { - case 0: /* jr5 */ + case 0: /* jr5 */ insn = N32_JREG (JR, 0, N16_RA5 (insn16), 0, 0); break; - case 4: /* ret5 */ + case 4: /* ret5 */ insn = N32_JREG (JR, 0, N16_RA5 (insn16), 0, 1); break; - case 1: /* jral5 */ + case 1: /* jral5 */ insn = N32_JREG (JRAL, REG_LP, N16_RA5 (insn16), 0, 0); break; - case 2: /* ex9.it imm5 */ + case 2: /* ex9.it imm5 */ /* ex9.it had no 32-bit variantl. */ break; - case 5: /* add5.pc */ + case 5: /* add5.pc */ /* add5.pc had no 32-bit variantl. */ break; } } - else /* bnes38 */ + else /* bnes38 */ insn = N32_BR1 (BNE, N16_RT38 (insn16), REG_R5, N16_IMM8S (insn16)); goto done; - case 0xe: /* lwi37/swi37 */ - if (insn16 & (1 << 7)) /* swi37.sp */ + case 0xe: /* lwi37/swi37 */ + if (insn16 & (1 << 7)) /* swi37.sp */ insn = N32_TYPE2 (SWI, N16_RT38 (insn16), REG_SP, N16_IMM7U (insn16)); - else /* lwi37.sp */ + else /* lwi37.sp */ insn = N32_TYPE2 (LWI, N16_RT38 (insn16), REG_SP, N16_IMM7U (insn16)); goto done; } @@ -7650,19 +9132,19 @@ turn_insn_to_sda_access (uint32_t insn, bfd_signed_vma type, uint32_t *pinsn) switch (N32_OP6 (insn)) { case N32_OP6_LBI: - /* lbi.gp */ + /* lbi.gp */ oinsn = N32_TYPE1 (LBGP, N32_RT5 (insn), 0); break; case N32_OP6_LBSI: - /* lbsi.gp */ + /* lbsi.gp */ oinsn = N32_TYPE1 (LBGP, N32_RT5 (insn), N32_BIT (19)); break; case N32_OP6_SBI: - /* sbi.gp */ + /* sbi.gp */ oinsn = N32_TYPE1 (SBGP, N32_RT5 (insn), 0); break; case N32_OP6_ORI: - /* addi.gp */ + /* addi.gp */ oinsn = N32_TYPE1 (SBGP, N32_RT5 (insn), N32_BIT (19)); break; } @@ -7672,15 +9154,15 @@ turn_insn_to_sda_access (uint32_t insn, bfd_signed_vma type, uint32_t *pinsn) switch (N32_OP6 (insn)) { case N32_OP6_LHI: - /* lhi.gp */ + /* lhi.gp */ oinsn = N32_TYPE1 (HWGP, N32_RT5 (insn), 0); break; case N32_OP6_LHSI: - /* lhsi.gp */ + /* lhsi.gp */ oinsn = N32_TYPE1 (HWGP, N32_RT5 (insn), N32_BIT (18)); break; case N32_OP6_SHI: - /* shi.gp */ + /* shi.gp */ oinsn = N32_TYPE1 (HWGP, N32_RT5 (insn), N32_BIT (19)); break; } @@ -7690,11 +9172,11 @@ turn_insn_to_sda_access (uint32_t insn, bfd_signed_vma type, uint32_t *pinsn) switch (N32_OP6 (insn)) { case N32_OP6_LWI: - /* lwi.gp */ + /* lwi.gp */ oinsn = N32_TYPE1 (HWGP, N32_RT5 (insn), __MF (6, 17, 3)); break; case N32_OP6_SWI: - /* swi.gp */ + /* swi.gp */ oinsn = N32_TYPE1 (HWGP, N32_RT5 (insn), __MF (7, 17, 3)); break; } @@ -7835,7 +9317,7 @@ calculate_got_memory_address (bfd *abfd, struct bfd_link_info *link_info, bfd_vma *local_got_offsets; /* Get the value of the symbol referred to by the reloc. */ struct elf_link_hash_entry *h; - struct elf_nds32_link_hash_table *htab = nds32_elf_hash_table (link_info); + struct elf_link_hash_table *ehtab = elf_hash_table (link_info); /* An external symbol. */ symndx = ELF32_R_SYM (irel->r_info) - symtab_hdr->sh_info; @@ -7847,18 +9329,13 @@ calculate_got_memory_address (bfd *abfd, struct bfd_link_info *link_info, if (symndx >= 0) { BFD_ASSERT (h != NULL); - return (htab->root.sgot->output_section->vma - + htab->root.sgot->output_offset - + h->got.offset); - } - else - { - local_got_offsets = elf_local_got_offsets (abfd); - BFD_ASSERT (local_got_offsets != NULL); - return (htab->root.sgot->output_section->vma - + htab->root.sgot->output_offset - + local_got_offsets[ELF32_R_SYM (irel->r_info)]); + return ehtab->sgot->output_section->vma + ehtab->sgot->output_offset + + h->got.offset; } + local_got_offsets = elf_local_got_offsets (abfd); + BFD_ASSERT (local_got_offsets != NULL); + return ehtab->sgot->output_section->vma + ehtab->sgot->output_offset + + local_got_offsets[ELF32_R_SYM (irel->r_info)]; /* The _GLOBAL_OFFSET_TABLE_ may be undefweak(or should be?). */ /* The check of h->root.type is passed. */ @@ -7899,7 +9376,6 @@ is_convert_32_to_16 (bfd *abfd, asection *sec, bfd_vma mem_addr; uint32_t insn = 0; Elf_Internal_Rela *pc_rel; - int pic_ext_target = 0; Elf_Internal_Shdr *symtab_hdr; Elf_Internal_Sym *isymbuf = NULL; int convert_type; @@ -7938,8 +9414,7 @@ is_convert_32_to_16 (bfd *abfd, asection *sec, || ELF32_R_TYPE (pc_rel->r_info) == R_NDS32_25_PCREL_RELA || ELF32_R_TYPE (pc_rel->r_info) == R_NDS32_25_PLTREL) { - off = calculate_offset (abfd, sec, pc_rel, isymbuf, symtab_hdr, - &pic_ext_target); + off = calculate_offset (abfd, sec, pc_rel, isymbuf, symtab_hdr); if (off >= ACCURATE_8BIT_S1 || off < -ACCURATE_8BIT_S1 || off == 0) return FALSE; @@ -7948,10 +9423,8 @@ is_convert_32_to_16 (bfd *abfd, asection *sec, else if (ELF32_R_TYPE (pc_rel->r_info) == R_NDS32_20_RELA) { /* movi => movi55 */ - mem_addr = calculate_memory_address (abfd, pc_rel, isymbuf, - symtab_hdr); - /* mem_addr is unsigned, but the value should - be between [-16, 15]. */ + mem_addr = calculate_memory_address (abfd, pc_rel, isymbuf, symtab_hdr); + /* mem_addr is unsigned, but the value should be between [-16, 15]. */ if ((mem_addr + 0x10) >> 5) return FALSE; break; @@ -7980,14 +9453,12 @@ is_convert_32_to_16 (bfd *abfd, asection *sec, || ((ELF32_R_TYPE (pc_rel->r_info) > R_NDS32_LOADSTORE) && (ELF32_R_TYPE (pc_rel->r_info) < R_NDS32_DWARF2_OP1_RELA))) { - /* Prevent unresolved addi instruction translate - to addi45 or addi333. */ + /* Prevent unresolved addi instruction translate to addi45 or addi333. */ return FALSE; } else if ((ELF32_R_TYPE (pc_rel->r_info) == R_NDS32_17IFC_PCREL_RELA)) { - off = calculate_offset (abfd, sec, pc_rel, isymbuf, symtab_hdr, - &pic_ext_target); + off = calculate_offset (abfd, sec, pc_rel, isymbuf, symtab_hdr); if (off >= ACCURATE_U9BIT_S1 || off <= 0) return FALSE; break; @@ -8085,7 +9556,7 @@ static Elf_Internal_Rela * find_relocs_at_address_addr (Elf_Internal_Rela *reloc, Elf_Internal_Rela *relocs, Elf_Internal_Rela *irelend, - enum elf_nds32_reloc_type reloc_type, + unsigned char reloc_type, bfd_vma offset_p) { Elf_Internal_Rela *rel_t = NULL; @@ -8281,8 +9752,9 @@ insert_nds32_elf_blank (nds32_elf_blank_t **blank_p, bfd_vma addr, bfd_vma len) if (addr < blank_t->offset + blank_t->size) { - if (addr > blank_t->offset + blank_t->size) - blank_t->size = addr - blank_t->offset; + /* Extend the origin blank. */ + if (addr + len > blank_t->offset + blank_t->size) + blank_t->size = addr + len - blank_t->offset; } else { @@ -8414,7 +9886,7 @@ nds32_elf_relax_delete_blanks (bfd *abfd, asection *sec, /* Relocations MUST be kept in memory, because relaxation adjust them. */ internal_relocs = _bfd_elf_link_read_relocs (abfd, sect, NULL, NULL, - TRUE /* keep_memory */); + TRUE /* keep_memory */); irelend = internal_relocs + sect->reloc_count; blank_t = blank_head; @@ -8436,7 +9908,7 @@ nds32_elf_relax_delete_blanks (bfd *abfd, asection *sec, unsigned long val = 0; unsigned long mask; long before, between; - long offset = 0; + long offset; switch (ELF32_R_TYPE (irel->r_info)) { @@ -8468,28 +9940,23 @@ nds32_elf_relax_delete_blanks (bfd *abfd, asection *sec, -- before ---| ***************** --------------------- between ---| - We only care how much data are relax between DIFF, - marked as ***. */ + We only care how much data are relax between DIFF, marked as ***. */ before = get_nds32_elf_blank_total (&blank_t, irel->r_addend, 0); - between = get_nds32_elf_blank_total (&blank_t, - irel->r_addend + offset, 0); + between = get_nds32_elf_blank_total (&blank_t, irel->r_addend + offset, 0); if (between == before) goto done_adjust_diff; switch (ELF32_R_TYPE (irel->r_info)) { case R_NDS32_DIFF8: - bfd_put_8 (abfd, offset - (between - before), - contents + irel->r_offset); + bfd_put_8 (abfd, offset - (between - before), contents + irel->r_offset); break; case R_NDS32_DIFF16: - bfd_put_16 (abfd, offset - (between - before), - contents + irel->r_offset); + bfd_put_16 (abfd, offset - (between - before), contents + irel->r_offset); break; case R_NDS32_DIFF32: - bfd_put_32 (abfd, offset - (between - before), - contents + irel->r_offset); + bfd_put_32 (abfd, offset - (between - before), contents + irel->r_offset); break; } } @@ -8501,12 +9968,10 @@ nds32_elf_relax_delete_blanks (bfd *abfd, asection *sec, unsigned long before, between; bfd_byte *endp, *p; - val = _bfd_read_unsigned_leb128 (abfd, contents + irel->r_offset, - &len); + val = _bfd_read_unsigned_leb128 (abfd, contents + irel->r_offset, &len); before = get_nds32_elf_blank_total (&blank_t, irel->r_addend, 0); - between = get_nds32_elf_blank_total (&blank_t, - irel->r_addend + val, 0); + between = get_nds32_elf_blank_total (&blank_t, irel->r_addend + val, 0); if (between == before) goto done_adjust_diff; @@ -8523,16 +9988,14 @@ done_adjust_diff: if (sec == sect) { raddr = irel->r_offset; - irel->r_offset -= get_nds32_elf_blank_total (&blank_t2, - irel->r_offset, 1); + irel->r_offset -= get_nds32_elf_blank_total (&blank_t2, irel->r_offset, 1); if (ELF32_R_TYPE (irel->r_info) == R_NDS32_NONE) continue; if (blank_t2 && blank_t2->next - && (blank_t2->offset > raddr - || blank_t2->next->offset <= raddr)) - _bfd_error_handler - (_("%B: Error: search_nds32_elf_blank reports wrong node\n"), abfd); + && (blank_t2->offset > raddr || blank_t2->next->offset <= raddr)) + _bfd_error_handler (_("%pB: %s\n"), abfd, + "Error: search_nds32_elf_blank reports wrong node"); /* Mark reloc in deleted portion as NONE. For some relocs like R_NDS32_LABEL that doesn't modify the @@ -8584,11 +10047,9 @@ done_adjust_diff: isym->st_value -= ahead; /* Adjust function size. */ - if (ELF32_ST_TYPE (isym->st_info) == STT_FUNC - && isym->st_size > 0) - isym->st_size -= - get_nds32_elf_blank_total - (&blank_t, orig_addr + isym->st_size, 0) - ahead; + if (ELF32_ST_TYPE (isym->st_info) == STT_FUNC && isym->st_size > 0) + isym->st_size -= get_nds32_elf_blank_total + (&blank_t, orig_addr + isym->st_size, 0) - ahead; } } } @@ -8617,9 +10078,8 @@ done_adjust_diff: /* Adjust function size. */ if (sym_hash->type == STT_FUNC) - sym_hash->size -= - get_nds32_elf_blank_total - (&blank_t, orig_addr + sym_hash->size, 0) - ahead; + sym_hash->size -= get_nds32_elf_blank_total + (&blank_t, orig_addr + sym_hash->size, 0) - ahead; } } @@ -8743,7 +10203,7 @@ relax_range_measurement (bfd *abfd) bfd_vma align; static int decide_relax_range = 0; int i; - int range_number = sizeof (sdata_init_range) / sizeof (sdata_init_range[0]); + int range_number = ARRAY_SIZE (sdata_init_range); if (decide_relax_range) return; @@ -8789,11 +10249,7 @@ relax_range_measurement (bfd *abfd) #define IS_OPTIMIZE(addend) ((addend) & 0x40000000) #define IS_16BIT_ON(addend) ((addend) & 0x20000000) -static const char * unrecognized_reloc_msg = - /* xgettext:c-format */ - N_("%B: warning: %s points to unrecognized reloc at %#Lx"); - -/* Relax LONGCALL1 relocation for nds32_elf_relax_section. */ +/* Relax LONGCALL1 relocation for nds32_elf_relax_section.*/ static bfd_boolean nds32_elf_relax_longcall1 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, @@ -8803,19 +10259,19 @@ nds32_elf_relax_longcall1 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, { /* There are 3 variations for LONGCALL1 case 4-4-2; 16-bit on, optimize off or optimize for space - sethi ta, hi20(symbol) ; LONGCALL1/HI20 + sethi ta, hi20(symbol) ; LONGCALL1/HI20 ori ta, ta, lo12(symbol) ; LO12S0 - jral5 ta ; + jral5 ta ; case 4-4-4; 16-bit off, optimize don't care - sethi ta, hi20(symbol) ; LONGCALL1/HI20 + sethi ta, hi20(symbol) ; LONGCALL1/HI20 ori ta, ta, lo12(symbol) ; LO12S0 - jral ta ; + jral ta ; case 4-4-4; 16-bit on, optimize for speed - sethi ta, hi20(symbol) ; LONGCALL1/HI20 + sethi ta, hi20(symbol) ; LONGCALL1/HI20 ori ta, ta, lo12(symbol) ; LO12S0 - jral ta ; + jral ta ; Check code for -mlong-calls output. */ /* Get the reloc for the address from which the register is @@ -8826,7 +10282,6 @@ nds32_elf_relax_longcall1 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, int seq_len; /* Original length of instruction sequence. */ uint32_t insn; Elf_Internal_Rela *hi_irelfn, *lo_irelfn, *irelend; - int pic_ext_target = 0; bfd_signed_vma foff; uint16_t insn16; @@ -8843,21 +10298,21 @@ nds32_elf_relax_longcall1 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, if (hi_irelfn == irelend || lo_irelfn == irelend) { - _bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LONGCALL1", - irel->r_offset); + _bfd_error_handler + ("%pB: warning: R_NDS32_LONGCALL1 points to unrecognized " + "reloc at 0x%lx.", abfd, (long) irel->r_offset); return FALSE; } /* Get the value of the symbol referred to by the reloc. */ - foff = calculate_offset (abfd, sec, hi_irelfn, isymbuf, symtab_hdr, - &pic_ext_target); + foff = calculate_offset (abfd, sec, hi_irelfn, isymbuf, symtab_hdr); /* This condition only happened when symbol is undefined. */ - if (pic_ext_target || foff == 0 || foff < -CONSERVATIVE_24BIT_S1 + if (foff == 0 || foff < -CONSERVATIVE_24BIT_S1 || foff >= CONSERVATIVE_24BIT_S1) return FALSE; - /* Relax to: jal symbol; 25_PCREL */ + /* Relax to: jal symbol; 25_PCREL */ /* For simplicity of coding, we are going to modify the section contents, the section relocs, and the BFD symbol table. We must tell the rest of the code not to free up this @@ -8894,7 +10349,7 @@ nds32_elf_relax_longcall1 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, } #define CONVERT_CONDITION_CALL(insn) (((insn) & 0xffff0000) ^ 0x90000) -/* Relax LONGCALL2 relocation for nds32_elf_relax_section. */ +/* Relax LONGCALL2 relocation for nds32_elf_relax_section.*/ static bfd_boolean nds32_elf_relax_longcall2 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, @@ -8904,7 +10359,7 @@ nds32_elf_relax_longcall2 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, { /* bltz rt, .L1 ; LONGCALL2 jal symbol ; 25_PCREL - .L1: */ + .L1: */ /* Get the reloc for the address from which the register is being loaded. This reloc will tell us which function is @@ -8913,7 +10368,6 @@ nds32_elf_relax_longcall2 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, bfd_vma laddr; uint32_t insn; Elf_Internal_Rela *i1_irelfn, *cond_irelfn, *irelend; - int pic_ext_target = 0; bfd_signed_vma foff; irelend = internal_relocs + sec->reloc_count; @@ -8924,23 +10378,23 @@ nds32_elf_relax_longcall2 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, if (i1_irelfn == irelend) { - _bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LONGCALL2", - irel->r_offset); + _bfd_error_handler + ("%pB: warning: R_NDS32_LONGCALL2 points to unrecognized " + "reloc at 0x%lx.", abfd, (long) irel->r_offset); return FALSE; } insn = bfd_getb32 (contents + laddr); /* Get the value of the symbol referred to by the reloc. */ - foff = calculate_offset (abfd, sec, i1_irelfn, isymbuf, symtab_hdr, - &pic_ext_target); + foff = calculate_offset (abfd, sec, i1_irelfn, isymbuf, symtab_hdr); if (foff == 0 || foff < -CONSERVATIVE_16BIT_S1 || foff >= CONSERVATIVE_16BIT_S1) return FALSE; /* Relax to bgezal rt, label ; 17_PCREL - or bltzal rt, label ; 17_PCREL */ + or bltzal rt, label ; 17_PCREL */ /* Convert to complimentary conditional call. */ insn = CONVERT_CONDITION_CALL (insn); @@ -8974,7 +10428,7 @@ nds32_elf_relax_longcall2 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, return TRUE; } -/* Relax LONGCALL3 relocation for nds32_elf_relax_section. */ +/* Relax LONGCALL3 relocation for nds32_elf_relax_section.*/ static bfd_boolean nds32_elf_relax_longcall3 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, @@ -8984,25 +10438,25 @@ nds32_elf_relax_longcall3 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, { /* There are 3 variations for LONGCALL3 case 4-4-4-2; 16-bit on, optimize off or optimize for space - bltz rt, $1 ; LONGCALL3 - sethi ta, hi20(symbol) ; HI20 + bltz rt, $1 ; LONGCALL3 + sethi ta, hi20(symbol) ; HI20 ori ta, ta, lo12(symbol) ; LO12S0 - jral5 ta ; + jral5 ta ; $1 case 4-4-4-4; 16-bit off, optimize don't care - bltz rt, $1 ; LONGCALL3 - sethi ta, hi20(symbol) ; HI20 + bltz rt, $1 ; LONGCALL3 + sethi ta, hi20(symbol) ; HI20 ori ta, ta, lo12(symbol) ; LO12S0 - jral ta ; + jral ta ; $1 case 4-4-4-4; 16-bit on, optimize for speed - bltz rt, $1 ; LONGCALL3 - sethi ta, hi20(symbol) ; HI20 + bltz rt, $1 ; LONGCALL3 + sethi ta, hi20(symbol) ; HI20 ori ta, ta, lo12(symbol) ; LO12S0 - jral ta ; - $1 */ + jral ta ; + $1 */ /* Get the reloc for the address from which the register is being loaded. This reloc will tell us which function is @@ -9012,7 +10466,6 @@ nds32_elf_relax_longcall3 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, int seq_len; /* Original length of instruction sequence. */ uint32_t insn; Elf_Internal_Rela *hi_irelfn, *lo_irelfn, *cond_irelfn, *irelend; - int pic_ext_target = 0; bfd_signed_vma foff; uint16_t insn16; @@ -9030,16 +10483,16 @@ nds32_elf_relax_longcall3 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, if (hi_irelfn == irelend || lo_irelfn == irelend) { - _bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LONGCALL3", - irel->r_offset); + _bfd_error_handler + ("%pB: warning: R_NDS32_LONGCALL3 points to unrecognized " + "reloc at 0x%lx.", abfd, (long) irel->r_offset); return FALSE; } /* Get the value of the symbol referred to by the reloc. */ - foff = calculate_offset (abfd, sec, hi_irelfn, isymbuf, symtab_hdr, - &pic_ext_target); + foff = calculate_offset (abfd, sec, hi_irelfn, isymbuf, symtab_hdr); - if (pic_ext_target || foff == 0 || foff < -CONSERVATIVE_24BIT_S1 + if (foff == 0 || foff < -CONSERVATIVE_24BIT_S1 || foff >= CONSERVATIVE_24BIT_S1) return FALSE; @@ -9047,7 +10500,7 @@ nds32_elf_relax_longcall3 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, if (foff >= -CONSERVATIVE_16BIT_S1 && foff < CONSERVATIVE_16BIT_S1) { /* Relax to bgezal rt, label ; 17_PCREL - or bltzal rt, label ; 17_PCREL */ + or bltzal rt, label ; 17_PCREL */ /* Convert to complimentary conditional call. */ insn = CONVERT_CONDITION_CALL (insn); @@ -9112,7 +10565,7 @@ nds32_elf_relax_longcall3 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, return TRUE; } -/* Relax LONGJUMP1 relocation for nds32_elf_relax_section. */ +/* Relax LONGJUMP1 relocation for nds32_elf_relax_section.*/ static bfd_boolean nds32_elf_relax_longjump1 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, @@ -9122,19 +10575,19 @@ nds32_elf_relax_longjump1 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, { /* There are 3 variations for LONGJUMP1 case 4-4-2; 16-bit bit on, optimize off or optimize for space - sethi ta, hi20(symbol) ; LONGJUMP1/HI20 - ori ta, ta, lo12(symbol) ; LO12S0 - jr5 ta ; + sethi ta, hi20(symbol) ; LONGJUMP1/HI20 + ori ta, ta, lo12(symbol) ; LO12S0 + jr5 ta ; case 4-4-4; 16-bit off, optimize don't care - sethi ta, hi20(symbol) ; LONGJUMP1/HI20 - ori ta, ta, lo12(symbol) ; LO12S0 - jr ta ; + sethi ta, hi20(symbol) ; LONGJUMP1/HI20 + ori ta, ta, lo12(symbol) ; LO12S0 + jr ta ; case 4-4-4; 16-bit on, optimize for speed - sethi ta, hi20(symbol) ; LONGJUMP1/HI20 - ori ta, ta, lo12(symbol) ; LO12S0 - jr ta ; */ + sethi ta, hi20(symbol) ; LONGJUMP1/HI20 + ori ta, ta, lo12(symbol) ; LO12S0 + jr ta ; */ /* Get the reloc for the address from which the register is being loaded. This reloc will tell us which function is @@ -9145,7 +10598,6 @@ nds32_elf_relax_longjump1 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, int insn16_on; /* 16-bit on/off. */ uint32_t insn; Elf_Internal_Rela *hi_irelfn, *lo_irelfn, *irelend; - int pic_ext_target = 0; bfd_signed_vma foff; uint16_t insn16; unsigned long reloc; @@ -9164,23 +10616,23 @@ nds32_elf_relax_longjump1 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, R_NDS32_LO12S0_ORI_RELA, laddr + 4); if (hi_irelfn == irelend || lo_irelfn == irelend) { - _bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LONGJUMP1", - irel->r_offset); + _bfd_error_handler + ("%pB: warning: R_NDS32_LONGJUMP1 points to unrecognized " + "reloc at 0x%lx.", abfd, (long) irel->r_offset); return FALSE; } /* Get the value of the symbol referred to by the reloc. */ - foff = calculate_offset (abfd, sec, hi_irelfn, isymbuf, symtab_hdr, - &pic_ext_target); + foff = calculate_offset (abfd, sec, hi_irelfn, isymbuf, symtab_hdr); - if (pic_ext_target || foff == 0 || foff >= CONSERVATIVE_24BIT_S1 + if (foff == 0 || foff >= CONSERVATIVE_24BIT_S1 || foff < -CONSERVATIVE_24BIT_S1) return FALSE; if (insn16_on && foff >= -ACCURATE_8BIT_S1 && foff < ACCURATE_8BIT_S1 && (seq_len & 0x2)) { - /* j8 label */ + /* j8 label */ /* 16-bit on, but not optimized for speed. */ reloc = R_NDS32_9_PCREL_RELA; insn16 = INSN_J8; @@ -9191,7 +10643,7 @@ nds32_elf_relax_longjump1 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, } else { - /* j label */ + /* j label */ reloc = R_NDS32_25_PCREL_RELA; insn = INSN_J; bfd_putb32 (insn, contents + irel->r_offset); @@ -9275,14 +10727,14 @@ nds32_elf_convert_branch (uint16_t insn16, uint32_t insn, switch ((insn16 & 0xf000) >> 12) { case 0xc: - /* beqz38 or bnez38 */ + /* beqz38 or bnez38 */ comp_insn16 = (insn16 ^ 0x0800) & 0xff00; comp_insn = (comp_insn16 & 0x0800) ? INSN_BNEZ : INSN_BEQZ; comp_insn |= ((comp_insn16 & 0x0700) >> 8) << 20; break; case 0xd: - /* beqs38 or bnes38 */ + /* beqs38 or bnes38 */ comp_insn16 = (insn16 ^ 0x0800) & 0xff00; comp_insn = (comp_insn16 & 0x0800) ? INSN_BNE : INSN_BEQ; comp_insn |= (((comp_insn16 & 0x0700) >> 8) << 20) @@ -9290,7 +10742,7 @@ nds32_elf_convert_branch (uint16_t insn16, uint32_t insn, break; case 0xe: - /* beqzS8 or bnezS8 */ + /* beqzS8 or bnezS8 */ comp_insn16 = (insn16 ^ 0x0100) & 0xff00; comp_insn = (comp_insn16 & 0x0100) ? INSN_BNEZ : INSN_BEQZ; comp_insn |= REG_R15 << 20; @@ -9306,7 +10758,7 @@ nds32_elf_convert_branch (uint16_t insn16, uint32_t insn, *re_insn16 = comp_insn16; } -/* Relax LONGJUMP2 relocation for nds32_elf_relax_section. */ +/* Relax LONGJUMP2 relocation for nds32_elf_relax_section.*/ static bfd_boolean nds32_elf_relax_longjump2 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, @@ -9329,7 +10781,7 @@ nds32_elf_relax_longjump2 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, case 4-4; 1st insn convertible, 16-bit on, optimize for speed bne rt, ra, $1 ; LONGJUMP2 j label ; 25_PCREL - $1: */ + $1: */ /* Get the reloc for the address from which the register is being loaded. This reloc will tell us which function is @@ -9338,7 +10790,7 @@ nds32_elf_relax_longjump2 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, bfd_vma laddr; int seq_len; /* Original length of instruction sequence. */ Elf_Internal_Rela *i2_irelfn, *cond_irelfn, *irelend; - int pic_ext_target = 0, first_size; + int first_size; unsigned int i; bfd_signed_vma foff; uint32_t insn, re_insn = 0; @@ -9359,7 +10811,7 @@ nds32_elf_relax_longjump2 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, irelend, R_NDS32_25_PCREL_RELA, laddr + first_size); - for (i = 0; i < sizeof (checked_types) / sizeof(checked_types[0]); i++) + for (i = 0; i < ARRAY_SIZE (checked_types); i++) { cond_irelfn = find_relocs_at_address_addr (irel, internal_relocs, irelend, @@ -9370,16 +10822,16 @@ nds32_elf_relax_longjump2 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, if (i2_irelfn == irelend || cond_irelfn == irelend) { - _bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LONGJUMP2", - irel->r_offset); + _bfd_error_handler + ("%pB: warning: R_NDS32_LONGJUMP2 points to unrecognized " + "reloc at 0x%lx.", abfd, (long) irel->r_offset); return FALSE; } /* Get the value of the symbol referred to by the reloc. */ foff = - calculate_offset (abfd, sec, i2_irelfn, isymbuf, symtab_hdr, - &pic_ext_target); - if (pic_ext_target || foff == 0 || foff < -CONSERVATIVE_16BIT_S1 + calculate_offset (abfd, sec, i2_irelfn, isymbuf, symtab_hdr); + if (foff == 0 || foff < -CONSERVATIVE_16BIT_S1 || foff >= CONSERVATIVE_16BIT_S1) return FALSE; @@ -9422,7 +10874,7 @@ nds32_elf_relax_longjump2 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, && (foff >= -(ACCURATE_14BIT_S1 - first_size) && foff < ACCURATE_14BIT_S1 - first_size)) { - /* beqs label ; 15_PCREL */ + /* beqs label ; 15_PCREL */ bfd_putb32 (re_insn, contents + irel->r_offset); *insn_len = 4; reloc = R_NDS32_15_PCREL_RELA; @@ -9432,7 +10884,7 @@ nds32_elf_relax_longjump2 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, && foff >= -CONSERVATIVE_16BIT_S1 && foff < CONSERVATIVE_16BIT_S1) { - /* beqz label ; 17_PCREL */ + /* beqz label ; 17_PCREL */ bfd_putb32 (re_insn, contents + irel->r_offset); *insn_len = 4; reloc = R_NDS32_17_PCREL_RELA; @@ -9465,7 +10917,7 @@ nds32_elf_relax_longjump2 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, return TRUE; } -/* Relax LONGJUMP3 relocation for nds32_elf_relax_section. */ +/* Relax LONGJUMP3 relocation for nds32_elf_relax_section.*/ static bfd_boolean nds32_elf_relax_longjump3 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, @@ -9476,42 +10928,42 @@ nds32_elf_relax_longjump3 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, /* There are 5 variations for LONGJUMP3 case 1: 2-4-4-2; 1st insn convertible, 16-bit on, optimize off or optimize for space - bnes38 rt, ra, $1 ; LONGJUMP3 - sethi ta, hi20(symbol) ; HI20 + bnes38 rt, ra, $1 ; LONGJUMP3 + sethi ta, hi20(symbol) ; HI20 ori ta, ta, lo12(symbol) ; LO12S0 - jr5 ta ; - $1: ; + jr5 ta ; + $1: ; case 2: 2-4-4-2; 1st insn convertible, 16-bit on, optimize for speed - bnes38 rt, ra, $1 ; LONGJUMP3 - sethi ta, hi20(symbol) ; HI20 + bnes38 rt, ra, $1 ; LONGJUMP3 + sethi ta, hi20(symbol) ; HI20 ori ta, ta, lo12(symbol) ; LO12S0 - jr5 ta ; - $1: ; LABEL + jr5 ta ; + $1: ; LABEL case 3: 4-4-4-2; 1st insn not convertible, 16-bit on, optimize off or optimize for space - bne rt, ra, $1 ; LONGJUMP3 - sethi ta, hi20(symbol) ; HI20 + bne rt, ra, $1 ; LONGJUMP3 + sethi ta, hi20(symbol) ; HI20 ori ta, ta, lo12(symbol) ; LO12S0 - jr5 ta ; - $1: ; + jr5 ta ; + $1: ; case 4: 4-4-4-4; 1st insn don't care, 16-bit off, optimize don't care 16-bit off if no INSN16 - bne rt, ra, $1 ; LONGJUMP3 - sethi ta, hi20(symbol) ; HI20 + bne rt, ra, $1 ; LONGJUMP3 + sethi ta, hi20(symbol) ; HI20 ori ta, ta, lo12(symbol) ; LO12S0 - jr ta ; - $1: ; + jr ta ; + $1: ; case 5: 4-4-4-4; 1st insn not convertible, 16-bit on, optimize for speed 16-bit off if no INSN16 - bne rt, ra, $1 ; LONGJUMP3 - sethi ta, hi20(symbol) ; HI20 + bne rt, ra, $1 ; LONGJUMP3 + sethi ta, hi20(symbol) ; HI20 ori ta, ta, lo12(symbol) ; LO12S0 - jr ta ; - $1: ; LABEL */ + jr ta ; + $1: ; LABEL */ /* Get the reloc for the address from which the register is being loaded. This reloc will tell us which function is @@ -9523,7 +10975,7 @@ nds32_elf_relax_longjump3 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, bfd_vma laddr; int seq_len; /* Original length of instruction sequence. */ Elf_Internal_Rela *hi_irelfn, *lo_irelfn, *cond_irelfn, *irelend; - int pic_ext_target = 0, first_size; + int first_size; unsigned int i; bfd_signed_vma foff; uint32_t insn, re_insn = 0; @@ -9551,7 +11003,7 @@ nds32_elf_relax_longjump3 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, R_NDS32_LO12S0_ORI_RELA, laddr + first_size + 4); - for (i = 0; i < sizeof (checked_types) / sizeof (checked_types[0]); i++) + for (i = 0; i < ARRAY_SIZE (checked_types); i++) { cond_irelfn = find_relocs_at_address_addr (irel, internal_relocs, irelend, @@ -9562,16 +11014,16 @@ nds32_elf_relax_longjump3 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, if (hi_irelfn == irelend || lo_irelfn == irelend || cond_irelfn == irelend) { - _bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LONGJUMP3", - irel->r_offset); + _bfd_error_handler + ("%pB: warning: R_NDS32_LONGJUMP3 points to unrecognized " + "reloc at 0x%lx.", abfd, (long) irel->r_offset); return FALSE; } /* Get the value of the symbol referred to by the reloc. */ - foff = calculate_offset (abfd, sec, hi_irelfn, isymbuf, symtab_hdr, - &pic_ext_target); + foff = calculate_offset (abfd, sec, hi_irelfn, isymbuf, symtab_hdr); - if (pic_ext_target || foff == 0 || foff < -CONSERVATIVE_24BIT_S1 + if (foff == 0 || foff < -CONSERVATIVE_24BIT_S1 || foff >= CONSERVATIVE_24BIT_S1) return FALSE; @@ -9624,7 +11076,7 @@ nds32_elf_relax_longjump3 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, && (foff >= -(ACCURATE_14BIT_S1 - first_size) && foff < ACCURATE_14BIT_S1 - first_size)) { - /* beqs label ; 15_PCREL */ + /* beqs label ; 15_PCREL */ bfd_putb32 (re_insn, contents + irel->r_offset); *insn_len = 4; reloc = R_NDS32_15_PCREL_RELA; @@ -9635,7 +11087,7 @@ nds32_elf_relax_longjump3 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, && foff >= -CONSERVATIVE_16BIT_S1 && foff < CONSERVATIVE_16BIT_S1) { - /* beqz label ; 17_PCREL */ + /* beqz label ; 17_PCREL */ bfd_putb32 (re_insn, contents + irel->r_offset); *insn_len = 4; reloc = R_NDS32_17_PCREL_RELA; @@ -9661,7 +11113,7 @@ nds32_elf_relax_longjump3 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, case 4-4; 1st insn convertible, 16-bit on, optimize for speed bne rt, ra, $1 ; LONGJUMP2 j label ; 25_PCREL - $1 */ + $1 */ /* Offset for first instruction. */ @@ -9711,7 +11163,7 @@ nds32_elf_relax_longjump3 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, return TRUE; } -/* Relax LONGCALL4 relocation for nds32_elf_relax_section. */ +/* Relax LONGCALL4 relocation for nds32_elf_relax_section.*/ static bfd_boolean nds32_elf_relax_longcall4 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, @@ -9728,7 +11180,6 @@ nds32_elf_relax_longcall4 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, uint32_t insn; Elf_Internal_Rela *hi_irel, *ptr_irel, *insn_irel, *em_irel, *call_irel; Elf_Internal_Rela *irelend; - int pic_ext_target = 0; bfd_signed_vma foff; irelend = internal_relocs + sec->reloc_count; @@ -9742,21 +11193,21 @@ nds32_elf_relax_longcall4 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, if (hi_irel == irelend) { - _bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LONGCALL4", - irel->r_offset); + _bfd_error_handler + ("%pB: warning: R_NDS32_LONGCALL4 points to unrecognized " + "reloc at 0x%lx.", abfd, (long) irel->r_offset); return FALSE; } /* Get the value of the symbol referred to by the reloc. */ - foff = calculate_offset (abfd, sec, hi_irel, isymbuf, symtab_hdr, - &pic_ext_target); + foff = calculate_offset (abfd, sec, hi_irel, isymbuf, symtab_hdr); /* This condition only happened when symbol is undefined. */ - if (pic_ext_target || foff == 0 || foff < -CONSERVATIVE_24BIT_S1 + if (foff == 0 || foff < -CONSERVATIVE_24BIT_S1 || foff >= CONSERVATIVE_24BIT_S1) return FALSE; - /* Relax to: jal symbol; 25_PCREL */ + /* Relax to: jal symbol; 25_PCREL */ /* For simplicity of coding, we are going to modify the section contents, the section relocs, and the BFD symbol table. We must tell the rest of the code not to free up this @@ -9772,8 +11223,9 @@ nds32_elf_relax_longcall4 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, if (ptr_irel == irelend || em_irel == irelend) { - _bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LONGCALL4", - irel->r_offset); + _bfd_error_handler + ("%pB: warning: R_NDS32_LONGCALL4 points to unrecognized " + "reloc at 0x%lx.", abfd, (long) irel->r_offset); return FALSE; } /* Check these is enough space to insert jal in R_NDS32_EMPTY. */ @@ -9812,7 +11264,7 @@ nds32_elf_relax_longcall4 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, return TRUE; } -/* Relax LONGCALL5 relocation for nds32_elf_relax_section. */ +/* Relax LONGCALL5 relocation for nds32_elf_relax_section.*/ static bfd_boolean nds32_elf_relax_longcall5 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, @@ -9828,7 +11280,6 @@ nds32_elf_relax_longcall5 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, bfd_vma laddr; uint32_t insn; Elf_Internal_Rela *cond_irel, *irelend; - int pic_ext_target = 0; bfd_signed_vma foff; irelend = internal_relocs + sec->reloc_count; @@ -9843,21 +11294,21 @@ nds32_elf_relax_longcall5 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, R_NDS32_25_PCREL_RELA, irel->r_addend); if (cond_irel == irelend) { - _bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LONGCALL5", - irel->r_offset); + _bfd_error_handler + ("%pB: warning: R_NDS32_LONGCALL5 points to unrecognized " + "reloc at 0x%lx.", abfd, (long) irel->r_offset); return FALSE; } /* Get the value of the symbol referred to by the reloc. */ - foff = calculate_offset (abfd, sec, cond_irel, isymbuf, symtab_hdr, - &pic_ext_target); + foff = calculate_offset (abfd, sec, cond_irel, isymbuf, symtab_hdr); if (foff == 0 || foff < -CONSERVATIVE_16BIT_S1 || foff >= CONSERVATIVE_16BIT_S1) return FALSE; /* Relax to bgezal rt, label ; 17_PCREL - or bltzal rt, label ; 17_PCREL */ + or bltzal rt, label ; 17_PCREL */ /* Convert to complimentary conditional call. */ insn = CONVERT_CONDITION_CALL (insn); @@ -9889,7 +11340,7 @@ nds32_elf_relax_longcall5 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, return TRUE; } -/* Relax LONGCALL6 relocation for nds32_elf_relax_section. */ +/* Relax LONGCALL6 relocation for nds32_elf_relax_section.*/ static bfd_boolean nds32_elf_relax_longcall6 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, @@ -9907,7 +11358,6 @@ nds32_elf_relax_longcall6 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, bfd_vma laddr; uint32_t insn; Elf_Internal_Rela *em_irel, *cond_irel, *irelend; - int pic_ext_target = 0; bfd_signed_vma foff; irelend = internal_relocs + sec->reloc_count; @@ -9921,16 +11371,16 @@ nds32_elf_relax_longcall6 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, if (em_irel == irelend) { - _bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LONGCALL6", - irel->r_offset); + _bfd_error_handler + ("%pB: warning: R_NDS32_LONGCALL6 points to unrecognized " + "reloc at 0x%lx.", abfd, (long) irel->r_offset); return FALSE; } /* Get the value of the symbol referred to by the reloc. */ - foff = calculate_offset (abfd, sec, em_irel, isymbuf, symtab_hdr, - &pic_ext_target); + foff = calculate_offset (abfd, sec, em_irel, isymbuf, symtab_hdr); - if (pic_ext_target || foff == 0 || foff < -CONSERVATIVE_24BIT_S1 + if (foff == 0 || foff < -CONSERVATIVE_24BIT_S1 || foff >= CONSERVATIVE_24BIT_S1) return FALSE; @@ -9943,7 +11393,7 @@ nds32_elf_relax_longcall6 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, if (foff >= -CONSERVATIVE_16BIT_S1 && foff < CONSERVATIVE_16BIT_S1) { /* Relax to bgezal rt, label ; 17_PCREL - or bltzal rt, label ; 17_PCREL */ + or bltzal rt, label ; 17_PCREL */ /* Convert to complimentary conditional call. */ *insn_len = 0; @@ -9959,8 +11409,9 @@ nds32_elf_relax_longcall6 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, R_NDS32_PTR_RESOLVED, irel->r_addend); if (cond_irel == irelend) { - _bfd_error_handler (unrecognized_reloc_msg, abfd, - "R_NDS32_LONGCALL6", irel->r_offset); + _bfd_error_handler + ("%pB: warning: R_NDS32_LONGCALL6 points to unrecognized " + "reloc at 0x%lx.", abfd, (long) irel->r_offset); return FALSE; } cond_irel->r_addend = 1; @@ -10008,8 +11459,9 @@ nds32_elf_relax_longcall6 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, R_NDS32_PTR_RESOLVED, irel->r_addend); if (cond_irel == irelend) { - _bfd_error_handler (unrecognized_reloc_msg, abfd, - "R_NDS32_LONGCALL6", irel->r_offset); + _bfd_error_handler + ("%pB: warning: R_NDS32_LONGCALL6 points to unrecognized " + "reloc at 0x%lx.", abfd, (long) irel->r_offset); return FALSE; } cond_irel->r_addend = 1; @@ -10024,7 +11476,7 @@ nds32_elf_relax_longcall6 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, return TRUE; } -/* Relax LONGJUMP4 relocation for nds32_elf_relax_section. */ +/* Relax LONGJUMP4 relocation for nds32_elf_relax_section.*/ static bfd_boolean nds32_elf_relax_longjump4 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, @@ -10041,7 +11493,6 @@ nds32_elf_relax_longjump4 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, int seq_len; /* Original length of instruction sequence. */ uint32_t insn; Elf_Internal_Rela *hi_irel, *ptr_irel, *em_irel, *call_irel, *irelend; - int pic_ext_target = 0; bfd_signed_vma foff; irelend = internal_relocs + sec->reloc_count; @@ -10058,21 +11509,21 @@ nds32_elf_relax_longjump4 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, if (hi_irel == irelend) { - _bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LONGJUMP4", - irel->r_offset); + _bfd_error_handler + ("%pB: warning: R_NDS32_LONGJUMP4 points to unrecognized " + "reloc at 0x%lx.", abfd, (long) irel->r_offset); return FALSE; } /* Get the value of the symbol referred to by the reloc. */ - foff = calculate_offset (abfd, sec, hi_irel, isymbuf, symtab_hdr, - &pic_ext_target); + foff = calculate_offset (abfd, sec, hi_irel, isymbuf, symtab_hdr); - if (pic_ext_target || foff == 0 || foff >= CONSERVATIVE_24BIT_S1 + if (foff == 0 || foff >= CONSERVATIVE_24BIT_S1 || foff < -CONSERVATIVE_24BIT_S1) return FALSE; /* Convert it to "j label", it may be converted to j8 in the final - pass of relaxation. Therefore, we do not consider this currently. */ + pass of relaxation. Therefore, we do not consider this currently.*/ ptr_irel = find_relocs_at_address_addr (irel, internal_relocs, irelend, R_NDS32_PTR_RESOLVED, irel->r_addend); em_irel = find_relocs_at_address_addr (irel, internal_relocs, irelend, @@ -10080,8 +11531,9 @@ nds32_elf_relax_longjump4 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, if (ptr_irel == irelend || em_irel == irelend) { - _bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LONGJUMP4", - irel->r_offset); + _bfd_error_handler + ("%pB: warning: R_NDS32_LONGJUMP4 points to unrecognized " + "reloc at 0x%lx.", abfd, (long) irel->r_offset); return FALSE; } @@ -10109,7 +11561,7 @@ nds32_elf_relax_longjump4 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, return TRUE; } -/* Relax LONGJUMP5 relocation for nds32_elf_relax_section. */ +/* Relax LONGJUMP5 relocation for nds32_elf_relax_section.*/ static bfd_boolean nds32_elf_relax_longjump5 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, @@ -10131,7 +11583,6 @@ nds32_elf_relax_longjump5 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, bfd_vma laddr; Elf_Internal_Rela *cond_irel, *irelend; - int pic_ext_target = 0; unsigned int i; bfd_signed_vma foff; uint32_t insn, re_insn = 0; @@ -10154,16 +11605,16 @@ nds32_elf_relax_longjump5 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, R_NDS32_25_PCREL_RELA, irel->r_addend); if (cond_irel == irelend) { - _bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LONGJUMP5", - irel->r_offset); + _bfd_error_handler + ("%pB: warning: R_NDS32_LONGJUMP5 points to unrecognized " + "reloc at 0x%lx.", abfd, (long) irel->r_offset); return FALSE; } /* Get the value of the symbol referred to by the reloc. */ - foff = calculate_offset (abfd, sec, cond_irel, isymbuf, symtab_hdr, - &pic_ext_target); + foff = calculate_offset (abfd, sec, cond_irel, isymbuf, symtab_hdr); - if (pic_ext_target || foff == 0 || foff < -CONSERVATIVE_16BIT_S1 + if (foff == 0 || foff < -CONSERVATIVE_16BIT_S1 || foff >= CONSERVATIVE_16BIT_S1) return FALSE; @@ -10208,7 +11659,7 @@ nds32_elf_relax_longjump5 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, /* Clean relocations. */ irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info), R_NDS32_NONE); - for (i = 0; i < sizeof (checked_types) / sizeof (checked_types[0]); i++) + for (i = 0; i < ARRAY_SIZE (checked_types); i++) { cond_irel = find_relocs_at_address_addr (irel, internal_relocs, irelend, checked_types[i], laddr); @@ -10234,7 +11685,7 @@ nds32_elf_relax_longjump5 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, return TRUE; } -/* Relax LONGJUMP6 relocation for nds32_elf_relax_section. */ +/* Relax LONGJUMP6 relocation for nds32_elf_relax_section.*/ static bfd_boolean nds32_elf_relax_longjump6 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, @@ -10265,7 +11716,6 @@ nds32_elf_relax_longjump6 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, int reloc_off = 0, cond_removed = 0; bfd_vma laddr; Elf_Internal_Rela *cond_irel, *em_irel, *irelend, *insn_irel; - int pic_ext_target = 0; unsigned int i; bfd_signed_vma foff; uint32_t insn, re_insn = 0; @@ -10283,16 +11733,16 @@ nds32_elf_relax_longjump6 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, if (em_irel == irelend) { - _bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LONGJUMP6", - irel->r_offset); + _bfd_error_handler + ("%pB: warning: R_NDS32_LONGJUMP6 points to unrecognized " + "reloc at 0x%lx.", abfd, (long) irel->r_offset); return FALSE; } /* Get the value of the symbol referred to by the reloc. */ - foff = calculate_offset (abfd, sec, em_irel, isymbuf, symtab_hdr, - &pic_ext_target); + foff = calculate_offset (abfd, sec, em_irel, isymbuf, symtab_hdr); - if (pic_ext_target || foff == 0 || foff < -CONSERVATIVE_24BIT_S1 + if (foff == 0 || foff < -CONSERVATIVE_24BIT_S1 || foff >= CONSERVATIVE_24BIT_S1) return FALSE; @@ -10318,7 +11768,7 @@ nds32_elf_relax_longjump6 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, if (N32_OP6 (re_insn) == N32_OP6_BR1 && (foff >= -CONSERVATIVE_14BIT_S1 && foff < CONSERVATIVE_14BIT_S1)) { - /* beqs label ; 15_PCREL */ + /* beqs label ; 15_PCREL */ bfd_putb32 (re_insn, contents + em_irel->r_offset); reloc = R_NDS32_15_PCREL_RELA; cond_removed = 1; @@ -10326,7 +11776,7 @@ nds32_elf_relax_longjump6 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, else if (N32_OP6 (re_insn) == N32_OP6_BR2 && foff >= -CONSERVATIVE_16BIT_S1 && foff < CONSERVATIVE_16BIT_S1) { - /* beqz label ; 17_PCREL */ + /* beqz label ; 17_PCREL */ bfd_putb32 (re_insn, contents + em_irel->r_offset); reloc = R_NDS32_17_PCREL_RELA; cond_removed = 1; @@ -10383,7 +11833,7 @@ nds32_elf_relax_longjump6 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, /* Clear relocations. */ irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info), R_NDS32_NONE); - for (i = 0; i < sizeof (checked_types) / sizeof (checked_types[0]); i++) + for (i = 0; i < ARRAY_SIZE (checked_types); i++) { cond_irel = find_relocs_at_address_addr (irel, internal_relocs, irelend, @@ -10415,7 +11865,7 @@ nds32_elf_relax_longjump6 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, return TRUE; } -/* Relax LONGJUMP7 relocation for nds32_elf_relax_section. */ +/* Relax LONGJUMP7 relocation for nds32_elf_relax_section.*/ static bfd_boolean nds32_elf_relax_longjump7 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, @@ -10435,7 +11885,6 @@ nds32_elf_relax_longjump7 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, bfd_vma laddr; Elf_Internal_Rela *cond_irel, *irelend, *insn_irel; - int pic_ext_target = 0; bfd_signed_vma foff; uint32_t insn, re_insn = 0; uint16_t insn16; @@ -10453,16 +11902,16 @@ nds32_elf_relax_longjump7 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, R_NDS32_15_PCREL_RELA, irel->r_addend); if (cond_irel == irelend) { - _bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LONGJUMP7", - irel->r_offset); + _bfd_error_handler + ("%pB: warning: R_NDS32_LONGJUMP7 points to unrecognized " + "reloc at 0x%lx.", abfd, (long) irel->r_offset); return FALSE; } /* Get the value of the symbol referred to by the reloc. */ - foff = calculate_offset (abfd, sec, cond_irel, isymbuf, symtab_hdr, - &pic_ext_target); + foff = calculate_offset (abfd, sec, cond_irel, isymbuf, symtab_hdr); - if (pic_ext_target || foff == 0 || foff < -CONSERVATIVE_8BIT_S1 + if (foff == 0 || foff < -CONSERVATIVE_8BIT_S1 || foff >= CONSERVATIVE_8BIT_S1) return FALSE; @@ -10516,6 +11965,123 @@ nds32_elf_relax_longjump7 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, return TRUE; } +/* Record the offset to gp, and check if it changed after relaxing. + If the offset is fixed or the offset is near enough, try to relax + the pattern. This is avoid truncated to fit when relaxing fixed + address symbol. Ex: _stack. */ +static bfd_boolean +nds32_elf_relax_guard (bfd_vma *access_addr, bfd_vma local_sda, asection *sec, + Elf_Internal_Rela *irel, bfd_boolean *again, + bfd_boolean init, + struct elf_nds32_link_hash_table *table, + Elf_Internal_Sym *isymbuf, Elf_Internal_Shdr *symtab_hdr) + +{ + /* The default linker script value. */ + int offset_to_gp; + static bfd_boolean sec_pass = FALSE; + static asection *first_sec = NULL, *sym_sec; + /* Record the number of instructions which may be removed. */ + static int count = 0, record_count; + Elf_Internal_Sym *isym; + struct elf_link_hash_entry *h = NULL; + int indx; + unsigned long r_symndx; + bfd *abfd = sec->owner; + static bfd_vma record_sda = 0; + int sda_offset = 0; + + /* Force doing relaxation when hyper-relax is high. */ + if (table->hyper_relax == 2) + return TRUE; + + /* Record the first section to get the round. */ + if (init) + { + if (!first_sec) + first_sec = sec; + else if (first_sec == sec) + { + record_count = count; + count = 0; + sec_pass = TRUE; + } + + if (!sec_pass) + *again = TRUE; + + return TRUE; + } + + if (record_sda == 0) + record_sda = local_sda; + else if (local_sda > record_sda) + /* In normal case, SDA is fixed or smaller except there is + DATA_SEGMENT_ALIGN in linker script.*/ + sda_offset = local_sda - record_sda; + + /* Although we doesn't delete all instructions here, counting all of + them to be conservative. */ + count++; + + r_symndx = ELF32_R_SYM (irel->r_info); + /* Global symbols. */ + if (r_symndx >= symtab_hdr->sh_info) + { + indx = ELF32_R_SYM (irel->r_info) - symtab_hdr->sh_info; + h = elf_sym_hashes (abfd)[indx]; + sym_sec = h->root.u.def.section; + if (NDS32_GUARD_SEC_P (sym_sec->flags) + || bfd_is_abs_section (sym_sec)) + { + /* Forbid doing relaxation when hyper-relax is low. */ + if (table->hyper_relax == 0) + return FALSE; + + offset_to_gp = *access_addr - local_sda; + if (elf32_nds32_hash_entry (h)->offset_to_gp == 0) + elf32_nds32_hash_entry (h)->offset_to_gp = offset_to_gp; + else if (abs (elf32_nds32_hash_entry (h)->offset_to_gp) + < abs (offset_to_gp) - sda_offset) + { + if (*access_addr >= local_sda) + *access_addr += (record_count * 4); + else + *access_addr -= (record_count * 4); + } + return sec_pass; + } + } + else + { + if (!elf32_nds32_allocate_local_sym_info (abfd)) + return FALSE; + isym = isymbuf + r_symndx; + + sym_sec = bfd_section_from_elf_index (abfd, isym->st_shndx); + if (NDS32_GUARD_SEC_P (sym_sec->flags)) + { + /* Forbid doing relaxation when hyper-relax is low. */ + if (table->hyper_relax == 0) + return FALSE; + + offset_to_gp = *access_addr - local_sda; + if (elf32_nds32_local_gp_offset (abfd)[r_symndx] == 0) + elf32_nds32_local_gp_offset (abfd)[r_symndx] = offset_to_gp; + else if (abs (elf32_nds32_local_gp_offset (abfd)[r_symndx]) + < abs (offset_to_gp) - sda_offset) + { + if (*access_addr >= local_sda) + *access_addr += (record_count * 4); + else + *access_addr -= (record_count * 4); + } + return sec_pass; + } + } + + return TRUE; +} #define GET_LOADSTORE_RANGE(addend) (((addend) >> 8) & 0x3f) /* Relax LOADSTORE relocation for nds32_elf_relax_section. */ @@ -10525,21 +12091,24 @@ nds32_elf_relax_loadstore (struct bfd_link_info *link_info, bfd *abfd, asection *sec, Elf_Internal_Rela *irel, Elf_Internal_Rela *internal_relocs, int *insn_len, bfd_byte *contents, Elf_Internal_Sym *isymbuf, - Elf_Internal_Shdr *symtab_hdr, int load_store_relax) + Elf_Internal_Shdr *symtab_hdr, int load_store_relax, + struct elf_nds32_link_hash_table *table) { - int eliminate_sethi = 0, range_type; - unsigned int i; + int eliminate_sethi = 0, range_type, i; bfd_vma local_sda, laddr; int seq_len; /* Original length of instruction sequence. */ uint32_t insn; Elf_Internal_Rela *hi_irelfn = NULL, *irelend; bfd_vma access_addr = 0; bfd_vma range_l = 0, range_h = 0; /* Upper/lower bound. */ + struct elf_link_hash_entry *h = NULL; + int indx; enum elf_nds32_reloc_type checked_types[] = { R_NDS32_HI20_RELA, R_NDS32_GOT_HI20, R_NDS32_GOTPC_HI20, R_NDS32_GOTOFF_HI20, R_NDS32_PLTREL_HI20, R_NDS32_PLT_GOTREL_HI20, - R_NDS32_TLS_LE_HI20 + R_NDS32_TLS_LE_HI20, R_NDS32_TLS_IE_HI20, + R_NDS32_TLS_IEGP_HI20, R_NDS32_TLS_DESC_HI20 }; irelend = internal_relocs + sec->reloc_count; @@ -10548,7 +12117,7 @@ nds32_elf_relax_loadstore (struct bfd_link_info *link_info, bfd *abfd, *insn_len = seq_len; /* Get the high part relocation. */ - for (i = 0; i < ARRAY_SIZE (checked_types); i++) + for (i = 0; (unsigned) i < ARRAY_SIZE (checked_types); i++) { hi_irelfn = find_relocs_at_address_addr (irel, internal_relocs, irelend, checked_types[i], laddr); @@ -10558,9 +12127,12 @@ nds32_elf_relax_loadstore (struct bfd_link_info *link_info, bfd *abfd, if (hi_irelfn == irelend) { - _bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LOADSTORE", - irel->r_offset); - return FALSE; + /* Not R_NDS32_HI20_RELA. */ + if (i != 0) + _bfd_error_handler + ("%pB: warning: R_NDS32_LOADSTORE points to unrecognized " + "reloc at 0x%lx.", abfd, (long) irel->r_offset); + return FALSE; } range_type = GET_LOADSTORE_RANGE (irel->r_addend); @@ -10574,39 +12146,41 @@ nds32_elf_relax_loadstore (struct bfd_link_info *link_info, bfd *abfd, access_addr = calculate_memory_address (abfd, hi_irelfn, isymbuf, symtab_hdr); - if (range_type == NDS32_LOADSTORE_IMM) + if (ELF32_R_SYM (hi_irelfn->r_info) >= symtab_hdr->sh_info) { - struct elf_link_hash_entry *h = NULL; - int indx; - - if (ELF32_R_SYM (hi_irelfn->r_info) >= symtab_hdr->sh_info) - { - indx = ELF32_R_SYM (hi_irelfn->r_info) - symtab_hdr->sh_info; - h = elf_sym_hashes (abfd)[indx]; - } + indx = ELF32_R_SYM (hi_irelfn->r_info) - symtab_hdr->sh_info; + h = elf_sym_hashes (abfd)[indx]; + } + /* Try movi. */ + if (range_type == NDS32_LOADSTORE_IMM) + { if ((access_addr < CONSERVATIVE_20BIT) && (!h || (h && strcmp (h->root.root.string, FP_BASE_NAME) != 0))) { eliminate_sethi = 1; break; } + } - /* This is avoid to relax symbol address which is fixed - relocations. Ex: _stack. */ - if (h && bfd_is_abs_section (h->root.u.def.section)) - return FALSE; + if (h && strcmp (h->root.root.string, FP_BASE_NAME) == 0) + { + eliminate_sethi = 1; + break; } + else if (!nds32_elf_relax_guard (&access_addr, local_sda, sec, hi_irelfn, + NULL, FALSE, table, isymbuf, symtab_hdr)) + return FALSE; if (!load_store_relax) return FALSE; /* Case for set gp register. */ if (N32_RT5 (insn) == REG_GP) - break; + return FALSE; if (range_type == NDS32_LOADSTORE_FLOAT_S - || range_type == NDS32_LOADSTORE_FLOAT_D) + || range_type == NDS32_LOADSTORE_FLOAT_S) { range_l = sdata_range[0][0]; range_h = sdata_range[0][1]; @@ -10618,57 +12192,6 @@ nds32_elf_relax_loadstore (struct bfd_link_info *link_info, bfd *abfd, } break; - case R_NDS32_GOT_HI20: - access_addr = - calculate_got_memory_address (abfd, link_info, hi_irelfn, symtab_hdr); - - /* If this symbol is not in .got, the return value will be -1. - Since the gp value is set to SDA_BASE but not GLOBAL_OFFSET_TABLE, - a negative offset is allowed. */ - if ((bfd_signed_vma) (access_addr - local_sda) < CONSERVATIVE_20BIT - && (bfd_signed_vma) (access_addr - local_sda) >= -CONSERVATIVE_20BIT) - eliminate_sethi = 1; - break; - - case R_NDS32_PLT_GOTREL_HI20: - access_addr = calculate_plt_memory_address (abfd, link_info, isymbuf, - hi_irelfn, symtab_hdr); - - if ((bfd_signed_vma) (access_addr - local_sda) < CONSERVATIVE_20BIT - && (bfd_signed_vma) (access_addr - local_sda) >= -CONSERVATIVE_20BIT) - eliminate_sethi = 1; - break; - - case R_NDS32_GOTOFF_HI20: - access_addr = - calculate_memory_address (abfd, hi_irelfn, isymbuf, symtab_hdr); - - if ((bfd_signed_vma) (access_addr - local_sda) < CONSERVATIVE_20BIT - && (bfd_signed_vma) (access_addr - local_sda) >= -CONSERVATIVE_20BIT) - eliminate_sethi = 1; - break; - - case R_NDS32_GOTPC_HI20: - /* The access_addr must consider r_addend of hi_irel. */ - access_addr = sec->output_section->vma + sec->output_offset - + irel->r_offset + hi_irelfn->r_addend; - - if ((bfd_signed_vma) (local_sda - access_addr) < CONSERVATIVE_20BIT - && (bfd_signed_vma) (local_sda - access_addr) >= -CONSERVATIVE_20BIT) - eliminate_sethi = 1; - break; - - case R_NDS32_TLS_LE_HI20: - access_addr = - calculate_memory_address (abfd, hi_irelfn, isymbuf, symtab_hdr); - BFD_ASSERT (elf_hash_table (link_info)->tls_sec != NULL); - access_addr -= (elf_hash_table (link_info)->tls_sec->vma + TP_OFFSET); - if ((range_type == NDS32_LOADSTORE_IMM) - && (bfd_signed_vma) (access_addr) < CONSERVATIVE_20BIT - && (bfd_signed_vma) (access_addr) >= -CONSERVATIVE_20BIT) - eliminate_sethi = 1; - break; - default: return FALSE; } @@ -10683,17 +12206,20 @@ nds32_elf_relax_loadstore (struct bfd_link_info *link_info, bfd *abfd, irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info), R_NDS32_NONE); *insn_len = 0; + return TRUE; } - return TRUE; + + return FALSE; } -/* Relax LO12 relocation for nds32_elf_relax_section. */ +/* Relax LO12 relocation for nds32_elf_relax_section.*/ static void nds32_elf_relax_lo12 (struct bfd_link_info *link_info, bfd *abfd, asection *sec, Elf_Internal_Rela *irel, Elf_Internal_Rela *internal_relocs, bfd_byte *contents, - Elf_Internal_Sym *isymbuf, Elf_Internal_Shdr *symtab_hdr) + Elf_Internal_Sym *isymbuf, Elf_Internal_Shdr *symtab_hdr, + struct elf_nds32_link_hash_table *table) { uint32_t insn; bfd_vma local_sda, laddr; @@ -10723,6 +12249,7 @@ nds32_elf_relax_lo12 (struct bfd_link_info *link_info, bfd *abfd, h = elf_sym_hashes (abfd)[indx]; } + /* Try movi. */ if (N32_OP6 (insn) == N32_OP6_ORI && access_addr < CONSERVATIVE_20BIT && (!h || (h && strcmp (h->root.root.string, FP_BASE_NAME) != 0))) { @@ -10731,13 +12258,14 @@ nds32_elf_relax_lo12 (struct bfd_link_info *link_info, bfd *abfd, insn = N32_TYPE1 (MOVI, N32_RT5 (insn), 0); bfd_putb32 (insn, contents + laddr); } - /* This is avoid to relax symbol address which is fixed - relocations. Ex: _stack. */ - else if (N32_OP6 (insn) == N32_OP6_ORI - && h && bfd_is_abs_section (h->root.u.def.section)) - return; else { + if (h && strcmp (h->root.root.string, FP_BASE_NAME) == 0) + { /* Fall through. */ } + else if (!nds32_elf_relax_guard (&access_addr, local_sda, sec, irel, NULL, + FALSE, table, isymbuf, symtab_hdr)) + return; + range_l = sdata_range[1][0]; range_h = sdata_range[1][1]; switch (ELF32_R_TYPE (irel->r_info)) @@ -10768,7 +12296,8 @@ nds32_elf_relax_lo12 (struct bfd_link_info *link_info, bfd *abfd, /* There are range_h and range_l because linker has to promise all sections move cross one page together. */ if ((local_sda <= access_addr && (access_addr - local_sda) < range_h) - || (local_sda > access_addr && (local_sda - access_addr) <= range_l)) + || (local_sda > access_addr && (local_sda - access_addr) <= range_l) + || (h && strcmp (h->root.root.string, FP_BASE_NAME) == 0)) { if (N32_OP6 (insn) == N32_OP6_ORI && N32_RT5 (insn) == REG_GP) { @@ -10790,7 +12319,6 @@ nds32_elf_relax_lo12 (struct bfd_link_info *link_info, bfd *abfd, if (irelfn != irelend && reloc != R_NDS32_SDA17S2_RELA) irelfn->r_info = ELF32_R_INFO (ELF32_R_SYM (irelfn->r_info), R_NDS32_NONE); - } } return; @@ -10798,7 +12326,7 @@ nds32_elf_relax_lo12 (struct bfd_link_info *link_info, bfd *abfd, /* Relax low part of PIC instruction pattern. */ -static void +ATTRIBUTE_UNUSED static void nds32_elf_relax_piclo12 (struct bfd_link_info *link_info, bfd *abfd, asection *sec, Elf_Internal_Rela *irel, bfd_byte *contents, Elf_Internal_Sym *isymbuf, @@ -10855,7 +12383,7 @@ nds32_elf_relax_piclo12 (struct bfd_link_info *link_info, bfd *abfd, /* Relax low part of LE TLS instruction pattern. */ -static void +ATTRIBUTE_UNUSED static void nds32_elf_relax_letlslo12 (struct bfd_link_info *link_info, bfd *abfd, Elf_Internal_Rela *irel, bfd_byte *contents, Elf_Internal_Sym *isymbuf, @@ -10885,7 +12413,7 @@ nds32_elf_relax_letlslo12 (struct bfd_link_info *link_info, bfd *abfd, /* Relax LE TLS calculate address instruction pattern. */ -static void +ATTRIBUTE_UNUSED static void nds32_elf_relax_letlsadd (struct bfd_link_info *link_info, bfd *abfd, asection *sec, Elf_Internal_Rela *irel, Elf_Internal_Rela *internal_relocs, @@ -10893,9 +12421,9 @@ nds32_elf_relax_letlsadd (struct bfd_link_info *link_info, bfd *abfd, Elf_Internal_Shdr *symtab_hdr, bfd_boolean *again) { /* Local TLS non-pic - sethi ta, hi20(symbol@tpoff) ; TLS_LE_HI20 + sethi ta, hi20(symbol@tpoff) ; TLS_LE_HI20 ori ta, ta, lo12(symbol@tpoff) ; TLS_LE_LO12 - add ra, ta, tp ; TLS_LE_ADD */ + add ra, ta, tp ; TLS_LE_ADD */ uint32_t insn; bfd_vma laddr; @@ -10931,14 +12459,13 @@ nds32_elf_relax_letlsadd (struct bfd_link_info *link_info, bfd *abfd, /* Relax LE TLS load store instruction pattern. */ -static void +ATTRIBUTE_UNUSED static void nds32_elf_relax_letlsls (struct bfd_link_info *link_info, bfd *abfd, asection *sec, Elf_Internal_Rela *irel, Elf_Internal_Rela *internal_relocs, bfd_byte *contents, Elf_Internal_Sym *isymbuf, Elf_Internal_Shdr *symtab_hdr, bfd_boolean *again) { - uint32_t insn; bfd_vma laddr; bfd_signed_vma foff; @@ -10970,7 +12497,6 @@ nds32_elf_relax_letlsls (struct bfd_link_info *link_info, bfd *abfd, success = 1; break; } - /* Fall through. */ case (N32_OP6_MEM << 8) | N32_MEM_LH: case (N32_OP6_MEM << 8) | N32_MEM_SH: case (N32_OP6_MEM << 8) | N32_MEM_LHS: @@ -10985,7 +12511,6 @@ nds32_elf_relax_letlsls (struct bfd_link_info *link_info, bfd *abfd, success = 1; break; } - /* Fall through. */ case (N32_OP6_MEM << 8) | N32_MEM_LW: case (N32_OP6_MEM << 8) | N32_MEM_SW: /* The range is +/-64k. */ @@ -10999,7 +12524,6 @@ nds32_elf_relax_letlsls (struct bfd_link_info *link_info, bfd *abfd, success = 1; break; } - /* Fall through. */ default: break; } @@ -11032,8 +12556,9 @@ nds32_elf_relax_ptr (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, if (re_irel == irelend) { - _bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_PTR", - irel->r_offset); + _bfd_error_handler + ("%pB: warning: R_NDS32_PTR points to unrecognized reloc at 0x%lx.", + abfd, (long) irel->r_offset); return FALSE; } @@ -11068,7 +12593,7 @@ nds32_elf_relax_ptr (bfd *abfd, asection *sec, Elf_Internal_Rela *irel, /* Relax PLT_GOT_SUFF relocation for nds32_elf_relax_section. */ -static void +ATTRIBUTE_UNUSED static void nds32_elf_relax_pltgot_suff (struct bfd_link_info *link_info, bfd *abfd, asection *sec, Elf_Internal_Rela *irel, Elf_Internal_Rela *internal_relocs, @@ -11123,7 +12648,7 @@ nds32_elf_relax_pltgot_suff (struct bfd_link_info *link_info, bfd *abfd, return; irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info), R_NDS32_PLT_GOTREL_LO19); - /* addi.gp */ + /* addi.gp */ insn = N32_TYPE1 (SBGP, N32_RT5 (insn), N32_BIT (19)); } else if (N32_OP6 (insn) == N32_OP6_JREG @@ -11153,7 +12678,7 @@ nds32_elf_relax_pltgot_suff (struct bfd_link_info *link_info, bfd *abfd, /* Relax GOT_SUFF relocation for nds32_elf_relax_section. */ -static void +ATTRIBUTE_UNUSED static void nds32_elf_relax_got_suff (struct bfd_link_info *link_info, bfd *abfd, asection *sec, Elf_Internal_Rela *irel, Elf_Internal_Rela *internal_relocs, @@ -11200,7 +12725,7 @@ nds32_elf_relax_got_suff (struct bfd_link_info *link_info, bfd *abfd, /* Relax PLT_GOT_SUFF relocation for nds32_elf_relax_section. */ -static void +ATTRIBUTE_UNUSED static void nds32_elf_relax_gotoff_suff (struct bfd_link_info *link_info, bfd *abfd, asection *sec, Elf_Internal_Rela *irel, Elf_Internal_Rela *internal_relocs, @@ -11303,6 +12828,85 @@ nds32_elf_relax_gotoff_suff (struct bfd_link_info *link_info, bfd *abfd, } +/* Relax LWC relocation for nds32_elf_relax_section. */ + +static void +nds32_elf_relax_flsi (struct bfd_link_info *link_info, bfd *abfd, + asection *sec, Elf_Internal_Rela *irel, + Elf_Internal_Rela *internal_relocs, + bfd_byte *contents, Elf_Internal_Sym *isymbuf, + Elf_Internal_Shdr *symtab_hdr, bfd_boolean *again) +{ + /* Pattern for bug-12566 + sethi ra, hi20(symbol) ; HI20/LOADSTORE + ori ra, ra, lo12(symbol) ; LO12S0/PTR/PTR/.../INSN16 + flsi fsa, [ra + offset1] ; LSI/PTR_RESOLVED/INSN16 + flsi fsb, [ra + offset2] ; LSI/PTR_RESOLVED/INSN16 + ... */ + + uint32_t insn; + bfd_vma local_sda, laddr; + unsigned long reloc; + bfd_vma access_addr, flsi_offset; + bfd_vma range_l = 0, range_h = 0; /* Upper/lower bound. */ + Elf_Internal_Rela *irelend, *re_irel; + unsigned int opcode; + + irelend = internal_relocs + sec->reloc_count; + laddr = irel->r_offset; + insn = bfd_getb32 (contents + laddr); + + if ((insn & 0x80000000) || !is_sda_access_insn (insn)) + return; + + /* Can not do relaxation for bi format. */ + if ((insn & 0x1000)) + return; + + /* Only deal with flsi, fssi, fldi, fsdi, so far. */ + opcode = N32_OP6 (insn); + if ((opcode == N32_OP6_LWC) || (opcode == N32_OP6_SWC)) + reloc = R_NDS32_SDA12S2_SP_RELA; + else if ((opcode == N32_OP6_LDC) || (opcode == N32_OP6_SDC)) + reloc = R_NDS32_SDA12S2_DP_RELA; + else + return; + + re_irel = find_relocs_at_address (irel, internal_relocs, irelend, + R_NDS32_PTR_RESOLVED); + if (re_irel == irelend) + { + _bfd_error_handler + ("%pB: warning: R_NDS32_LSI has no R_NDS32_PTR_RESOLVED at 0x%lx.", + abfd, (long) irel->r_offset); + return; + } + + /* For SDA base relative relaxation. */ + nds32_elf_final_sda_base (sec->output_section->owner, link_info, + &local_sda, FALSE); + access_addr = calculate_memory_address (abfd, irel, isymbuf, symtab_hdr); + flsi_offset = (insn & 0xfff) << 2; + access_addr += flsi_offset; + range_l = sdata_range[0][0]; + range_h = sdata_range[0][1]; + + if ((local_sda <= access_addr && (access_addr - local_sda) < range_h) + || (local_sda > access_addr && (local_sda - access_addr) <= range_l)) + { + /* Turn flsi instruction into sda access format. */ + insn = (insn & 0x7ff07000) | (REG_GP << 15); + + /* Add relocation type to flsi. */ + irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info), reloc); + irel->r_addend += flsi_offset; + bfd_putb32 (insn, contents + re_irel->r_offset); + + re_irel->r_addend |= 1; + *again = TRUE; + } +} + static bfd_boolean nds32_relax_adjust_label (bfd *abfd, asection *sec, Elf_Internal_Rela *internal_relocs, @@ -11387,9 +12991,11 @@ nds32_relax_adjust_label (bfd *abfd, asection *sec, { /* Remove all LABEL relocation from label_rel to tmp_rel including relocations with same offset as tmp_rel. */ - for (tmp2_rel = label_rel; tmp2_rel < tmp_rel - || tmp2_rel->r_offset == tmp_rel->r_offset; tmp2_rel++) + for (tmp2_rel = label_rel; tmp2_rel < tmp_rel; tmp2_rel++) { + if (tmp2_rel->r_offset == tmp_rel->r_offset) + break; + if (ELF32_R_TYPE (tmp2_rel->r_info) == R_NDS32_LABEL && tmp2_rel->r_addend < 2) tmp2_rel->r_info = @@ -11416,7 +13022,8 @@ nds32_relax_adjust_label (bfd *abfd, asection *sec, We may convert a 16-bit instruction right before a label to 32-bit, in order to align the label if necessary all reloc entries has been sorted by r_offset. */ - for (irel = internal_relocs; irel < irelend; irel++) + for (irel = internal_relocs; + irel < irelend && irel->r_offset < sec->size; irel++) { if (ELF32_R_TYPE (irel->r_info) != R_NDS32_INSN16 && ELF32_R_TYPE (irel->r_info) != R_NDS32_LABEL) @@ -11568,118 +13175,6 @@ nds32_relax_adjust_label (bfd *abfd, asection *sec, return TRUE; } -/* Pick relaxation round. */ - -static int -nds32_elf_pick_relax (bfd_boolean init, asection *sec, bfd_boolean *again, - struct elf_nds32_link_hash_table *table, - struct bfd_link_info *link_info) -{ - static asection *final_sec, *first_sec = NULL; - static bfd_boolean normal_again = FALSE; - static bfd_boolean set = FALSE; - static bfd_boolean first = TRUE; - int round_table[] = { - NDS32_RELAX_NORMAL_ROUND, - NDS32_RELAX_JUMP_IFC_ROUND, - NDS32_RELAX_EX9_BUILD_ROUND, - NDS32_RELAX_EX9_REPLACE_ROUND, - }; - static int pass = 0; - static int relax_round; - - /* The new round. */ - if (init && first_sec == sec) - { - set = TRUE; - normal_again = FALSE; - } - - if (first) - { - /* Run an empty run to get the final section. */ - relax_round = NDS32_RELAX_EMPTY_ROUND; - - /* It has to enter relax again because we can - not make sure what the final turn is. */ - *again = TRUE; - - first = FALSE; - first_sec = sec; - } - - if (!set) - { - /* Not reenter yet. */ - final_sec = sec; - return relax_round; - } - - relax_round = round_table[pass]; - - if (!init && relax_round == NDS32_RELAX_NORMAL_ROUND && *again) - normal_again = TRUE; - - if (!init && final_sec == sec) - { - switch (relax_round) - { - case NDS32_RELAX_NORMAL_ROUND: - if (!normal_again) - { - /* Normal relaxation done. */ - if (table->target_optimize & NDS32_RELAX_JUMP_IFC_ON) - { - pass++; - *again = TRUE; - } - else if (table->target_optimize & NDS32_RELAX_EX9_ON) - { - pass += 2; /* NDS32_RELAX_EX9_BUILD_ROUND */ - *again = TRUE; - } - else if (table->ex9_import_file) - { - /* Import ex9 table. */ - if (table->update_ex9_table) - pass += 2; /* NDS32_RELAX_EX9_BUILD_ROUND */ - else - pass += 3; /* NDS32_RELAX_EX9_REPLACE_ROUND */ - nds32_elf_ex9_import_table (link_info); - *again = TRUE; - } - } - break; - case NDS32_RELAX_JUMP_IFC_ROUND: - if (!nds32_elf_ifc_finish (link_info)) - _bfd_error_handler (_("error: Jump IFC Fail.")); - if (table->target_optimize & NDS32_RELAX_EX9_ON) - { - pass++; - *again = TRUE; - } - break; - case NDS32_RELAX_EX9_BUILD_ROUND: - nds32_elf_ex9_finish (link_info); - pass++; - *again = TRUE; - break; - case NDS32_RELAX_EX9_REPLACE_ROUND: - if (table->target_optimize & NDS32_RELAX_JUMP_IFC_ON) - { - /* Do jump IFC optimization again. */ - if (!nds32_elf_ifc_finish (link_info)) - _bfd_error_handler (_("error: Jump IFC Fail.")); - } - break; - default: - break; - } - } - - return relax_round; -} - static bfd_boolean nds32_elf_relax_section (bfd *abfd, asection *sec, struct bfd_link_info *link_info, bfd_boolean *again) @@ -11697,26 +13192,25 @@ nds32_elf_relax_section (bfd *abfd, asection *sec, uint32_t insn; uint16_t insn16; - /* Target dependnet option. */ + /* Target dependent option. */ struct elf_nds32_link_hash_table *table; int load_store_relax; - int relax_round; relax_blank_list = NULL; - *again = FALSE; /* Nothing to do for - * relocatable link or - * non-relocatable section or - * non-code section or - * empty content or - * no reloc entry. */ + relocatable link or + non-relocatable section or + non-code section or + empty content or + no reloc entry. */ if (bfd_link_relocatable (link_info) || (sec->flags & SEC_RELOC) == 0 - || (sec->flags & SEC_EXCLUDE) != 0 + || (sec->flags & SEC_EXCLUDE) == 1 || (sec->flags & SEC_CODE) == 0 - || sec->size == 0) + || sec->size == 0 + || sec->reloc_count == 0) return TRUE; /* 09.12.11 Workaround. */ @@ -11725,44 +13219,14 @@ nds32_elf_relax_section (bfd *abfd, asection *sec, if (sec->alignment_power > 2) return TRUE; +#ifdef NDS32_LINUX_TOOLCHAIN + /* Do TLS model conversion once at first. */ + nds32_elf_unify_tls_model (abfd, sec, contents, link_info); +#endif + /* The optimization type to do. */ table = nds32_elf_hash_table (link_info); - relax_round = nds32_elf_pick_relax (TRUE, sec, again, table, link_info); - switch (relax_round) - { - case NDS32_RELAX_JUMP_IFC_ROUND: - /* Here is the entrance of ifc jump relaxation. */ - if (!nds32_elf_ifc_calc (link_info, abfd, sec)) - return FALSE; - nds32_elf_pick_relax (FALSE, sec, again, table, link_info); - return TRUE; - - case NDS32_RELAX_EX9_BUILD_ROUND: - /* Here is the entrance of ex9 relaxation. There are two pass of - ex9 relaxation. The one is to traverse all instructions and build - the hash table. The other one is to compare instructions and replace - it by ex9.it. */ - if (!nds32_elf_ex9_build_hash_table (abfd, sec, link_info)) - return FALSE; - nds32_elf_pick_relax (FALSE, sec, again, table, link_info); - return TRUE; - - case NDS32_RELAX_EX9_REPLACE_ROUND: - if (!nds32_elf_ex9_replace_instruction (link_info, abfd, sec)) - return FALSE; - return TRUE; - - case NDS32_RELAX_EMPTY_ROUND: - nds32_elf_pick_relax (FALSE, sec, again, table, link_info); - return TRUE; - - case NDS32_RELAX_NORMAL_ROUND: - default: - if (sec->reloc_count == 0) - return TRUE; - break; - } /* The begining of general relaxation. */ @@ -11775,20 +13239,10 @@ nds32_elf_relax_section (bfd *abfd, asection *sec, relax_range_measurement (abfd); } - if (is_ITB_BASE_set == 0) - { - /* Set the _ITB_BASE_. */ - if (!nds32_elf_ex9_itb_base (link_info)) - { - _bfd_error_handler (_("%B: error: Cannot set _ITB_BASE_"), abfd); - bfd_set_error (bfd_error_bad_value); - } - } - symtab_hdr = &elf_tdata (abfd)->symtab_hdr; /* Relocations MUST be kept in memory, because relaxation adjust them. */ internal_relocs = _bfd_elf_link_read_relocs (abfd, sec, NULL, NULL, - TRUE /* keep_memory */); + TRUE /* keep_memory */); if (internal_relocs == NULL) goto error_return; @@ -11802,10 +13256,7 @@ nds32_elf_relax_section (bfd *abfd, asection *sec, if (ELF32_R_TYPE (irel->r_info) == R_NDS32_RELAX_ENTRY) { if (irel->r_addend & R_NDS32_RELAX_ENTRY_DISABLE_RELAX_FLAG) - { - nds32_elf_pick_relax (FALSE, sec, again, table, link_info); - return TRUE; - } + return TRUE; if (irel->r_addend & R_NDS32_RELAX_ENTRY_OPTIMIZE_FLAG) optimize = 1; @@ -11888,7 +13339,8 @@ nds32_elf_relax_section (bfd *abfd, asection *sec, || ELF32_R_TYPE (irel->r_info) == R_NDS32_17IFC_PCREL_RELA || ELF32_R_TYPE (irel->r_info) == R_NDS32_TLS_LE_LO12 || ELF32_R_TYPE (irel->r_info) == R_NDS32_TLS_LE_ADD - || ELF32_R_TYPE (irel->r_info) == R_NDS32_TLS_LE_LS) + || ELF32_R_TYPE (irel->r_info) == R_NDS32_TLS_LE_LS + || ELF32_R_TYPE (irel->r_info) == R_NDS32_LSI) seq_len = 0; else continue; @@ -11967,71 +13419,41 @@ nds32_elf_relax_section (bfd *abfd, asection *sec, removed = nds32_elf_relax_loadstore (link_info, abfd, sec, irel, internal_relocs, &insn_len, contents, isymbuf, symtab_hdr, - load_store_relax); + load_store_relax, table); break; case R_NDS32_LO12S0_RELA: case R_NDS32_LO12S1_RELA: + case R_NDS32_LO12S2_RELA: case R_NDS32_LO12S2_DP_RELA: case R_NDS32_LO12S2_SP_RELA: - case R_NDS32_LO12S2_RELA: /* Relax for low part. */ nds32_elf_relax_lo12 (link_info, abfd, sec, irel, internal_relocs, - contents, isymbuf, symtab_hdr); + contents, isymbuf, symtab_hdr, table); /* It is impossible to delete blank, so just continue. */ continue; + case R_NDS32_PTR: + removed = nds32_elf_relax_ptr (abfd, sec, irel, internal_relocs, + &insn_len, &seq_len, contents); + break; + case R_NDS32_LSI: + nds32_elf_relax_flsi (link_info, abfd, sec, irel, internal_relocs, + contents, isymbuf, symtab_hdr, again); + continue; case R_NDS32_GOT_LO12: case R_NDS32_GOTOFF_LO12: case R_NDS32_PLTREL_LO12: case R_NDS32_PLT_GOTREL_LO12: case R_NDS32_GOTPC_LO12: - /* Relax for PIC gp-relative low part. */ - nds32_elf_relax_piclo12 (link_info, abfd, sec, irel, contents, - isymbuf, symtab_hdr); - - /* It is impossible to delete blank, so just continue. */ - continue; case R_NDS32_TLS_LE_LO12: - /* Relax for LE TLS low part. */ - nds32_elf_relax_letlslo12 (link_info, abfd, irel, contents, - isymbuf, symtab_hdr); - - /* It is impossible to delete blank, so just continue. */ - continue; case R_NDS32_TLS_LE_ADD: - nds32_elf_relax_letlsadd (link_info, abfd, sec, irel, internal_relocs, - contents, isymbuf, symtab_hdr, again); - /* It is impossible to delete blank, so just continue. */ - continue; case R_NDS32_TLS_LE_LS: - nds32_elf_relax_letlsls (link_info, abfd, sec, irel, internal_relocs, - contents, isymbuf, symtab_hdr, again); - continue; - case R_NDS32_PTR: - removed = nds32_elf_relax_ptr (abfd, sec, irel, internal_relocs, - &insn_len, &seq_len, contents); - break; case R_NDS32_PLT_GOT_SUFF: - nds32_elf_relax_pltgot_suff (link_info, abfd, sec, irel, - internal_relocs, contents, - isymbuf, symtab_hdr, again); - /* It is impossible to delete blank, so just continue. */ - continue; case R_NDS32_GOT_SUFF: - nds32_elf_relax_got_suff (link_info, abfd, sec, irel, - internal_relocs, contents, - symtab_hdr, again); - /* It is impossible to delete blank, so just continue. */ - continue; case R_NDS32_GOTOFF_SUFF: - nds32_elf_relax_gotoff_suff (link_info, abfd, sec, irel, - internal_relocs, contents, - isymbuf, symtab_hdr, again); - /* It is impossible to delete blank, so just continue. */ continue; default: continue; - } if (removed && seq_len - insn_len > 0) { @@ -12051,7 +13473,7 @@ nds32_elf_relax_section (bfd *abfd, asection *sec, irelend, isymbuf)) goto error_return; - if (!*again) + if (*again == FALSE) { if (!nds32_fag_remove_unused_fpbase (abfd, sec, internal_relocs, irelend)) @@ -12059,9 +13481,7 @@ nds32_elf_relax_section (bfd *abfd, asection *sec, } } - nds32_elf_pick_relax (FALSE, sec, again, table, link_info); - - if (!*again) + if (*again == FALSE) { if (!nds32_relax_adjust_label (abfd, sec, internal_relocs, contents, &relax_blank_list, optimize, opt_size)) @@ -12078,15 +13498,15 @@ nds32_elf_relax_section (bfd *abfd, asection *sec, relax_blank_list = NULL; } - if (!*again) + if (*again == FALSE) { /* Closing the section, so we don't relax it anymore. */ bfd_vma sec_size_align; Elf_Internal_Rela *tmp_rel; /* Pad to alignment boundary. Only handle current section alignment. */ - sec_size_align = (sec->size + (~((-1U) << sec->alignment_power))) - & ((-1U) << sec->alignment_power); + sec_size_align = (sec->size + (~((bfd_vma)(-1) << sec->alignment_power))) + & ((bfd_vma)(-1) << sec->alignment_power); if ((sec_size_align - sec->size) & 0x2) { insn16 = NDS32_NOP16; @@ -12128,8 +13548,7 @@ error_return: goto finish; } -static struct bfd_elf_special_section const nds32_elf_special_sections[] = -{ +static struct bfd_elf_special_section const nds32_elf_special_sections[] = { {".sdata", 6, -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE}, {".sbss", 5, -2, SHT_NOBITS, SHF_ALLOC + SHF_WRITE}, {NULL, 0, 0, 0, 0} @@ -12182,14 +13601,14 @@ bfd_elf32_nds32_set_target_option (struct bfd_link_info *link_info, int eliminate_gc_relocs, FILE * sym_ld_script, int load_store_relax, int target_optimize, int relax_status, - int relax_round, FILE * ex9_export_file, - FILE * ex9_import_file, - int update_ex9_table, int ex9_limit, - bfd_boolean ex9_loop_aware, - bfd_boolean ifc_loop_aware) + int relax_round, int hyper_relax, + int tls_desc_trampoline, char *abi) { struct elf_nds32_link_hash_table *table; + /* Initialize indirect call hash table. */ + nds32_elf_ict_hash_init (); + table = nds32_elf_hash_table (link_info); if (table == NULL) return; @@ -12201,12 +13620,81 @@ bfd_elf32_nds32_set_target_option (struct bfd_link_info *link_info, table->target_optimize = target_optimize; table->relax_status = relax_status; table->relax_round = relax_round; - table->ex9_export_file = ex9_export_file; - table->ex9_import_file = ex9_import_file; - table->update_ex9_table = update_ex9_table; - table->ex9_limit = ex9_limit; - table->ex9_loop_aware = ex9_loop_aware; - table->ifc_loop_aware = ifc_loop_aware; + table->hyper_relax = hyper_relax; + table->tls_desc_trampoline = tls_desc_trampoline; + output_abi = abi; +} + +void +bfd_elf32_nds32_append_section (struct bfd_link_info *link_info, bfd *abfd) +{ + asection *itable; + struct bfd_link_hash_entry *h; + unsigned int i, count = 0; + + /* Count number of indirect call function. */ + indirect_call_table.frozen = 1; + for (i = 0; i < indirect_call_table.size; i++) + { + struct bfd_hash_entry *p; + struct elf_nds32_ict_hash_entry *entry; + + for (p = indirect_call_table.table[i]; p != NULL; p = p->next) + { + entry = (struct elf_nds32_ict_hash_entry *) p; + entry->order = count; + count++; + } + } + indirect_call_table.frozen = 0; + + if (count) + { + h = bfd_link_hash_lookup (link_info->hash, "_INDIRECT_CALL_TABLE_BASE_", + FALSE, FALSE, FALSE); + if (h && (h->type == bfd_link_hash_defined + || h->type == bfd_link_hash_defweak + || h->type == bfd_link_hash_common)) + { + _bfd_error_handler (_("Warning: _INDIRECT_CALL_TABLE_BASE_ has already" + "be defined. All ICT suffix is ignored.")); + ignore_indirect_call = TRUE; + return; + } + + if (ict_model == R_NDS32_RELAX_ENTRY_ICT_LARGE) + itable = bfd_make_section_with_flags (abfd, NDS32_ICT_SECTION, + SEC_DATA | SEC_ALLOC | SEC_LOAD + | SEC_HAS_CONTENTS | SEC_READONLY + | SEC_IN_MEMORY | SEC_KEEP + | SEC_RELOC); + else + itable = bfd_make_section_with_flags (abfd, NDS32_ICT_SECTION, + SEC_CODE | SEC_ALLOC | SEC_LOAD + | SEC_HAS_CONTENTS | SEC_READONLY + | SEC_IN_MEMORY | SEC_KEEP + | SEC_RELOC); + if (itable) + { + itable->gc_mark = 1; + itable->alignment_power = 2; + itable->size = count * 4; + itable->contents = bfd_zalloc (abfd, itable->size); + + /* Add a symbol in the head of .nds32.ict to objdump clearly. */ + h = bfd_link_hash_lookup (link_info->hash, + "_INDIRECT_CALL_TABLE_BASE_", + FALSE, FALSE, FALSE); + _bfd_generic_link_add_one_symbol + (link_info, link_info->output_bfd, "_INDIRECT_CALL_TABLE_BASE_", + BSF_GLOBAL | BSF_WEAK, itable, 0, (const char *) NULL, FALSE, + get_elf_backend_data (link_info->output_bfd)->collect, &h); + } + + ict_file = fopen ("nds32_ict.s", FOPEN_WT); + if(ict_file == NULL) + _bfd_error_handler (_("Warning: Fail to build nds32_ict.s.")); + } } /* These functions and data-structures are used for fp-as-gp @@ -12394,7 +13882,7 @@ nds32_fag_find_base (struct nds32_fag *head, struct nds32_fag **bestpp) static bfd_boolean nds32_fag_mark_relax (struct bfd_link_info *link_info, - bfd *abfd, struct nds32_fag *best_fag, + asection *sec, struct nds32_fag *best_fag, Elf_Internal_Rela *internal_relocs, Elf_Internal_Rela *irelend) { @@ -12402,7 +13890,7 @@ nds32_fag_mark_relax (struct bfd_link_info *link_info, bfd_vma best_fpbase, gp; bfd *output_bfd; - output_bfd = abfd->sections->output_section->owner; + output_bfd = sec->output_section->owner; nds32_elf_final_sda_base (output_bfd, link_info, &gp, FALSE); best_fpbase = best_fag->addr; @@ -12525,8 +14013,7 @@ nds32_relax_fp_as_gp (struct bfd_link_info *link_info, { /* Begin of the region. */ if (begin_rel) - /* xgettext:c-format */ - _bfd_error_handler (_("%B: Nested OMIT_FP in %A."), abfd, sec); + _bfd_error_handler (_("%pB: Nested OMIT_FP in %pA."), abfd, sec); begin_rel = irel; nds32_fag_init (&fag_head); @@ -12544,8 +14031,7 @@ nds32_relax_fp_as_gp (struct bfd_link_info *link_info, if (begin_rel == NULL) { - /* xgettext:c-format */ - _bfd_error_handler (_("%B: Unmatched OMIT_FP in %A."), abfd, sec); + _bfd_error_handler (_("%pB: Unmatched OMIT_FP in %pA."), abfd, sec); continue; } @@ -12557,7 +14043,7 @@ nds32_relax_fp_as_gp (struct bfd_link_info *link_info, /* Check if it is worth, and FP_BASE is near enough to SDA_BASE. */ if (accu < FAG_THRESHOLD - || !nds32_fag_mark_relax (link_info, abfd, best_fag, + || !nds32_fag_mark_relax (link_info, sec, best_fag, internal_relocs, irelend)) { /* Not worth to do fp-as-gp. */ @@ -12811,9 +14297,9 @@ nds32_elf_get_relocated_section_contents (bfd *abfd, case bfd_reloc_dangerous: BFD_ASSERT (error_message != NULL); (*link_info->callbacks->reloc_dangerous) - (link_info, error_message, - input_bfd, input_section, (*parent)->address); - break; + (link_info, error_message, input_bfd, input_section, + (*parent)->address); + break; case bfd_reloc_overflow: (*link_info->callbacks->reloc_overflow) (link_info, NULL, @@ -12827,9 +14313,8 @@ nds32_elf_get_relocated_section_contents (bfd *abfd, complete binaries. Do not abort, but issue an error message instead. */ link_info->callbacks->einfo - /* xgettext:c-format */ - (_("%X%P: %B(%A): relocation \"%R\" goes out of range\n"), - abfd, input_section, * parent); + (_("%X%P: %pB(%pA): relocation \"%R\" goes out of range\n"), + abfd, input_section, *parent); goto error_return; default: @@ -12847,745 +14332,807 @@ error_return: free (reloc_vector); return NULL; } - -/* Link-time IFC relaxation. - In this optimization, we chains jump instructions - of the same destination with ifcall. */ +/* Check target symbol. */ -/* List to save jal and j relocation. */ -struct elf_nds32_ifc_symbol_entry +static bfd_boolean +nds32_elf_is_target_special_symbol (bfd *abfd ATTRIBUTE_UNUSED, asymbol *sym) { - asection *sec; - struct elf_link_hash_entry *h; - struct elf_nds32_ifc_irel_list *irel_head; - unsigned long insn; - int times; - int enable; /* Apply ifc. */ - int ex9_enable; /* Apply ifc after ex9. */ - struct elf_nds32_ifc_symbol_entry *next; -}; + if (!sym || !sym->name || sym->name[0] != '$') + return FALSE; + return TRUE; +} -struct elf_nds32_ifc_irel_list +/* nds32 find maybe function sym. Ignore target special symbol + first, and then go the general function. */ + +static bfd_size_type +nds32_elf_maybe_function_sym (const asymbol *sym, asection *sec, + bfd_vma *code_off) { - Elf_Internal_Rela *irel; - asection *sec; - bfd_vma addr; - /* If this is set, then it is the last instruction for - ifc-chain, so it must be keep for the actual branching. */ - int keep; - struct elf_nds32_ifc_irel_list *next; -}; + if (nds32_elf_is_target_special_symbol (NULL, (asymbol *) sym)) + return 0; -static struct elf_nds32_ifc_symbol_entry *ifc_symbol_head = NULL; + return _bfd_elf_maybe_function_sym (sym, sec, code_off); +} -/* Insert symbol of jal and j for ifc. */ + +/* Do TLS model conversion. */ -static void -nds32_elf_ifc_insert_symbol (asection *sec, - struct elf_link_hash_entry *h, - Elf_Internal_Rela *irel, - unsigned long insn) +typedef struct relax_group_list_t { - struct elf_nds32_ifc_symbol_entry *ptr = ifc_symbol_head; + Elf_Internal_Rela *relo; + struct relax_group_list_t *next; + struct relax_group_list_t *next_sibling; + int id; +} relax_group_list_t; - /* Check there is target of existing entry the same as the new one. */ - while (ptr != NULL) - { - if (((h == NULL && ptr->sec == sec - && ELF32_R_SYM (ptr->irel_head->irel->r_info) == ELF32_R_SYM (irel->r_info) - && ptr->irel_head->irel->r_addend == irel->r_addend) - || h != NULL) - && ptr->h == h - && ptr->insn == insn) - { - /* The same target exist, so insert into list. */ - struct elf_nds32_ifc_irel_list *irel_list = ptr->irel_head; +int +list_insert (relax_group_list_t *pHead, Elf_Internal_Rela *pElem); - while (irel_list->next != NULL) - irel_list = irel_list->next; - irel_list->next = bfd_malloc (sizeof (struct elf_nds32_ifc_irel_list)); - irel_list = irel_list->next; - irel_list->irel = irel; - irel_list->keep = 1; +int +list_insert_sibling (relax_group_list_t *pNode, Elf_Internal_Rela *pElem); - if (h == NULL) - irel_list->sec = NULL; - else - irel_list->sec = sec; - irel_list->next = NULL; - return; - } - if (ptr->next == NULL) - break; - ptr = ptr->next; - } +void +dump_chain (relax_group_list_t *pHead); - /* There is no same target entry, so build a new one. */ - if (ifc_symbol_head == NULL) - { - ifc_symbol_head = bfd_malloc (sizeof (struct elf_nds32_ifc_symbol_entry)); - ptr = ifc_symbol_head; - } - else +int +list_insert (relax_group_list_t *pHead, Elf_Internal_Rela *pElem) +{ + relax_group_list_t *pNext = pHead; + + /* find place */ + while (pNext->next) { - ptr->next = bfd_malloc (sizeof (struct elf_nds32_ifc_symbol_entry)); - ptr = ptr->next; + if (pNext->next->id > (int) pElem->r_addend) + break; + + pNext = pNext->next; } - ptr->h = h; - ptr->irel_head = bfd_malloc (sizeof (struct elf_nds32_ifc_irel_list)); - ptr->irel_head->irel = irel; - ptr->insn = insn; - ptr->irel_head->keep = 1; + /* insert node */ + relax_group_list_t *pNew = bfd_malloc (sizeof (relax_group_list_t)); + if (!pNew) + return FALSE; - if (h == NULL) - { - /* Local symbols. */ - ptr->sec = sec; - ptr->irel_head->sec = NULL; - } - else - { - /* Global symbol. */ - ptr->sec = NULL; - ptr->irel_head->sec = sec; - } + relax_group_list_t *tmp = pNext->next; + pNext->next = pNew; - ptr->irel_head->next = NULL; - ptr->times = 0; - ptr->enable = 0; - ptr->ex9_enable = 0; - ptr->next = NULL; -} + pNew->id = pElem->r_addend; + pNew->relo = pElem; + pNew->next = tmp; + pNew->next_sibling = NULL; -/* Gather all jal and j instructions. */ + return TRUE; +} -static bfd_boolean -nds32_elf_ifc_calc (struct bfd_link_info *info, - bfd *abfd, asection *sec) +int +list_insert_sibling (relax_group_list_t *pNode, Elf_Internal_Rela *pElem) { - Elf_Internal_Rela *internal_relocs; - Elf_Internal_Rela *irelend; - Elf_Internal_Rela *irel; - Elf_Internal_Shdr *symtab_hdr; - bfd_byte *contents = NULL; - uint32_t insn, insn_with_reg; - unsigned long r_symndx; - struct elf_link_hash_entry *h; - struct elf_link_hash_entry **sym_hashes = elf_sym_hashes (abfd); - struct elf_nds32_link_hash_table *table; - bfd_boolean ifc_loop_aware; + relax_group_list_t *pNext = pNode; - internal_relocs = _bfd_elf_link_read_relocs (abfd, sec, NULL, NULL, - TRUE /* keep_memory */); - irelend = internal_relocs + sec->reloc_count; - symtab_hdr = &elf_tdata (abfd)->symtab_hdr; + /* find place */ + while (pNext->next_sibling) + { + pNext = pNext->next_sibling; + } - /* Check if the object enable ifc. */ - irel = find_relocs_at_address (internal_relocs, internal_relocs, irelend, - R_NDS32_RELAX_ENTRY); + /* insert node */ + relax_group_list_t *pNew = bfd_malloc (sizeof (relax_group_list_t)); + if (!pNew) + return FALSE; - if (irel == NULL - || irel >= irelend - || ELF32_R_TYPE (irel->r_info) != R_NDS32_RELAX_ENTRY - || (ELF32_R_TYPE (irel->r_info) == R_NDS32_RELAX_ENTRY - && !(irel->r_addend & R_NDS32_RELAX_ENTRY_IFC_FLAG))) - return TRUE; + relax_group_list_t *tmp = pNext->next_sibling; + pNext->next_sibling = pNew; - if (!nds32_get_section_contents (abfd, sec, &contents, TRUE)) - return FALSE; + pNew->id = -1; + pNew->relo = pElem; + pNew->next = NULL; + pNew->next_sibling = tmp; - table = nds32_elf_hash_table (info); - ifc_loop_aware = table->ifc_loop_aware; - while (irel != NULL && irel < irelend) - { - /* Traverse all relocation and gather all of them to build the list. */ + return TRUE; +} - if (ELF32_R_TYPE (irel->r_info) == R_NDS32_RELAX_REGION_BEGIN) +void +dump_chain (relax_group_list_t *pHead) +{ + relax_group_list_t *pNext = pHead->next; + while (pNext) + { + printf("group %d @ 0x%08x", pNext->id, (unsigned)pNext->relo->r_offset); + relax_group_list_t *pNextSib = pNext->next_sibling; + while (pNextSib) { - if (ifc_loop_aware == 1 - && (irel->r_addend & R_NDS32_RELAX_REGION_INNERMOST_LOOP_FLAG) != 0) - { - /* Check the region if loop or not. If it is true and - ifc-loop-aware is true, ignore the region till region end. */ - while (irel != NULL - && irel < irelend - && (ELF32_R_TYPE (irel->r_info) != R_NDS32_RELAX_REGION_END - || (irel->r_addend & R_NDS32_RELAX_REGION_INNERMOST_LOOP_FLAG) != 0)) - irel++; - } + printf(", %d", (unsigned) ELF32_R_TYPE (pNextSib->relo->r_info)); + pNextSib = pNextSib->next_sibling; } + pNext = pNext->next; + printf("\n"); + } +} - if (ELF32_R_TYPE (irel->r_info) == R_NDS32_25_PCREL_RELA) +/* check R_NDS32_RELAX_GROUP of each section. + there might be multiple sections in one object file. */ +int +elf32_nds32_check_relax_group (bfd *abfd, asection *asec) +{ + elf32_nds32_relax_group_t *relax_group_ptr = + elf32_nds32_relax_group_ptr (abfd); + + int min_id = relax_group_ptr->min_id; + int max_id = relax_group_ptr->max_id; + + Elf_Internal_Rela *rel; + Elf_Internal_Rela *relend; + Elf_Internal_Rela *relocs; + enum elf_nds32_reloc_type rtype; + + do + { + /* Relocations MUST be kept in memory, because relaxation adjust them. */ + relocs = _bfd_elf_link_read_relocs (abfd, asec, NULL, NULL, + TRUE /* keep_memory */); + if (relocs == NULL) + break; + + /* check R_NDS32_RELAX_GROUP */ + relend = relocs + asec->reloc_count; + for (rel = relocs; rel < relend; rel++) { - insn = bfd_getb32 (contents + irel->r_offset); - nds32_elf_get_insn_with_reg (irel, insn, &insn_with_reg); - r_symndx = ELF32_R_SYM (irel->r_info); - if (r_symndx < symtab_hdr->sh_info) - { - /* Local symbol. */ - nds32_elf_ifc_insert_symbol (sec, NULL, irel, insn_with_reg); - } - else - { - /* External symbol. */ - h = sym_hashes[r_symndx - symtab_hdr->sh_info]; - nds32_elf_ifc_insert_symbol (sec, h, irel, insn_with_reg); - } + int id; + rtype = ELF32_R_TYPE (rel->r_info); + if (rtype != R_NDS32_RELAX_GROUP) + continue; + + id = rel->r_addend; + if (id < min_id) + min_id = id; + else if (id > max_id) + max_id = id; } - irel++; } - return TRUE; + while (FALSE); + + if ((relocs != NULL) && (elf_section_data (asec)->relocs != relocs)) + free (relocs); + + if ((min_id != relax_group_ptr->min_id) + || (max_id != relax_group_ptr->max_id)) + { + relax_group_ptr->count = max_id - min_id + 1; + BFD_ASSERT(min_id <= relax_group_ptr->min_id); + relax_group_ptr->min_id = min_id; + BFD_ASSERT(max_id >= relax_group_ptr->max_id); + relax_group_ptr->max_id = max_id; + } + + return relax_group_ptr->count; } -/* Determine whether j and jal should be substituted. */ +/* Reorder RELAX_GROUP ID when command line option '-r' is applied. */ +/* TODO: find a way to free me. */ +struct section_id_list_t *relax_group_section_id_list = NULL; -static void -nds32_elf_ifc_filter (struct bfd_link_info *info) +struct section_id_list_t * +elf32_nds32_lookup_section_id (int id, struct section_id_list_t **lst_ptr) { - struct elf_nds32_ifc_symbol_entry *ptr = ifc_symbol_head; - struct elf_nds32_ifc_irel_list *irel_ptr = NULL; - struct elf_nds32_ifc_irel_list *irel_keeper = NULL; - struct elf_nds32_link_hash_table *table; - int target_optimize; - bfd_vma address; + struct section_id_list_t *result = NULL; + struct section_id_list_t *lst = *lst_ptr; - table = nds32_elf_hash_table (info); - target_optimize = table->target_optimize; - while (ptr) + if (NULL == lst) { - irel_ptr = ptr->irel_head; - if (ptr->h == NULL) + result = (struct section_id_list_t *) calloc ( + 1, sizeof (struct section_id_list_t)); + BFD_ASSERT (result); /* feed me */ + result->id = id; + *lst_ptr = result; + } + else + { + struct section_id_list_t *cur = lst; + struct section_id_list_t *prv = NULL; + struct section_id_list_t *sec = NULL; + while (cur) { - /* Local symbol. */ - irel_keeper = irel_ptr; - while (irel_ptr && irel_ptr->next) + if (cur->id < id) { - /* Check there is jump target can be used. */ - if ((irel_ptr->next->irel->r_offset - - irel_keeper->irel->r_offset) > 1022) - irel_keeper = irel_ptr->next; - else - { - ptr->enable = 1; - irel_ptr->keep = 0; - } - irel_ptr = irel_ptr->next; + prv = cur; + cur = cur->next; + continue; } - } - else - { - /* Global symbol. */ - /* We have to get the absolute address and decide - whether to keep it or not. */ - while (irel_ptr) + + if (cur->id > id) { - address = (irel_ptr->irel->r_offset - + irel_ptr->sec->output_section->vma - + irel_ptr->sec->output_offset); - irel_ptr->addr = address; - irel_ptr = irel_ptr->next; + cur = NULL; /* to insert after prv */ + sec = cur; /* in case prv == NULL */ } - irel_ptr = ptr->irel_head; - while (irel_ptr) - { - /* Sort by address. */ - struct elf_nds32_ifc_irel_list *irel_dest = irel_ptr; - struct elf_nds32_ifc_irel_list *irel_temp = irel_ptr; - struct elf_nds32_ifc_irel_list *irel_ptr_prev = NULL; - struct elf_nds32_ifc_irel_list *irel_dest_prev = NULL; - - /* Get the smallest one. */ - while (irel_temp->next) - { - if (irel_temp->next->addr < irel_dest->addr) - { - irel_dest_prev = irel_temp; - irel_dest = irel_temp->next; - } - irel_temp = irel_temp->next; - } + break; + } - if (irel_dest != irel_ptr) - { - if (irel_ptr_prev) - irel_ptr_prev->next = irel_dest; - if (irel_dest_prev) - irel_dest_prev->next = irel_ptr; - irel_temp = irel_ptr->next; - irel_ptr->next = irel_dest->next; - irel_dest->next = irel_temp; - } - irel_ptr_prev = irel_ptr; - irel_ptr = irel_ptr->next; + if (NULL == cur) + { + /* insert after prv */ + result = (struct section_id_list_t *) calloc ( + 1, sizeof (struct section_id_list_t)); + BFD_ASSERT (result); /* feed me */ + result->id = id; + if (NULL != prv) + { + result->next = prv->next; + prv->next = result; } - - irel_ptr = ptr->irel_head; - irel_keeper = irel_ptr; - while (irel_ptr && irel_ptr->next) + else { - if ((irel_ptr->next->addr - irel_keeper->addr) > 1022) - irel_keeper = irel_ptr->next; - else - { - ptr->enable = 1; - irel_ptr->keep = 0; - } - irel_ptr = irel_ptr->next; + *lst_ptr = result; + result->next = sec; } } - - /* Ex9 enable. Reserve it for ex9. */ - if ((target_optimize & NDS32_RELAX_EX9_ON) - && ptr->irel_head != irel_keeper) - ptr->enable = 0; - ptr = ptr->next; } -} -/* Determine whether j and jal should be substituted after ex9 done. */ + return result; +} -static void -nds32_elf_ifc_filter_after_ex9 (void) +int +elf32_nds32_unify_relax_group (bfd *abfd, asection *asec) { - struct elf_nds32_ifc_symbol_entry *ptr = ifc_symbol_head; - struct elf_nds32_ifc_irel_list *irel_ptr = NULL; + static int next_relax_group_bias = 0; + + elf32_nds32_relax_group_t *relax_group_ptr = + elf32_nds32_relax_group_ptr (abfd); + + bfd_boolean result = TRUE; + Elf_Internal_Rela *rel; + Elf_Internal_Rela *relend; + Elf_Internal_Rela *relocs = NULL; + enum elf_nds32_reloc_type rtype; + struct section_id_list_t *node = NULL; + int count = 0; - while (ptr) + do { - if (ptr->enable == 0) + if (0 == relax_group_ptr->count) + break; + + /* check if this section has handled */ + node = elf32_nds32_lookup_section_id (asec->id, &relax_group_section_id_list); + if (NULL == node) + break; /* hit, the section id has handled. */ + + /* Relocations MUST be kept in memory, because relaxation adjust them. */ + relocs = _bfd_elf_link_read_relocs (abfd, asec, NULL, NULL, + TRUE /* keep_memory */); + if (relocs == NULL) { - /* Check whether ifc is applied or not. */ - irel_ptr = ptr->irel_head; - ptr->ex9_enable = 1; - while (irel_ptr) - { - if (ELF32_R_TYPE (irel_ptr->irel->r_info) == R_NDS32_TRAN) - { - /* Ex9 already. */ - ptr->ex9_enable = 0; - break; - } - irel_ptr = irel_ptr->next; - } + BFD_ASSERT (0); /* feed me */ + break; } - ptr = ptr->next; - } -} - -/* Wrapper to do ifc relaxation. */ -bfd_boolean -nds32_elf_ifc_finish (struct bfd_link_info *info) -{ - int relax_status; - struct elf_nds32_link_hash_table *table; + /* allocate group id bias for this bfd! */ + if (0 == relax_group_ptr->init) + { + relax_group_ptr->bias = next_relax_group_bias; + next_relax_group_bias += relax_group_ptr->count; + relax_group_ptr->init = 1; + } - table = nds32_elf_hash_table (info); - relax_status = table->relax_status; + /* reorder relax group groups */ + relend = relocs + asec->reloc_count; + for (rel = relocs; rel < relend; rel++) + { + rtype = ELF32_R_TYPE(rel->r_info); + if (rtype != R_NDS32_RELAX_GROUP) + continue; - if (!(relax_status & NDS32_RELAX_JUMP_IFC_DONE)) - nds32_elf_ifc_filter (info); - else - nds32_elf_ifc_filter_after_ex9 (); + /* change it */ + rel->r_addend += relax_group_ptr->bias; + /* debugging count */ + count++; + } + } + while (FALSE); - if (!nds32_elf_ifc_replace (info)) - return FALSE; + if (relocs != NULL && elf_section_data (asec)->relocs != relocs) + free (relocs); - if (table) - table->relax_status |= NDS32_RELAX_JUMP_IFC_DONE; - return TRUE; + return result; } -/* Traverse the result of ifc filter and replace it with ifcall9. */ - -static bfd_boolean -nds32_elf_ifc_replace (struct bfd_link_info *info) +int +nds32_elf_unify_tls_model (bfd *inbfd, asection *insec, bfd_byte *incontents, + struct bfd_link_info *lnkinfo) { - struct elf_nds32_ifc_symbol_entry *ptr = ifc_symbol_head; - struct elf_nds32_ifc_irel_list *irel_ptr = NULL; - nds32_elf_blank_t *relax_blank_list = NULL; - bfd_byte *contents = NULL; - Elf_Internal_Rela *internal_relocs; + bfd_boolean result = TRUE; Elf_Internal_Rela *irel; Elf_Internal_Rela *irelend; - unsigned short insn16 = INSN_IFCALL9; - struct elf_nds32_link_hash_table *table; - int relax_status; + Elf_Internal_Rela *internal_relocs; + unsigned long r_symndx; + enum elf_nds32_reloc_type r_type; - table = nds32_elf_hash_table (info); - relax_status = table->relax_status; + Elf_Internal_Sym *local_syms = NULL; + bfd_byte *contents = NULL; - while (ptr) + relax_group_list_t chain = { .id = -1, .next = NULL, .next_sibling = NULL }; + + Elf_Internal_Shdr *symtab_hdr = &elf_tdata (inbfd)->symtab_hdr; + struct elf_link_hash_entry **sym_hashes, **sym_hashes_end; + sym_hashes = elf_sym_hashes (inbfd); + sym_hashes_end = + sym_hashes + symtab_hdr->sh_size / sizeof (Elf32_External_Sym); + if (!elf_bad_symtab (inbfd)) + sym_hashes_end -= symtab_hdr->sh_info; + + /* reorder RELAX_GROUP when command line option '-r' is applied */ + if (bfd_link_relocatable (lnkinfo)) { - /* Traverse the ifc gather list, and replace the - filter entries by ifcall9. */ - if ((!(relax_status & NDS32_RELAX_JUMP_IFC_DONE) && ptr->enable == 1) - || ((relax_status & NDS32_RELAX_JUMP_IFC_DONE) - && ptr->ex9_enable == 1)) - { - irel_ptr = ptr->irel_head; - if (ptr->h == NULL) - { - /* Local symbol. */ - internal_relocs = _bfd_elf_link_read_relocs - (ptr->sec->owner, ptr->sec, NULL, NULL, TRUE /* keep_memory */); - irelend = internal_relocs + ptr->sec->reloc_count; + elf32_nds32_unify_relax_group (inbfd, insec); + /* goto finish; */ + return result; + } - if (!nds32_get_section_contents (ptr->sec->owner, ptr->sec, - &contents, TRUE)) - return FALSE; + /* Relocations MUST be kept in memory, because relaxation adjust them. */ + internal_relocs = _bfd_elf_link_read_relocs (inbfd, insec, NULL, NULL, + TRUE /* keep_memory */); + if (internal_relocs == NULL) + goto error_return; - while (irel_ptr) - { - if (irel_ptr->keep == 0 && irel_ptr->next) - { - /* The one can be replaced. We have to check whether - there is any alignment point in the region. */ - irel = irel_ptr->irel; - while (((irel_ptr->next->keep == 0 - && irel < irel_ptr->next->irel) - || (irel_ptr->next->keep == 1 && irel < irelend)) - && !(ELF32_R_TYPE (irel->r_info) == R_NDS32_LABEL - && (irel->r_addend & 0x1f) == 2)) - irel++; - if (irel >= irelend - || !(ELF32_R_TYPE (irel->r_info) == R_NDS32_LABEL - && (irel->r_addend & 0x1f) == 2 - && ((irel->r_offset - get_nds32_elf_blank_total - (&relax_blank_list, irel->r_offset, 1)) - & 0x02) == 0)) - { - /* Replace by ifcall9. */ - bfd_putb16 (insn16, contents + irel_ptr->irel->r_offset); - if (!insert_nds32_elf_blank_recalc_total - (&relax_blank_list, irel_ptr->irel->r_offset + 2, 2)) - return FALSE; - irel_ptr->irel->r_info = - ELF32_R_INFO (ELF32_R_SYM (irel_ptr->irel->r_info), - R_NDS32_10IFCU_PCREL_RELA); - } - } - irel_ptr = irel_ptr->next; - } + irelend = internal_relocs + insec->reloc_count; + irel = find_relocs_at_address (internal_relocs, internal_relocs, + irelend, R_NDS32_RELAX_ENTRY); + if (irel == irelend) + goto finish; - /* Delete the redundant code. */ - if (relax_blank_list) - { - nds32_elf_relax_delete_blanks (ptr->sec->owner, ptr->sec, - relax_blank_list); - relax_blank_list = NULL; - } - } - else + /* chain/remove groups */ + for (irel = internal_relocs; irel < irelend; irel++) + { + r_symndx = ELF32_R_SYM (irel->r_info); + r_type = ELF32_R_TYPE (irel->r_info); + if (r_type != R_NDS32_RELAX_GROUP) + continue; + + /* remove it */ + irel->r_info = ELF32_R_INFO (r_symndx, R_NDS32_NONE); + /* chain it now */ + if (!list_insert (&chain, irel)) + goto error_return; + } + + /* collect group relocations */ + /* presume relocations are sorted */ + relax_group_list_t *pNext = chain.next; + while (pNext) + { + for (irel = internal_relocs; irel < irelend; irel++) + { + if (irel->r_offset == pNext->relo->r_offset) { - /* Global symbol. */ - while (irel_ptr) - { - if (irel_ptr->keep == 0 && irel_ptr->next) - { - /* The one can be replaced, and we have to check - whether there is any alignment point in the region. */ - internal_relocs = _bfd_elf_link_read_relocs - (irel_ptr->sec->owner, irel_ptr->sec, NULL, NULL, - TRUE /* keep_memory */); - irelend = internal_relocs + irel_ptr->sec->reloc_count; - if (!nds32_get_section_contents (irel_ptr->sec->owner, - irel_ptr->sec, &contents, - TRUE)) - return FALSE; + /* ignore Non-TLS relocation types */ + r_type = ELF32_R_TYPE (irel->r_info); + if ((R_NDS32_TLS_LE_HI20 > r_type) + || (R_NDS32_RELAX_ENTRY == r_type)) + continue; - irel = irel_ptr->irel; - while (((irel_ptr->sec == irel_ptr->next->sec - && irel_ptr->next->keep == 0 - && irel < irel_ptr->next->irel) - || ((irel_ptr->sec != irel_ptr->next->sec - || irel_ptr->next->keep == 1) - && irel < irelend)) - && !(ELF32_R_TYPE (irel->r_info) == R_NDS32_LABEL - && (irel->r_addend & 0x1f) == 2)) - irel++; - if (irel >= irelend - || !(ELF32_R_TYPE (irel->r_info) == R_NDS32_LABEL - && (irel->r_addend & 0x1f) == 2 - && ((irel->r_offset - - get_nds32_elf_blank_total (&relax_blank_list, - irel->r_offset, 1)) & 0x02) == 0)) - { - /* Replace by ifcall9. */ - bfd_putb16 (insn16, contents + irel_ptr->irel->r_offset); - if (!insert_nds32_elf_blank_recalc_total - (&relax_blank_list, irel_ptr->irel->r_offset + 2, 2)) - return FALSE; - - /* Delete the redundant code, and clear the relocation. */ - nds32_elf_relax_delete_blanks (irel_ptr->sec->owner, - irel_ptr->sec, - relax_blank_list); - irel_ptr->irel->r_info = - ELF32_R_INFO (ELF32_R_SYM (irel_ptr->irel->r_info), - R_NDS32_10IFCU_PCREL_RELA); - relax_blank_list = NULL; - } - } + if (!list_insert_sibling (pNext, irel)) + goto error_return; + } + else if (irel->r_offset > pNext->relo->r_offset) + { + pNext = pNext->next; + if (!pNext) + break; - irel_ptr = irel_ptr->next; - } + bfd_vma current_offset = pNext->relo->r_offset; + if (irel->r_offset > current_offset) + irel = internal_relocs; /* restart from head */ + else + --irel; /* check current irel again */ + continue; + } + else + { + //printf("irel->off = 0x%08x, pNext->relo->off = 0x%08x (0x%08x)\n", (unsigned)irel->r_offset, (unsigned)pNext->relo->r_offset, (unsigned)first_offset); } } - ptr = ptr->next; + if (pNext) + pNext = pNext->next; } - return TRUE; -} - -/* Relocate ifcall. */ - -static bfd_boolean -nds32_elf_ifc_reloc (void) -{ - struct elf_nds32_ifc_symbol_entry *ptr = ifc_symbol_head; - struct elf_nds32_ifc_irel_list *irel_ptr = NULL; - struct elf_nds32_ifc_irel_list *irel_keeper = NULL; - bfd_vma relocation, address; - unsigned short insn16; - bfd_byte *contents = NULL; - static bfd_boolean done = FALSE; +#ifdef DUBUG_VERBOSE + dump_chain(&chain); +#endif - if (done) - return TRUE; + /* Get symbol table and section content. */ + if (incontents) + contents = incontents; + else if (!nds32_get_section_contents (inbfd, insec, &contents, TRUE) + || !nds32_get_local_syms (inbfd, insec, &local_syms)) + goto error_return; - done = TRUE; + char *local_got_tls_type = elf32_nds32_local_got_tls_type (inbfd); - while (ptr) + /* convert TLS model each group if necessary */ + pNext = chain.next; + int cur_grp_id = -1; + int sethi_rt = -1; + int add_rt = -1; + enum elf_nds32_tls_type tls_type, org_tls_type, eff_tls_type; + tls_type = org_tls_type = eff_tls_type = 0; + while (pNext) { - /* Check the entry is enable ifcall. */ - if (ptr->enable == 1 || ptr->ex9_enable == 1) + relax_group_list_t *pNextSig = pNext->next_sibling; + while (pNextSig) { - /* Get the reserve jump. */ - irel_ptr = ptr->irel_head; - while (irel_ptr) + struct elf_link_hash_entry *h = NULL; + irel = pNextSig->relo; + r_symndx = ELF32_R_SYM(irel->r_info); + r_type = ELF32_R_TYPE(irel->r_info); + + if (pNext->id != cur_grp_id) { - if (irel_ptr->keep == 1) + cur_grp_id = pNext->id; + org_tls_type = get_tls_type (r_type, NULL); + if (r_symndx >= symtab_hdr->sh_info) { - irel_keeper = irel_ptr; - break; + h = sym_hashes[r_symndx - symtab_hdr->sh_info]; + while (h->root.type == bfd_link_hash_indirect + || h->root.type == bfd_link_hash_warning) + h = (struct elf_link_hash_entry *) h->root.u.i.link; + tls_type = ((struct elf_nds32_link_hash_entry *) h)->tls_type; + } + else + { + /* TODO: find local symbol hash if necessary? */ + tls_type = local_got_tls_type ? local_got_tls_type[r_symndx] : GOT_NORMAL; } - irel_ptr = irel_ptr->next; + + eff_tls_type = 1 << (fls (tls_type) - 1); + sethi_rt = N32_RT5(bfd_getb32 (contents + irel->r_offset)); } - irel_ptr = ptr->irel_head; - if (ptr->h == NULL) + if (eff_tls_type != org_tls_type) { - /* Local symbol. */ - if (!nds32_get_section_contents (ptr->sec->owner, ptr->sec, - &contents, TRUE)) - return FALSE; - - while (irel_ptr) + switch (org_tls_type) { - if (irel_ptr->keep == 0 - && ELF32_R_TYPE (irel_ptr->irel->r_info) == R_NDS32_10IFCU_PCREL_RELA) + /* DESC to IEGP/IE/LE. */ + case GOT_TLS_DESC: + switch (eff_tls_type) { - relocation = irel_keeper->irel->r_offset; - relocation = relocation - irel_ptr->irel->r_offset; - while (irel_keeper && relocation > 1022) + case GOT_TLS_IE: + switch (r_type) { - irel_keeper = irel_keeper->next; - if (irel_keeper && irel_keeper->keep == 1) - { - relocation = irel_keeper->irel->r_offset; - relocation = relocation - irel_ptr->irel->r_offset; - } + case R_NDS32_TLS_DESC_HI20: + irel->r_info = ELF32_R_INFO(r_symndx, + R_NDS32_TLS_IE_HI20); + break; + case R_NDS32_TLS_DESC_LO12: + irel->r_info = ELF32_R_INFO(r_symndx, + R_NDS32_TLS_IE_LO12); + break; + case R_NDS32_TLS_DESC_ADD: + { + uint32_t insn = bfd_getb32 ( + contents + irel->r_offset); + add_rt = N32_RT5 (insn); + insn = N32_TYPE2 (LWI, add_rt, sethi_rt, 0); + bfd_putb32 (insn, contents + irel->r_offset); + + irel->r_info = ELF32_R_INFO(r_symndx, R_NDS32_NONE); +/* irel->r_info = ELF32_R_INFO (r_symndx, R_NDS32_TLS_IE_LW); +*/ + } + break; + case R_NDS32_TLS_DESC_FUNC: + bfd_putb32 (INSN_NOP, contents + irel->r_offset); + irel->r_info = ELF32_R_INFO(r_symndx, + R_NDS32_RELAX_REMOVE); + break; + case R_NDS32_TLS_DESC_CALL: + { + uint32_t insn = N32_ALU1(ADD, REG_R0, add_rt, + REG_TP); + bfd_putb32 (insn, contents + irel->r_offset); + + irel->r_info = ELF32_R_INFO(r_symndx, R_NDS32_NONE); + } + break; + case R_NDS32_LOADSTORE: + case R_NDS32_PTR: + case R_NDS32_PTR_RESOLVED: + case R_NDS32_NONE: + case R_NDS32_LABEL: + break; + default: + BFD_ASSERT(0); + break; } - if (relocation > 1022) + break; + case GOT_TLS_IEGP: + switch (r_type) { - /* Double check. */ - irel_keeper = ptr->irel_head; - while (irel_keeper) - { - if (irel_keeper->keep == 1) - { - relocation = irel_keeper->irel->r_offset; - relocation = relocation - irel_ptr->irel->r_offset; - } - if (relocation <= 1022) - break; - irel_keeper = irel_keeper->next; - } - if (!irel_keeper) - return FALSE; + case R_NDS32_TLS_DESC_HI20: + irel->r_info = ELF32_R_INFO(r_symndx, + R_NDS32_TLS_IEGP_HI20); + break; + case R_NDS32_TLS_DESC_LO12: + irel->r_info = ELF32_R_INFO(r_symndx, + R_NDS32_TLS_IEGP_LO12); + break; + case R_NDS32_TLS_DESC_ADD: + { + uint32_t insn = bfd_getb32 ( + contents + irel->r_offset); + add_rt = N32_RT5 (insn); + insn = N32_MEM(LW, add_rt, sethi_rt, REG_GP, 0); + bfd_putb32 (insn, contents + irel->r_offset); + + irel->r_info = ELF32_R_INFO(r_symndx, R_NDS32_NONE); +/* irel->r_info = ELF32_R_INFO (r_symndx, R_NDS32_TLS_IEGP_LW); +*/ + } + break; + case R_NDS32_TLS_DESC_FUNC: + bfd_putb32 (INSN_NOP, contents + irel->r_offset); + irel->r_info = ELF32_R_INFO(r_symndx, + R_NDS32_RELAX_REMOVE); + break; + case R_NDS32_TLS_DESC_CALL: + { + uint32_t insn = N32_ALU1(ADD, REG_R0, add_rt, + REG_TP); + bfd_putb32 (insn, contents + irel->r_offset); + + irel->r_info = ELF32_R_INFO(r_symndx, R_NDS32_NONE); + } + break; + case R_NDS32_LOADSTORE: + case R_NDS32_PTR: + case R_NDS32_PTR_RESOLVED: + case R_NDS32_NONE: + case R_NDS32_LABEL: + break; + default: + BFD_ASSERT(0); + break; } - irel_ptr->irel->r_info = - ELF32_R_INFO (ELF32_R_SYM (irel_ptr->irel->r_info), - R_NDS32_NONE); - insn16 = INSN_IFCALL9 | (relocation >> 1); - bfd_putb16 (insn16, contents + irel_ptr->irel->r_offset); + break; + case GOT_TLS_LE: + switch (r_type) + { + case R_NDS32_TLS_DESC_HI20: + irel->r_info = ELF32_R_INFO (r_symndx, R_NDS32_TLS_LE_HI20); + break; + case R_NDS32_TLS_DESC_LO12: + irel->r_info = ELF32_R_INFO (r_symndx, R_NDS32_TLS_LE_LO12); + break; + case R_NDS32_TLS_DESC_ADD: + { + uint32_t insn = bfd_getb32 (contents + irel->r_offset); + add_rt = N32_RT5 (insn); + insn = N32_ALU1 (ADD, REG_R0, sethi_rt, REG_TP); + bfd_putb32 (insn, contents + irel->r_offset); + + irel->r_info = ELF32_R_INFO (r_symndx, R_NDS32_TLS_LE_ADD); + } + break; + case R_NDS32_TLS_DESC_FUNC: + bfd_putb32 (INSN_NOP, contents + irel->r_offset); + irel->r_info = ELF32_R_INFO (r_symndx, R_NDS32_RELAX_REMOVE); + break; + case R_NDS32_TLS_DESC_CALL: + bfd_putb32 (INSN_NOP, contents + irel->r_offset); + irel->r_info = ELF32_R_INFO (r_symndx, R_NDS32_RELAX_REMOVE); + break; + case R_NDS32_LOADSTORE: + case R_NDS32_PTR: + case R_NDS32_PTR_RESOLVED: + case R_NDS32_NONE: + case R_NDS32_LABEL: + break; + default: + BFD_ASSERT(0); + break; + } + break; + default: +#ifdef DEBUG_VERBOSE + printf ( + "SKIP: %s: %s @ 0x%08x tls_type = 0x%08x, eff_tls_type = 0x%08x, org_tls_type = 0x%08x\n", + inbfd->filename, h ? h->root.root.string : "local", + (unsigned) irel->r_offset, tls_type, eff_tls_type, + org_tls_type); +#endif + break; } - irel_ptr = irel_ptr->next; - } - } - else - { - /* Global symbol. */ - while (irel_ptr) - { - if (irel_ptr->keep == 0 - && ELF32_R_TYPE (irel_ptr->irel->r_info) == R_NDS32_10IFCU_PCREL_RELA) + break; + /* IEGP to IE/LE. */ + case GOT_TLS_IEGP: + switch (eff_tls_type) { - /* Get the distance between ifcall and jump. */ - relocation = (irel_keeper->irel->r_offset - + irel_keeper->sec->output_section->vma - + irel_keeper->sec->output_offset); - address = (irel_ptr->irel->r_offset - + irel_ptr->sec->output_section->vma - + irel_ptr->sec->output_offset); - relocation = relocation - address; - - /* The distance is over ragne, find callee again. */ - while (irel_keeper && relocation > 1022) + case GOT_TLS_IE: + switch (r_type) { - irel_keeper = irel_keeper->next; - if (irel_keeper && irel_keeper->keep ==1) - { - relocation = (irel_keeper->irel->r_offset - + irel_keeper->sec->output_section->vma - + irel_keeper->sec->output_offset); - relocation = relocation - address; - } + case R_NDS32_TLS_IEGP_HI20: + irel->r_info = ELF32_R_INFO(r_symndx, + R_NDS32_TLS_IE_HI20); + break; + case R_NDS32_TLS_IEGP_LO12: + irel->r_info = ELF32_R_INFO(r_symndx, + R_NDS32_TLS_IE_LO12); + break; + case R_NDS32_PTR_RESOLVED: + { + uint32_t insn = bfd_getb32 ( + contents + irel->r_offset); + add_rt = N32_RT5 (insn); + insn = N32_TYPE2 (LWI, add_rt, sethi_rt, 0); + bfd_putb32 (insn, contents + irel->r_offset); + } + break; + case R_NDS32_TLS_IEGP_LW: + break; + case R_NDS32_LOADSTORE: + case R_NDS32_PTR: + case R_NDS32_NONE: + case R_NDS32_LABEL: + break; + default: + BFD_ASSERT(0); + break; } - - if (relocation > 1022) + break; + case GOT_TLS_LE: + switch (r_type) { - /* Double check. */ - irel_keeper = ptr->irel_head; - while (irel_keeper) - { - if (irel_keeper->keep == 1) - { - - relocation = (irel_keeper->irel->r_offset - + irel_keeper->sec->output_section->vma - + irel_keeper->sec->output_offset); - relocation = relocation - address; - } - if (relocation <= 1022) - break; - irel_keeper = irel_keeper->next; - } - if (!irel_keeper) - return FALSE; + case R_NDS32_TLS_IEGP_HI20: + irel->r_info = ELF32_R_INFO (r_symndx, R_NDS32_TLS_LE_HI20); + break; + case R_NDS32_TLS_IEGP_LO12: + irel->r_info = ELF32_R_INFO (r_symndx, R_NDS32_TLS_LE_LO12); + break; + case R_NDS32_TLS_IEGP_LW: + /* irel->r_info = ELF32_R_INFO(r_symndx, R_NDS32_TLS_LE_ADD); */ + bfd_putb32 (INSN_NOP, contents + irel->r_offset); + irel->r_info = ELF32_R_INFO (r_symndx, R_NDS32_RELAX_REMOVE); + break; + case R_NDS32_LOADSTORE: + case R_NDS32_PTR: + case R_NDS32_NONE: + case R_NDS32_LABEL: + case R_NDS32_PTR_RESOLVED: + break; + default: + BFD_ASSERT(0); + break; } - if (!nds32_get_section_contents - (irel_ptr->sec->owner, irel_ptr->sec, &contents, TRUE)) - return FALSE; - insn16 = INSN_IFCALL9 | (relocation >> 1); - bfd_putb16 (insn16, contents + irel_ptr->irel->r_offset); - irel_ptr->irel->r_info = - ELF32_R_INFO (ELF32_R_SYM (irel_ptr->irel->r_info), - R_NDS32_NONE); + break; + default: +#ifdef DEBUG_VERBOSE + printf ( + "SKIP: %s: %s @ 0x%08x tls_type = 0x%08x, eff_tls_type = 0x%08x, org_tls_type = 0x%08x\n", + inbfd->filename, h ? h->root.root.string : "local", + (unsigned) irel->r_offset, tls_type, eff_tls_type, + org_tls_type); +#endif + break; + } + break; + /* IE to LE. */ + case GOT_TLS_IE: + switch (eff_tls_type) + { + case GOT_TLS_LE: + switch (r_type) + { + case R_NDS32_TLS_IE_HI20: + irel->r_info = ELF32_R_INFO (r_symndx, R_NDS32_TLS_LE_HI20); + break; + case R_NDS32_TLS_IE_LO12S2: + { + uint32_t insn = bfd_getb32 (contents + irel->r_offset); + add_rt = N32_RT5 (insn); + insn = N32_TYPE2 (ORI, add_rt, sethi_rt, 0); + bfd_putb32 (insn, contents + irel->r_offset); + + irel->r_info = ELF32_R_INFO (r_symndx, R_NDS32_TLS_LE_LO12); + } + break; + /* + case R_NDS32_TLS_IE_ADD: + irel->r_info = ELF32_R_INFO (r_symndx, R_NDS32_TLS_LE_ADD); + break; + */ + case R_NDS32_LOADSTORE: + case R_NDS32_PTR: + case R_NDS32_NONE: + case R_NDS32_LABEL: + break; + default: + BFD_ASSERT(0); + break; + } + break; + default: +#ifdef DEBUG_VERBOSE + printf ( + "SKIP: %s: %s @ 0x%08x tls_type = 0x%08x, eff_tls_type = 0x%08x, org_tls_type = 0x%08x\n", + inbfd->filename, h ? h->root.root.string : "local", + (unsigned) irel->r_offset, tls_type, eff_tls_type, + org_tls_type); +#endif + break; } - irel_ptr =irel_ptr->next; + break; + default: +#ifdef DEBUG_VERBOSE + printf ( + "SKIP: %s: %s @ 0x%08x tls_type = 0x%08x, eff_tls_type = 0x%08x, org_tls_type = 0x%08x\n", + inbfd->filename, h ? h->root.root.string : "local", + (unsigned) irel->r_offset, tls_type, eff_tls_type, + org_tls_type); +#endif + break; } } + pNextSig = pNextSig->next_sibling; } - ptr = ptr->next; - } - - return TRUE; -} -/* End of IFC relaxation. */ - -/* EX9 Instruction Table Relaxation. */ +#if 1 + pNext = pNext->next; +#else + while (pNext) + { + if (pNext->id != cur_grp_id) + break; + pNext = pNext->next; + } +#endif + } -/* Global hash list. */ -struct elf_link_hash_entry_list -{ - struct elf_link_hash_entry *h; - struct elf_link_hash_entry_list *next; -}; +finish: + if (incontents) + contents = NULL; -/* Save different destination but same insn. */ -struct elf_link_hash_entry_mul_list -{ - /* Global symbol times. */ - int times; - /* Save relocation for each global symbol but useful?? */ - Elf_Internal_Rela *irel; - /* For sethi, two sethi may have the same high-part but different low-parts. */ - Elf_Internal_Rela rel_backup; - struct elf_link_hash_entry_list *h_list; - struct elf_link_hash_entry_mul_list *next; -}; + if (internal_relocs != NULL + && elf_section_data (insec)->relocs != internal_relocs) + free (internal_relocs); -/* Instruction hash table. */ -struct elf_nds32_code_hash_entry -{ - struct bfd_hash_entry root; - int times; - /* For insn that can use relocation or constant ex: sethi. */ - int const_insn; - asection *sec; - struct elf_link_hash_entry_mul_list *m_list; - /* Using r_addend. */ - Elf_Internal_Rela *irel; - /* Using r_info. */ - Elf_Internal_Rela rel_backup; -}; + if (contents != NULL + && elf_section_data (insec)->this_hdr.contents != contents) + free (contents); -/* Instruction count list. */ -struct elf_nds32_insn_times_entry -{ - const char *string; - int times; - int order; - asection *sec; - struct elf_link_hash_entry_mul_list *m_list; - Elf_Internal_Rela *irel; - Elf_Internal_Rela rel_backup; - struct elf_nds32_insn_times_entry *next; -}; + if (local_syms != NULL && symtab_hdr->contents != (bfd_byte *) local_syms) + free (local_syms); -/* J and JAL symbol list. */ -struct elf_nds32_symbol_entry -{ - char *string; - unsigned long insn; - struct elf_nds32_symbol_entry *next; -}; + if (chain.next) + { + pNext = chain.next; + relax_group_list_t *pDel; + while (pNext) + { + pDel = pNext; + pNext = pNext->next; + free (pDel); + } + } -/* Relocation list. */ -struct elf_nds32_irel_entry -{ - Elf_Internal_Rela *irel; - struct elf_nds32_irel_entry *next; -}; + return result; -/* ex9.it insn need to be fixed. */ -struct elf_nds32_ex9_refix -{ - Elf_Internal_Rela *irel; - asection *sec; - struct elf_link_hash_entry *h; - int order; - struct elf_nds32_ex9_refix *next; -}; +error_return: + result = FALSE; + goto finish; +} -static struct bfd_hash_table ex9_code_table; -static struct elf_nds32_insn_times_entry *ex9_insn_head = NULL; -static struct elf_nds32_ex9_refix *ex9_refix_head = NULL; +/* End TLS model conversion. */ + -/* EX9 hash function. */ +/* Rom-patch table hash function. */ static struct bfd_hash_entry * -nds32_elf_code_hash_newfunc (struct bfd_hash_entry *entry, - struct bfd_hash_table *table, - const char *string) +nds32_elf_ict_hash_newfunc (struct bfd_hash_entry *entry, + struct bfd_hash_table *table, + const char *string) { - struct elf_nds32_code_hash_entry *ret; + struct elf_nds32_ict_hash_entry *ret; /* Allocate the structure if it has not already been allocated by a subclass. */ @@ -13602,1837 +15149,118 @@ nds32_elf_code_hash_newfunc (struct bfd_hash_entry *entry, if (entry == NULL) return entry; - ret = (struct elf_nds32_code_hash_entry*) entry; - ret->times = 0; - ret->const_insn = 0; - ret->m_list = NULL; - ret->sec = NULL; - ret->irel = NULL; + ret = (struct elf_nds32_ict_hash_entry*) entry; + ret->order = 0; return &ret->root; } -/* Insert ex9 entry - this insert must be stable sorted by times. */ - static void -nds32_elf_ex9_insert_entry (struct elf_nds32_insn_times_entry *ptr) +nds32_elf_ict_hash_init (void) { - struct elf_nds32_insn_times_entry *temp; - struct elf_nds32_insn_times_entry *temp2; - - if (ex9_insn_head == NULL) - { - ex9_insn_head = ptr; - ptr->next = NULL; - } - else - { - temp = ex9_insn_head; - temp2 = ex9_insn_head; - while (temp->next && - (temp->next->times >= ptr->times - || temp->times == -1)) - { - if (temp->times == -1) - temp2 = temp; - temp = temp->next; - } - if (ptr->times > temp->times && temp->times != -1) - { - ptr->next = temp; - if (temp2->times == -1) - temp2->next = ptr; - else - ex9_insn_head = ptr; - } - else if (temp->next == NULL) - { - temp->next = ptr; - ptr->next = NULL; - } - else - { - ptr->next = temp->next; - temp->next = ptr; - } - } + if (!bfd_hash_table_init_n (&indirect_call_table, nds32_elf_ict_hash_newfunc, + sizeof (struct elf_nds32_ict_hash_entry), + 1023)) + _bfd_error_handler (_("ld error: cannot init rom patch hash table\n")); + return; } -/* Examine each insn times in hash table. - Handle multi-link hash entry. - - TODO: This function doesn't assign so much info since it is fake. */ - -static int -nds32_elf_examine_insn_times (struct elf_nds32_code_hash_entry *h) +/* Relocate for NDS32_ICT_SECTION. */ +static void +nds32_elf_ict_relocate (bfd *output_bfd, struct bfd_link_info *info) { - struct elf_nds32_insn_times_entry *ptr; - int times; - - if (h->m_list == NULL) - { - /* Local symbol insn or insn without relocation. */ - if (h->times < 3) - return TRUE; - - ptr = (struct elf_nds32_insn_times_entry *) - bfd_malloc (sizeof (struct elf_nds32_insn_times_entry)); - ptr->times = h->times; - ptr->string = h->root.string; - ptr->m_list = NULL; - ptr->sec = h->sec; - ptr->irel = h->irel; - ptr->rel_backup = h->rel_backup; - nds32_elf_ex9_insert_entry (ptr); - } - else - { - /* Global symbol insn. */ - /* Only sethi insn has multiple m_list. */ - struct elf_link_hash_entry_mul_list *m_list = h->m_list; + static bfd_boolean done = FALSE; + asection *sec; + bfd_byte *contents = NULL; + uint32_t insn; + unsigned int i; + struct elf_link_hash_entry *h; + struct bfd_link_hash_entry *h2; + bfd_vma relocation, base; - times = 0; - while (m_list) - { - times += m_list->times; - m_list = m_list->next; - } - if (times >= 3) - { - m_list = h->m_list; - ptr = (struct elf_nds32_insn_times_entry *) - bfd_malloc (sizeof (struct elf_nds32_insn_times_entry)); - ptr->times = times; /* Use the total times. */ - ptr->string = h->root.string; - ptr->m_list = m_list; - ptr->sec = h->sec; - ptr->irel = m_list->irel; - ptr->rel_backup = m_list->rel_backup; - nds32_elf_ex9_insert_entry (ptr); - } - if (h->const_insn == 1) - { - /* sethi with constant value. */ - if (h->times < 3) - return TRUE; + if (done) + return; - ptr = (struct elf_nds32_insn_times_entry *) - bfd_malloc (sizeof (struct elf_nds32_insn_times_entry)); - ptr->times = h->times; - ptr->string = h->root.string; - ptr->m_list = NULL; - ptr->sec = NULL; - ptr->irel = NULL; - ptr->rel_backup = h->rel_backup; - nds32_elf_ex9_insert_entry (ptr); - } - } - return TRUE; -} + done = TRUE; -/* Count each insn times in hash table. - Handle multi-link hash entry. */ + sec = nds32_elf_get_target_section (info, NDS32_ICT_SECTION); + h2 = bfd_link_hash_lookup (info->hash, "_INDIRECT_CALL_TABLE_BASE_", + FALSE, FALSE, FALSE); + base = ((h2->u.def.value + + h2->u.def.section->output_section->vma + + h2->u.def.section->output_offset)); -static int -nds32_elf_count_insn_times (struct elf_nds32_code_hash_entry *h) -{ - int reservation, times; - unsigned long relocation, min_relocation; - struct elf_nds32_insn_times_entry *ptr; + if (!nds32_get_section_contents (sec->owner, sec, &contents, TRUE)) + return; - if (h->m_list == NULL) - { - /* Local symbol insn or insn without relocation. */ - if (h->times < 3) - return TRUE; - ptr = (struct elf_nds32_insn_times_entry *) - bfd_malloc (sizeof (struct elf_nds32_insn_times_entry)); - ptr->times = h->times; - ptr->string = h->root.string; - ptr->m_list = NULL; - ptr->sec = h->sec; - ptr->irel = h->irel; - ptr->rel_backup = h->rel_backup; - nds32_elf_ex9_insert_entry (ptr); - } - else + indirect_call_table.frozen = 1; + for (i = 0; i < indirect_call_table.size; i++) { - /* Global symbol insn. */ - /* Only sethi insn has multiple m_list. */ - struct elf_link_hash_entry_mul_list *m_list = h->m_list; + struct bfd_hash_entry *p; + struct elf_nds32_ict_hash_entry *entry; - if (ELF32_R_TYPE (m_list->rel_backup.r_info) == R_NDS32_HI20_RELA - && m_list->next != NULL) + for (p = indirect_call_table.table[i]; p != NULL; p = p->next) { - /* Sethi insn has different symbol or addend but has same hi20. */ - times = 0; - reservation = 1; - relocation = 0; - min_relocation = 0xffffffff; - while (m_list) + entry = (struct elf_nds32_ict_hash_entry *) p; + insn = INSN_J; + h = entry->h; + if ((h->root.type == bfd_link_hash_defined + || h->root.type == bfd_link_hash_defweak) + && h->root.u.def.section != NULL + && h->root.u.def.section->output_section != NULL) { - /* Get the minimum sethi address - and calculate how many entry the sethi-list have to use. */ - if ((m_list->h_list->h->root.type == bfd_link_hash_defined - || m_list->h_list->h->root.type == bfd_link_hash_defweak) - && (m_list->h_list->h->root.u.def.section != NULL - && m_list->h_list->h->root.u.def.section->output_section != NULL)) + if (ict_model == R_NDS32_RELAX_ENTRY_ICT_LARGE) { - relocation = (m_list->h_list->h->root.u.def.value + - m_list->h_list->h->root.u.def.section->output_section->vma + - m_list->h_list->h->root.u.def.section->output_offset); - relocation += m_list->irel->r_addend; + insn = h->root.u.def.value + + h->root.u.def.section->output_section->vma + + h->root.u.def.section->output_offset; + bfd_put_32 (output_bfd, insn, contents + (entry->order) * 4); } else - relocation = 0; - if (relocation < min_relocation) - min_relocation = relocation; - times += m_list->times; - m_list = m_list->next; + { + relocation = h->root.u.def.value + + h->root.u.def.section->output_section->vma + + h->root.u.def.section->output_offset; + insn |= ((relocation - base - entry->order * 4) >> 1) + & 0xffffff; + bfd_putb32 (insn, contents + (entry->order) * 4); + } } - if (min_relocation < ex9_relax_size) - reservation = (min_relocation >> 12) + 1; else - reservation = (min_relocation >> 12) - - ((min_relocation - ex9_relax_size) >> 12) + 1; - if (reservation < (times / 3)) { - /* Efficient enough to use ex9. */ - int i; - - for (i = reservation ; i > 0; i--) + if (ict_model == R_NDS32_RELAX_ENTRY_ICT_LARGE) { - /* Allocate number of reservation ex9 entry. */ - ptr = (struct elf_nds32_insn_times_entry *) - bfd_malloc (sizeof (struct elf_nds32_insn_times_entry)); - ptr->times = h->m_list->times / reservation; - ptr->string = h->root.string; - ptr->m_list = h->m_list; - ptr->sec = h->sec; - ptr->irel = h->m_list->irel; - ptr->rel_backup = h->m_list->rel_backup; - nds32_elf_ex9_insert_entry (ptr); + insn = 0; + bfd_put_32 (output_bfd, insn, contents + (entry->order) * 4); } + else + bfd_putb32 (insn, contents + (entry->order) * 4); } } - else - { - /* Normal global symbol that means no different address symbol - using same ex9 entry. */ - if (m_list->times >= 3) - { - ptr = (struct elf_nds32_insn_times_entry *) - bfd_malloc (sizeof (struct elf_nds32_insn_times_entry)); - ptr->times = m_list->times; - ptr->string = h->root.string; - ptr->m_list = h->m_list; - ptr->sec = h->sec; - ptr->irel = h->m_list->irel; - ptr->rel_backup = h->m_list->rel_backup; - nds32_elf_ex9_insert_entry (ptr); - } - } - - if (h->const_insn == 1) - { - /* sethi with constant value. */ - if (h->times < 3) - return TRUE; - - ptr = (struct elf_nds32_insn_times_entry *) - bfd_malloc (sizeof (struct elf_nds32_insn_times_entry)); - ptr->times = h->times; - ptr->string = h->root.string; - ptr->m_list = NULL; - ptr->sec = NULL; - ptr->irel = NULL; - ptr->rel_backup = h->rel_backup; - nds32_elf_ex9_insert_entry (ptr); - } } - - return TRUE; + indirect_call_table.frozen = 0; } -/* Hash table traverse function. */ - -static void -nds32_elf_code_hash_traverse (int (*func) (struct elf_nds32_code_hash_entry*)) +static asection* +nds32_elf_get_target_section (struct bfd_link_info *info, char *name) { - unsigned int i; + asection *sec = NULL; + bfd *abfd; - ex9_code_table.frozen = 1; - for (i = 0; i < ex9_code_table.size; i++) + for (abfd = info->input_bfds; abfd != NULL; abfd = abfd->link.next) { - struct bfd_hash_entry *p; - - for (p = ex9_code_table.table[i]; p != NULL; p = p->next) - if (!func ((struct elf_nds32_code_hash_entry *) p)) - goto out; - } -out: - ex9_code_table.frozen = 0; -} - - -/* Give order number to insn list. */ - -static void -nds32_elf_order_insn_times (struct bfd_link_info *info) -{ - struct elf_nds32_insn_times_entry *ex9_insn; - struct elf_nds32_insn_times_entry *temp = NULL; - struct elf_nds32_link_hash_table *table; - int ex9_limit; - int number = 0; - - if (ex9_insn_head == NULL) - return; - -/* The max number of entries is 512. */ - ex9_insn = ex9_insn_head; - table = nds32_elf_hash_table (info); - ex9_limit = table->ex9_limit; - - ex9_insn = ex9_insn_head; - - while (ex9_insn != NULL && number < ex9_limit) - { - ex9_insn->order = number; - number++; - temp = ex9_insn; - ex9_insn = ex9_insn->next; - } - - if (ex9_insn && temp) - temp->next = NULL; - - while (ex9_insn != NULL) - { - /* Free useless entry. */ - temp = ex9_insn; - ex9_insn = ex9_insn->next; - free (temp); - } -} - -/* Build .ex9.itable section. */ - -static void -nds32_elf_ex9_build_itable (struct bfd_link_info *link_info) -{ - asection *table_sec; - struct elf_nds32_insn_times_entry *ptr; - bfd *it_abfd; - int number = 0; - bfd_byte *contents = NULL; - - for (it_abfd = link_info->input_bfds; it_abfd != NULL; - it_abfd = it_abfd->link.next) - { - /* Find the section .ex9.itable, and put all entries into it. */ - table_sec = bfd_get_section_by_name (it_abfd, ".ex9.itable"); - if (table_sec != NULL) - { - if (!nds32_get_section_contents (it_abfd, table_sec, &contents, TRUE)) - return; - - for (ptr = ex9_insn_head; ptr !=NULL ; ptr = ptr->next) - number++; - - table_sec->size = number * 4; - - if (number == 0) - return; - - elf_elfheader (link_info->output_bfd)->e_flags |= E_NDS32_HAS_EX9_INST; - number = 0; - for (ptr = ex9_insn_head; ptr !=NULL ; ptr = ptr->next) - { - long val; - - val = strtol (ptr->string, NULL, 16); - bfd_putb32 ((bfd_vma) val, (char *) contents + (number * 4)); - number++; - } - break; - } - } -} - -/* Get insn with regs according to relocation type. */ - -static void -nds32_elf_get_insn_with_reg (Elf_Internal_Rela *irel, - uint32_t insn, uint32_t *insn_with_reg) -{ - reloc_howto_type *howto = NULL; - - if (irel == NULL - || (ELF32_R_TYPE (irel->r_info) >= (int) ARRAY_SIZE (nds32_elf_howto_table) - && (ELF32_R_TYPE (irel->r_info) - R_NDS32_RELAX_ENTRY) - >= (int) ARRAY_SIZE (nds32_elf_relax_howto_table))) - { - *insn_with_reg = insn; - return; - } - - howto = bfd_elf32_bfd_reloc_type_table_lookup (ELF32_R_TYPE (irel->r_info)); - *insn_with_reg = insn & (0xffffffff ^ howto->dst_mask); -} - -/* Mask number of address bits according to relocation. */ - -static unsigned long -nds32_elf_irel_mask (Elf_Internal_Rela *irel) -{ - reloc_howto_type *howto = NULL; - - if (irel == NULL - || (ELF32_R_TYPE (irel->r_info) >= (int) ARRAY_SIZE (nds32_elf_howto_table) - && (ELF32_R_TYPE (irel->r_info) - R_NDS32_RELAX_ENTRY) - >= (int) ARRAY_SIZE (nds32_elf_relax_howto_table))) - return 0; - - howto = bfd_elf32_bfd_reloc_type_table_lookup (ELF32_R_TYPE (irel->r_info)); - return howto->dst_mask; -} - -static void -nds32_elf_insert_irel_entry (struct elf_nds32_irel_entry **irel_list, - struct elf_nds32_irel_entry *irel_ptr) -{ - if (*irel_list == NULL) - { - *irel_list = irel_ptr; - irel_ptr->next = NULL; - } - else - { - irel_ptr->next = *irel_list; - *irel_list = irel_ptr; - } -} - -static void -nds32_elf_ex9_insert_fix (asection * sec, Elf_Internal_Rela * irel, - struct elf_link_hash_entry *h, int order) -{ - struct elf_nds32_ex9_refix *ptr; - - ptr = bfd_malloc (sizeof (struct elf_nds32_ex9_refix)); - ptr->sec = sec; - ptr->irel = irel; - ptr->h = h; - ptr->order = order; - ptr->next = NULL; - - if (ex9_refix_head == NULL) - ex9_refix_head = ptr; - else - { - struct elf_nds32_ex9_refix *temp = ex9_refix_head; - - while (temp->next != NULL) - temp = temp->next; - temp->next = ptr; - } -} - -enum -{ - DATA_EXIST = 1, - CLEAN_PRE = 1 << 1, - PUSH_PRE = 1 << 2 -}; - -/* Check relocation type if supporting for ex9. */ - -static int -nds32_elf_ex9_relocation_check (struct bfd_link_info *info, - Elf_Internal_Rela **irel, - Elf_Internal_Rela *irelend, - nds32_elf_blank_t *relax_blank_list, - asection *sec,bfd_vma *off, - bfd_byte *contents) -{ - /* Suppress ex9 if `.no_relax ex9' or inner loop. */ - bfd_boolean nested_ex9, nested_loop; - bfd_boolean ex9_loop_aware; - /* We use the highest 1 byte of result to record - how many bytes location counter has to move. */ - int result = 0; - Elf_Internal_Rela *irel_save = NULL; - struct elf_nds32_link_hash_table *table; - - table = nds32_elf_hash_table (info); - ex9_loop_aware = table->ex9_loop_aware; - - while ((*irel) != NULL && (*irel) < irelend && *off == (*irel)->r_offset) - { - switch (ELF32_R_TYPE ((*irel)->r_info)) - { - case R_NDS32_RELAX_REGION_BEGIN: - /* Ignore code block. */ - nested_ex9 = FALSE; - nested_loop = FALSE; - if (((*irel)->r_addend & R_NDS32_RELAX_REGION_NO_EX9_FLAG) - || (ex9_loop_aware - && ((*irel)->r_addend & R_NDS32_RELAX_REGION_INNERMOST_LOOP_FLAG))) - { - /* Check the region if loop or not. If it is true and - ex9-loop-aware is true, ignore the region till region end. */ - /* To save the status for in .no_relax ex9 region and - loop region to conform the block can do ex9 relaxation. */ - nested_ex9 = ((*irel)->r_addend & R_NDS32_RELAX_REGION_NO_EX9_FLAG); - nested_loop = (ex9_loop_aware - && ((*irel)->r_addend & R_NDS32_RELAX_REGION_INNERMOST_LOOP_FLAG)); - while ((*irel) && (*irel) < irelend && (nested_ex9 || nested_loop)) - { - (*irel)++; - if (ELF32_R_TYPE ((*irel)->r_info) == R_NDS32_RELAX_REGION_BEGIN) - { - /* There may be nested region. */ - if (((*irel)->r_addend & R_NDS32_RELAX_REGION_NO_EX9_FLAG) != 0) - nested_ex9 = TRUE; - else if (ex9_loop_aware - && ((*irel)->r_addend & R_NDS32_RELAX_REGION_INNERMOST_LOOP_FLAG)) - nested_loop = TRUE; - } - else if (ELF32_R_TYPE ((*irel)->r_info) == R_NDS32_RELAX_REGION_END) - { - /* The end of region. */ - if (((*irel)->r_addend & R_NDS32_RELAX_REGION_NO_EX9_FLAG) != 0) - nested_ex9 = FALSE; - else if (ex9_loop_aware - && ((*irel)->r_addend & R_NDS32_RELAX_REGION_INNERMOST_LOOP_FLAG)) - nested_loop = FALSE; - } - else if (ELF32_R_TYPE ((*irel)->r_info) == R_NDS32_LABEL - && ((*irel)->r_addend & 0x1f) == 2) - { - /* Alignment exist in the region. */ - result |= CLEAN_PRE; - if (((*irel)->r_offset - - get_nds32_elf_blank_total (&relax_blank_list, - (*irel)->r_offset, 0)) & 0x02) - result |= PUSH_PRE; - } - } - if ((*irel) >= irelend) - *off = sec->size; - else - *off = (*irel)->r_offset; - - /* The final instruction in the region, regard this one as data to ignore it. */ - result |= DATA_EXIST; - return result; - } - break; - - case R_NDS32_LABEL: - if (((*irel)->r_addend & 0x1f) == 2) - { - /* Check this point is align and decide to do ex9 or not. */ - result |= CLEAN_PRE; - if (((*irel)->r_offset - - get_nds32_elf_blank_total (&relax_blank_list, - (*irel)->r_offset, 0)) & 0x02) - result |= PUSH_PRE; - } - break; - case R_NDS32_32_RELA: - /* Data. */ - result |= (4 << 24); - result |= DATA_EXIST; - break; - case R_NDS32_16_RELA: - /* Data. */ - result |= (2 << 24); - result |= DATA_EXIST; - break; - case R_NDS32_DATA: - /* Data. */ - /* The least code alignment is 2. If the data is only one byte, - we have to shift one more byte. */ - if ((*irel)->r_addend == 1) - result |= ((*irel)->r_addend << 25) ; - else - result |= ((*irel)->r_addend << 24) ; - - result |= DATA_EXIST; - break; - - case R_NDS32_25_PCREL_RELA: - case R_NDS32_SDA16S3_RELA: - case R_NDS32_SDA15S3_RELA: - case R_NDS32_SDA15S3: - case R_NDS32_SDA17S2_RELA: - case R_NDS32_SDA15S2_RELA: - case R_NDS32_SDA12S2_SP_RELA: - case R_NDS32_SDA12S2_DP_RELA: - case R_NDS32_SDA15S2: - case R_NDS32_SDA18S1_RELA: - case R_NDS32_SDA15S1_RELA: - case R_NDS32_SDA15S1: - case R_NDS32_SDA19S0_RELA: - case R_NDS32_SDA15S0_RELA: - case R_NDS32_SDA15S0: - case R_NDS32_HI20_RELA: - case R_NDS32_LO12S0_ORI_RELA: - case R_NDS32_LO12S0_RELA: - case R_NDS32_LO12S1_RELA: - case R_NDS32_LO12S2_RELA: - /* These relocation is supported ex9 relaxation currently. */ - /* We have to save the relocation for using later, since we have - to check there is any alignment in the same address. */ - irel_save = *irel; - break; - default: - /* Not support relocations. */ - if (ELF32_R_TYPE ((*irel)->r_info) < ARRAY_SIZE (nds32_elf_howto_table) - && ELF32_R_TYPE ((*irel)->r_info) != R_NDS32_NONE - && ELF32_R_TYPE ((*irel)->r_info) != R_NDS32_INSN16) - { - /* Note: To optimize aggressively, it maybe can ignore R_NDS32_INSN16 here. - But we have to consider if there is any side-effect. */ - if (!(result & DATA_EXIST)) - { - /* We have to confirm there is no data relocation in the - same address. In general case, this won't happen. */ - /* We have to do ex9 conservative, for those relocation not - considerd we ignore instruction. */ - result |= DATA_EXIST; - if (*(contents + *off) & 0x80) - result |= (2 << 24); - else - result |= (4 << 24); - break; - } - } - } - if ((*irel) < irelend - && ((*irel) + 1) < irelend - && (*irel)->r_offset == ((*irel) + 1)->r_offset) - /* There are relocations pointing to the same address, we have to - check all of them. */ - (*irel)++; - else - { - if (irel_save) - *irel = irel_save; - return result; - } - } - return result; -} - -/* Replace with ex9 instruction. */ - -static bfd_boolean -nds32_elf_ex9_push_insn (uint16_t insn16, bfd_byte *contents, bfd_vma pre_off, - nds32_elf_blank_t **relax_blank_list, - struct elf_nds32_irel_entry *pre_irel_ptr, - struct elf_nds32_irel_entry **irel_list) -{ - if (insn16 != 0) - { - /* Implement the ex9 relaxation. */ - bfd_putb16 (insn16, contents + pre_off); - if (!insert_nds32_elf_blank_recalc_total (relax_blank_list, - pre_off + 2, 2)) - return FALSE; - if (pre_irel_ptr != NULL) - nds32_elf_insert_irel_entry (irel_list, pre_irel_ptr); - } - return TRUE; -} - -/* Replace input file instruction which is in ex9 itable. */ - -static bfd_boolean -nds32_elf_ex9_replace_instruction (struct bfd_link_info *info, bfd *abfd, asection *sec) -{ - struct elf_nds32_insn_times_entry *ex9_insn = ex9_insn_head; - bfd_byte *contents = NULL; - bfd_vma off; - uint16_t insn16, insn_ex9; - /* `pre_*' are used to track previous instruction that can use ex9.it. */ - bfd_vma pre_off = -1; - uint16_t pre_insn16 = 0; - struct elf_nds32_irel_entry *pre_irel_ptr = NULL; - Elf_Internal_Rela *internal_relocs; - Elf_Internal_Rela *irel; - Elf_Internal_Rela *irelend; - Elf_Internal_Shdr *symtab_hdr; - Elf_Internal_Sym *isym = NULL; - nds32_elf_blank_t *relax_blank_list = NULL; - uint32_t insn = 0; - uint32_t insn_with_reg = 0; - uint32_t it_insn; - uint32_t it_insn_with_reg; - unsigned long r_symndx; - asection *isec; - struct elf_nds32_irel_entry *irel_list = NULL; - struct elf_link_hash_entry **sym_hashes = elf_sym_hashes (abfd); - int data_flag, do_replace, save_irel; - struct elf_link_hash_entry_list *h_list; - - - /* Load section instructions, relocations, and symbol table. */ - if (!nds32_get_section_contents (abfd, sec, &contents, TRUE) - || !nds32_get_local_syms (abfd, sec, &isym)) - return FALSE; - internal_relocs = - _bfd_elf_link_read_relocs (abfd, sec, NULL, NULL, TRUE /* keep_memory */); - irelend = internal_relocs + sec->reloc_count; - symtab_hdr = &elf_tdata (abfd)->symtab_hdr; - - off = 0; - - /* Check if the object enable ex9. */ - irel = find_relocs_at_address (internal_relocs, internal_relocs, - irelend, R_NDS32_RELAX_ENTRY); - - /* Check this section trigger ex9 relaxation. */ - if (irel == NULL - || irel >= irelend - || ELF32_R_TYPE (irel->r_info) != R_NDS32_RELAX_ENTRY - || (ELF32_R_TYPE (irel->r_info) == R_NDS32_RELAX_ENTRY - && !(irel->r_addend & R_NDS32_RELAX_ENTRY_EX9_FLAG))) - return TRUE; - - irel = internal_relocs; - - /* Check alignment and fetch proper relocation. */ - while (off < sec->size) - { - struct elf_link_hash_entry *h = NULL; - struct elf_nds32_irel_entry *irel_ptr = NULL; - - /* Syn the instruction and the relocation. */ - while (irel != NULL && irel < irelend && irel->r_offset < off) - irel++; - - data_flag = nds32_elf_ex9_relocation_check (info, &irel, irelend, - relax_blank_list, sec, - &off, contents); - if (data_flag & PUSH_PRE) - if (!nds32_elf_ex9_push_insn (pre_insn16, contents, pre_off, - &relax_blank_list, pre_irel_ptr, - &irel_list)) - return FALSE; - - if (data_flag & CLEAN_PRE) - { - pre_off = 0; - pre_insn16 = 0; - pre_irel_ptr = NULL; - } - if (data_flag & DATA_EXIST) - { - /* We save the move offset in the highest byte. */ - off += (data_flag >> 24); - continue; - } - - if (*(contents + off) & 0x80) - { - /* 2-byte instruction. */ - off += 2; - continue; - } - - /* Load the instruction and its opcode with register for comparing. */ - ex9_insn = ex9_insn_head; - insn = bfd_getb32 (contents + off); - insn_with_reg = 0; - while (ex9_insn) - { - it_insn = strtol (ex9_insn->string, NULL, 16); - it_insn_with_reg = 0; - do_replace = 0; - save_irel = 0; - - if (irel != NULL && irel < irelend && irel->r_offset == off) - { - /* Insn with relocation. */ - nds32_elf_get_insn_with_reg (irel, insn, &insn_with_reg); - - if (ex9_insn->irel != NULL) - nds32_elf_get_insn_with_reg (ex9_insn->irel, it_insn, - &it_insn_with_reg); - - if (ex9_insn->irel != NULL - && (ELF32_R_TYPE (irel->r_info) == - ELF32_R_TYPE (ex9_insn->irel->r_info)) - && (insn_with_reg == it_insn_with_reg)) - { - /* Insn relocation and format is the same as table entry. */ - - if (ELF32_R_TYPE (irel->r_info) == R_NDS32_25_PCREL_RELA - || ELF32_R_TYPE (irel->r_info) == R_NDS32_LO12S0_ORI_RELA - || ELF32_R_TYPE (irel->r_info) == R_NDS32_LO12S0_RELA - || ELF32_R_TYPE (irel->r_info) == R_NDS32_LO12S1_RELA - || ELF32_R_TYPE (irel->r_info) == R_NDS32_LO12S2_RELA - || (ELF32_R_TYPE (irel->r_info) >= R_NDS32_SDA15S3 - && ELF32_R_TYPE (irel->r_info) <= R_NDS32_SDA15S0) - || (ELF32_R_TYPE (irel->r_info) >= R_NDS32_SDA15S3_RELA - && ELF32_R_TYPE (irel->r_info) <= R_NDS32_SDA15S0_RELA) - || (ELF32_R_TYPE (irel->r_info) >= R_NDS32_SDA12S2_DP_RELA - && ELF32_R_TYPE (irel->r_info) <= - R_NDS32_SDA12S2_SP_RELA) - || (ELF32_R_TYPE (irel->r_info) >= R_NDS32_SDA16S3_RELA - && ELF32_R_TYPE (irel->r_info) <= R_NDS32_SDA19S0_RELA)) - { - r_symndx = ELF32_R_SYM (irel->r_info); - if (r_symndx < symtab_hdr->sh_info) - { - /* Local symbol. */ - int shndx = isym[r_symndx].st_shndx; - - isec = elf_elfsections (abfd)[shndx]->bfd_section; - if (ex9_insn->sec == isec - && ex9_insn->irel->r_addend == irel->r_addend - && ex9_insn->irel->r_info == irel->r_info) - { - do_replace = 1; - save_irel = 1; - } - } - else - { - /* External symbol. */ - h = sym_hashes[r_symndx - symtab_hdr->sh_info]; - if (ex9_insn->m_list) - { - h_list = ex9_insn->m_list->h_list; - while (h_list) - { - if (h == h_list->h - && (ex9_insn->m_list->irel->r_addend == - irel->r_addend)) - { - do_replace = 1; - save_irel = 1; - break; - } - h_list = h_list->next; - } - } - } - } - else if (ELF32_R_TYPE (irel->r_info) == R_NDS32_HI20_RELA) - { - r_symndx = ELF32_R_SYM (irel->r_info); - if (r_symndx < symtab_hdr->sh_info) - { - /* Local symbols. Compare its base symbol and offset. */ - int shndx = isym[r_symndx].st_shndx; - - isec = elf_elfsections (abfd)[shndx]->bfd_section; - if (ex9_insn->sec == isec - && ex9_insn->irel->r_addend == irel->r_addend - && ex9_insn->irel->r_info == irel->r_info) - { - do_replace = 1; - save_irel = 1; - } - } - else - { - /* External symbol. */ - struct elf_link_hash_entry_mul_list *m_list; - - h = sym_hashes[r_symndx - symtab_hdr->sh_info]; - m_list = ex9_insn->m_list; - - while (m_list) - { - h_list = m_list->h_list; - - while (h_list) - { - if (h == h_list->h - && (m_list->irel->r_addend - == irel->r_addend)) - { - do_replace = 1; - save_irel = 1; - if (ex9_insn->next - && ex9_insn->m_list - && ex9_insn->m_list == ex9_insn->next->m_list) - { - /* sethi multiple entry must be fixed */ - nds32_elf_ex9_insert_fix (sec, irel, - h, ex9_insn->order); - } - break; - } - h_list = h_list->next; - } - m_list = m_list->next; - } - } - } - } - - /* Import table: Check the symbol hash table and the - jump target. Only R_NDS32_25_PCREL_RELA now. */ - else if (ex9_insn->times == -1 - && ELF32_R_TYPE (irel->r_info) == R_NDS32_25_PCREL_RELA) - { - nds32_elf_get_insn_with_reg (irel, it_insn, &it_insn_with_reg); - if (insn_with_reg == it_insn_with_reg) - { - char code[10]; - bfd_vma relocation; - - r_symndx = ELF32_R_SYM (irel->r_info); - if (r_symndx >= symtab_hdr->sh_info) - { - h = sym_hashes[r_symndx - symtab_hdr->sh_info]; - if ((h->root.type == bfd_link_hash_defined - || h->root.type == bfd_link_hash_defweak) - && h->root.u.def.section != NULL - && h->root.u.def.section->output_section != NULL - && h->root.u.def.section->gc_mark == 1 - && bfd_is_abs_section (h->root.u.def.section) - && h->root.u.def.value > sec->size) - { - relocation = h->root.u.def.value + - h->root.u.def.section->output_section->vma + - h->root.u.def.section->output_offset; - relocation += irel->r_addend; - insn = insn_with_reg - | ((relocation >> 1) & 0xffffff); - snprintf (code, sizeof (code), "%08x", insn); - if (strcmp (code, ex9_insn->string) == 0) - { - do_replace = 1; - save_irel = 1; - } - } - } - } - } - else if (ELF32_R_TYPE (irel->r_info) == R_NDS32_RELAX_REGION_BEGIN - || ELF32_R_TYPE (irel->r_info) == R_NDS32_RELAX_REGION_END - || ELF32_R_TYPE (irel->r_info) == R_NDS32_NONE) - { - /* These relocations do not have to relocate contens, so it can - be regard as instruction without relocation. */ - if (insn == it_insn && ex9_insn->irel == NULL) - do_replace = 1; - } - } - else - { - /* Instruction without relocation, we only - have to compare their byte code. */ - if (insn == it_insn && ex9_insn->irel == NULL) - do_replace = 1; - } - - /* Insntruction match so replacing the code here. */ - if (do_replace == 1) - { - /* There are two formats of ex9 instruction. */ - if (ex9_insn->order < 32) - insn_ex9 = INSN_EX9_IT_2; - else - insn_ex9 = INSN_EX9_IT_1; - insn16 = insn_ex9 | ex9_insn->order; - - /* Insert ex9 instruction. */ - nds32_elf_ex9_push_insn (pre_insn16, contents, pre_off, - &relax_blank_list, pre_irel_ptr, - &irel_list); - pre_off = off; - pre_insn16 = insn16; - - if (save_irel) - { - /* For instuction with relocation do relax. */ - irel_ptr = (struct elf_nds32_irel_entry *) - bfd_malloc (sizeof (struct elf_nds32_irel_entry)); - irel_ptr->irel = irel; - irel_ptr->next = NULL; - pre_irel_ptr = irel_ptr; - } - else - pre_irel_ptr = NULL; - break; - } - ex9_insn = ex9_insn->next; - } - off += 4; - } - - /* Insert ex9 instruction. */ - nds32_elf_ex9_push_insn (pre_insn16, contents, pre_off, - &relax_blank_list, pre_irel_ptr, - &irel_list); - - /* Delete the redundant code. */ - if (relax_blank_list) - { - nds32_elf_relax_delete_blanks (abfd, sec, relax_blank_list); - relax_blank_list = NULL; - } - - /* Clear the relocation that is replaced by ex9. */ - while (irel_list) - { - struct elf_nds32_irel_entry *irel_ptr; - - irel_ptr = irel_list; - irel_list = irel_ptr->next; - irel_ptr->irel->r_info = - ELF32_R_INFO (ELF32_R_SYM (irel_ptr->irel->r_info), R_NDS32_TRAN); - free (irel_ptr); - } - return TRUE; -} - -/* Initialize ex9 hash table. */ - -int -nds32_elf_ex9_init (void) -{ - if (!bfd_hash_table_init_n (&ex9_code_table, nds32_elf_code_hash_newfunc, - sizeof (struct elf_nds32_code_hash_entry), - 1023)) - { - _bfd_error_handler (_("Linker: cannot init ex9 hash table error \n")); - return FALSE; - } - return TRUE; -} - -/* Predict how many bytes will be relaxed with ex9 and ifc. */ - -static void -nds32_elf_ex9_total_relax (struct bfd_link_info *info) -{ - struct elf_nds32_insn_times_entry *ex9_insn; - struct elf_nds32_insn_times_entry *temp; - int target_optimize; - struct elf_nds32_link_hash_table *table; - - if (ex9_insn_head == NULL) - return; - - table = nds32_elf_hash_table (info); - target_optimize = table->target_optimize; - ex9_insn = ex9_insn_head; - while (ex9_insn) - { - ex9_relax_size = ex9_insn->times * 2 + ex9_relax_size; - temp = ex9_insn; - ex9_insn = ex9_insn->next; - free (temp); - } - ex9_insn_head = NULL; - - if ((target_optimize & NDS32_RELAX_JUMP_IFC_ON)) - { - /* Examine ifc reduce size. */ - struct elf_nds32_ifc_symbol_entry *ifc_ent = ifc_symbol_head; - struct elf_nds32_ifc_irel_list *irel_ptr = NULL; - int size = 0; - - while (ifc_ent) - { - if (ifc_ent->enable == 0) - { - /* Not ifc yet. */ - irel_ptr = ifc_ent->irel_head; - while (irel_ptr) - { - size += 2; - irel_ptr = irel_ptr->next; - } - } - size -= 2; - ifc_ent = ifc_ent->next; - } - ex9_relax_size += size; - } -} - -/* Finish ex9 table. */ - -void -nds32_elf_ex9_finish (struct bfd_link_info *link_info) -{ - nds32_elf_code_hash_traverse (nds32_elf_examine_insn_times); - nds32_elf_order_insn_times (link_info); - nds32_elf_ex9_total_relax (link_info); - /* Traverse the hash table and count its times. */ - nds32_elf_code_hash_traverse (nds32_elf_count_insn_times); - nds32_elf_order_insn_times (link_info); - nds32_elf_ex9_build_itable (link_info); -} - -/* Relocate the entries in ex9 table. */ - -static bfd_vma -nds32_elf_ex9_reloc_insn (struct elf_nds32_insn_times_entry *ptr, - struct bfd_link_info *link_info) -{ - Elf_Internal_Sym *isym = NULL; - bfd_vma relocation = -1; - struct elf_link_hash_entry *h; - - if (ptr->m_list != NULL) - { - /* Global symbol. */ - h = ptr->m_list->h_list->h; - if ((h->root.type == bfd_link_hash_defined - || h->root.type == bfd_link_hash_defweak) - && h->root.u.def.section != NULL - && h->root.u.def.section->output_section != NULL) - { - - relocation = h->root.u.def.value + - h->root.u.def.section->output_section->vma + - h->root.u.def.section->output_offset; - relocation += ptr->m_list->irel->r_addend; - } - else - relocation = 0; - } - else if (ptr->sec !=NULL) - { - /* Local symbol. */ - Elf_Internal_Sym sym; - asection *sec = NULL; - asection isec; - asection *isec_ptr = &isec; - Elf_Internal_Rela irel_backup = *(ptr->irel); - asection *sec_backup = ptr->sec; - bfd *abfd = ptr->sec->owner; - - if (!nds32_get_local_syms (abfd, sec, &isym)) - return FALSE; - isym = isym + ELF32_R_SYM (ptr->irel->r_info); - - sec = bfd_section_from_elf_index (abfd, isym->st_shndx); - if (sec != NULL) - *isec_ptr = *sec; - sym = *isym; - - /* The purpose is same as elf_link_input_bfd. */ - if (isec_ptr != NULL - && isec_ptr->sec_info_type == SEC_INFO_TYPE_MERGE - && ELF_ST_TYPE (isym->st_info) != STT_SECTION) - { - sym.st_value = - _bfd_merged_section_offset (ptr->sec->output_section->owner, &isec_ptr, - elf_section_data (isec_ptr)->sec_info, - isym->st_value); - } - relocation = _bfd_elf_rela_local_sym (link_info->output_bfd, &sym, - &ptr->sec, ptr->irel); - if (ptr->irel != NULL) - relocation += ptr->irel->r_addend; - - /* Restore origin value since there may be some insntructions that - could not be replaced with ex9.it. */ - *(ptr->irel) = irel_backup; - ptr->sec = sec_backup; - } - - return relocation; -} - -/* Import ex9 table and build list. */ - -void -nds32_elf_ex9_import_table (struct bfd_link_info *info) -{ - int num = 0; - bfd_byte *contents; - FILE *ex9_import_file; - int update_ex9_table; - struct elf_nds32_link_hash_table *table; - - table = nds32_elf_hash_table (info); - ex9_import_file = table->ex9_import_file; - rewind (table->ex9_import_file); - - contents = bfd_malloc (sizeof (bfd_byte) * 4); - - /* Read instructions from the input file and build the list. */ - while (!feof (ex9_import_file)) - { - unsigned long insn; - char *code; - struct elf_nds32_insn_times_entry *ptr; - size_t nread; - - nread = fread (contents, sizeof (bfd_byte) * 4, 1, ex9_import_file); - /* Ignore the final byte 0x0a. */ - if (nread < 1) - break; - insn = bfd_getb32 (contents); - code = bfd_malloc (sizeof (char) * 9); - snprintf (code, 9, "%08lx", (insn & 0xffffffff)); - ptr = bfd_malloc (sizeof (struct elf_nds32_insn_times_entry)); - ptr->string = code; - ptr->order = num; - ptr->times = -1; - ptr->sec = NULL; - ptr->m_list = NULL; - ptr->rel_backup.r_offset = 0; - ptr->rel_backup.r_info = 0; - ptr->rel_backup.r_addend = 0; - ptr->irel = NULL; - ptr->next = NULL; - nds32_elf_ex9_insert_entry (ptr); - num++; - } - - update_ex9_table = table->update_ex9_table; - if (update_ex9_table == 1) - { - /* It has to consider of sethi need to use multiple page - but it not be done yet. */ - nds32_elf_code_hash_traverse (nds32_elf_examine_insn_times); - nds32_elf_order_insn_times (info); - } -} - -/* Export ex9 table. */ - -static void -nds32_elf_ex9_export (struct bfd_link_info *info, - bfd_byte *contents, int size) -{ - FILE *ex9_export_file; - struct elf_nds32_link_hash_table *table; - - table = nds32_elf_hash_table (info); - ex9_export_file = table->ex9_export_file; - fwrite (contents, sizeof (bfd_byte), size, ex9_export_file); - fclose (ex9_export_file); -} - -/* Adjust relocations of J and JAL in ex9.itable. - Export ex9 table. */ - -static void -nds32_elf_ex9_reloc_jmp (struct bfd_link_info *link_info) -{ - asection *table_sec = NULL; - struct elf_nds32_insn_times_entry *ex9_insn = ex9_insn_head; - struct elf_nds32_insn_times_entry *temp_ptr, *temp_ptr2; - bfd *it_abfd; - uint32_t insn, insn_with_reg, source_insn; - bfd_byte *contents = NULL, *source_contents = NULL; - int size = 0; - bfd_vma gp; - int shift, update_ex9_table, offset = 0; - reloc_howto_type *howto = NULL; - Elf_Internal_Rela rel_backup; - unsigned short insn_ex9; - struct elf_nds32_link_hash_table *table; - FILE *ex9_export_file; - static bfd_boolean done = FALSE; - - if (done) - return; - - done = TRUE; - - table = nds32_elf_hash_table (link_info); - if (table) - table->relax_status |= NDS32_RELAX_EX9_DONE; - - - update_ex9_table = table->update_ex9_table; - /* Generated ex9.itable exactly. */ - if (update_ex9_table == 0) - { - for (it_abfd = link_info->input_bfds; it_abfd != NULL; - it_abfd = it_abfd->link.next) - { - table_sec = bfd_get_section_by_name (it_abfd, ".ex9.itable"); - if (table_sec != NULL) - break; - } - - if (table_sec != NULL) - { - bfd *output_bfd; - - output_bfd = table_sec->output_section->owner; - nds32_elf_final_sda_base (output_bfd, link_info, &gp, FALSE); - if (table_sec->size == 0) - return; - - if (!nds32_get_section_contents (it_abfd, table_sec, &contents, TRUE)) - return; - } - } - else - { - /* Set gp. */ - bfd *output_bfd; - - output_bfd = link_info->input_bfds->sections->output_section->owner; - nds32_elf_final_sda_base (output_bfd, link_info, &gp, FALSE); - contents = bfd_malloc (sizeof (bfd_byte) * 2048); - } - - /* Relocate instruction. */ - while (ex9_insn) - { - bfd_vma relocation, min_relocation = 0xffffffff; - - insn = strtol (ex9_insn->string, NULL, 16); - insn_with_reg = 0; - if (ex9_insn->m_list != NULL || ex9_insn->sec != NULL) - { - if (ex9_insn->m_list) - rel_backup = ex9_insn->m_list->rel_backup; - else - rel_backup = ex9_insn->rel_backup; - - nds32_elf_get_insn_with_reg (&rel_backup, insn, &insn_with_reg); - howto = - bfd_elf32_bfd_reloc_type_table_lookup (ELF32_R_TYPE - (rel_backup.r_info)); - shift = howto->rightshift; - if (ELF32_R_TYPE (rel_backup.r_info) == R_NDS32_25_PCREL_RELA - || ELF32_R_TYPE (rel_backup.r_info) == R_NDS32_LO12S0_ORI_RELA - || ELF32_R_TYPE (rel_backup.r_info) == R_NDS32_LO12S0_RELA - || ELF32_R_TYPE (rel_backup.r_info) == R_NDS32_LO12S1_RELA - || ELF32_R_TYPE (rel_backup.r_info) == R_NDS32_LO12S2_RELA) - { - relocation = nds32_elf_ex9_reloc_insn (ex9_insn, link_info); - insn = - insn_with_reg | ((relocation >> shift) & - nds32_elf_irel_mask (&rel_backup)); - bfd_putb32 (insn, contents + (ex9_insn->order) * 4); - } - else if ((ELF32_R_TYPE (rel_backup.r_info) >= R_NDS32_SDA15S3 - && ELF32_R_TYPE (rel_backup.r_info) <= R_NDS32_SDA15S0) - || (ELF32_R_TYPE (rel_backup.r_info) >= R_NDS32_SDA15S3_RELA - && ELF32_R_TYPE (rel_backup.r_info) <= R_NDS32_SDA15S0_RELA) - || (ELF32_R_TYPE (rel_backup.r_info) >= R_NDS32_SDA12S2_DP_RELA - && ELF32_R_TYPE (rel_backup.r_info) <= R_NDS32_SDA12S2_SP_RELA) - || (ELF32_R_TYPE (rel_backup.r_info) >= R_NDS32_SDA16S3_RELA - && ELF32_R_TYPE (rel_backup.r_info) <= R_NDS32_SDA19S0_RELA)) - { - relocation = nds32_elf_ex9_reloc_insn (ex9_insn, link_info); - insn = - insn_with_reg | (((relocation - gp) >> shift) & - nds32_elf_irel_mask (&rel_backup)); - bfd_putb32 (insn, contents + (ex9_insn->order) * 4); - } - else if (ELF32_R_TYPE (rel_backup.r_info) == R_NDS32_HI20_RELA) - { - /* Sethi may be multiple entry for one insn. */ - if (ex9_insn->next && ex9_insn->m_list - && ex9_insn->m_list == ex9_insn->next->m_list) - { - struct elf_link_hash_entry_mul_list *m_list; - struct elf_nds32_ex9_refix *fix_ptr; - struct elf_link_hash_entry *h; - - temp_ptr = ex9_insn; - temp_ptr2 = ex9_insn; - m_list = ex9_insn->m_list; - while (m_list) - { - h = m_list->h_list->h; - relocation = h->root.u.def.value + - h->root.u.def.section->output_section->vma + - h->root.u.def.section->output_offset; - relocation += m_list->irel->r_addend; - - if (relocation < min_relocation) - min_relocation = relocation; - m_list = m_list->next; - } - relocation = min_relocation; - - /* Put insntruction into ex9 table. */ - insn = insn_with_reg - | ((relocation >> shift) & nds32_elf_irel_mask (&rel_backup)); - bfd_putb32 (insn, contents + (ex9_insn->order) * 4); - relocation = relocation + 0x1000; /* hi20 */ - - while (ex9_insn->next && ex9_insn->m_list - && ex9_insn->m_list == ex9_insn->next->m_list) - { - /* Multiple sethi. */ - ex9_insn = ex9_insn->next; - size += 4; - insn = - insn_with_reg | ((relocation >> shift) & - nds32_elf_irel_mask (&rel_backup)); - bfd_putb32 (insn, contents + (ex9_insn->order) * 4); - relocation = relocation + 0x1000; /* hi20 */ - } - - fix_ptr = ex9_refix_head; - while (fix_ptr) - { - /* Fix ex9 insn. */ - /* temp_ptr2 points to the head of multiple sethi. */ - temp_ptr = temp_ptr2; - while (fix_ptr->order != temp_ptr->order && fix_ptr->next) - { - fix_ptr = fix_ptr->next; - } - if (fix_ptr->order != temp_ptr->order) - break; - - /* Set source insn. */ - relocation = - fix_ptr->h->root.u.def.value + - fix_ptr->h->root.u.def.section->output_section->vma + - fix_ptr->h->root.u.def.section->output_offset; - relocation += fix_ptr->irel->r_addend; - /* sethi imm is imm20s. */ - source_insn = insn_with_reg | ((relocation >> shift) & 0xfffff); - - while (temp_ptr) - { - /* Match entry and source code. */ - insn = bfd_getb32 (contents + (temp_ptr->order) * 4 + offset); - if (insn == source_insn) - { - /* Fix the ex9 insn. */ - if (temp_ptr->order != fix_ptr->order) - { - if (!nds32_get_section_contents - (fix_ptr->sec->owner, fix_ptr->sec, - &source_contents, TRUE)) - _bfd_error_handler - (_("Linker: error cannot fixed ex9 relocation \n")); - if (temp_ptr->order < 32) - insn_ex9 = INSN_EX9_IT_2; - else - insn_ex9 = INSN_EX9_IT_1; - insn_ex9 = insn_ex9 | temp_ptr->order; - bfd_putb16 (insn_ex9, source_contents + fix_ptr->irel->r_offset); - } - break; - } - else - { - if (!temp_ptr->next || temp_ptr->m_list != temp_ptr->next->m_list) - _bfd_error_handler - (_("Linker: error cannot fixed ex9 relocation \n")); - else - temp_ptr = temp_ptr->next; - } - } - fix_ptr = fix_ptr->next; - } - } - else - { - relocation = nds32_elf_ex9_reloc_insn (ex9_insn, link_info); - insn = insn_with_reg - | ((relocation >> shift) & nds32_elf_irel_mask (&rel_backup)); - bfd_putb32 (insn, contents + (ex9_insn->order) * 4); - } - } - } - else - { - /* Insn without relocation does not have to be fixed - if need to update export table. */ - if (update_ex9_table == 1) - bfd_putb32 (insn, contents + (ex9_insn->order) * 4); - } - ex9_insn = ex9_insn->next; - size += 4; + sec = bfd_get_section_by_name (abfd, name); + if (sec != NULL) + break; } - ex9_export_file = table->ex9_export_file; - if (ex9_export_file != NULL) - nds32_elf_ex9_export (link_info, contents, table_sec->size); - else if (update_ex9_table == 1) - { - table->ex9_export_file = table->ex9_import_file; - rewind (table->ex9_export_file); - nds32_elf_ex9_export (link_info, contents, size); - } -} - -/* Generate ex9 hash table. */ - -static bfd_boolean -nds32_elf_ex9_build_hash_table (bfd *abfd, asection *sec, - struct bfd_link_info *link_info) -{ - Elf_Internal_Rela *internal_relocs; - Elf_Internal_Rela *irelend; - Elf_Internal_Rela *irel; - Elf_Internal_Rela *jrel; - Elf_Internal_Rela rel_backup; - Elf_Internal_Shdr *symtab_hdr; - Elf_Internal_Sym *isym = NULL; - asection *isec; - struct elf_link_hash_entry **sym_hashes; - bfd_byte *contents = NULL; - bfd_vma off = 0; - unsigned long r_symndx; - uint32_t insn, insn_with_reg; - struct elf_link_hash_entry *h; - int data_flag, shift, align; - bfd_vma relocation; - /* Suppress ex9 if `.no_relax ex9' or inner loop. */ - reloc_howto_type *howto = NULL; - - sym_hashes = elf_sym_hashes (abfd); - /* Load section instructions, relocations, and symbol table. */ - if (!nds32_get_section_contents (abfd, sec, &contents, TRUE)) - return FALSE; - - internal_relocs = _bfd_elf_link_read_relocs (abfd, sec, NULL, NULL, - TRUE /* keep_memory */); - irelend = internal_relocs + sec->reloc_count; - symtab_hdr = &elf_tdata (abfd)->symtab_hdr; - if (!nds32_get_local_syms (abfd, sec, &isym)) - return FALSE; - - /* Check the object if enable ex9. */ - irel = find_relocs_at_address (internal_relocs, internal_relocs, irelend, - R_NDS32_RELAX_ENTRY); - - /* Check this section trigger ex9 relaxation. */ - if (irel == NULL - || irel >= irelend - || ELF32_R_TYPE (irel->r_info) != R_NDS32_RELAX_ENTRY - || (ELF32_R_TYPE (irel->r_info) == R_NDS32_RELAX_ENTRY - && !(irel->r_addend & R_NDS32_RELAX_ENTRY_EX9_FLAG))) - return TRUE; - - irel = internal_relocs; - - /* Push each insn into hash table. */ - while (off < sec->size) - { - char code[10]; - struct elf_nds32_code_hash_entry *entry; - - while (irel != NULL && irel < irelend && irel->r_offset < off) - irel++; - - data_flag = nds32_elf_ex9_relocation_check (link_info, &irel, irelend, - NULL, sec, &off, contents); - if (data_flag & DATA_EXIST) - { - /* We save the move offset in the highest byte. */ - off += (data_flag >> 24); - continue; - } - - if (*(contents + off) & 0x80) - { - off += 2; - } - else - { - h = NULL; - isec = NULL; - jrel = NULL; - rel_backup.r_info = 0; - rel_backup.r_offset = 0; - rel_backup.r_addend = 0; - /* Load the instruction and its opcode with register for comparing. */ - insn = bfd_getb32 (contents + off); - insn_with_reg = 0; - if (irel != NULL && irel < irelend && irel->r_offset == off) - { - nds32_elf_get_insn_with_reg (irel, insn, &insn_with_reg); - howto = bfd_elf32_bfd_reloc_type_table_lookup (ELF32_R_TYPE (irel->r_info)); - shift = howto->rightshift; - align = (1 << shift) - 1; - if (ELF32_R_TYPE (irel->r_info) == R_NDS32_25_PCREL_RELA - || ELF32_R_TYPE (irel->r_info) == R_NDS32_HI20_RELA - || ELF32_R_TYPE (irel->r_info) == R_NDS32_LO12S0_ORI_RELA - || ELF32_R_TYPE (irel->r_info) == R_NDS32_LO12S0_RELA - || ELF32_R_TYPE (irel->r_info) == R_NDS32_LO12S1_RELA - || ELF32_R_TYPE (irel->r_info) == R_NDS32_LO12S2_RELA - ||(ELF32_R_TYPE (irel->r_info) >= R_NDS32_SDA15S3 - && ELF32_R_TYPE (irel->r_info) <= R_NDS32_SDA15S0) - || (ELF32_R_TYPE (irel->r_info) >= R_NDS32_SDA15S3_RELA - && ELF32_R_TYPE (irel->r_info) <= R_NDS32_SDA15S0_RELA) - || (ELF32_R_TYPE (irel->r_info) >= R_NDS32_SDA12S2_DP_RELA - && ELF32_R_TYPE (irel->r_info) <= R_NDS32_SDA12S2_SP_RELA) - || (ELF32_R_TYPE (irel->r_info) >= R_NDS32_SDA16S3_RELA - && ELF32_R_TYPE (irel->r_info) <= R_NDS32_SDA19S0_RELA)) - { - r_symndx = ELF32_R_SYM (irel->r_info); - jrel = irel; - rel_backup = *irel; - if (r_symndx < symtab_hdr->sh_info) - { - /* Local symbol. */ - int shndx = isym[r_symndx].st_shndx; - - bfd_vma st_value = (isym + r_symndx)->st_value; - isec = elf_elfsections (abfd)[shndx]->bfd_section; - relocation = (isec->output_section->vma + isec->output_offset - + st_value + irel->r_addend); - } - else - { - /* External symbol. */ - bfd_boolean warned ATTRIBUTE_UNUSED; - bfd_boolean ignored ATTRIBUTE_UNUSED; - bfd_boolean unresolved_reloc ATTRIBUTE_UNUSED; - asection *sym_sec; - - /* Maybe there is a better way to get h and relocation */ - RELOC_FOR_GLOBAL_SYMBOL (link_info, abfd, sec, irel, - r_symndx, symtab_hdr, sym_hashes, - h, sym_sec, relocation, - unresolved_reloc, warned, ignored); - relocation += irel->r_addend; - if ((h->root.type != bfd_link_hash_defined - && h->root.type != bfd_link_hash_defweak) - || strcmp (h->root.root.string, "_FP_BASE_") == 0) - { - off += 4; - continue; - } - } - - /* Check for gp relative instruction alignment. */ - if ((ELF32_R_TYPE (irel->r_info) >= R_NDS32_SDA15S3 - && ELF32_R_TYPE (irel->r_info) <= R_NDS32_SDA15S0) - || (ELF32_R_TYPE (irel->r_info) >= R_NDS32_SDA15S3_RELA - && ELF32_R_TYPE (irel->r_info) <= R_NDS32_SDA15S0_RELA) - || (ELF32_R_TYPE (irel->r_info) >= R_NDS32_SDA12S2_DP_RELA - && ELF32_R_TYPE (irel->r_info) <= R_NDS32_SDA12S2_SP_RELA) - || (ELF32_R_TYPE (irel->r_info) >= R_NDS32_SDA16S3_RELA - && ELF32_R_TYPE (irel->r_info) <= R_NDS32_SDA19S0_RELA)) - { - bfd_vma gp; - bfd *output_bfd = sec->output_section->owner; - bfd_reloc_status_type r; - - /* If the symbol is in the abs section, the out_bfd will be null. - This happens when the relocation has a symbol@GOTOFF. */ - r = nds32_elf_final_sda_base (output_bfd, link_info, &gp, FALSE); - if (r != bfd_reloc_ok) - { - off += 4; - continue; - } - - relocation -= gp; - - /* Make sure alignment is correct. */ - if (relocation & align) - { - /* Incorrect alignment. */ - _bfd_error_handler - /* xgettext:c-format */ - (_("%B: warning: unaligned small data access " - "for entry: {%Ld, %Ld, %Ld}, addr = %#Lx, align = %#x"), - abfd, irel->r_offset, - irel->r_info, irel->r_addend, relocation, align); - off += 4; - continue; - } - } - - insn = insn_with_reg - | ((relocation >> shift) & nds32_elf_irel_mask (irel)); - } - else if (ELF32_R_TYPE (irel->r_info) == R_NDS32_RELAX_REGION_BEGIN - || ELF32_R_TYPE (irel->r_info) == R_NDS32_RELAX_REGION_END - || ELF32_R_TYPE (irel->r_info) == R_NDS32_NONE) - { - /* These relocations do not have to relocate contens, so it can - be regard as instruction without relocation. */ - } - else - { - off += 4; - continue; - } - } - - snprintf (code, sizeof (code), "%08x", insn); - /* Copy "code". */ - entry = (struct elf_nds32_code_hash_entry*) - bfd_hash_lookup (&ex9_code_table, code, TRUE, TRUE); - if (entry == NULL) - { - _bfd_error_handler - (_("failed creating ex9.it %s hash table entry"), code); - return FALSE; - } - if (h) - { - if (h->root.type == bfd_link_hash_undefined) - return TRUE; - /* Global symbol. */ - /* In order to do sethi with different symbol but same value. */ - if (entry->m_list == NULL) - { - struct elf_link_hash_entry_mul_list *m_list_new; - struct elf_link_hash_entry_list *h_list_new; - - m_list_new = (struct elf_link_hash_entry_mul_list *) - bfd_malloc (sizeof (struct elf_link_hash_entry_mul_list)); - h_list_new = (struct elf_link_hash_entry_list *) - bfd_malloc (sizeof (struct elf_link_hash_entry_list)); - entry->m_list = m_list_new; - m_list_new->h_list = h_list_new; - m_list_new->rel_backup = rel_backup; - m_list_new->times = 1; - m_list_new->irel = jrel; - m_list_new->next = NULL; - h_list_new->h = h; - h_list_new->next = NULL; - } - else - { - struct elf_link_hash_entry_mul_list *m_list = entry->m_list; - struct elf_link_hash_entry_list *h_list; - - while (m_list) - { - /* Build the different symbols that point to the same address. */ - h_list = m_list->h_list; - if (h_list->h->root.u.def.value == h->root.u.def.value - && h_list->h->root.u.def.section->output_section->vma - == h->root.u.def.section->output_section->vma - && h_list->h->root.u.def.section->output_offset - == h->root.u.def.section->output_offset - && m_list->rel_backup.r_addend == rel_backup.r_addend) - { - m_list->times++; - m_list->irel = jrel; - while (h_list->h != h && h_list->next) - h_list = h_list->next; - if (h_list->h != h) - { - struct elf_link_hash_entry_list *h_list_new; - - h_list_new = (struct elf_link_hash_entry_list *) - bfd_malloc (sizeof (struct elf_link_hash_entry_list)); - h_list->next = h_list_new; - h_list_new->h = h; - h_list_new->next = NULL; - } - break; - } - /* The sethi case may have different address but the - hi20 is the same. */ - else if (ELF32_R_TYPE (jrel->r_info) == R_NDS32_HI20_RELA - && m_list->next == NULL) - { - struct elf_link_hash_entry_mul_list *m_list_new; - struct elf_link_hash_entry_list *h_list_new; - - m_list_new = (struct elf_link_hash_entry_mul_list *) - bfd_malloc (sizeof (struct elf_link_hash_entry_mul_list)); - h_list_new = (struct elf_link_hash_entry_list *) - bfd_malloc (sizeof (struct elf_link_hash_entry_list)); - m_list->next = m_list_new; - m_list_new->h_list = h_list_new; - m_list_new->rel_backup = rel_backup; - m_list_new->times = 1; - m_list_new->irel = jrel; - m_list_new->next = NULL; - h_list_new->h = h; - h_list_new->next = NULL; - break; - } - m_list = m_list->next; - } - if (!m_list) - { - off += 4; - continue; - } - } - } - else - { - /* Local symbol and insn without relocation*/ - entry->times++; - entry->rel_backup = rel_backup; - } - - /* Use in sethi insn with constant and global symbol in same format. */ - if (!jrel) - entry->const_insn = 1; - else - entry->irel = jrel; - entry->sec = isec; - off += 4; - } - } - return TRUE; + return sec; } - -/* Set the _ITB_BASE, and point it to ex9 table. */ - -bfd_boolean -nds32_elf_ex9_itb_base (struct bfd_link_info *link_info) -{ - bfd *abfd; - asection *sec; - bfd *output_bfd = NULL; - struct bfd_link_hash_entry *bh = NULL; - - if (is_ITB_BASE_set == 1) - return TRUE; - - is_ITB_BASE_set = 1; - - bh = bfd_link_hash_lookup (link_info->hash, "_ITB_BASE_", FALSE, FALSE, TRUE); - - if (bh && (bh->type == bfd_link_hash_defined - || bh->type == bfd_link_hash_defweak)) - return TRUE; - - for (abfd = link_info->input_bfds; abfd != NULL; - abfd = abfd->link.next) - { - sec = bfd_get_section_by_name (abfd, ".ex9.itable"); - if (sec != NULL) - { - output_bfd = sec->output_section->owner; - break; - } - } - if (output_bfd == NULL) - { - output_bfd = link_info->output_bfd; - if (output_bfd->sections == NULL) - return TRUE; - else - sec = bfd_abs_section_ptr; - } - bh = bfd_link_hash_lookup (link_info->hash, "_ITB_BASE_", - FALSE, FALSE, TRUE); - return (_bfd_generic_link_add_one_symbol - (link_info, output_bfd, "_ITB_BASE_", - BSF_GLOBAL | BSF_WEAK, sec, 0, - (const char *) NULL, FALSE, get_elf_backend_data - (output_bfd)->collect, &bh)); -} /* End EX9.IT */ #define ELF_ARCH bfd_arch_nds32 #define ELF_MACHINE_CODE EM_NDS32 #define ELF_MAXPAGESIZE 0x1000 -#define ELF_TARGET_ID NDS32_ELF_DATA +#define ELF_TARGET_ID NDS32_ELF_DATA #define TARGET_BIG_SYM nds32_elf32_be_vec #define TARGET_BIG_NAME "elf32-nds32be" @@ -15448,7 +15276,7 @@ nds32_elf_ex9_itb_base (struct bfd_link_info *link_info) #define bfd_elf32_bfd_relax_section nds32_elf_relax_section #define bfd_elf32_bfd_set_private_flags nds32_elf_set_private_flags -#define bfd_elf32_mkobject nds32_elf_mkobject +#define bfd_elf32_mkobject nds32_elf_mkobject #define elf_backend_action_discarded nds32_elf_action_discarded #define elf_backend_add_symbol_hook nds32_elf_add_symbol_hook #define elf_backend_check_relocs nds32_elf_check_relocs @@ -15469,7 +15297,9 @@ nds32_elf_ex9_itb_base (struct bfd_link_info *link_info) #define elf_backend_final_write_processing nds32_elf_final_write_processing #define elf_backend_special_sections nds32_elf_special_sections #define bfd_elf32_bfd_get_relocated_section_contents \ - nds32_elf_get_relocated_section_contents + nds32_elf_get_relocated_section_contents +#define bfd_elf32_bfd_is_target_special_symbol nds32_elf_is_target_special_symbol +#define elf_backend_maybe_function_sym nds32_elf_maybe_function_sym #define elf_backend_can_gc_sections 1 #define elf_backend_can_refcount 1 @@ -15480,7 +15310,6 @@ nds32_elf_ex9_itb_base (struct bfd_link_info *link_info) #define elf_backend_may_use_rel_p 1 #define elf_backend_default_use_rela_p 1 #define elf_backend_may_use_rela_p 1 -#define elf_backend_dtrel_excludes_plt 1 #include "elf32-target.h" diff --git a/bfd/elf32-nds32.h b/bfd/elf32-nds32.h index 7e09e01..8016c89 100644 --- a/bfd/elf32-nds32.h +++ b/bfd/elf32-nds32.h @@ -22,6 +22,8 @@ #ifndef ELF32_NDS32_H #define ELF32_NDS32_H +#include "bfd_stdint.h" + #ifdef __cplusplus extern "C" { #endif @@ -40,12 +42,13 @@ extern "C" { /* To distinguish the assembly code generated by compiler or written manually. */ #define R_NDS32_RELAX_ENTRY_VERBATIM_FLAG (1 << 28) -/* EX9 and link-time IFC must be explicitly enabled, so we - won't mess up handcraft assembly code. */ -/* Enable EX9 optimization for this section. */ -#define R_NDS32_RELAX_ENTRY_EX9_FLAG (1 << 2) -/* Enable IFC optimization for this section. */ -#define R_NDS32_RELAX_ENTRY_IFC_FLAG (1 << 3) +/* Two bits for ICT to comply with files without directive. */ +/* ICT small model. */ +#define R_NDS32_RELAX_ENTRY_ICT_SMALL (0x2 << 4) +/* ICT large model. */ +#define R_NDS32_RELAX_ENTRY_ICT_LARGE (0x3 << 4) +/* Mask for get ict bits. */ +#define R_NDS32_RELAX_ENTRY_ICT_MASK (0x3 << 4) /* Relocation flags for R_NDS32_INSN16. */ @@ -66,8 +69,6 @@ extern "C" { /* NOT_OMIT_FP_FLAG is set if this region is not worth for fp-as-gp. */ #define R_NDS32_RELAX_REGION_NOT_OMIT_FP_FLAG (1 << 1) -/* Suppress EX9 optimization in the region. */ -#define R_NDS32_RELAX_REGION_NO_EX9_FLAG (1 << 2) /* A Innermost loop region. Some optimizations is suppressed in this region due to performance drop. */ #define R_NDS32_RELAX_REGION_INNERMOST_LOOP_FLAG (1 << 4) @@ -91,35 +92,57 @@ enum NDS32_RELAX_NONE_ROUND = 0, NDS32_RELAX_NORMAL_ROUND, NDS32_RELAX_JUMP_IFC_ROUND, + NDS32_RELAX_IFC_ROUND, NDS32_RELAX_EX9_BUILD_ROUND, NDS32_RELAX_EX9_REPLACE_ROUND, NDS32_RELAX_EMPTY_ROUND }; -/* Optimization status mask. */ -#define NDS32_RELAX_JUMP_IFC_DONE (1 << 0) -#define NDS32_RELAX_EX9_DONE (1 << 1) +/* Security tag. */ +enum +{ + NDS32_SECURITY_NONE = 0, + NDS32_SECURITY_START, + NDS32_SECURITY_RESTART, + NDS32_SECURITY_END +}; /* Optimization turn on mask. */ -#define NDS32_RELAX_JUMP_IFC_ON (1 << 0) +#define NDS32_RELAX_IFC_ON (1 << 0) #define NDS32_RELAX_EX9_ON (1 << 1) extern void nds32_insertion_sort (void *, size_t, size_t, int (*) (const void *, const void *)); -extern int nds32_elf_ex9_init (void); -extern int nds32_convert_32_to_16 (bfd *, uint32_t, uint16_t *, int *); -extern int nds32_convert_16_to_32 (bfd *, uint16_t, uint32_t *); -extern void bfd_elf32_nds32_set_target_option (struct bfd_link_info *, - int, int, FILE *, int, - int, int, int, FILE *, - FILE *, int, int, - bfd_boolean, bfd_boolean); +struct section_id_list_t +{ + int id; + struct section_id_list_t *next; +}; + +extern struct section_id_list_t * +elf32_nds32_lookup_section_id (int, struct section_id_list_t **); +extern int elf32_nds32_check_relax_group (bfd *, asection *); +extern int elf32_nds32_unify_relax_group (bfd *, asection *); +extern int nds32_elf_unify_tls_model (bfd *, asection *, bfd_byte *, + struct bfd_link_info *); + +extern void bfd_elf32_nds32_set_target_option (struct bfd_link_info *, int, int, + FILE *, int, int, int, int, int, + int, char *); +extern void bfd_elf32_nds32_append_section (struct bfd_link_info*, bfd *); +extern int nds32_convert_32_to_16 (bfd *, uint32_t, uint16_t *, int *); +extern int nds32_convert_16_to_32 (bfd *, uint16_t, uint32_t *); #define nds32_elf_hash_table(info) \ (elf_hash_table_id ((struct elf_link_hash_table *) ((info)->hash)) \ - == NDS32_ELF_DATA ? \ - ((struct elf_nds32_link_hash_table *) ((info)->hash)) : NULL) + == NDS32_ELF_DATA ? ((struct elf_nds32_link_hash_table *) ((info)->hash)) : NULL) + +#define elf32_nds32_compute_jump_table_size(htab) \ + ((htab)->next_tls_desc_index * 4) + +#define elf32_nds32_local_tlsdesc_gotent(bfd) \ + (elf_nds32_tdata (bfd)->local_tlsdesc_gotent) /* Hash table structure for target nds32. There are some members to save target options passed from nds32elf.em to bfd. */ @@ -144,12 +167,34 @@ struct elf_nds32_link_hash_table int target_optimize; /* Switch optimization. */ int relax_status; /* Finished optimization. */ int relax_round; /* Going optimization. */ - FILE *ex9_export_file; /* --mexport-ex9= */ - FILE *ex9_import_file; /* --mimport-ex9= */ - int update_ex9_table; /* --mupdate-ex9. */ - int ex9_limit; - bfd_boolean ex9_loop_aware; /* Ignore ex9 if inside a loop. */ - bfd_boolean ifc_loop_aware; /* Ignore ifc if inside a loop. */ + bfd_boolean hyper_relax; /* Relax for symbol not in RW sections. */ + int tls_desc_trampoline; /* --m[no-]tlsdesc-trampoline. */ + + /* The offset into splt of the PLT entry for the TLS descriptor + resolver. Special values are 0, if not necessary (or not found + to be necessary yet), and -1 if needed but not determined + yet. */ + bfd_vma dt_tlsdesc_plt; + + /* The offset into sgot of the GOT entry used by the PLT entry + above. */ + bfd_vma dt_tlsdesc_got; + + /* Offset in .plt section of tls_nds32_trampoline. */ + bfd_vma tls_trampoline; + + /* The index of the next unused R_NDS32_TLS_DESC slot in .rel.plt. */ + bfd_vma next_tls_desc_index; + + /* How many R_NDS32_TLS_DESC relocations were generated so far. */ + bfd_vma num_tls_desc; + + /* The amount of space used by the reserved portion of the sgotplt + section, plus whatever space is used by the jump slots. */ + bfd_vma sgotplt_jump_table_size; + + /* True if the target uses REL relocations. */ + int use_rel; }; #ifdef __cplusplus diff --git a/bfd/elf32-nios2.c b/bfd/elf32-nios2.c index aad4bd0..e160054 100644 --- a/bfd/elf32-nios2.c +++ b/bfd/elf32-nios2.c @@ -31,6 +31,7 @@ #include "elf/nios2.h" #include "opcode/nios2.h" #include "elf32-nios2.h" +#include "libiberty.h" /* Use RELA relocations. */ #ifndef USE_RELA @@ -1578,10 +1579,8 @@ lookup_howto (unsigned int rtype, bfd *abfd) int i; /* R2 relocations are a superset of R1, so use that for the lookup table. */ - int r1_howto_tbl_size = (int) (sizeof (elf_nios2_r1_howto_table_rel) - / sizeof (elf_nios2_r1_howto_table_rel[0])); - int r2_howto_tbl_size = (int) (sizeof (elf_nios2_r2_howto_table_rel) - / sizeof (elf_nios2_r2_howto_table_rel[0])); + int r1_howto_tbl_size = (int) ARRAY_SIZE (elf_nios2_r1_howto_table_rel); + int r2_howto_tbl_size = (int) ARRAY_SIZE (elf_nios2_r2_howto_table_rel); if (!initialized) { @@ -1597,18 +1596,19 @@ lookup_howto (unsigned int rtype, bfd *abfd) } } - BFD_ASSERT (rtype <= R_NIOS2_ILLEGAL); + if (rtype > R_NIOS2_ILLEGAL) + return NULL; i = elf_code_to_howto_index[rtype]; if (BFD_IS_R2 (abfd)) { if (i >= r2_howto_tbl_size) - return 0; + return NULL; return elf_nios2_r2_howto_table_rel + i; } else { if (i >= r1_howto_tbl_size) - return 0; + return NULL; return elf_nios2_r1_howto_table_rel + i; } } @@ -1620,7 +1620,8 @@ struct elf_reloc_map enum elf_nios2_reloc_type elf_val; }; -static const struct elf_reloc_map nios2_reloc_map[] = { +static const struct elf_reloc_map nios2_reloc_map[] = +{ {BFD_RELOC_NONE, R_NIOS2_NONE}, {BFD_RELOC_NIOS2_S16, R_NIOS2_S16}, {BFD_RELOC_NIOS2_U16, R_NIOS2_U16}, @@ -2204,7 +2205,7 @@ nios2_add_stub (const char *stub_name, if (hsh == NULL) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: cannot create stub entry %s"), + _bfd_error_handler (_("%pB: cannot create stub entry %s"), section->owner, stub_name); return NULL; @@ -2926,7 +2927,7 @@ nios2_elf32_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) if (bfd_big_endian (ibfd)) { _bfd_error_handler - (_("error: %B: Big-endian R2 is not supported."), ibfd); + (_("error: %pB: big-endian R2 is not supported"), ibfd); bfd_set_error (bfd_error_bad_value); return FALSE; } @@ -2942,7 +2943,7 @@ nios2_elf32_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) architectures. */ _bfd_error_handler /* xgettext:c-format */ - (_("error: %B: Conflicting CPU architectures %d/%d"), + (_("error: %pB: conflicting CPU architectures %d/%d"), ibfd, new_flags, old_flags); bfd_set_error (bfd_error_bad_value); return FALSE; @@ -2954,18 +2955,16 @@ nios2_elf32_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) return TRUE; } - /* Implement bfd_elf32_bfd_reloc_type_lookup: Given a BFD reloc type, return a howto structure. */ + static reloc_howto_type * nios2_elf32_bfd_reloc_type_lookup (bfd *abfd, bfd_reloc_code_real_type code) { int i; - for (i = 0; - i < (int) (sizeof (nios2_reloc_map) / sizeof (struct elf_reloc_map)); - ++i) + for (i = 0; i < (int) ARRAY_SIZE (nios2_reloc_map); ++i) if (nios2_reloc_map[i].bfd_val == code) return lookup_howto (nios2_reloc_map[i].elf_val, abfd); return NULL; @@ -2973,6 +2972,7 @@ nios2_elf32_bfd_reloc_type_lookup (bfd *abfd, /* Implement bfd_elf32_bfd_reloc_name_lookup: Given a reloc name, return a howto structure. */ + static reloc_howto_type * nios2_elf32_bfd_reloc_name_lookup (bfd *abfd, const char *r_name) @@ -2984,32 +2984,40 @@ nios2_elf32_bfd_reloc_name_lookup (bfd *abfd, if (BFD_IS_R2 (abfd)) { howto_tbl = elf_nios2_r2_howto_table_rel; - howto_tbl_size = (int) (sizeof (elf_nios2_r2_howto_table_rel) - / sizeof (elf_nios2_r2_howto_table_rel[0])); + howto_tbl_size = (int) ARRAY_SIZE (elf_nios2_r2_howto_table_rel); } else { howto_tbl = elf_nios2_r1_howto_table_rel; - howto_tbl_size = (int) (sizeof (elf_nios2_r1_howto_table_rel) - / sizeof (elf_nios2_r1_howto_table_rel[0])); + howto_tbl_size = (int) ARRAY_SIZE (elf_nios2_r1_howto_table_rel); } for (i = 0; i < howto_tbl_size; i++) if (howto_tbl[i].name && strcasecmp (howto_tbl[i].name, r_name) == 0) return howto_tbl + i; + return NULL; } /* Implement elf_info_to_howto: Given a ELF32 relocation, fill in a arelent structure. */ -static void + +static bfd_boolean nios2_elf32_info_to_howto (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst) { unsigned int r_type; r_type = ELF32_R_TYPE (dst->r_info); - cache_ptr->howto = lookup_howto (r_type, abfd); + if ((cache_ptr->howto = lookup_howto (r_type, abfd)) == NULL) + { + /* xgettext:c-format */ + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; + } + return TRUE; } /* Return the base VMA address which should be subtracted from real addresses @@ -3831,10 +3839,10 @@ nios2_elf32_relocate_section (bfd *output_bfd, if (h) name = h->root.root.string; /* xgettext:c-format */ - format = _("Unable to reach %s (at 0x%08x) from the " + format = _("unable to reach %s (at 0x%08x) from the " "global pointer (at 0x%08x) because the " "offset (%d) is out of the allowed range, " - "-32678 to 32767.\n" ); + "-32678 to 32767\n" ); sprintf (msgbuf, format, name, symbol_address, gp, (signed)relocation); msg = msgbuf; @@ -4355,10 +4363,10 @@ nios2_elf32_relocate_section (bfd *output_bfd, { _bfd_error_handler /* xgettext:c-format */ - (_("%B(%A+%#Lx): %s relocation not " + (_("%pB(%pA+%#" PRIx64 "): %s relocation not " "permitted in shared object"), input_bfd, input_section, - rel->r_offset, howto->name); + (uint64_t) rel->r_offset, howto->name); return FALSE; } else diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c index c3a2a8f..91b780f 100644 --- a/bfd/elf32-or1k.c +++ b/bfd/elf32-or1k.c @@ -701,8 +701,8 @@ or1k_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, /* Set the howto pointer for an Or1k ELF reloc. */ -static void -or1k_info_to_howto_rela (bfd * abfd ATTRIBUTE_UNUSED, +static bfd_boolean +or1k_info_to_howto_rela (bfd * abfd, arelent * cache_ptr, Elf_Internal_Rela * dst) { @@ -712,10 +712,13 @@ or1k_info_to_howto_rela (bfd * abfd ATTRIBUTE_UNUSED, if (r_type >= (unsigned int) R_OR1K_max) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: invalid OR1K reloc number: %d"), abfd, r_type); - r_type = 0; + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; } cache_ptr->howto = & or1k_elf_howto_table[r_type]; + return TRUE; } @@ -962,7 +965,8 @@ or1k_elf_relocate_section (bfd *output_bfd, /* Addend should be zero. */ if (rel->r_addend != 0) _bfd_error_handler - (_("internal error: addend should be zero for R_OR1K_GOT16")); + (_("internal error: addend should be zero for %s"), + "R_OR1K_GOT16"); break; @@ -1049,7 +1053,7 @@ or1k_elf_relocate_section (bfd *output_bfd, { BFD_FAIL (); _bfd_error_handler - (_("%B: probably compiled without -fPIC?"), + (_("%pB: probably compiled without -fPIC?"), input_bfd); bfd_set_error (bfd_error_bad_value); return FALSE; @@ -1071,7 +1075,7 @@ or1k_elf_relocate_section (bfd *output_bfd, /* TODO: implement support for local dynamic. */ BFD_FAIL (); _bfd_error_handler - (_("%B: support for local dynamic not implemented"), + (_("%pB: support for local dynamic not implemented"), input_bfd); bfd_set_error (bfd_error_bad_value); return FALSE; @@ -1206,7 +1210,7 @@ or1k_elf_relocate_section (bfd *output_bfd, be used as linker input. */ BFD_FAIL (); _bfd_error_handler - (_("%B: will not resolve runtime TLS relocation"), + (_("%pB: will not resolve runtime TLS relocation"), input_bfd); bfd_set_error (bfd_error_bad_value); return FALSE; @@ -1526,7 +1530,7 @@ or1k_elf_check_relocs (bfd *abfd, { _bfd_error_handler /* xgettext:c-format */ - (_("%B: bad relocation section name `%s\'"), + (_("%pB: bad relocation section name `%s\'"), abfd, name); } @@ -2278,7 +2282,7 @@ maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) info->flags |= DF_TEXTREL; info->callbacks->minfo - (_("%B: dynamic relocation against `%T' in read-only section `%A'\n"), + (_("%pB: dynamic relocation against `%pT' in read-only section `%pA'\n"), sec->owner, h->root.root.string, sec); /* Not an error, just cut short the traversal. */ @@ -2638,7 +2642,8 @@ elf32_or1k_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) if ((in_flags & EF_OR1K_NODELAY) != (out_flags & EF_OR1K_NODELAY)) { _bfd_error_handler - (_("%B: EF_OR1K_NODELAY flag mismatch with previous modules"), ibfd); + (_("%pB: %s flag mismatch with previous modules"), + ibfd, "EF_OR1K_NODELAY"); bfd_set_error (bfd_error_bad_value); return FALSE; diff --git a/bfd/elf32-pj.c b/bfd/elf32-pj.c index 3487524..470d20a 100644 --- a/bfd/elf32-pj.c +++ b/bfd/elf32-pj.c @@ -310,8 +310,8 @@ pj_elf_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, /* Given an ELF reloc, fill in the howto field of a relent. */ -static void -pj_elf_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, +static bfd_boolean +pj_elf_info_to_howto (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst) { @@ -322,13 +322,14 @@ pj_elf_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, if (r >= R_PJ_max) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: unrecognised PicoJava reloc number: %d"), + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), abfd, r); bfd_set_error (bfd_error_bad_value); - r = R_PJ_NONE; + return FALSE; } cache_ptr->howto = &pj_elf_howto_table[r]; + return TRUE; } /* Take this moment to fill in the special picoJava bits in the diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c index 32104a1..66bbf0d 100644 --- a/bfd/elf32-ppc.c +++ b/bfd/elf32-ppc.c @@ -69,7 +69,7 @@ static bfd_reloc_status_type ppc_elf_unhandled_reloc /* For new-style .glink and .plt. */ #define GLINK_PLTRESOLVE 16*4 #define GLINK_ENTRY_SIZE(htab, h) \ - (((!htab->params->speculate_indirect_jumps ? 6*4 : 4*4) \ + ((4*4 \ + (h != NULL \ && h == htab->tls_get_addr \ && !htab->params->no_tls_get_addr_opt ? 8*4 : 0) \ @@ -155,8 +155,6 @@ static const bfd_vma ppc_elf_vxworks_pic_plt0_entry #define BA 0x48000002 #define BCL_20_31 0x429f0005 #define BCTR 0x4e800420 -#define CRSETEQ 0x4c421242 -#define BEQCTRM 0x4dc20420 #define BEQLR 0x4d820020 #define CMPWI_11_0 0x2c0b0000 #define LIS_11 0x3d600000 @@ -2016,7 +2014,7 @@ ppc_elf_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, /* Set the howto pointer for a PowerPC ELF reloc. */ -static void +static bfd_boolean ppc_elf_info_to_howto (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst) @@ -2031,24 +2029,27 @@ ppc_elf_info_to_howto (bfd *abfd, if (r_type >= R_PPC_max) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: unrecognised PPC reloc number: %d"), + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), abfd, r_type); bfd_set_error (bfd_error_bad_value); - r_type = R_PPC_NONE; + return FALSE; } + cache_ptr->howto = ppc_elf_howto_table[r_type]; /* Just because the above assert didn't trigger doesn't mean that ELF32_R_TYPE (dst->r_info) is necessarily a valid relocation. */ - if (!cache_ptr->howto) + if (cache_ptr->howto == NULL) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: invalid relocation type %d"), + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), abfd, r_type); bfd_set_error (bfd_error_bad_value); - cache_ptr->howto = ppc_elf_howto_table[R_PPC_NONE]; + return FALSE; } + + return TRUE; } /* Handle the R_PPC_ADDR16_HA and R_PPC_REL16_HA relocs. */ @@ -2736,7 +2737,7 @@ ppc_elf_begin_write_processing (bfd *abfd, struct bfd_link_info *link_info) continue; /* xgettext:c-format */ - error_message = _("corrupt %s section in %B"); + error_message = _("corrupt %s section in %pB"); length = asec->size; if (length < 20) goto fail; @@ -2756,7 +2757,7 @@ ppc_elf_begin_write_processing (bfd *abfd, struct bfd_link_info *link_info) || (bfd_bread (buffer, length, ibfd) != length)) { /* xgettext:c-format */ - error_message = _("unable to read in %s section from %B"); + error_message = _("unable to read in %s section from %pB"); goto fail; } @@ -2798,7 +2799,7 @@ ppc_elf_begin_write_processing (bfd *abfd, struct bfd_link_info *link_info) { ibfd = abfd; /* xgettext:c-format */ - error_message = _("warning: unable to set size of %s section in %B"); + error_message = _("warning: unable to set size of %s section in %pB"); } } @@ -2848,7 +2849,7 @@ ppc_elf_final_write_processing (bfd *abfd, bfd_boolean linker ATTRIBUTE_UNUSED) if (buffer == NULL) { _bfd_error_handler - (_("failed to allocate space for new APUinfo section.")); + (_("failed to allocate space for new APUinfo section")); return; } @@ -2867,10 +2868,10 @@ ppc_elf_final_write_processing (bfd *abfd, bfd_boolean linker ATTRIBUTE_UNUSED) } if (length != asec->size) - _bfd_error_handler (_("failed to compute new APUinfo section.")); + _bfd_error_handler (_("failed to compute new APUinfo section")); if (! bfd_set_section_contents (abfd, asec, buffer, (file_ptr) 0, length)) - _bfd_error_handler (_("failed to install new APUinfo section.")); + _bfd_error_handler (_("failed to install new APUinfo section")); free (buffer); @@ -2880,14 +2881,15 @@ ppc_elf_final_write_processing (bfd *abfd, bfd_boolean linker ATTRIBUTE_UNUSED) static bfd_boolean is_nonpic_glink_stub (bfd *abfd, asection *glink, bfd_vma off) { - bfd_byte buf[3 * 4]; + bfd_byte buf[4 * 4]; if (!bfd_get_section_contents (abfd, glink, buf, off, sizeof buf)) return FALSE; return ((bfd_get_32 (abfd, buf + 0) & 0xffff0000) == LIS_11 && (bfd_get_32 (abfd, buf + 4) & 0xffff0000) == LWZ_11_11 - && bfd_get_32 (abfd, buf + 8) == MTCTR_11); + && bfd_get_32 (abfd, buf + 8) == MTCTR_11 + && bfd_get_32 (abfd, buf + 12) == BCTR); } static bfd_boolean @@ -3366,7 +3368,7 @@ ppc_elf_link_hash_table_create (bfd *abfd) { struct ppc_elf_link_hash_table *ret; static struct ppc_elf_params default_params - = { PLT_OLD, 0, 1, 0, 1, 0, 0, 12, 0, 0, 0 }; + = { PLT_OLD, 0, 0, 1, 0, 0, 12, 0, 0, 0 }; ret = bfd_zmalloc (sizeof (struct ppc_elf_link_hash_table)); if (ret == NULL) @@ -3926,7 +3928,7 @@ bad_shared_reloc (bfd *abfd, enum elf_ppc_reloc_type r_type) { _bfd_error_handler /* xgettext:c-format */ - (_("%B: relocation %s cannot be used when making a shared object"), + (_("%pB: relocation %s cannot be used when making a shared object"), abfd, ppc_elf_howto_table[r_type]->name); bfd_set_error (bfd_error_bad_value); @@ -3963,7 +3965,7 @@ ppc_elf_check_relocs (bfd *abfd, return TRUE; #ifdef DEBUG - _bfd_error_handler ("ppc_elf_check_relocs called for section %A in %B", + _bfd_error_handler ("ppc_elf_check_relocs called for section %pA in %pB", sec, abfd); #endif @@ -4639,21 +4641,21 @@ _bfd_elf_ppc_merge_fp_attributes (bfd *ibfd, struct bfd_link_info *info) else if (out_fp != 2 && in_fp == 2) _bfd_error_handler /* xgettext:c-format */ - (_("Warning: %B uses hard float, %B uses soft float"), obfd, ibfd); + (_("warning: %pB uses hard float, %pB uses soft float"), obfd, ibfd); else if (out_fp == 2 && in_fp != 2) _bfd_error_handler /* xgettext:c-format */ - (_("Warning: %B uses hard float, %B uses soft float"), ibfd, obfd); + (_("warning: %pB uses hard float, %pB uses soft float"), ibfd, obfd); else if (out_fp == 1 && in_fp == 3) _bfd_error_handler /* xgettext:c-format */ - (_("Warning: %B uses double-precision hard float, " - "%B uses single-precision hard float"), obfd, ibfd); + (_("warning: %pB uses double-precision hard float, " + "%pB uses single-precision hard float"), obfd, ibfd); else if (out_fp == 3 && in_fp == 1) _bfd_error_handler /* xgettext:c-format */ - (_("Warning: %B uses double-precision hard float, " - "%B uses single-precision hard float"), ibfd, obfd); + (_("warning: %pB uses double-precision hard float, " + "%pB uses single-precision hard float"), ibfd, obfd); in_fp = in_attr->i & 0xc; out_fp = out_attr->i & 0xc; @@ -4667,23 +4669,23 @@ _bfd_elf_ppc_merge_fp_attributes (bfd *ibfd, struct bfd_link_info *info) else if (out_fp != 2 * 4 && in_fp == 2 * 4) _bfd_error_handler /* xgettext:c-format */ - (_("Warning: %B uses 64-bit long double, " - "%B uses 128-bit long double"), ibfd, obfd); + (_("warning: %pB uses 64-bit long double, " + "%pB uses 128-bit long double"), ibfd, obfd); else if (in_fp != 2 * 4 && out_fp == 2 * 4) _bfd_error_handler /* xgettext:c-format */ - (_("Warning: %B uses 64-bit long double, " - "%B uses 128-bit long double"), obfd, ibfd); + (_("warning: %pB uses 64-bit long double, " + "%pB uses 128-bit long double"), obfd, ibfd); else if (out_fp == 1 * 4 && in_fp == 3 * 4) _bfd_error_handler /* xgettext:c-format */ - (_("Warning: %B uses IBM long double, " - "%B uses IEEE long double"), ibfd, obfd); + (_("warning: %pB uses IBM long double, " + "%pB uses IEEE long double"), ibfd, obfd); else if (out_fp == 3 * 4 && in_fp == 1 * 4) _bfd_error_handler /* xgettext:c-format */ - (_("Warning: %B uses IBM long double, " - "%B uses IEEE long double"), obfd, ibfd); + (_("warning: %pB uses IBM long double, " + "%pB uses IEEE long double"), obfd, ibfd); } } @@ -4733,12 +4735,12 @@ ppc_elf_merge_obj_attributes (bfd *ibfd, struct bfd_link_info *info) else if (out_vec < in_vec) _bfd_error_handler /* xgettext:c-format */ - (_("Warning: %B uses AltiVec vector ABI, %B uses SPE vector ABI"), + (_("warning: %pB uses AltiVec vector ABI, %pB uses SPE vector ABI"), obfd, ibfd); else if (out_vec > in_vec) _bfd_error_handler /* xgettext:c-format */ - (_("Warning: %B uses AltiVec vector ABI, %B uses SPE vector ABI"), + (_("warning: %pB uses AltiVec vector ABI, %pB uses SPE vector ABI"), ibfd, obfd); } @@ -4761,13 +4763,13 @@ ppc_elf_merge_obj_attributes (bfd *ibfd, struct bfd_link_info *info) else if (out_struct < in_struct) _bfd_error_handler /* xgettext:c-format */ - (_("Warning: %B uses r3/r4 for small structure returns, " - "%B uses memory"), obfd, ibfd); + (_("warning: %pB uses r3/r4 for small structure returns, " + "%pB uses memory"), obfd, ibfd); else if (out_struct > in_struct) _bfd_error_handler /* xgettext:c-format */ - (_("Warning: %B uses r3/r4 for small structure returns, " - "%B uses memory"), ibfd, obfd); + (_("warning: %pB uses r3/r4 for small structure returns, " + "%pB uses memory"), ibfd, obfd); } /* Merge Tag_compatibility attributes and any common GNU ones. */ @@ -4821,7 +4823,7 @@ ppc_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) { error = TRUE; _bfd_error_handler - (_("%B: compiled with -mrelocatable and linked with " + (_("%pB: compiled with -mrelocatable and linked with " "modules compiled normally"), ibfd); } else if ((new_flags & (EF_PPC_RELOCATABLE | EF_PPC_RELOCATABLE_LIB)) == 0 @@ -4829,7 +4831,7 @@ ppc_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) { error = TRUE; _bfd_error_handler - (_("%B: compiled normally and linked with " + (_("%pB: compiled normally and linked with " "modules compiled with -mrelocatable"), ibfd); } @@ -4857,7 +4859,7 @@ ppc_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) error = TRUE; _bfd_error_handler /* xgettext:c-format */ - (_("%B: uses different e_flags (%#x) fields " + (_("%pB: uses different e_flags (%#x) fields " "than previous modules (%#x)"), ibfd, new_flags, old_flags); } @@ -4898,7 +4900,7 @@ ppc_elf_vle_split16 (bfd *input_bfd, else _bfd_error_handler /* xgettext:c-format */ - (_("%B(%A+0x%lx): expected 16A style relocation on 0x%08x insn"), + (_("%pB(%pA+0x%lx): expected 16A style relocation on 0x%08x insn"), input_bfd, input_section, offset, opcode); } } @@ -4917,7 +4919,7 @@ ppc_elf_vle_split16 (bfd *input_bfd, else _bfd_error_handler /* xgettext:c-format */ - (_("%B(%A+0x%lx): expected 16D style relocation on 0x%08x insn"), + (_("%pB(%pA+0x%lx): expected 16D style relocation on 0x%08x insn"), input_bfd, input_section, offset, opcode); } } @@ -5008,10 +5010,9 @@ ppc_elf_select_plt_layout (bfd *output_bfd ATTRIBUTE_UNUSED, if (htab->plt_type == PLT_OLD && htab->params->plt_style == PLT_NEW) { if (htab->old_bfd != NULL) - info->callbacks->einfo (_("%P: bss-plt forced due to %B\n"), - htab->old_bfd); + _bfd_error_handler (_("bss-plt forced due to %pB"), htab->old_bfd); else - info->callbacks->einfo (_("%P: bss-plt forced by profiling\n")); + _bfd_error_handler (_("bss-plt forced by profiling")); } BFD_ASSERT (htab->plt_type != PLT_VXWORKS); @@ -6164,7 +6165,7 @@ maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) info->flags |= DF_TEXTREL; info->callbacks->minfo - (_("%B: dynamic relocation against `%T' in read-only section `%A'\n"), + (_("%pB: dynamic relocation against `%pT' in read-only section `%pA'\n"), sec->owner, h->root.root.string, sec); /* Not an error, just cut short the traversal. */ @@ -6272,7 +6273,7 @@ ppc_elf_size_dynamic_sections (bfd *output_bfd, == (SEC_READONLY | SEC_ALLOC)) { info->flags |= DF_TEXTREL; - info->callbacks->minfo (_("%B: dynamic relocation in read-only section `%A'\n"), + info->callbacks->minfo (_("%pB: dynamic relocation in read-only section `%pA'\n"), p->sec->owner, p->sec); } } @@ -7171,8 +7172,6 @@ ppc_elf_relax_section (bfd *abfd, size = 4 * ARRAY_SIZE (stub_entry); insn_offset = 0; } - if (!htab->params->speculate_indirect_jumps) - size += 8; stub_rtype = R_PPC_RELAX; if (tsec == htab->elf.splt || tsec == htab->glink) @@ -7454,26 +7453,6 @@ elf_finish_pointer_linker_section (bfd *input_bfd, #define PPC_HI(v) (((v) >> 16) & 0xffff) #define PPC_HA(v) PPC_HI ((v) + 0x8000) -static inline bfd_byte * -output_bctr (struct ppc_elf_link_hash_table *htab, bfd *obfd, bfd_byte *p) -{ - if (!htab->params->speculate_indirect_jumps) - { - bfd_put_32 (obfd, CRSETEQ, p); - p += 4; - bfd_put_32 (obfd, BEQCTRM, p); - p += 4; - bfd_put_32 (obfd, B, p); - p += 4; - } - else - { - bfd_put_32 (obfd, BCTR, p); - p += 4; - } - return p; -} - static void write_glink_stub (struct elf_link_hash_entry *h, struct plt_entry *ent, asection *plt_sec, unsigned char *p, @@ -7541,7 +7520,8 @@ write_glink_stub (struct elf_link_hash_entry *h, struct plt_entry *ent, p += 4; bfd_put_32 (output_bfd, MTCTR_11, p); p += 4; - p = output_bctr (htab, output_bfd, p); + bfd_put_32 (output_bfd, BCTR, p); + p += 4; while (p < end) { bfd_put_32 (output_bfd, htab->params->ppc476_workaround ? BA : NOP, p); @@ -7717,7 +7697,7 @@ ppc_elf_relocate_section (bfd *output_bfd, struct ppc_elf_relax_info *relax_info = NULL; #ifdef DEBUG - _bfd_error_handler ("ppc_elf_relocate_section called for %B section %A, " + _bfd_error_handler ("ppc_elf_relocate_section called for %pB section %pA, " "%ld relocations%s", input_bfd, input_section, (long) input_section->reloc_count, @@ -8183,8 +8163,9 @@ ppc_elf_relocate_section (bfd *output_bfd, else _bfd_error_handler /* xgettext:c-format */ - (_("%B(%A+%#Lx): error: %s with unexpected instruction %#x"), - input_bfd, input_section, rel->r_offset, + (_("%pB(%pA+%#" PRIx64 "): error: " + "%s with unexpected instruction %#x"), + input_bfd, input_section, (uint64_t) rel->r_offset, "R_PPC_ADDR16_HA", insn); } else if (r_type == R_PPC_ADDR16_LO) @@ -8218,8 +8199,9 @@ ppc_elf_relocate_section (bfd *output_bfd, else _bfd_error_handler /* xgettext:c-format */ - (_("%B(%A+%#Lx): error: %s with unexpected instruction %#x"), - input_bfd, input_section, rel->r_offset, + (_("%pB(%pA+%#" PRIx64 "): error: " + "%s with unexpected instruction %#x"), + input_bfd, input_section, (uint64_t) rel->r_offset, "R_PPC_ADDR16_LO", insn); } } @@ -8361,10 +8343,9 @@ ppc_elf_relocate_section (bfd *output_bfd, switch (r_type) { default: - info->callbacks->einfo - /* xgettext:c-format */ - (_("%P: %B: unknown relocation type %d for symbol %s\n"), - input_bfd, (int) r_type, sym_name); + /* xgettext:c-format */ + _bfd_error_handler (_("%pB: %s unsupported"), + input_bfd, howto->name); bfd_set_error (bfd_error_bad_value); ret = FALSE; @@ -8979,7 +8960,6 @@ ppc_elf_relocate_section (bfd *output_bfd, stub = stub_entry; size = ARRAY_SIZE (stub_entry); } - --size; relocation += addend; if (bfd_link_relocatable (info)) @@ -9004,7 +8984,6 @@ ppc_elf_relocate_section (bfd *output_bfd, bfd_put_32 (input_bfd, insn, contents + insn_offset); insn_offset += 4; } - output_bctr (htab, input_bfd, contents + insn_offset); /* Rewrite the reloc and convert one of the trailing nop relocs to describe this relocation. */ @@ -9121,10 +9100,10 @@ ppc_elf_relocate_section (bfd *output_bfd, if (!(strcmp (name, ".sdata") == 0 || strcmp (name, ".sbss") == 0)) { - info->callbacks->einfo + _bfd_error_handler /* xgettext:c-format */ - (_("%P: %B: the target (%s) of a %s relocation is " - "in the wrong output section (%s)\n"), + (_("%pB: the target (%s) of a %s relocation is " + "in the wrong output section (%s)"), input_bfd, sym_name, howto->name, @@ -9152,10 +9131,10 @@ ppc_elf_relocate_section (bfd *output_bfd, if (!(strcmp (name, ".sdata2") == 0 || strcmp (name, ".sbss2") == 0)) { - info->callbacks->einfo + _bfd_error_handler /* xgettext:c-format */ - (_("%P: %B: the target (%s) of a %s relocation is " - "in the wrong output section (%s)\n"), + (_("%pB: the target (%s) of a %s relocation is " + "in the wrong output section (%s)"), input_bfd, sym_name, howto->name, @@ -9243,10 +9222,10 @@ ppc_elf_relocate_section (bfd *output_bfd, } else { - info->callbacks->einfo + _bfd_error_handler /* xgettext:c-format */ - (_("%P: %B: the target (%s) of a %s relocation is " - "in the wrong output section (%s)\n"), + (_("%pB: the target (%s) of a %s relocation is " + "in the wrong output section (%s)"), input_bfd, sym_name, howto->name, @@ -9333,7 +9312,7 @@ ppc_elf_relocate_section (bfd *output_bfd, { _bfd_error_handler /* xgettext:c-format */ - (_("%B: the target (%s) of a %s relocation is " + (_("%pB: the target (%s) of a %s relocation is " "in the wrong output section (%s)"), input_bfd, sym_name, @@ -9439,12 +9418,9 @@ ppc_elf_relocate_section (bfd *output_bfd, case R_PPC_EMB_RELST_HI: case R_PPC_EMB_RELST_HA: case R_PPC_EMB_BIT_FLD: - info->callbacks->einfo - /* xgettext:c-format */ - (_("%P: %B: relocation %s is not yet supported for symbol %s\n"), - input_bfd, - howto->name, - sym_name); + /* xgettext:c-format */ + _bfd_error_handler (_("%pB: %s unsupported"), + input_bfd, howto->name); bfd_set_error (bfd_error_invalid_operation); ret = FALSE; @@ -10429,11 +10405,10 @@ ppc_elf_finish_dynamic_sections (bfd *output_bfd, else { /* xgettext:c-format */ - info->callbacks->einfo (_("%P: %s not defined in linker created %s\n"), - htab->elf.hgot->root.root.string, - (htab->elf.sgotplt != NULL - ? htab->elf.sgotplt->name - : htab->elf.sgot->name)); + _bfd_error_handler (_("%s not defined in linker created %pA"), + htab->elf.hgot->root.root.string, + (htab->elf.sgotplt != NULL + ? htab->elf.sgotplt : htab->elf.sgot)); bfd_set_error (bfd_error_bad_value); ret = FALSE; } @@ -10713,7 +10688,8 @@ ppc_elf_finish_dynamic_sections (bfd *output_bfd, p += 4; bfd_put_32 (output_bfd, ADD_11_0_11, p); p += 4; - p = output_bctr (htab, output_bfd, p); + bfd_put_32 (output_bfd, BCTR, p); + p += 4; while (p < endp) { bfd_put_32 (output_bfd, diff --git a/bfd/elf32-ppc.h b/bfd/elf32-ppc.h index 8977efa..f56d027 100644 --- a/bfd/elf32-ppc.h +++ b/bfd/elf32-ppc.h @@ -35,9 +35,6 @@ struct ppc_elf_params /* Set if individual PLT call stubs should be aligned. */ int plt_stub_align; - /* Clear if PLT call stubs should use a speculative execution barrier. */ - int speculate_indirect_jumps; - /* Whether to emit symbols for stubs. */ int emit_stub_syms; diff --git a/bfd/elf32-pru.c b/bfd/elf32-pru.c index 71bb0a0..a3c431b 100644 --- a/bfd/elf32-pru.c +++ b/bfd/elf32-pru.c @@ -30,6 +30,7 @@ #include "elf-bfd.h" #include "elf/pru.h" #include "opcode/pru.h" +#include "libiberty.h" #define SWAP_VALS(A,B) \ do { \ @@ -291,38 +292,42 @@ static reloc_howto_type elf_pru_howto_table_rel[] = { static unsigned char elf_code_to_howto_index[R_PRU_ILLEGAL + 1]; /* Return the howto for relocation RTYPE. */ + static reloc_howto_type * lookup_howto (unsigned int rtype) { - static int initialized = 0; + static bfd_boolean initialized = FALSE; int i; int howto_tbl_size = (int) (sizeof (elf_pru_howto_table_rel) / sizeof (elf_pru_howto_table_rel[0])); - if (!initialized) + if (! initialized) { - initialized = 1; + initialized = TRUE; memset (elf_code_to_howto_index, 0xff, sizeof (elf_code_to_howto_index)); for (i = 0; i < howto_tbl_size; i++) elf_code_to_howto_index[elf_pru_howto_table_rel[i].type] = i; } - BFD_ASSERT (rtype <= R_PRU_ILLEGAL); + if (rtype > R_PRU_ILLEGAL) + return NULL; i = elf_code_to_howto_index[rtype]; if (i >= howto_tbl_size) - return 0; + return NULL; return elf_pru_howto_table_rel + i; } /* Map for converting BFD reloc types to PRU reloc types. */ + struct elf_reloc_map { bfd_reloc_code_real_type bfd_val; enum elf_pru_reloc_type elf_val; }; -static const struct elf_reloc_map pru_reloc_map[] = { +static const struct elf_reloc_map pru_reloc_map[] = +{ {BFD_RELOC_NONE, R_PRU_NONE}, {BFD_RELOC_PRU_16_PMEM, R_PRU_16_PMEM}, {BFD_RELOC_PRU_U16_PMEMIMM, R_PRU_U16_PMEMIMM}, @@ -346,6 +351,7 @@ static const struct elf_reloc_map pru_reloc_map[] = { /* Assorted hash table functions. */ /* Create an entry in a PRU ELF linker hash table. */ + static struct bfd_hash_entry * link_hash_newfunc (struct bfd_hash_entry *entry, struct bfd_hash_table *table, const char *string) @@ -368,14 +374,14 @@ link_hash_newfunc (struct bfd_hash_entry *entry, /* Implement bfd_elf32_bfd_reloc_type_lookup: Given a BFD reloc type, return a howto structure. */ + static reloc_howto_type * pru_elf32_bfd_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED, bfd_reloc_code_real_type code) { - int i; - for (i = 0; - i < (int) (sizeof (pru_reloc_map) / sizeof (struct elf_reloc_map)); - ++i) + unsigned int i; + + for (i = 0; i < ARRAY_SIZE (pru_reloc_map); ++i) if (pru_reloc_map[i].bfd_val == code) return lookup_howto ((unsigned int) pru_reloc_map[i].elf_val); return NULL; @@ -383,15 +389,14 @@ pru_elf32_bfd_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED, /* Implement bfd_elf32_bfd_reloc_name_lookup: Given a reloc name, return a howto structure. */ + static reloc_howto_type * pru_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, const char *r_name) { unsigned int i; - for (i = 0; - i < (sizeof (elf_pru_howto_table_rel) - / sizeof (elf_pru_howto_table_rel[0])); - i++) + + for (i = 0; i < ARRAY_SIZE (elf_pru_howto_table_rel); i++) if (elf_pru_howto_table_rel[i].name && strcasecmp (elf_pru_howto_table_rel[i].name, r_name) == 0) return &elf_pru_howto_table_rel[i]; @@ -401,15 +406,24 @@ pru_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, /* Implement elf_info_to_howto: Given a ELF32 relocation, fill in a arelent structure. */ -static void -pru_elf32_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, arelent *cache_ptr, + +static bfd_boolean +pru_elf32_info_to_howto (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst) { unsigned int r_type; r_type = ELF32_R_TYPE (dst->r_info); - BFD_ASSERT (r_type < R_PRU_ILLEGAL); + if (r_type >= R_PRU_ILLEGAL) + { + /* xgettext:c-format */ + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; + } + cache_ptr->howto = lookup_howto (r_type); + return cache_ptr->howto != NULL; } /* Do the relocations that require special handling. */ diff --git a/bfd/elf32-rl78.c b/bfd/elf32-rl78.c index 48714c2..e072b1a 100644 --- a/bfd/elf32-rl78.c +++ b/bfd/elf32-rl78.c @@ -278,8 +278,8 @@ rl78_reloc_name_lookup (bfd * abfd ATTRIBUTE_UNUSED, const char * r_name) /* Set the howto pointer for an RL78 ELF reloc. */ -static void -rl78_info_to_howto_rela (bfd * abfd ATTRIBUTE_UNUSED, +static bfd_boolean +rl78_info_to_howto_rela (bfd * abfd, arelent * cache_ptr, Elf_Internal_Rela * dst) { @@ -289,10 +289,13 @@ rl78_info_to_howto_rela (bfd * abfd ATTRIBUTE_UNUSED, if (r_type >= (unsigned int) R_RL78_max) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: invalid RL78 reloc number: %d"), abfd, r_type); - r_type = 0; + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; } cache_ptr->howto = rl78_elf_howto_table + r_type; + return TRUE; } static bfd_vma @@ -367,7 +370,7 @@ static unsigned int rl78_stack_top; if (rl78_stack_top < NUM_STACK_ENTRIES) \ rl78_stack [rl78_stack_top ++] = (val); \ else \ - _bfd_error_handler (_("Internal Error: RL78 reloc stack overflow")); \ + _bfd_error_handler (_("internal error: RL78 reloc stack overflow")); \ } \ while (0) @@ -378,7 +381,7 @@ static unsigned int rl78_stack_top; (dest) = rl78_stack [-- rl78_stack_top];\ else \ { \ - _bfd_error_handler (_("Internal Error: RL78 reloc stack underflow")); \ + _bfd_error_handler (_("internal error: RL78 reloc stack underflow")); \ (dest) = 0; \ } \ } \ @@ -1047,7 +1050,8 @@ rl78_elf_relocate_section { relocation = 0; if (h->root.type != bfd_link_hash_undefweak) - _bfd_error_handler (_("Warning: RL78_SYM reloc with an unknown symbol")); + _bfd_error_handler + (_("warning: RL78_SYM reloc with an unknown symbol")); } (void) rl78_compute_complex_reloc (r_type, relocation, input_section); break; @@ -1078,7 +1082,7 @@ rl78_elf_relocate_section and emit a more helpful error message. */ if (r_type == R_RL78_DIR24S_PCREL) /* xgettext:c-format */ - msg = _("%B(%A): error: call to undefined function '%s'"); + msg = _("%pB(%pA): error: call to undefined function '%s'"); else (*info->callbacks->reloc_overflow) (info, (h ? &h->root : NULL), name, howto->name, (bfd_vma) 0, @@ -1092,27 +1096,27 @@ rl78_elf_relocate_section case bfd_reloc_other: /* xgettext:c-format */ - msg = _("%B(%A): warning: unaligned access to symbol '%s' in the small data area"); + msg = _("%pB(%pA): warning: unaligned access to symbol '%s' in the small data area"); break; case bfd_reloc_outofrange: /* xgettext:c-format */ - msg = _("%B(%A): internal error: out of range error"); + msg = _("%pB(%pA): internal error: out of range error"); break; case bfd_reloc_notsupported: /* xgettext:c-format */ - msg = _("%B(%A): internal error: unsupported relocation error"); + msg = _("%pB(%pA): internal error: unsupported relocation error"); break; case bfd_reloc_dangerous: /* xgettext:c-format */ - msg = _("%B(%A): internal error: dangerous relocation"); + msg = _("%pB(%pA): internal error: dangerous relocation"); break; default: /* xgettext:c-format */ - msg = _("%B(%A): internal error: unknown error"); + msg = _("%pB(%pA): internal error: unknown error"); break; } @@ -1199,8 +1203,8 @@ rl78_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) _bfd_error_handler /* xgettext:c-format */ - (_("RL78 ABI conflict: G10 file %B cannot be linked" - " with %s file %B"), + (_("RL78 ABI conflict: G10 file %pB cannot be linked" + " with %s file %pB"), ibfd, rl78_cpu_name (out_cpu), obfd); } else @@ -1216,7 +1220,7 @@ rl78_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) _bfd_error_handler /* xgettext:c-format */ - (_("RL78 ABI conflict: cannot link %s file %B with %s file %B"), + (_("RL78 ABI conflict: cannot link %s file %pB with %s file %pB"), rl78_cpu_name (in_cpu), ibfd, rl78_cpu_name (out_cpu), obfd); } @@ -1229,11 +1233,11 @@ rl78_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) if (old_flags & E_FLAG_RL78_64BIT_DOUBLES) /* xgettext:c-format */ - _bfd_error_handler (_("- %B is 64-bit, %B is not"), + _bfd_error_handler (_("- %pB is 64-bit, %pB is not"), obfd, ibfd); else /* xgettext:c-format */ - _bfd_error_handler (_("- %B is 64-bit, %B is not"), + _bfd_error_handler (_("- %pB is 64-bit, %pB is not"), ibfd, obfd); error = TRUE; } diff --git a/bfd/elf32-rx.c b/bfd/elf32-rx.c index a0e1f78..1f70b97 100644 --- a/bfd/elf32-rx.c +++ b/bfd/elf32-rx.c @@ -300,8 +300,8 @@ rx_reloc_name_lookup (bfd * abfd ATTRIBUTE_UNUSED, const char * r_name) /* Set the howto pointer for an RX ELF reloc. */ -static void -rx_info_to_howto_rela (bfd * abfd ATTRIBUTE_UNUSED, +static bfd_boolean +rx_info_to_howto_rela (bfd * abfd, arelent * cache_ptr, Elf_Internal_Rela * dst) { @@ -311,10 +311,21 @@ rx_info_to_howto_rela (bfd * abfd ATTRIBUTE_UNUSED, if (r_type >= (unsigned int) R_RX_max) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: invalid RX reloc number: %d"), abfd, r_type); - r_type = 0; + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; } cache_ptr->howto = rx_elf_howto_table + r_type; + if (cache_ptr->howto->name == NULL) + { + /* xgettext:c-format */ + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; + } + return TRUE; } static bfd_vma @@ -592,14 +603,14 @@ rx_elf_relocate_section if (table_end_cache <= entry_vma || entry_vma < table_start_cache) { /* xgettext:c-format */ - _bfd_error_handler (_("%B:%A: table entry %s outside table"), + _bfd_error_handler (_("%pB:%pA: table entry %s outside table"), input_bfd, input_section, name); } else if ((int) (entry_vma - table_start_cache) % 4) { /* xgettext:c-format */ - _bfd_error_handler (_("%B:%A: table entry %s not word-aligned within table"), + _bfd_error_handler (_("%pB:%pA: table entry %s not word-aligned within table"), input_bfd, input_section, name); } @@ -660,13 +671,20 @@ rx_elf_relocate_section r = bfd_reloc_ok; -#define RANGE(a,b) if (a > (long) relocation || (long) relocation > b) r = bfd_reloc_overflow -#define ALIGN(m) if (relocation & m) r = bfd_reloc_other; -#define OP(i) (contents[rel->r_offset + (i)]) +#define RANGE(a,b) \ + if (a > (long) relocation || (long) relocation > b) \ + r = bfd_reloc_overflow +#define ALIGN(m) \ + if (relocation & m) \ + r = bfd_reloc_other +#define OP(i) \ + (contents[rel->r_offset + (i)]) #define WARN_REDHAT(type) \ - /* xgettext:c-format */ \ - _bfd_error_handler (_("%B:%A: Warning: deprecated Red Hat reloc " type " detected against: %s."), \ - input_bfd, input_section, name) + /* xgettext:c-format */ \ + _bfd_error_handler \ + (_("%pB:%pA: warning: deprecated Red Hat reloc " \ + "%s detected against: %s"), \ + input_bfd, input_section, #type, name) /* Check for unsafe relocs in PID mode. These are any relocs where an absolute address is being computed. There are special cases @@ -684,9 +702,12 @@ rx_elf_relocate_section && strcmp (name, "__romdatastart") != 0 \ && !saw_subtract) \ /* xgettext:c-format */ \ - _bfd_error_handler (_("%B(%A): unsafe PID relocation %s at %#Lx (against %s in %s)"), \ + _bfd_error_handler (_("%pB(%pA): unsafe PID relocation %s " \ + "at %#" PRIx64 " (against %s in %s)"), \ input_bfd, input_section, howto->name, \ - input_section->output_section->vma + input_section->output_offset + rel->r_offset, \ + (uint64_t) (input_section->output_section->vma \ + + input_section->output_offset \ + + rel->r_offset), \ name, sec->name); \ } \ while (0) @@ -1264,7 +1285,8 @@ rx_elf_relocate_section + sec->output_offset + rel->r_addend); else - _bfd_error_handler (_("Warning: RX_SYM reloc with an unknown symbol")); + _bfd_error_handler + (_("warning: RX_SYM reloc with an unknown symbol")); } break; @@ -1432,7 +1454,7 @@ rx_elf_relocate_section and emit a more helpful error message. */ if (r_type == R_RX_DIR24S_PCREL) /* xgettext:c-format */ - msg = _("%B(%A): error: call to undefined function '%s'"); + msg = _("%pB(%pA): error: call to undefined function '%s'"); else (*info->callbacks->reloc_overflow) (info, (h ? &h->root : NULL), name, howto->name, (bfd_vma) 0, @@ -1446,27 +1468,27 @@ rx_elf_relocate_section case bfd_reloc_other: /* xgettext:c-format */ - msg = _("%B(%A): warning: unaligned access to symbol '%s' in the small data area"); + msg = _("%pB(%pA): warning: unaligned access to symbol '%s' in the small data area"); break; case bfd_reloc_outofrange: /* xgettext:c-format */ - msg = _("%B(%A): internal error: out of range error"); + msg = _("%pB(%pA): internal error: out of range error"); break; case bfd_reloc_notsupported: /* xgettext:c-format */ - msg = _("%B(%A): internal error: unsupported relocation error"); + msg = _("%pB(%pA): internal error: unsupported relocation error"); break; case bfd_reloc_dangerous: /* xgettext:c-format */ - msg = _("%B(%A): internal error: dangerous relocation"); + msg = _("%pB(%pA): internal error: dangerous relocation"); break; default: /* xgettext:c-format */ - msg = _("%B(%A): internal error: unknown error"); + msg = _("%pB(%pA): internal error: unknown error"); break; } @@ -3143,8 +3165,8 @@ rx_elf_merge_private_bfd_data (bfd * ibfd, struct bfd_link_info *info) } else { - _bfd_error_handler (_("There is a conflict merging the" - " ELF header flags from %B"), + _bfd_error_handler (_("there is a conflict merging the" + " ELF header flags from %pB"), ibfd); _bfd_error_handler (_(" the input file's flags: %s"), describe_flags (new_flags)); @@ -3755,7 +3777,7 @@ rx_table_find (struct bfd_hash_entry *vent, void *vinfo) && h->type != bfd_link_hash_defweak)) { /* xgettext:c-format */ - _bfd_error_handler (_("%B:%A: table %s missing corresponding %s"), + _bfd_error_handler (_("%pB:%pA: table %s missing corresponding %s"), abfd, sec, name, buf); return TRUE; } @@ -3763,7 +3785,7 @@ rx_table_find (struct bfd_hash_entry *vent, void *vinfo) if (h->u.def.section != ent->u.def.section) { /* xgettext:c-format */ - _bfd_error_handler (_("%B:%A: %s and %s must be in the same input section"), + _bfd_error_handler (_("%pB:%pA: %s and %s must be in the same input section"), h->u.def.section->owner, h->u.def.section, name, buf); return TRUE; diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c index c5e7581..d077104 100644 --- a/bfd/elf32-s390.c +++ b/bfd/elf32-s390.c @@ -323,12 +323,13 @@ elf_s390_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, /* We need to use ELF32_R_TYPE so we have our own copy of this function, and elf32-s390.c has its own copy. */ -static void -elf_s390_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, +static bfd_boolean +elf_s390_info_to_howto (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst) { unsigned int r_type = ELF32_R_TYPE(dst->r_info); + switch (r_type) { case R_390_GNU_VTINHERIT: @@ -343,12 +344,15 @@ elf_s390_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, if (r_type >= sizeof (elf_howto_table) / sizeof (elf_howto_table[0])) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: invalid relocation type %d"), - abfd, (int) r_type); - r_type = R_390_NONE; + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; } cache_ptr->howto = &elf_howto_table[r_type]; } + + return TRUE; } /* A relocation function which doesn't do anything. */ @@ -953,7 +957,7 @@ elf_s390_check_relocs (bfd *abfd, if (r_symndx >= NUM_SHDR_ENTRIES (symtab_hdr)) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: bad symbol index: %d"), + _bfd_error_handler (_("%pB: bad symbol index: %d"), abfd, r_symndx); return FALSE; } @@ -1181,7 +1185,7 @@ elf_s390_check_relocs (bfd *abfd, { _bfd_error_handler /* xgettext:c-format */ - (_("%B: `%s' accessed both as normal and thread local symbol"), + (_("%pB: `%s' accessed both as normal and thread local symbol"), abfd, h->root.root.string); return FALSE; } @@ -1848,7 +1852,7 @@ maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) info->flags |= DF_TEXTREL; info->callbacks->minfo - (_("%B: dynamic relocation against `%T' in read-only section `%A'\n"), + (_("%pB: dynamic relocation against `%pT' in read-only section `%pA'\n"), sec->owner, h->root.root.string, sec); /* Not an error, just cut short the traversal. */ @@ -2134,10 +2138,10 @@ invalid_tls_insn (bfd *input_bfd, howto = elf_howto_table + ELF32_R_TYPE (rel->r_info); _bfd_error_handler /* xgettext:c-format */ - (_("%B(%A+%#Lx): invalid instruction for TLS relocation %s"), + (_("%pB(%pA+%#" PRIx64 "): invalid instruction for TLS relocation %s"), input_bfd, input_section, - rel->r_offset, + (uint64_t) rel->r_offset, howto->name); bfd_set_error (bfd_error_bad_value); } @@ -3201,10 +3205,11 @@ elf_s390_relocate_section (bfd *output_bfd, rel->r_offset) != (bfd_vma) -1) _bfd_error_handler /* xgettext:c-format */ - (_("%B(%A+%#Lx): unresolvable %s relocation against symbol `%s'"), + (_("%pB(%pA+%#" PRIx64 "): " + "unresolvable %s relocation against symbol `%s'"), input_bfd, input_section, - rel->r_offset, + (uint64_t) rel->r_offset, howto->name, h->root.root.string); @@ -3258,9 +3263,9 @@ elf_s390_relocate_section (bfd *output_bfd, { _bfd_error_handler /* xgettext:c-format */ - (_("%B(%A+%#Lx): reloc against `%s': error %d"), + (_("%pB(%pA+%#" PRIx64 "): reloc against `%s': error %d"), input_bfd, input_section, - rel->r_offset, name, (int) r); + (uint64_t) rel->r_offset, name, (int) r); return FALSE; } } diff --git a/bfd/elf32-score.c b/bfd/elf32-score.c index 897ab8a..42ef221 100644 --- a/bfd/elf32-score.c +++ b/bfd/elf32-score.c @@ -2375,7 +2375,7 @@ score_elf_final_link_relocate (reloc_howto_type *howto, } /* Score backend functions. */ -static void +static bfd_boolean s3_bfd_score_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, arelent *bfd_reloc, Elf_Internal_Rela *elf_reloc) @@ -2384,9 +2384,10 @@ s3_bfd_score_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, r_type = ELF32_R_TYPE (elf_reloc->r_info); if (r_type >= ARRAY_SIZE (elf32_score_howto_table)) - bfd_reloc->howto = NULL; - else - bfd_reloc->howto = &elf32_score_howto_table[r_type]; + return FALSE; + + bfd_reloc->howto = &elf32_score_howto_table[r_type]; + return TRUE; } /* Relocate an score ELF section. */ @@ -2448,7 +2449,8 @@ s3_bfd_score_elf_relocate_section (bfd *output_bfd, r_symndx = ELF32_R_SYM (rel->r_info); r_type = ELF32_R_TYPE (rel->r_info); - s3_bfd_score_info_to_howto (input_bfd, &bfd_reloc, (Elf_Internal_Rela *) rel); + if (! s3_bfd_score_info_to_howto (input_bfd, &bfd_reloc, (Elf_Internal_Rela *) rel)) + continue; howto = bfd_reloc.howto; h = NULL; @@ -2741,7 +2743,7 @@ s3_bfd_score_elf_relocate_section (bfd *output_bfd, /* Use bfd_reloc_other to check lw48, sw48 word align. */ case bfd_reloc_other: - msg = _("address not word align"); + msg = _("address not word aligned"); goto common_error; default: @@ -2822,7 +2824,7 @@ s3_bfd_score_elf_check_relocs (bfd *abfd, { _bfd_error_handler /* xgettext:c-format */ - (_("%B: Malformed reloc detected for section %A"), abfd, sec); + (_("%pB: malformed reloc detected for section %pA"), abfd, sec); bfd_set_error (bfd_error_bad_value); return FALSE; } @@ -2876,8 +2878,8 @@ s3_bfd_score_elf_check_relocs (bfd *abfd, { _bfd_error_handler /* xgettext:c-format */ - (_("%B: CALL15 reloc at %#Lx not against global symbol"), - abfd, rel->r_offset); + (_("%pB: CALL15 reloc at %#" PRIx64 " not against global symbol"), + abfd, (uint64_t) rel->r_offset); bfd_set_error (bfd_error_bad_value); return FALSE; } @@ -4045,7 +4047,7 @@ s3_elf32_score_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) if (((in_flags & EF_SCORE_PIC) != 0) != ((out_flags & EF_SCORE_PIC) != 0)) _bfd_error_handler - (_("%B: warning: linking PIC files with non-PIC files"), ibfd); + (_("%pB: warning: linking PIC files with non-PIC files"), ibfd); /* FIXME: Maybe dependency fix compatibility should be checked here. */ @@ -4069,7 +4071,7 @@ s3_elf32_score_new_section_hook (bfd *abfd, asection *sec) /*****************************************************************************/ /* s3_s7: backend hooks. */ -static void +static bfd_boolean _bfd_score_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, arelent *bfd_reloc, Elf_Internal_Rela *elf_reloc) @@ -4450,7 +4452,7 @@ _bfd_score_elf_common_definition (Elf_Internal_Sym *sym) #define ELF_MACHINE_ALT1 EM_SCORE_OLD #define ELF_MAXPAGESIZE 0x8000 -#define elf_info_to_howto 0 +#define elf_info_to_howto NULL #define elf_info_to_howto_rel _bfd_score_info_to_howto #define elf_backend_relocate_section _bfd_score_elf_relocate_section #define elf_backend_check_relocs _bfd_score_elf_check_relocs @@ -4466,8 +4468,7 @@ _bfd_score_elf_common_definition (Elf_Internal_Sym *sym) _bfd_score_elf_always_size_sections #define elf_backend_size_dynamic_sections \ _bfd_score_elf_size_dynamic_sections -#define elf_backend_omit_section_dynsym \ - ((bfd_boolean (*) (bfd *, struct bfd_link_info *, asection *)) bfd_true) +#define elf_backend_omit_section_dynsym _bfd_elf_omit_section_dynsym_all #define elf_backend_create_dynamic_sections \ _bfd_score_elf_create_dynamic_sections #define elf_backend_finish_dynamic_symbol \ diff --git a/bfd/elf32-score.h b/bfd/elf32-score.h index dc9fd1e..ed5c9fc 100644 --- a/bfd/elf32-score.h +++ b/bfd/elf32-score.h @@ -30,7 +30,7 @@ s7_bfd_score_elf_hide_symbol (struct bfd_link_info *, struct elf_link_hash_entry *, bfd_boolean); -extern void +extern bfd_boolean s7_bfd_score_info_to_howto (bfd *, arelent *, Elf_Internal_Rela *); extern bfd_boolean diff --git a/bfd/elf32-score7.c b/bfd/elf32-score7.c index 2b803e6..3c022e6 100644 --- a/bfd/elf32-score7.c +++ b/bfd/elf32-score7.c @@ -2214,7 +2214,7 @@ score_elf_final_link_relocate (reloc_howto_type *howto, /* Score backend functions. */ -void +bfd_boolean s7_bfd_score_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, arelent *bfd_reloc, Elf_Internal_Rela *elf_reloc) @@ -2223,9 +2223,10 @@ s7_bfd_score_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, r_type = ELF32_R_TYPE (elf_reloc->r_info); if (r_type >= ARRAY_SIZE (elf32_score_howto_table)) - bfd_reloc->howto = NULL; - else - bfd_reloc->howto = &elf32_score_howto_table[r_type]; + return FALSE; + + bfd_reloc->howto = &elf32_score_howto_table[r_type]; + return TRUE; } /* Relocate an score ELF section. */ @@ -2288,7 +2289,8 @@ s7_bfd_score_elf_relocate_section (bfd *output_bfd, r_symndx = ELF32_R_SYM (rel->r_info); r_type = ELF32_R_TYPE (rel->r_info); - s7_bfd_score_info_to_howto (input_bfd, &bfd_reloc, (Elf_Internal_Rela *) rel); + if (! s7_bfd_score_info_to_howto (input_bfd, &bfd_reloc, (Elf_Internal_Rela *) rel)) + continue; howto = bfd_reloc.howto; h = NULL; @@ -2627,7 +2629,7 @@ s7_bfd_score_elf_check_relocs (bfd *abfd, { _bfd_error_handler /* xgettext:c-format */ - (_("%B: Malformed reloc detected for section %A"), abfd, sec); + (_("%pB: malformed reloc detected for section %pA"), abfd, sec); bfd_set_error (bfd_error_bad_value); return FALSE; } @@ -2681,8 +2683,8 @@ s7_bfd_score_elf_check_relocs (bfd *abfd, { _bfd_error_handler /* xgettext:c-format */ - (_("%B: CALL15 reloc at %#Lx not against global symbol"), - abfd, rel->r_offset); + (_("%pB: CALL15 reloc at %#" PRIx64 " not against global symbol"), + abfd, (uint64_t) rel->r_offset); bfd_set_error (bfd_error_bad_value); return FALSE; } @@ -3850,7 +3852,7 @@ s7_elf32_score_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) if (((in_flags & EF_SCORE_PIC) != 0) != ((out_flags & EF_SCORE_PIC) != 0)) { - _bfd_error_handler (_("%B: warning: linking PIC files with non-PIC files"), ibfd); + _bfd_error_handler (_("%pB: warning: linking PIC files with non-PIC files"), ibfd); } /* Maybe dependency fix compatibility should be checked here. */ @@ -3871,5 +3873,4 @@ s7_elf32_score_new_section_hook (bfd *abfd, asection *sec) return _bfd_elf_new_section_hook (abfd, sec); } -#define elf_backend_omit_section_dynsym \ - ((bfd_boolean (*) (bfd *, struct bfd_link_info *, asection *)) bfd_true) +#define elf_backend_omit_section_dynsym _bfd_elf_omit_section_dynsym_all diff --git a/bfd/elf32-sh-symbian.c b/bfd/elf32-sh-symbian.c index 9abfd73..b0f519b 100644 --- a/bfd/elf32-sh-symbian.c +++ b/bfd/elf32-sh-symbian.c @@ -127,7 +127,7 @@ sh_symbian_import_as (struct bfd_link_info *info, bfd * abfd, bfd_set_error (bfd_error_invalid_operation); /* xgettext:c-format */ - _bfd_error_handler (_("%B: IMPORT AS directive for %s conceals previous IMPORT AS"), + _bfd_error_handler (_("%pB: IMPORT AS directive for %s conceals previous IMPORT AS"), abfd, current_name); return FALSE; } @@ -381,7 +381,7 @@ sh_symbian_process_embedded_commands (struct bfd_link_info *info, bfd * abfd, bfd_set_error (bfd_error_invalid_operation); /* xgettext:c-format */ - _bfd_error_handler (_("%B: Unrecognised .directive command: %s"), + _bfd_error_handler (_("%pB: unrecognized .directive command: %s"), abfd, directive); break; } @@ -499,7 +499,7 @@ sh_symbian_relocate_section (bfd * output_bfd, if (new_hash == NULL) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: Failed to add renamed symbol %s"), + _bfd_error_handler (_("%pB: failed to add renamed symbol %s"), input_bfd, ptr->new_name); continue; } diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c index b4854a2..d0f5ac8 100644 --- a/bfd/elf32-sh.c +++ b/bfd/elf32-sh.c @@ -472,7 +472,7 @@ sh_elf_reloc_name_lookup (bfd *abfd, const char *r_name) /* Given an ELF reloc, fill in the howto field of a relent. */ -static void +static bfd_boolean sh_elf_info_to_howto (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst) { unsigned int r; @@ -488,13 +488,14 @@ sh_elf_info_to_howto (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst) || (r >= R_SH_FIRST_INVALID_RELOC_6 && r <= R_SH_LAST_INVALID_RELOC_6)) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: unrecognised SH reloc number: %d"), + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), abfd, r); bfd_set_error (bfd_error_bad_value); - r = R_SH_NONE; + return FALSE; } cache_ptr->howto = get_howto_table (abfd) + r; + return TRUE; } /* This function handles relaxing for SH ELF. See the corresponding @@ -577,8 +578,9 @@ sh_elf_relax_section (bfd *abfd, asection *sec, if (laddr >= sec->size) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: %#Lx: warning: bad R_SH_USES offset"), - abfd, irel->r_offset); + _bfd_error_handler + (_("%pB: %#" PRIx64 ": warning: bad R_SH_USES offset"), + abfd, (uint64_t) irel->r_offset); continue; } insn = bfd_get_16 (abfd, contents + laddr); @@ -589,8 +591,9 @@ sh_elf_relax_section (bfd *abfd, asection *sec, { _bfd_error_handler /* xgettext:c-format */ - (_("%B: %#Lx: warning: R_SH_USES points to unrecognized insn 0x%x"), - abfd, irel->r_offset, insn); + (_("%pB: %#" PRIx64 ": warning: " + "R_SH_USES points to unrecognized insn 0x%x"), + abfd, (uint64_t) irel->r_offset, insn); continue; } @@ -607,8 +610,8 @@ sh_elf_relax_section (bfd *abfd, asection *sec, { _bfd_error_handler /* xgettext:c-format */ - (_("%B: %#Lx: warning: bad R_SH_USES load offset"), - abfd, irel->r_offset); + (_("%pB: %#" PRIx64 ": warning: bad R_SH_USES load offset"), + abfd, (uint64_t) irel->r_offset); continue; } @@ -623,8 +626,8 @@ sh_elf_relax_section (bfd *abfd, asection *sec, { _bfd_error_handler /* xgettext:c-format */ - (_("%B: %#Lx: warning: could not find expected reloc"), - abfd, paddr); + (_("%pB: %#" PRIx64 ": warning: could not find expected reloc"), + abfd, (uint64_t) paddr); continue; } @@ -652,8 +655,8 @@ sh_elf_relax_section (bfd *abfd, asection *sec, { _bfd_error_handler /* xgettext:c-format */ - (_("%B: %#Lx: warning: symbol in unexpected section"), - abfd, paddr); + (_("%pB: %#" PRIx64 ": warning: symbol in unexpected section"), + abfd, (uint64_t) paddr); continue; } @@ -782,8 +785,9 @@ sh_elf_relax_section (bfd *abfd, asection *sec, { _bfd_error_handler /* xgettext:c-format */ - (_("%B: %#Lx: warning: could not find expected COUNT reloc"), - abfd, paddr); + (_("%pB: %#" PRIx64 ": warning: " + "could not find expected COUNT reloc"), + abfd, (uint64_t) paddr); continue; } @@ -792,8 +796,8 @@ sh_elf_relax_section (bfd *abfd, asection *sec, if (irelcount->r_addend == 0) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: %#Lx: warning: bad count"), - abfd, paddr); + _bfd_error_handler (_("%pB: %#" PRIx64 ": warning: bad count"), + abfd, (uint64_t) paddr); continue; } @@ -1196,8 +1200,8 @@ sh_elf_relax_delete_bytes (bfd *abfd, asection *sec, bfd_vma addr, { _bfd_error_handler /* xgettext:c-format */ - (_("%B: %#Lx: fatal: reloc overflow while relaxing"), - abfd, irel->r_offset); + (_("%pB: %#" PRIx64 ": fatal: reloc overflow while relaxing"), + abfd, (uint64_t) irel->r_offset); bfd_set_error (bfd_error_bad_value); return FALSE; } @@ -1567,8 +1571,8 @@ sh_elf_swap_insns (bfd *abfd, asection *sec, void *relocs, { _bfd_error_handler /* xgettext:c-format */ - (_("%B: %#Lx: fatal: reloc overflow while relaxing"), - abfd, irel->r_offset); + (_("%pB: %#" PRIx64 ": fatal: reloc overflow while relaxing"), + abfd, (uint64_t) irel->r_offset); bfd_set_error (bfd_error_bad_value); return FALSE; } @@ -3286,7 +3290,7 @@ maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) info->flags |= DF_TEXTREL; info->callbacks->minfo - (_("%B: dynamic relocation against `%T' in read-only section `%A'\n"), + (_("%pB: dynamic relocation against `%pT' in read-only section `%pA'\n"), sec->owner, h->root.root.string, sec); /* Not an error, just cut short the traversal. */ @@ -3389,7 +3393,7 @@ sh_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, if ((p->sec->output_section->flags & SEC_READONLY) != 0) { info->flags |= DF_TEXTREL; - info->callbacks->minfo (_("%B: dynamic relocation in read-only section `%A'\n"), + info->callbacks->minfo (_("%pB: dynamic relocation in read-only section `%pA'\n"), p->sec->owner, p->sec); } @@ -3944,7 +3948,7 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info, if ((sym->st_other & STO_SH5_ISA32) != 0) (*info->callbacks->reloc_dangerous) (info, - _("Unexpected STO_SH5_ISA32 on local symbol is not handled"), + _("unexpected STO_SH5_ISA32 on local symbol is not handled"), input_bfd, input_section, rel->r_offset); if (sec != NULL && discarded_section (sec)) @@ -4000,9 +4004,10 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info, { _bfd_error_handler /* xgettext:c-format */ - (_("%B(%A+%#Lx): %s relocation against SEC_MERGE section"), + (_("%pB(%pA+%#" PRIx64 "): " + "%s relocation against SEC_MERGE section"), input_bfd, input_section, - rel->r_offset, howto->name); + (uint64_t) rel->r_offset, howto->name); return FALSE; } @@ -4118,10 +4123,11 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info, { _bfd_error_handler /* xgettext:c-format */ - (_("%B(%A+%#Lx): unresolvable %s relocation against symbol `%s'"), + (_("%pB(%pA+%#" PRIx64 "): " + "unresolvable %s relocation against symbol `%s'"), input_bfd, input_section, - rel->r_offset, + (uint64_t) rel->r_offset, howto->name, h->root.root.string); return FALSE; @@ -4197,9 +4203,10 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info, { _bfd_error_handler /* xgettext:c-format */ - (_("%B: %#Lx: fatal: unaligned branch target for relax-support relocation"), + (_("%pB: %#" PRIx64 ": fatal: " + "unaligned branch target for relax-support relocation"), input_section->owner, - rel->r_offset); + (uint64_t) rel->r_offset); bfd_set_error (bfd_error_bad_value); return FALSE; } @@ -4231,10 +4238,10 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info, { _bfd_error_handler /* xgettext:c-format */ - (_("%B: %#Lx: fatal: unaligned %s relocation %#Lx"), - input_section->owner, - rel->r_offset, howto->name, - relocation); + (_("%pB: %#" PRIx64 ": fatal: " + "unaligned %s relocation %#" PRIx64), + input_section->owner, (uint64_t) rel->r_offset, + howto->name, (uint64_t) relocation); bfd_set_error (bfd_error_bad_value); return FALSE; } @@ -4247,10 +4254,11 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info, { _bfd_error_handler /* xgettext:c-format */ - (_("%B: %#Lx: fatal: unaligned %s relocation %#Lx"), + (_("%pB: %#" PRIx64 ": fatal: " + "unaligned %s relocation %#" PRIx64 ""), input_section->owner, - rel->r_offset, howto->name, - relocation); + (uint64_t) rel->r_offset, howto->name, + (uint64_t) relocation); bfd_set_error (bfd_error_bad_value); return FALSE; } @@ -4262,10 +4270,11 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info, { _bfd_error_handler /* xgettext:c-format */ - (_("%B: %#Lx: fatal: R_SH_PSHA relocation %Ld not in range -32..32"), + (_("%pB: %#" PRIx64 ": fatal: R_SH_PSHA relocation %" PRId64 + " not in range -32..32"), input_section->owner, - rel->r_offset, - relocation); + (uint64_t) rel->r_offset, + (int64_t) relocation); bfd_set_error (bfd_error_bad_value); return FALSE; } @@ -4277,10 +4286,11 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info, { _bfd_error_handler /* xgettext:c-format */ - (_("%B: %#Lx: fatal: R_SH_PSHL relocation %Ld not in range -32..32"), + (_("%pB: %#" PRIx64 ": fatal: R_SH_PSHL relocation %" PRId64 + " not in range -32..32"), input_section->owner, - rel->r_offset, - relocation); + (uint64_t) rel->r_offset, + (int64_t) relocation); bfd_set_error (bfd_error_bad_value); return FALSE; } @@ -4423,10 +4433,11 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info, { _bfd_error_handler /* xgettext:c-format */ - (_("%B(%A+%#Lx): cannot emit fixup to `%s' in read-only section"), + (_("%pB(%pA+%#" PRIx64 "): " + "cannot emit fixup to `%s' in read-only section"), input_bfd, input_section, - rel->r_offset, + (uint64_t) rel->r_offset, symname); return FALSE; } @@ -4896,10 +4907,11 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info, { _bfd_error_handler /* xgettext:c-format */ - (_("%B(%A+%#Lx): cannot emit fixup to `%s' in read-only section"), + (_("%pB(%pA+%#" PRIx64 "): " + "cannot emit fixup to `%s' in read-only section"), input_bfd, input_section, - rel->r_offset, + (uint64_t) rel->r_offset, symname); return FALSE; } @@ -4998,9 +5010,10 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info, { _bfd_error_handler /* xgettext:c-format */ - (_("%B(%A+%#Lx): %s relocation against external symbol \"%s\""), - input_bfd, input_section, rel->r_offset, howto->name, - h->root.root.string); + (_("%pB(%pA+%#" PRIx64 "): " + "%s relocation against external symbol \"%s\""), + input_bfd, input_section, (uint64_t) rel->r_offset, + howto->name, h->root.root.string); return FALSE; } else @@ -6043,18 +6056,18 @@ sh_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec, && (old_got_type == GOT_NORMAL || got_type == GOT_NORMAL)) _bfd_error_handler /* xgettext:c-format */ - (_("%B: `%s' accessed both as normal and FDPIC symbol"), + (_("%pB: `%s' accessed both as normal and FDPIC symbol"), abfd, h->root.root.string); else if (old_got_type == GOT_FUNCDESC || got_type == GOT_FUNCDESC) _bfd_error_handler /* xgettext:c-format */ - (_("%B: `%s' accessed both as FDPIC and thread local symbol"), + (_("%pB: `%s' accessed both as FDPIC and thread local symbol"), abfd, h->root.root.string); else _bfd_error_handler /* xgettext:c-format */ - (_("%B: `%s' accessed both as normal and thread local symbol"), + (_("%pB: `%s' accessed both as normal and thread local symbol"), abfd, h->root.root.string); return FALSE; } @@ -6080,7 +6093,7 @@ sh_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec, if (rel->r_addend) { _bfd_error_handler - (_("%B: Function descriptor relocation with non-zero addend"), + (_("%pB: Function descriptor relocation with non-zero addend"), abfd); return FALSE; } @@ -6129,12 +6142,12 @@ sh_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec, if (old_got_type == GOT_NORMAL) _bfd_error_handler /* xgettext:c-format */ - (_("%B: `%s' accessed both as normal and FDPIC symbol"), + (_("%pB: `%s' accessed both as normal and FDPIC symbol"), abfd, h->root.root.string); else _bfd_error_handler /* xgettext:c-format */ - (_("%B: `%s' accessed both as FDPIC and thread local symbol"), + (_("%pB: `%s' accessed both as FDPIC and thread local symbol"), abfd, h->root.root.string); } } @@ -6318,7 +6331,7 @@ sh_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec, if (bfd_link_dll (info)) { _bfd_error_handler - (_("%B: TLS local exec code cannot be linked into shared objects"), + (_("%pB: TLS local exec code cannot be linked into shared objects"), abfd); return FALSE; } @@ -6433,7 +6446,7 @@ sh_merge_bfd_arch (bfd *ibfd, struct bfd_link_info *info) { _bfd_error_handler /* xgettext:c-format */ - (_("%B: uses %s instructions while previous modules " + (_("%pB: uses %s instructions while previous modules " "use %s instructions"), ibfd, SH_ARCH_SET_HAS_DSP (new_arch) ? "dsp" : "floating point", @@ -6482,7 +6495,7 @@ sh_elf_merge_private_data (bfd *ibfd, struct bfd_link_info *info) if (! sh_merge_bfd_arch (ibfd, info)) { - _bfd_error_handler (_("%B: uses instructions which are incompatible " + _bfd_error_handler (_("%pB: uses instructions which are incompatible " "with instructions used in previous modules"), ibfd); bfd_set_error (bfd_error_bad_value); @@ -6495,7 +6508,7 @@ sh_elf_merge_private_data (bfd *ibfd, struct bfd_link_info *info) if (fdpic_object_p (ibfd) != fdpic_object_p (obfd)) { - _bfd_error_handler (_("%B: attempt to mix FDPIC and non-FDPIC objects"), + _bfd_error_handler (_("%pB: attempt to mix FDPIC and non-FDPIC objects"), ibfd); bfd_set_error (bfd_error_bad_value); return FALSE; diff --git a/bfd/elf32-sh64.c b/bfd/elf32-sh64.c index 51eca0b..b635841 100644 --- a/bfd/elf32-sh64.c +++ b/bfd/elf32-sh64.c @@ -222,14 +222,14 @@ sh64_elf_merge_private_data (bfd *ibfd, struct bfd_link_info *info) if (bfd_get_arch_size (ibfd) == 32 && bfd_get_arch_size (obfd) == 64) /* xgettext:c-format */ - msg = _("%B: compiled as 32-bit object and %B is 64-bit"); + msg = _("%pB: compiled as 32-bit object and %pB is 64-bit"); else if (bfd_get_arch_size (ibfd) == 64 && bfd_get_arch_size (obfd) == 32) /* xgettext:c-format */ - msg = _("%B: compiled as 64-bit object and %B is 32-bit"); + msg = _("%pB: compiled as 64-bit object and %pB is 32-bit"); else /* xgettext:c-format */ - msg = _("%B: object size does not match that of target %B"); + msg = _("%pB: object size does not match that of target %pB"); _bfd_error_handler (msg, ibfd, obfd); bfd_set_error (bfd_error_wrong_format); @@ -248,7 +248,7 @@ sh64_elf_merge_private_data (bfd *ibfd, struct bfd_link_info *info) else if ((new_flags & EF_SH_MACH_MASK) != EF_SH5) { _bfd_error_handler - ("%B: uses non-SH64 instructions while previous modules" + ("%pB: uses non-SH64 instructions while previous modules" " use SH64 instructions", ibfd); bfd_set_error (bfd_error_bad_value); @@ -452,7 +452,7 @@ sh64_elf_add_symbol_hook (bfd *abfd, struct bfd_link_info *info, { /* Make sure we don't get confused on invalid input. */ _bfd_error_handler - (_("%B: encountered datalabel symbol in input"), abfd); + (_("%pB: encountered datalabel symbol in input"), abfd); bfd_set_error (bfd_error_bad_value); return FALSE; } @@ -547,7 +547,7 @@ shmedia_prepare_reloc (struct bfd_link_info *info, bfd *abfd, if ((insn & SHMEDIA_PTB_BIT) != 0) { _bfd_error_handler - (_("%B: GAS error: unexpected PTB insn with R_SH_PT_16"), + (_("%pB: GAS error: unexpected PTB insn with R_SH_PT_16"), input_section->owner); return FALSE; } @@ -597,9 +597,10 @@ shmedia_prepare_reloc (struct bfd_link_info *info, bfd *abfd, { _bfd_error_handler /* xgettext:c-format */ - (_("%B: error: unaligned relocation type %d at %#Lx reloc %#Lx"), + (_("%pB: error: unaligned relocation type %d " + "at %#" PRIx64 " reloc %#" PRIx64), input_section->owner, (int) ELF32_R_TYPE (rel->r_info), - rel->r_offset, *relocation); + (uint64_t) rel->r_offset, (uint64_t) *relocation); return FALSE; } @@ -673,7 +674,7 @@ sh64_elf_final_write_processing (bfd *abfd, { bfd_set_error (bfd_error_file_truncated); _bfd_error_handler - (_("%B: could not write out added .cranges entries"), abfd); + (_("%pB: could not write out added .cranges entries"), abfd); } } @@ -732,7 +733,7 @@ sh64_elf_final_write_processing (bfd *abfd, { bfd_set_error (bfd_error_file_truncated); _bfd_error_handler - (_("%B: could not write out sorted .cranges entries"), abfd); + (_("%pB: could not write out sorted .cranges entries"), abfd); } } } diff --git a/bfd/elf32-sparc.c b/bfd/elf32-sparc.c index e8ca810..1a18e1e 100644 --- a/bfd/elf32-sparc.c +++ b/bfd/elf32-sparc.c @@ -86,7 +86,7 @@ elf32_sparc_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) { error = TRUE; _bfd_error_handler - (_("%B: compiled for a 64 bit system and target is 32 bit"), ibfd); + (_("%pB: compiled for a 64 bit system and target is 32 bit"), ibfd); } else if ((ibfd->flags & DYNAMIC) == 0) { @@ -99,7 +99,7 @@ elf32_sparc_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) && previous_ibfd_e_flags != (unsigned long) -1) { _bfd_error_handler - (_("%B: linking little endian files with big endian files"), ibfd); + (_("%pB: linking little endian files with big endian files"), ibfd); error = TRUE; } previous_ibfd_e_flags = elf_elfheader (ibfd)->e_flags & EF_SPARC_LEDATA; diff --git a/bfd/elf32-spu.c b/bfd/elf32-spu.c index 941ae58..c3bfbbd 100644 --- a/bfd/elf32-spu.c +++ b/bfd/elf32-spu.c @@ -145,8 +145,8 @@ spu_elf_bfd_to_reloc_type (bfd_reloc_code_real_type code) } } -static void -spu_elf_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, +static bfd_boolean +spu_elf_info_to_howto (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst) { @@ -157,12 +157,13 @@ spu_elf_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, if (r_type >= R_SPU_max) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: unrecognised SPU reloc number: %d"), + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), abfd, r_type); bfd_set_error (bfd_error_bad_value); - r_type = R_SPU_NONE; + return FALSE; } cache_ptr->howto = &elf_howto_table[(int) r_type]; + return TRUE; } static reloc_howto_type * @@ -723,16 +724,16 @@ spu_elf_find_overlays (struct bfd_link_info *info) if ((s->vma - vma_start) & (htab->params->line_size - 1)) { - info->callbacks->einfo (_("%X%P: overlay section %A " - "does not start on a cache line.\n"), + info->callbacks->einfo (_("%X%P: overlay section %pA " + "does not start on a cache line\n"), s); bfd_set_error (bfd_error_bad_value); return 0; } else if (s->size > htab->params->line_size) { - info->callbacks->einfo (_("%X%P: overlay section %A " - "is larger than a cache line.\n"), + info->callbacks->einfo (_("%X%P: overlay section %pA " + "is larger than a cache line\n"), s); bfd_set_error (bfd_error_bad_value); return 0; @@ -751,8 +752,8 @@ spu_elf_find_overlays (struct bfd_link_info *info) s = alloc_sec[i]; if (s->vma < ovl_end) { - info->callbacks->einfo (_("%X%P: overlay section %A " - "is not in cache area.\n"), + info->callbacks->einfo (_("%X%P: overlay section %pA " + "is not in cache area\n"), alloc_sec[i-1]); bfd_set_error (bfd_error_bad_value); return 0; @@ -792,9 +793,9 @@ spu_elf_find_overlays (struct bfd_link_info *info) if (s0->vma != s->vma) { /* xgettext:c-format */ - info->callbacks->einfo (_("%X%P: overlay sections %A " - "and %A do not start at the " - "same address.\n"), + info->callbacks->einfo (_("%X%P: overlay sections %pA " + "and %pA do not start at the " + "same address\n"), s0, s); bfd_set_error (bfd_error_bad_value); return 0; @@ -1018,7 +1019,7 @@ needs_ovl_stub (struct elf_link_hash_entry *h, } _bfd_error_handler /* xgettext:c-format */ - (_("warning: call to non-function symbol %s defined in %B"), + (_("warning: call to non-function symbol %s defined in %pB"), sym_name, sym_sec->owner); } @@ -1368,7 +1369,7 @@ build_stub (struct bfd_link_info *info, if (stub_type != br000_ovl_stub && lrlive != stub_type - br000_ovl_stub) /* xgettext:c-format */ - info->callbacks->einfo (_("%A:0x%v lrlive .brinfo (%u) differs " + info->callbacks->einfo (_("%pA:0x%v lrlive .brinfo (%u) differs " "from analysis (%u)\n"), isec, irela->r_offset, lrlive, stub_type - br000_ovl_stub); @@ -1900,7 +1901,7 @@ define_ovtab_symbol (struct spu_link_hash_table *htab, const char *name) else if (h->root.u.def.section->owner != NULL) { /* xgettext:c-format */ - _bfd_error_handler (_("%B is not allowed to define %s"), + _bfd_error_handler (_("%pB is not allowed to define %s"), h->root.u.def.section->owner, h->root.root.string); bfd_set_error (bfd_error_bad_value); @@ -2611,7 +2612,7 @@ find_function (asection *sec, bfd_vma offset, struct bfd_link_info *info) return &sinfo->fun[mid]; } /* xgettext:c-format */ - info->callbacks->einfo (_("%A:0x%v not found in function table\n"), + info->callbacks->einfo (_("%pA:0x%v not found in function table\n"), sec, offset); bfd_set_error (bfd_error_bad_value); return NULL; @@ -2752,8 +2753,8 @@ mark_functions_via_relocs (asection *sec, if (!warned) info->callbacks->einfo /* xgettext:c-format */ - (_("%B(%A+0x%v): call to non-code section" - " %B(%A), analysis incomplete\n"), + (_("%pB(%pA+0x%v): call to non-code section" + " %pB(%pA), analysis incomplete\n"), sec->owner, sec, irela->r_offset, sym_sec->owner, sym_sec); warned = TRUE; @@ -3321,7 +3322,7 @@ remove_cycles (struct function_info *fun, const char *f2 = func_name (call->fun); /* xgettext:c-format */ - info->callbacks->info (_("Stack analysis will ignore the call " + info->callbacks->info (_("stack analysis will ignore the call " "from %s to %s\n"), f1, f2); } @@ -4541,7 +4542,7 @@ spu_elf_auto_overlay (struct bfd_link_info *info) if (i == base) { /* xgettext:c-format */ - info->callbacks->einfo (_("%B:%A%s exceeds overlay size\n"), + info->callbacks->einfo (_("%pB:%pA%s exceeds overlay size\n"), ovly_sections[2 * i]->owner, ovly_sections[2 * i], ovly_sections[2 * i + 1] ? " + rodata" : ""); @@ -5040,10 +5041,11 @@ spu_elf_relocate_section (bfd *output_bfd, { _bfd_error_handler /* xgettext:c-format */ - (_("%B(%s+%#Lx): unresolvable %s relocation against symbol `%s'"), + (_("%pB(%s+%#" PRIx64 "): " + "unresolvable %s relocation against symbol `%s'"), input_bfd, bfd_get_section_name (input_bfd, input_section), - rel->r_offset, + (uint64_t) rel->r_offset, howto->name, sym_name); ret = FALSE; diff --git a/bfd/elf32-tic6x.c b/bfd/elf32-tic6x.c index 758b6a8..96965b3 100644 --- a/bfd/elf32-tic6x.c +++ b/bfd/elf32-tic6x.c @@ -1495,7 +1495,7 @@ elf32_tic6x_reloc_name_lookup (bfd *abfd, const char *r_name) return NULL; } -static void +static bfd_boolean elf32_tic6x_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, arelent *bfd_reloc, Elf_Internal_Rela *elf_reloc) { @@ -1503,12 +1503,28 @@ elf32_tic6x_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, arelent *bfd_reloc, r_type = ELF32_R_TYPE (elf_reloc->r_info); if (r_type >= ARRAY_SIZE (elf32_tic6x_howto_table)) - bfd_reloc->howto = NULL; - else - bfd_reloc->howto = &elf32_tic6x_howto_table[r_type]; + { + /* xgettext:c-format */ + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; + } + + bfd_reloc->howto = &elf32_tic6x_howto_table[r_type]; + if (bfd_reloc->howto == NULL || bfd_reloc->howto->name == NULL) + { + /* xgettext:c-format */ + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; + } + + return TRUE; } -static void +static bfd_boolean elf32_tic6x_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED, arelent *bfd_reloc, Elf_Internal_Rela *elf_reloc) { @@ -1516,9 +1532,25 @@ elf32_tic6x_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED, arelent *bfd_reloc, r_type = ELF32_R_TYPE (elf_reloc->r_info); if (r_type >= ARRAY_SIZE (elf32_tic6x_howto_table_rel)) - bfd_reloc->howto = NULL; - else - bfd_reloc->howto = &elf32_tic6x_howto_table_rel[r_type]; + { + /* xgettext:c-format */ + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; + } + + bfd_reloc->howto = &elf32_tic6x_howto_table_rel[r_type]; + if (bfd_reloc->howto == NULL || bfd_reloc->howto->name == NULL) + { + /* xgettext:c-format */ + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; + } + + return TRUE; } void @@ -2213,6 +2245,7 @@ elf32_tic6x_relocate_section (bfd *output_bfd, bfd_reloc_status_type r; struct bfd_link_hash_entry *sbh; bfd_boolean is_rel; + bfd_boolean res; r_type = ELF32_R_TYPE (rel->r_info); r_symndx = ELF32_R_SYM (rel->r_info); @@ -2221,11 +2254,11 @@ elf32_tic6x_relocate_section (bfd *output_bfd, relocs, rel); if (is_rel) - elf32_tic6x_info_to_howto_rel (input_bfd, &bfd_reloc, rel); + res = elf32_tic6x_info_to_howto_rel (input_bfd, &bfd_reloc, rel); else - elf32_tic6x_info_to_howto (input_bfd, &bfd_reloc, rel); - howto = bfd_reloc.howto; - if (howto == NULL) + res = elf32_tic6x_info_to_howto (input_bfd, &bfd_reloc, rel); + + if (!res || (howto = bfd_reloc.howto) == NULL) { bfd_set_error (bfd_error_bad_value); return FALSE; @@ -2457,7 +2490,7 @@ elf32_tic6x_relocate_section (bfd *output_bfd, } else { - _bfd_error_handler (_("%B: SB-relative relocation but " + _bfd_error_handler (_("%pB: SB-relative relocation but " "__c6xabi_DSBT_BASE not defined"), input_bfd); ok = FALSE; @@ -2567,21 +2600,21 @@ elf32_tic6x_relocate_section (bfd *output_bfd, if (h == NULL) _bfd_error_handler /* xgettext:c-format */ - (_("%B, section %A: relocation %s with non-zero addend %Ld" - " against local symbol"), + (_("%pB, section %pA: relocation %s with non-zero addend %" + PRId64 " against local symbol"), input_bfd, input_section, elf32_tic6x_howto_table[r_type].name, - rel->r_addend); + (int64_t) rel->r_addend); else _bfd_error_handler /* xgettext:c-format */ - (_("%B, section %A: relocation %s with non-zero addend %Ld" - " against symbol `%s'"), + (_("%pB, section %pA: relocation %s with non-zero addend %" + PRId64 " against symbol `%s'"), input_bfd, input_section, elf32_tic6x_howto_table[r_type].name, - rel->r_addend, + (int64_t) rel->r_addend, h->root.root.string[0] != '\0' ? h->root.root.string : _("[whose name is lost]")); @@ -2606,8 +2639,9 @@ elf32_tic6x_relocate_section (bfd *output_bfd, default: /* Unknown relocation. */ /* xgettext:c-format */ - _bfd_error_handler (_("%B: invalid relocation type %d"), + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), input_bfd, r_type); + bfd_set_error (bfd_error_bad_value); ok = FALSE; continue; } @@ -2746,7 +2780,7 @@ elf32_tic6x_check_relocs (bfd *abfd, struct bfd_link_info *info, if (r_symndx >= NUM_SHDR_ENTRIES (symtab_hdr)) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: bad symbol index: %d"), + _bfd_error_handler (_("%pB: bad symbol index: %d"), abfd, r_symndx); return FALSE; } @@ -3202,7 +3236,7 @@ maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) info->flags |= DF_TEXTREL; info->callbacks->minfo - (_("%B: dynamic relocation against `%T' in read-only section `%A'\n"), + (_("%pB: dynamic relocation against `%pT' in read-only section `%pA'\n"), sec->owner, h->root.root.string, sec); /* Not an error, just cut short the traversal. */ @@ -3579,7 +3613,7 @@ elf32_tic6x_obj_attrs_handle_unknown (bfd *abfd, int tag) { _bfd_error_handler /* xgettext:c-format */ - (_("%B: error: unknown mandatory EABI object attribute %d"), + (_("%pB: error: unknown mandatory EABI object attribute %d"), abfd, tag); bfd_set_error (bfd_error_bad_value); return FALSE; @@ -3588,7 +3622,7 @@ elf32_tic6x_obj_attrs_handle_unknown (bfd *abfd, int tag) { _bfd_error_handler /* xgettext:c-format */ - (_("%B: warning: unknown EABI object attribute %d"), + (_("%pB: warning: unknown EABI object attribute %d"), abfd, tag); return TRUE; } @@ -3702,7 +3736,7 @@ elf32_tic6x_merge_attributes (bfd *ibfd, struct bfd_link_info *info) { _bfd_error_handler /* xgettext:c-format */ - (_("error: %B requires more stack alignment than %B preserves"), + (_("error: %pB requires more stack alignment than %pB preserves"), ibfd, obfd); result = FALSE; } @@ -3711,7 +3745,7 @@ elf32_tic6x_merge_attributes (bfd *ibfd, struct bfd_link_info *info) { _bfd_error_handler /* xgettext:c-format */ - (_("error: %B requires more stack alignment than %B preserves"), + (_("error: %pB requires more stack alignment than %pB preserves"), obfd, ibfd); result = FALSE; } @@ -3721,7 +3755,7 @@ elf32_tic6x_merge_attributes (bfd *ibfd, struct bfd_link_info *info) if (array_align_in == -1) { _bfd_error_handler - (_("error: unknown Tag_ABI_array_object_alignment value in %B"), + (_("error: unknown Tag_ABI_array_object_alignment value in %pB"), ibfd); result = FALSE; } @@ -3730,7 +3764,7 @@ elf32_tic6x_merge_attributes (bfd *ibfd, struct bfd_link_info *info) if (array_align_out == -1) { _bfd_error_handler - (_("error: unknown Tag_ABI_array_object_alignment value in %B"), + (_("error: unknown Tag_ABI_array_object_alignment value in %pB"), obfd); result = FALSE; } @@ -3739,7 +3773,7 @@ elf32_tic6x_merge_attributes (bfd *ibfd, struct bfd_link_info *info) if (array_expect_in == -1) { _bfd_error_handler - (_("error: unknown Tag_ABI_array_object_align_expected value in %B"), + (_("error: unknown Tag_ABI_array_object_align_expected value in %pB"), ibfd); result = FALSE; } @@ -3748,7 +3782,7 @@ elf32_tic6x_merge_attributes (bfd *ibfd, struct bfd_link_info *info) if (array_expect_out == -1) { _bfd_error_handler - (_("error: unknown Tag_ABI_array_object_align_expected value in %B"), + (_("error: unknown Tag_ABI_array_object_align_expected value in %pB"), obfd); result = FALSE; } @@ -3757,7 +3791,7 @@ elf32_tic6x_merge_attributes (bfd *ibfd, struct bfd_link_info *info) { _bfd_error_handler /* xgettext:c-format */ - (_("error: %B requires more array alignment than %B preserves"), + (_("error: %pB requires more array alignment than %pB preserves"), ibfd, obfd); result = FALSE; } @@ -3765,7 +3799,7 @@ elf32_tic6x_merge_attributes (bfd *ibfd, struct bfd_link_info *info) { _bfd_error_handler /* xgettext:c-format */ - (_("error: %B requires more array alignment than %B preserves"), + (_("error: %pB requires more array alignment than %pB preserves"), obfd, ibfd); result = FALSE; } @@ -3788,7 +3822,7 @@ elf32_tic6x_merge_attributes (bfd *ibfd, struct bfd_link_info *info) { _bfd_error_handler /* xgettext:c-format */ - (_("warning: %B and %B differ in wchar_t size"), obfd, ibfd); + (_("warning: %pB and %pB differ in wchar_t size"), obfd, ibfd); } break; @@ -3807,7 +3841,7 @@ elf32_tic6x_merge_attributes (bfd *ibfd, struct bfd_link_info *info) { _bfd_error_handler /* xgettext:c-format */ - (_("warning: %B and %B differ in whether code is " + (_("warning: %pB and %pB differ in whether code is " "compiled for DSBT"), obfd, ibfd); } diff --git a/bfd/elf32-tilepro.c b/bfd/elf32-tilepro.c index 96ba98d..55b19f8 100644 --- a/bfd/elf32-tilepro.c +++ b/bfd/elf32-tilepro.c @@ -783,7 +783,7 @@ tilepro_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, /* Set the howto pointer for an TILEPro ELF reloc. */ -static void +static bfd_boolean tilepro_info_to_howto_rela (bfd * abfd ATTRIBUTE_UNUSED, arelent * cache_ptr, Elf_Internal_Rela * dst) @@ -793,11 +793,19 @@ tilepro_info_to_howto_rela (bfd * abfd ATTRIBUTE_UNUSED, if (r_type <= (unsigned int) R_TILEPRO_IMM16_X1_TLS_LE_HA) cache_ptr->howto = &tilepro_elf_howto_table [r_type]; else if (r_type - R_TILEPRO_GNU_VTINHERIT - <= (unsigned int) R_TILEPRO_GNU_VTENTRY) + <= ((unsigned int) R_TILEPRO_GNU_VTENTRY + - (unsigned int) R_TILEPRO_GNU_VTINHERIT)) cache_ptr->howto = &tilepro_elf_howto_table2 [r_type - R_TILEPRO_GNU_VTINHERIT]; else - abort (); + { + /* xgettext:c-format */ + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; + } + return TRUE; } typedef tilepro_bundle_bits (*tilepro_create_func)(int); @@ -1468,7 +1476,7 @@ tilepro_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, if (r_symndx >= NUM_SHDR_ENTRIES (symtab_hdr)) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: bad symbol index: %d"), + _bfd_error_handler (_("%pB: bad symbol index: %d"), abfd, r_symndx); return FALSE; } @@ -1581,7 +1589,7 @@ tilepro_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, { _bfd_error_handler /* xgettext:c-format */ - (_("%B: `%s' accessed both as normal and thread local symbol"), + (_("%pB: `%s' accessed both as normal and thread local symbol"), abfd, h ? h->root.root.string : ""); return FALSE; } @@ -2234,7 +2242,7 @@ maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) info->flags |= DF_TEXTREL; info->callbacks->minfo - (_("%B: dynamic relocation against `%T' in read-only section `%A'\n"), + (_("%pB: dynamic relocation against `%pT' in read-only section `%pA'\n"), sec->owner, h->root.root.string, sec); /* Not an error, just cut short the traversal. */ @@ -2257,7 +2265,7 @@ tilepro_elf_omit_section_dynsym (bfd *output_bfd, if (strcmp (p->name, ".got") == 0) return FALSE; - return _bfd_elf_link_omit_section_dynsym (output_bfd, info, p); + return _bfd_elf_omit_section_dynsym_default (output_bfd, info, p); } /* Set the sizes of the dynamic sections. */ @@ -2328,7 +2336,7 @@ tilepro_elf_size_dynamic_sections (bfd *output_bfd, { info->flags |= DF_TEXTREL; - info->callbacks->minfo (_("%B: dynamic relocation in read-only section `%A'\n"), + info->callbacks->minfo (_("%pB: dynamic relocation in read-only section `%pA'\n"), p->sec->owner, p->sec); } } @@ -3144,7 +3152,7 @@ tilepro_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info, { BFD_FAIL (); _bfd_error_handler - (_("%B: probably compiled without -fPIC?"), + (_("%pB: probably compiled without -fPIC?"), input_bfd); bfd_set_error (bfd_error_bad_value); return FALSE; @@ -3398,10 +3406,11 @@ tilepro_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info, rel->r_offset) != (bfd_vma) -1) _bfd_error_handler /* xgettext:c-format */ - (_("%B(%A+%#Lx): unresolvable %s relocation against symbol `%s'"), + (_("%pB(%pA+%#" PRIx64 "): " + "unresolvable %s relocation against symbol `%s'"), input_bfd, input_section, - rel->r_offset, + (uint64_t) rel->r_offset, howto->name, h->root.root.string); @@ -3749,7 +3758,7 @@ tilepro_elf_finish_dynamic_sections (bfd *output_bfd, if (bfd_is_abs_section (htab->elf.sgotplt->output_section)) { _bfd_error_handler - (_("discarded output section: `%A'"), htab->elf.sgotplt); + (_("discarded output section: `%pA'"), htab->elf.sgotplt); return FALSE; } diff --git a/bfd/elf32-v850.c b/bfd/elf32-v850.c index 99c060a..430153a 100644 --- a/bfd/elf32-v850.c +++ b/bfd/elf32-v850.c @@ -61,7 +61,7 @@ v850_elf_check_relocs (bfd *abfd, return TRUE; #ifdef DEBUG - _bfd_error_handler ("v850_elf_check_relocs called for section %A in %B", + _bfd_error_handler ("v850_elf_check_relocs called for section %pA in %pB", sec, abfd); #endif @@ -150,19 +150,19 @@ v850_elf_check_relocs (bfd *abfd, switch (h->other & V850_OTHER_MASK) { default: - msg = _("Variable `%s' cannot occupy in multiple small data regions"); + msg = _("variable `%s' cannot occupy in multiple small data regions"); break; case V850_OTHER_SDA | V850_OTHER_ZDA | V850_OTHER_TDA: - msg = _("Variable `%s' can only be in one of the small, zero, and tiny data regions"); + msg = _("variable `%s' can only be in one of the small, zero, and tiny data regions"); break; case V850_OTHER_SDA | V850_OTHER_ZDA: - msg = _("Variable `%s' cannot be in both small and zero data regions simultaneously"); + msg = _("variable `%s' cannot be in both small and zero data regions simultaneously"); break; case V850_OTHER_SDA | V850_OTHER_TDA: - msg = _("Variable `%s' cannot be in both small and tiny data regions simultaneously"); + msg = _("variable `%s' cannot be in both small and tiny data regions simultaneously"); break; case V850_OTHER_ZDA | V850_OTHER_TDA: - msg = _("Variable `%s' cannot be in both zero and tiny data regions simultaneously"); + msg = _("variable `%s' cannot be in both zero and tiny data regions simultaneously"); break; } @@ -460,7 +460,7 @@ v850_elf_perform_lo16_relocation (bfd *abfd, unsigned long *insn, } else { - _bfd_error_handler (_("FAILED to find previous HI16 reloc")); + _bfd_error_handler (_("failed to find previous HI16 reloc")); return FALSE; } } @@ -490,7 +490,8 @@ v850_elf_perform_relocation (bfd *abfd, { default: #ifdef DEBUG - fprintf (stderr, "%B: reloc number %d not recognised\n", abfd, r_type); + _bfd_error_handler ("%pB: unsupported relocation type %#x", + abfd, r_type); #endif return bfd_reloc_notsupported; @@ -1884,8 +1885,8 @@ v850_elf_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, /* Set the howto pointer for an V850 ELF reloc. */ -static void -v850_elf_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED, +static bfd_boolean +v850_elf_info_to_howto_rel (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst) { @@ -1895,16 +1896,19 @@ v850_elf_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED, if (r_type >= (unsigned int) R_V850_max) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: invalid V850 reloc number: %d"), abfd, r_type); - r_type = 0; + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; } cache_ptr->howto = &v850_elf_howto_table[r_type]; + return TRUE; } /* Set the howto pointer for a V850 ELF reloc (type RELA). */ -static void -v850_elf_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED, +static bfd_boolean +v850_elf_info_to_howto_rela (bfd *abfd, arelent * cache_ptr, Elf_Internal_Rela *dst) { @@ -1914,10 +1918,13 @@ v850_elf_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED, if (r_type >= (unsigned int) R_V850_max) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: invalid V850 reloc number: %d"), abfd, r_type); - r_type = 0; + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; } cache_ptr->howto = &v850_elf_howto_table[r_type]; + return TRUE; } static bfd_boolean @@ -2145,7 +2152,8 @@ v850_elf_final_link_relocate (reloc_howto_type *howto, default: #ifdef DEBUG - fprintf (stderr, "%B: reloc number %d not recognised\n", input_bfd, r_type); + _bfd_error_handler ("%pB: unsupported relocation type %#x", + input_bfd, r_type); #endif return bfd_reloc_notsupported; } @@ -2521,7 +2529,7 @@ v850_elf_merge_notes (bfd * ibfd, bfd *obfd) { _bfd_error_handler /* xgettext:c-format */ - (_("error: %B needs 8-byte alignment but %B is set for 4-byte alignment"), + (_("error: %pB needs 8-byte alignment but %pB is set for 4-byte alignment"), ibfd, obfd); result = FALSE; } @@ -2537,8 +2545,8 @@ v850_elf_merge_notes (bfd * ibfd, bfd *obfd) { _bfd_error_handler /* xgettext:c-format */ - (_("error: %B uses 64-bit doubles but " - "%B uses 32-bit doubles"), ibfd, obfd); + (_("error: %pB uses 64-bit doubles but " + "%pB uses 32-bit doubles"), ibfd, obfd); result = FALSE; } else @@ -2552,7 +2560,7 @@ v850_elf_merge_notes (bfd * ibfd, bfd *obfd) { _bfd_error_handler /* xgettext:c-format */ - (_("error: %B uses FPU-3.0 but %B only supports FPU-2.0"), + (_("error: %pB uses FPU-3.0 but %pB only supports FPU-2.0"), ibfd, obfd); result = FALSE; } @@ -2809,7 +2817,7 @@ v850_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) if ((in_flags & EF_V800_850E3) != (out_flags & EF_V800_850E3)) { _bfd_error_handler - (_("%B: Architecture mismatch with previous modules"), ibfd); + (_("%pB: architecture mismatch with previous modules"), ibfd); elf_elfheader (obfd)->e_flags |= EF_V800_850E3; } @@ -2865,7 +2873,7 @@ v850_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) } _bfd_error_handler - (_("%B: Architecture mismatch with previous modules"), ibfd); + (_("%pB: architecture mismatch with previous modules"), ibfd); } return result; @@ -3598,9 +3606,9 @@ v850_elf_relax_section (bfd *abfd, { _bfd_error_handler /* xgettext:c-format */ - (_("%B: %#Lx: warning: R_V850_LONGCALL points to " + (_("%pB: %#" PRIx64 ": warning: %s points to " "unrecognized insns"), - abfd, irel->r_offset); + abfd, (uint64_t) irel->r_offset, "R_V850_LONGCALL"); continue; } @@ -3608,10 +3616,11 @@ v850_elf_relax_section (bfd *abfd, { _bfd_error_handler /* xgettext:c-format */ - (_("%B: %#Lx: warning: R_V850_LONGCALL points to " + (_("%pB: %#" PRIx64 ": warning: %s points to " "unrecognized insn %#x"), abfd, - irel->r_offset + no_match, + (uint64_t) (irel->r_offset + no_match), + "R_V850_LONGCALL", insn[no_match]); continue; } @@ -3653,9 +3662,9 @@ v850_elf_relax_section (bfd *abfd, { _bfd_error_handler /* xgettext:c-format */ - (_("%B: %#Lx: warning: R_V850_LONGCALL points to " + (_("%pB: %#" PRIx64 ": warning: %s points to " "unrecognized reloc"), - abfd, irel->r_offset); + abfd, (uint64_t) irel->r_offset, "R_V850_LONGCALL"); continue; } @@ -3693,10 +3702,10 @@ v850_elf_relax_section (bfd *abfd, { _bfd_error_handler /* xgettext:c-format */ - (_("%B: %#Lx: warning: R_V850_LONGCALL points to " - "unrecognized reloc %#Lx"), - abfd, irel->r_offset, - irelcall->r_offset); + (_("%pB: %#" PRIx64 ": warning: %s points to " + "unrecognized reloc %#" PRIx64), + abfd, (uint64_t) irel->r_offset, "R_V850_LONGCALL", + (uint64_t) irelcall->r_offset); continue; } @@ -3836,9 +3845,9 @@ v850_elf_relax_section (bfd *abfd, { _bfd_error_handler /* xgettext:c-format */ - (_("%B: %#Lx: warning: R_V850_LONGJUMP points to " + (_("%pB: %#" PRIx64 ": warning: %s points to " "unrecognized insns"), - abfd, irel->r_offset); + abfd, (uint64_t) irel->r_offset, "R_V850_LONGJUMP"); continue; } @@ -3846,10 +3855,11 @@ v850_elf_relax_section (bfd *abfd, { _bfd_error_handler /* xgettext:c-format */ - (_("%B: %#Lx: warning: R_V850_LONGJUMP points to " + (_("%pB: %#" PRIx64 ": warning: %s points to " "unrecognized insn %#x"), abfd, - irel->r_offset + no_match, + (uint64_t) (irel->r_offset + no_match), + "R_V850_LONGJUMP", insn[no_match]); continue; } @@ -3880,9 +3890,9 @@ v850_elf_relax_section (bfd *abfd, { _bfd_error_handler /* xgettext:c-format */ - (_("%B: %#Lx: warning: R_V850_LONGJUMP points to " + (_("%pB: %#" PRIx64 ": warning: %s points to " "unrecognized reloc"), - abfd, irel->r_offset); + abfd, (uint64_t) irel->r_offset, "R_V850_LONGJUMP"); continue; } @@ -4241,25 +4251,30 @@ v800_elf_reloc_name_lookup (bfd * abfd, const char * r_name) /* Set the howto pointer in CACHE_PTR for a V800 ELF reloc. */ -static void +static bfd_boolean v800_elf_info_to_howto (bfd * abfd, arelent * cache_ptr, Elf_Internal_Rela * dst) { unsigned int r_type = ELF32_R_TYPE (dst->r_info); - BFD_ASSERT (bfd_get_arch (abfd) == bfd_arch_v850_rh850); - - BFD_ASSERT (r_type < (unsigned int) R_V800_max); - if (r_type == R_V800_NONE) r_type = R_V810_NONE; - BFD_ASSERT (r_type >= (unsigned int) R_V810_NONE); - r_type -= R_V810_NONE; - BFD_ASSERT (r_type < ARRAY_SIZE (v800_elf_howto_table)); + if (bfd_get_arch (abfd) != bfd_arch_v850_rh850 + || r_type >= (unsigned int) R_V800_max + || r_type < (unsigned int) R_V810_NONE + || (r_type - R_V810_NONE) >= ARRAY_SIZE (v800_elf_howto_table)) + { + /* xgettext:c-format */ + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; + } - cache_ptr->howto = v800_elf_howto_table + r_type; + cache_ptr->howto = v800_elf_howto_table + (r_type - R_V810_NONE); + return TRUE; } #undef TARGET_LITTLE_SYM diff --git a/bfd/elf32-vax.c b/bfd/elf32-vax.c index 54364ed..0236180 100644 --- a/bfd/elf32-vax.c +++ b/bfd/elf32-vax.c @@ -27,7 +27,7 @@ #include "elf/vax.h" static reloc_howto_type *reloc_type_lookup (bfd *, bfd_reloc_code_real_type); -static void rtype_to_howto (bfd *, arelent *, Elf_Internal_Rela *); +static bfd_boolean rtype_to_howto (bfd *, arelent *, Elf_Internal_Rela *); static struct bfd_hash_entry *elf_vax_link_hash_newfunc (struct bfd_hash_entry *, struct bfd_hash_table *, const char *); @@ -278,7 +278,7 @@ static reloc_howto_type howto_table[] = { FALSE), /* pcrel_offset */ }; -static void +static bfd_boolean rtype_to_howto (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst) { unsigned int r_type; @@ -287,12 +287,13 @@ rtype_to_howto (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst) if (r_type >= R_VAX_max) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: unrecognised VAX reloc number: %d"), + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), abfd, r_type); bfd_set_error (bfd_error_bad_value); - r_type = R_VAX_NONE; + return FALSE; } cache_ptr->howto = &howto_table[r_type]; + return TRUE; } #define elf_info_to_howto rtype_to_howto @@ -628,10 +629,10 @@ elf_vax_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec, if (eh->got_addend != (bfd_vma) rel->r_addend) _bfd_error_handler /* xgettext:c-format */ - (_("%B: warning: GOT addend of %Ld to `%s' does" - " not match previous GOT addend of %Ld"), - abfd, rel->r_addend, h->root.root.string, - eh->got_addend); + (_("%pB: warning: GOT addend of %" PRId64 " to `%s' does" + " not match previous GOT addend of %" PRId64), + abfd, (int64_t) rel->r_addend, h->root.root.string, + (int64_t) eh->got_addend); } } @@ -1442,9 +1443,10 @@ elf_vax_relocate_section (bfd *output_bfd, else if (rel->r_addend != 0) _bfd_error_handler /* xgettext:c-format */ - (_("%B: warning: PLT addend of %Ld to `%s'" - " from %A section ignored"), - input_bfd, rel->r_addend, h->root.root.string, input_section); + (_("%pB: warning: PLT addend of %" PRId64 " to `%s'" + " from %pA section ignored"), + input_bfd, (int64_t) rel->r_addend, h->root.root.string, + input_section); rel->r_addend = 0; break; @@ -1567,15 +1569,16 @@ elf_vax_relocate_section (bfd *output_bfd, if (h != NULL) _bfd_error_handler /* xgettext:c-format */ - (_("%B: warning: %s relocation against symbol `%s'" - " from %A section"), + (_("%pB: warning: %s relocation against symbol `%s'" + " from %pA section"), input_bfd, howto->name, h->root.root.string, input_section); else _bfd_error_handler /* xgettext:c-format */ - (_("%B: warning: %s relocation to %#Lx from %A section"), - input_bfd, howto->name, outrel.r_addend, + (_("%pB: warning: %s relocation to %#" PRIx64 + " from %pA section"), + input_bfd, howto->name, (uint64_t) outrel.r_addend, input_section); } loc = sreloc->contents; diff --git a/bfd/elf32-visium.c b/bfd/elf32-visium.c index 45f3337..3f8d16a 100644 --- a/bfd/elf32-visium.c +++ b/bfd/elf32-visium.c @@ -458,8 +458,8 @@ visium_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, const char *r_name) /* Set the howto pointer for a VISIUM ELF reloc. */ -static void -visium_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED, arelent *cache_ptr, +static bfd_boolean +visium_info_to_howto_rela (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst) { unsigned int r_type = ELF32_R_TYPE (dst->r_info); @@ -478,12 +478,15 @@ visium_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED, arelent *cache_ptr, if (r_type >= (unsigned int) R_VISIUM_max) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: invalid Visium reloc number: %d"), abfd, r_type); - r_type = 0; + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; } cache_ptr->howto = &visium_elf_howto_table[r_type]; break; } + return TRUE; } /* Look through the relocs for a section during the first phase. @@ -814,7 +817,7 @@ visium_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) if (mismatch) _bfd_error_handler /* xgettext:c-format */ - (_("%B: compiled %s -mtune=%s and linked with modules" + (_("%pB: compiled %s -mtune=%s and linked with modules" " compiled %s -mtune=%s"), ibfd, new_opt_with, opt_arch, old_opt_with, opt_arch); } diff --git a/bfd/elf32-wasm32.c b/bfd/elf32-wasm32.c index 5205bef..9fc48de 100644 --- a/bfd/elf32-wasm32.c +++ b/bfd/elf32-wasm32.c @@ -103,26 +103,29 @@ elf32_wasm32_rtype_to_howto (bfd *abfd, unsigned r_type) if (i >= ARRAY_SIZE (elf32_wasm32_howto_table)) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: invalid relocation type %d"), - abfd, (int) r_type); - i = R_WASM32_NONE; + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return NULL; } if (elf32_wasm32_howto_table[i].type != r_type) return NULL; - return &elf32_wasm32_howto_table[i]; + return elf32_wasm32_howto_table + i; } /* Translate the ELF-internal relocation RELA into CACHE_PTR. */ -static void -elf32_wasm32_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED, +static bfd_boolean +elf32_wasm32_info_to_howto_rela (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst) { unsigned int r_type = ELF32_R_TYPE (dst->r_info); + cache_ptr->howto = elf32_wasm32_rtype_to_howto (abfd, r_type); + return cache_ptr->howto != NULL; } #define ELF_ARCH bfd_arch_wasm32 diff --git a/bfd/elf32-xc16x.c b/bfd/elf32-xc16x.c index 42a3dca..66fe33d 100644 --- a/bfd/elf32-xc16x.c +++ b/bfd/elf32-xc16x.c @@ -212,9 +212,7 @@ xc16x_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, { unsigned int i; - for (i = 0; - i < sizeof (xc16x_elf_howto_table) / sizeof (xc16x_elf_howto_table[0]); - i++) + for (i = 0; i < ARRAY_SIZE (xc16x_elf_howto_table); i++) if (xc16x_elf_howto_table[i].name != NULL && strcasecmp (xc16x_elf_howto_table[i].name, r_name) == 0) return &xc16x_elf_howto_table[i]; @@ -225,8 +223,8 @@ xc16x_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, /* For a particular operand this function is called to finalise the type of relocation. */ -static void -elf32_xc16x_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, arelent *bfd_reloc, +static bfd_boolean +elf32_xc16x_info_to_howto (bfd *abfd, arelent *bfd_reloc, Elf_Internal_Rela *elf_reloc) { unsigned int r; @@ -237,9 +235,12 @@ elf32_xc16x_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, arelent *bfd_reloc, if (xc16x_elf_howto_table[i].type == r) { bfd_reloc->howto = &xc16x_elf_howto_table[i]; - return; + return TRUE; } - abort (); + /* xgettext:c-format */ + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), abfd, r); + bfd_set_error (bfd_error_bad_value); + return FALSE; } static bfd_reloc_status_type diff --git a/bfd/elf32-xgate.c b/bfd/elf32-xgate.c index 5a93b5e..a367526 100644 --- a/bfd/elf32-xgate.c +++ b/bfd/elf32-xgate.c @@ -34,7 +34,7 @@ static reloc_howto_type * bfd_elf32_bfd_reloc_type_lookup (bfd *, bfd_reloc_code_real_type); static reloc_howto_type * bfd_elf32_bfd_reloc_name_lookup (bfd *, const char *); -static void +static bfd_boolean xgate_info_to_howto_rel (bfd *, arelent *, Elf_Internal_Rela *); static bfd_boolean xgate_elf_set_mach_from_flags (bfd *); @@ -395,7 +395,7 @@ bfd_elf32_bfd_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED, for (i = 0; i < ARRAY_SIZE (xgate_reloc_map); i++) if (xgate_reloc_map[i].bfd_reloc_val == code) return &elf_xgate_howto_table[xgate_reloc_map[i].elf_reloc_val]; - + return NULL; } @@ -414,8 +414,8 @@ bfd_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, const char *r_name) /* Set the howto pointer for an XGATE ELF reloc. */ -static void -xgate_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED, +static bfd_boolean +xgate_info_to_howto_rel (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst) { @@ -425,10 +425,13 @@ xgate_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED, if (r_type >= (unsigned int) R_XGATE_max) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: invalid XGate reloc number: %d"), abfd, r_type); - r_type = 0; + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; } cache_ptr->howto = &elf_xgate_howto_table[r_type]; + return TRUE; } /* Destroy an XGATE ELF linker hash table. */ @@ -701,12 +704,12 @@ elf32_xgate_post_process_headers (bfd *abfd ATTRIBUTE_UNUSED, struct bfd_link_in #define TARGET_BIG_SYM xgate_elf32_vec #define TARGET_BIG_NAME "elf32-xgate" -#define elf_info_to_howto 0 +#define elf_info_to_howto NULL #define elf_info_to_howto_rel xgate_info_to_howto_rel #define elf_backend_check_relocs elf32_xgate_check_relocs #define elf_backend_relocate_section elf32_xgate_relocate_section #define elf_backend_object_p xgate_elf_set_mach_from_flags -#define elf_backend_final_write_processing 0 +#define elf_backend_final_write_processing NULL #define elf_backend_can_gc_sections 1 #define elf_backend_special_sections elf32_xgate_special_sections #define elf_backend_post_process_headers elf32_xgate_post_process_headers diff --git a/bfd/elf32-xstormy16.c b/bfd/elf32-xstormy16.c index 476f9e0..4cd7e62 100644 --- a/bfd/elf32-xstormy16.c +++ b/bfd/elf32-xstormy16.c @@ -375,8 +375,8 @@ xstormy16_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, /* Set the howto pointer for an XSTORMY16 ELF reloc. */ -static void -xstormy16_info_to_howto_rela (bfd * abfd ATTRIBUTE_UNUSED, +static bfd_boolean +xstormy16_info_to_howto_rela (bfd * abfd, arelent * cache_ptr, Elf_Internal_Rela * dst) { @@ -385,11 +385,19 @@ xstormy16_info_to_howto_rela (bfd * abfd ATTRIBUTE_UNUSED, if (r_type <= (unsigned int) R_XSTORMY16_12) cache_ptr->howto = &xstormy16_elf_howto_table [r_type]; else if (r_type - R_XSTORMY16_GNU_VTINHERIT - <= (unsigned int) R_XSTORMY16_GNU_VTENTRY) + <= ((unsigned int) R_XSTORMY16_GNU_VTENTRY + - (unsigned int) R_XSTORMY16_GNU_VTINHERIT)) cache_ptr->howto = &xstormy16_elf_howto_table2 [r_type - R_XSTORMY16_GNU_VTINHERIT]; else - abort (); + { + /* xgettext:c-format */ + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; + } + return TRUE; } /* We support 16-bit pointers to code above 64k by generating a thunk @@ -1009,7 +1017,7 @@ xstormy16_elf_gc_mark_hook (asection *sec, #define elf_backend_always_size_sections \ xstormy16_elf_always_size_sections #define elf_backend_omit_section_dynsym \ - ((bfd_boolean (*) (bfd *, struct bfd_link_info *, asection *)) bfd_true) + _bfd_elf_omit_section_dynsym_all #define elf_backend_finish_dynamic_sections \ xstormy16_elf_finish_dynamic_sections diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c index b3a7467..cd08796 100644 --- a/bfd/elf32-xtensa.c +++ b/bfd/elf32-xtensa.c @@ -450,6 +450,9 @@ elf_xtensa_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED, break; } + /* xgettext:c-format */ + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), abfd, (int) code); + bfd_set_error (bfd_error_bad_value); TRACE ("Unknown"); return NULL; } @@ -472,8 +475,8 @@ elf_xtensa_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, /* Given an ELF "rela" relocation, find the corresponding howto and record it in the BFD internal arelent representation of the relocation. */ -static void -elf_xtensa_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED, +static bfd_boolean +elf_xtensa_info_to_howto_rela (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst) { @@ -482,10 +485,13 @@ elf_xtensa_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED, if (r_type >= (unsigned int) R_XTENSA_max) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: invalid XTENSA reloc number: %d"), abfd, r_type); - r_type = 0; + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; } cache_ptr->howto = &elf_howto_table[r_type]; + return TRUE; } @@ -923,7 +929,7 @@ xtensa_read_table_entries (bfd *abfd, blocks[blk - 1].size != 0) { /* xgettext:c-format */ - _bfd_error_handler (_("%B(%A): invalid property table"), + _bfd_error_handler (_("%pB(%pA): invalid property table"), abfd, section); bfd_set_error (bfd_error_bad_value); free (blocks); @@ -1015,7 +1021,7 @@ elf_xtensa_check_relocs (bfd *abfd, if (r_symndx >= NUM_SHDR_ENTRIES (symtab_hdr)) { /* xgettext:c-format */ - _bfd_error_handler (_("%B: bad symbol index: %d"), + _bfd_error_handler (_("%pB: bad symbol index: %d"), abfd, r_symndx); return FALSE; } @@ -1189,7 +1195,7 @@ elf_xtensa_check_relocs (bfd *abfd, { _bfd_error_handler /* xgettext:c-format */ - (_("%B: `%s' accessed both as normal and thread local symbol"), + (_("%pB: `%s' accessed both as normal and thread local symbol"), abfd, h ? h->root.root.string : ""); return FALSE; @@ -2652,8 +2658,10 @@ elf_xtensa_relocate_section (bfd *output_bfd, { _bfd_error_handler /* xgettext:c-format */ - (_("%B(%A+%#Lx): relocation offset out of range (size=%#Lx)"), - input_bfd, input_section, rel->r_offset, input_size); + (_("%pB(%pA+%#" PRIx64 "): " + "relocation offset out of range (size=%#" PRIx64 ")"), + input_bfd, input_section, (uint64_t) rel->r_offset, + (uint64_t) input_size); bfd_set_error (bfd_error_bad_value); return FALSE; } @@ -2678,12 +2686,12 @@ elf_xtensa_relocate_section (bfd *output_bfd, _bfd_error_handler ((sym_type == STT_TLS /* xgettext:c-format */ - ? _("%B(%A+%#Lx): %s used with TLS symbol %s") + ? _("%pB(%pA+%#" PRIx64 "): %s used with TLS symbol %s") /* xgettext:c-format */ - : _("%B(%A+%#Lx): %s used with non-TLS symbol %s")), + : _("%pB(%pA+%#" PRIx64 "): %s used with non-TLS symbol %s")), input_bfd, input_section, - rel->r_offset, + (uint64_t) rel->r_offset, howto->name, name); } @@ -2936,10 +2944,11 @@ elf_xtensa_relocate_section (bfd *output_bfd, { _bfd_error_handler /* xgettext:c-format */ - (_("%B(%A+%#Lx): unresolvable %s relocation against symbol `%s'"), + (_("%pB(%pA+%#" PRIx64 "): " + "unresolvable %s relocation against symbol `%s'"), input_bfd, input_section, - rel->r_offset, + (uint64_t) rel->r_offset, howto->name, name); return FALSE; @@ -3347,7 +3356,7 @@ elf_xtensa_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) { _bfd_error_handler /* xgettext:c-format */ - (_("%B: incompatible machine type. Output is 0x%x. Input is 0x%x"), + (_("%pB: incompatible machine type; output is 0x%x; input is 0x%x"), ibfd, out_mach, in_mach); bfd_set_error (bfd_error_wrong_format); return FALSE; @@ -4578,7 +4587,7 @@ elf_xtensa_do_asm_simplify (bfd_byte *contents, if (content_length