This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

bfd_error_handler bfd_vma and bfd_size_type args


This patch uses the new %L _bfd_error_handler support for printing
bfd_vma arguments, and fixes a many other format and/or argument
errors in error messages.

Most of the errors were found the hard way, by inspection, until I
figured you could put ATTRIBUTE_PRINTF_1 on _bfd_error_handler and
run the bfd source through sed to replace all %B and %A specifiers
with %p.  gcc then complains about %Ld, %Lu, and %Lx when compiling
on a 64-bit host, but anything else is a real error.

bfd/
	* binary.c (binary_set_section_contents): Don't print filepos in
	error message.
	(coff_write_object_contents): Cast size_t for error message.
	(coff_slurp_line_table): Don't use bfd_vma symndx.
	(coff_slurp_reloc_table): Remove unneeded cast.
	* dwarf2.c (read_section): Cast bfd_int64_t to long long for
	error message.
	(find_abstract_instance_name): Likewise.
	* elf32-arm.c (arm_type_of_stub): Correct error arg order.
	(bfd_elf32_arm_stm32l4xx_erratum_scan): Don't cast error arg.
	(elf32_arm_check_relocs): Make r_symndx an int.
	* elf32-cris.c (cris_elf_check_relocs): Delete extraneous %s in
	format string.
	* elf32-metag.c (elf_metag_relocate_section): Delete extra error
	message arg.
	* elf32-nds32.c (nds32_elf_ex9_build_hash_table): Rewrite bogus
	error message.
	* elf32-i386.c (elf_i386_check_relocs): Make r_symndx an int.
	* elf32-s390.c (elf_s390_check_relocs): Likewise.
	* elf32-tic6x.c (elf32_tic6x_check_relocs): Likewise.
	* elf32-tilepro.c (tilepro_elf_check_relocs): Likewise.
	* elf32-xtensa.c (elf_xtensa_check_relocs): Likewise.
	* elf64-s390.c (elf_s390_check_relocs): Likewise.
	* elf64-x86-64.c (elf_x86_64_check_relocs): Likewise.
	* elfnn-aarch64.c (elfNN_aarch64_check_relocs): Likewise.
	* elfnn-riscv.c (riscv_elf_check_relocs): Likewise.
	* elfxx-sparc.c (_bfd_sparc_elf_check_relocs): Likewise.
	* elfxx-tilegx.c (tilegx_elf_check_relocs): Likewise.
	* elf64-mmix.c (_bfd_mmix_after_linker_allocation): Cast size_t args
	and use %lu for error message.
	* elflink.c (elf_link_adjust_relocs): Delete extra error message arg.
	* mmo.c (mmo_scan): Make stab_loc a file_ptr.  Cast expression for
	error message.

	* elf32-arm.c (elf32_arm_tls_relax): Correct format string and args
	in error message.
	(elf32_arm_final_link_relocate): Likewise.
	* coff-arm.c (bfd_arm_process_before_allocation): Likewise.
	* coffcode.h (styp_to_sec_flags): Likewise.
	* cofflink.c (_bfd_coff_write_global_sym): Likewise.
	* ecoff.c (_bfd_ecoff_slurp_symbol_table): Likewise.
	* elf32-arc.c (arc_elf_merge_private_bfd_data): Likewise.
	* elf32-bfin.c (bfinfdpic_check_relocs): Likewise.
	(elf32_bfin_merge_private_bfd_data): Likewise.
	* elf32-cris.c (cris_elf_relocate_section): Likewise.
	* elf32-frv.c (frv_elf_merge_private_bfd_data): Likewise.
	* elf32-i370.c (i370_elf_merge_private_bfd_data): Likewise.
	(i370_elf_relocate_section): Likewise.
	* elf32-iq2000.c (iq2000_elf_merge_private_bfd_data): Likewise.
	* elf32-m32c.c (m32c_elf_merge_private_bfd_data): Likewise.
	* elf32-m68hc1x.c (_bfd_m68hc11_elf_merge_private_bfd_data): Likewise.
	* elf32-mcore.c (mcore_elf_relocate_section): Likewise.
	* elf32-mep.c (mep_elf_merge_private_bfd_data): Likewise.
	* elf32-mt.c (mt_elf_merge_private_bfd_data): Likewise.
	* elf64-sparc.c (elf64_sparc_merge_private_bfd_data): Likewise.
	* elfxx-mips.c (mips_elf_merge_obj_e_flags): Likewise.
	(_bfd_mips_elf_merge_private_bfd_data): Likewise.
	* ieee.c (ieee_write_id, read_id): Likewise.
	* mach-o.c (bfd_mach_o_write_contents): Likewise.
	(bfd_mach_o_layout_commands, bfd_mach_o_read_section_32): Likewise.
	(bfd_mach_o_read_section_64, bfd_mach_o_read_symtab_symbol): Likewise.
	(bfd_mach_o_read_command, bfd_mach_o_header_p): Likewise.
	* peXXigen.c (_bfd_XXi_swap_aouthdr_in): Likewise.
	* stabs.c (_bfd_link_section_stabs): Likewise.

	* coff-arm.c (coff_arm_relocate_section): Use L modifier in error
	format.
	* coff-mcore.c (coff_mcore_relocate_section): Likewise.
	* coff-ppc.c (coff_ppc_relocate_section): Likewise.
	* coff-rs6000.c (xcoff_reloc_type_toc): Likewise.
	* coff-sh.c (sh_relax_section): Likewise.
	(sh_relax_delete_bytes, sh_swap_insns): Likewise.
	* coff-tic80.c (coff_tic80_relocate_section): Likewise.
	* coffcode.h (coff_slurp_reloc_table): Likewise.
	* coffgen.c (_bfd_coff_get_external_symbols): Likewise.
	(_bfd_coff_read_string_table): Likewise.
	* cofflink.c (_bfd_coff_generic_relocate_section): Likewise.
	* compress.c (bfd_get_full_section_contents): Likewise.
	* dwarf2.c (read_formatted_entries, decode_line_info): Likewise.
	* elf-m10300.c (mn10300_elf_relocate_section): Likewise.
	* elf.c (bfd_elf_string_from_elf_section): Likewise.
	* elf32-arc.c (arc_special_overflow_checks): Likewise.
	* elf32-arm.c (elf32_arm_tls_relax): Likewise.
	(elf32_arm_final_link_relocate, elf32_arm_relocate_section): Likewise.
	(elf32_arm_write_section): Likewise.
	* elf32-bfin.c (bfin_relocate_section): Likewise.
	(bfinfdpic_relocate_section): Likewise.
	* elf32-hppa.c (hppa_build_one_stub): Likewise.
	(final_link_relocate, elf32_hppa_relocate_section): Likewise.
	* elf32-i386.c (elf_i386_tls_transition): Likewise.
	(elf_i386_relocate_section): Likewise.
	* elf32-ip2k.c (ip2k_final_link_relocate): Likewise.
	* elf32-lm32.c (lm32_elf_finish_dynamic_sections): Likewise.
	* elf32-m32r.c (m32r_elf_relocate_section): Likewise.
	* elf32-m68k.c (elf_m68k_relocate_section): Likewise.
	* elf32-metag.c (elf_metag_relocate_section): Likewise.
	* elf32-nds32.c (unrecognized_reloc_msg): Likewise.
	(nds32_elf_relax_longcall1, nds32_elf_relax_longcall2): Likewise.
	(nds32_elf_relax_longcall3, nds32_elf_relax_longjump1): Likewise.
	(nds32_elf_relax_longjump2, nds32_elf_relax_longjump3): Likewise.
	(nds32_elf_relax_longcall4, nds32_elf_relax_longcall5): Likewise.
	(nds32_elf_relax_longcall6, nds32_elf_relax_longjump4): Likewise.
	(nds32_elf_relax_longjump5, nds32_elf_relax_longjump6): Likewise.
	(nds32_elf_relax_longjump7, nds32_elf_relax_loadstore): Likewise.
	(nds32_elf_relax_ptr, nds32_elf_ex9_build_hash_table): Likewise.
	* elf32-nios2.c (nios2_elf32_relocate_section): Likewise.
	* elf32-rx.c (UNSAFE_FOR_PID): Likewise.
	* elf32-s390.c (invalid_tls_insn, elf_s390_relocate_section): Likewise.
	* elf32-score.c (s3_bfd_score_elf_check_relocs): Likewise.
	* elf32-score7.c (s7_bfd_score_elf_check_relocs): Likewise.
	* elf32-sh.c (sh_elf_relax_section): Likewise.
	(sh_elf_relax_delete_bytes, sh_elf_swap_insns): Likewise.
	(sh_elf_relocate_section): Likewise.
	* elf32-sh64.c (shmedia_prepare_reloc): Likewise.
	* elf32-spu.c (spu_elf_relocate_section): Likewise.
	* elf32-tic6x.c (elf32_tic6x_relocate_section): Likewise.
	* elf32-tilepro.c (tilepro_elf_relocate_section): Likewise.
	* elf32-v850.c (v850_elf_relax_section): Likewise.
	* elf32-vax.c (elf_vax_check_relocs): Likewise.
	(elf_vax_relocate_section): Likewise.
	* elf32-xtensa.c (elf_xtensa_relocate_section): Likewise.
	(extend_ebb_bounds_forward, extend_ebb_bounds_backward): Likewise.
	(compute_text_actions, compute_ebb_proposed_actions): Likewise.
	(do_fix_for_relocatable_link): Likewise.
	* elf64-alpha.c (elf64_alpha_relax_got_load): Likewise.
	(elf64_alpha_relax_with_lituse): Likewise.
	* elf64-hppa.c (elf64_hppa_finish_dynamic_symbol): Likewise.
	(elf_hppa_final_link_relocate): Likewise.
	* elf64-ia64-vms.c (elf64_ia64_relax_section): Likewise.
	(elf64_ia64_choose_gp, elf64_ia64_relocate_section): Likewise.
	(elf64_vms_link_add_object_symbols): Likewise.
	* elf64-mmix.c (mmix_elf_perform_relocation): Likewise.
	(mmix_final_link_relocate): Likewise.
	* elf64-s390.c (invalid_tls_insn): Likewise.
	(elf_s390_relocate_section): Likewise.
	* elf64-sh64.c (sh_elf64_relocate_section): Likewise.
	* elf64-x86-64.c (elf_x86_64_tls_transition): Likewise.
	(elf_x86_64_relocate_section): Likewise.
	* elfcode.h (elf_slurp_symbol_table): Likewise.
	* elfcore.h (elf_core_file_p): Likewise.
	* elflink.c (elf_link_read_relocs_from_section): Likewise.
	* elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Likewise.
	(elfNN_aarch64_relocate_section): Likewise.
	* elfnn-ia64.c (elfNN_ia64_relax_section): Likewise.
	(elfNN_ia64_choose_gp, elfNN_ia64_relocate_section): Likewise.
	* elfnn-riscv.c (riscv_elf_relocate_section): Likewise.
	* elfxx-mips.c (_bfd_mips_elf_check_relocs): Likewise.
	(_bfd_mips_elf_relocate_section): Likewise.
	(_bfd_mips_elf_finish_dynamic_symbol, mips_finish_exec_plt): Likewise.
	* elfxx-sparc.c (_bfd_sparc_elf_relocate_section): Likewise.
	* elfxx-tilegx.c (tilegx_elf_relocate_section): Likewise.
	* ieee.c (ieee_slurp_external_symbols): Likewise.
	* ihex.c (ihex_write_object_content): Likewise.
	* mach-o.c (bfd_mach_o_build_exec_seg_command): Likewise.
	* merge.c (_bfd_merged_section_offset): Likewise.
	* mmo.c (mmo_write_loc_chunk): Likewise.
	(mmo_write_object_contents): Likewise.
	* peXXigen.c (_bfd_XX_bfd_copy_private_bfd_data_common): Likewise.
	* stabs.c (_bfd_link_section_stabs): Likewise.
	* xcofflink.c (xcoff_link_add_symbols, xcoff_find_tc0): Likewise.
ld/
	* testsuite/ld-arc/nps-1b.err: Update.
	* testsuite/ld-x86-64/ilp32-11.d: Update.

diff --git a/bfd/binary.c b/bfd/binary.c
index 1018d56..4145e11 100644
--- a/bfd/binary.c
+++ b/bfd/binary.c
@@ -274,8 +274,8 @@ binary_set_section_contents (bfd *abfd,
 	    _bfd_error_handler
 	      /* xgettext:c-format */
 	      (_("warning: writing section `%A' at huge (ie negative) "
-		 "file offset 0x%lx."),
-	       s, (unsigned long) s->filepos);
+		 "file offset"),
+	       s);
 	}
 
       abfd->output_has_begun = TRUE;
diff --git a/bfd/coff-arm.c b/bfd/coff-arm.c
index b66ebe4..8a2fe1a 100644
--- a/bfd/coff-arm.c
+++ b/bfd/coff-arm.c
@@ -1743,8 +1743,8 @@ coff_arm_relocate_section (bfd *output_bfd,
 	case bfd_reloc_outofrange:
 	  _bfd_error_handler
 	    /* xgettext:c-format */
-	    (_("%B: bad reloc address 0x%lx in section `%A'"),
-	     input_bfd, (unsigned long) rel->r_vaddr, input_section);
+	    (_("%B: bad reloc address %#Lx in section `%A'"),
+	     input_bfd, rel->r_vaddr, input_section);
 	  return FALSE;
 	case bfd_reloc_overflow:
 	  {
@@ -2068,7 +2068,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: %d"),
+	      _bfd_error_handler (_("%B: illegal symbol index in reloc: %ld"),
 				  abfd, symndx);
 	      continue;
 	    }
diff --git a/bfd/coff-mcore.c b/bfd/coff-mcore.c
index 3ede766..e770afd 100644
--- a/bfd/coff-mcore.c
+++ b/bfd/coff-mcore.c
@@ -479,10 +479,9 @@ coff_mcore_relocate_section (bfd * output_bfd,
 	  _bfd_error_handler
 	    /* xgettext: c-format */
 	    (_("Warning: unsupported reloc %s <file %B, section %A>\n"
-	       "sym %ld (%s), r_vaddr %ld (%lx)"),
+	       "sym %ld (%s), r_vaddr %Ld (%#Lx)"),
 	     howto->name, input_bfd, input_section,
-	     rel->r_symndx, my_name, (long) rel->r_vaddr,
-	     (unsigned long) rel->r_vaddr);
+	     rel->r_symndx, my_name, rel->r_vaddr, rel->r_vaddr);
 	  break;
 
 	case IMAGE_REL_MCORE_PCREL_IMM8BY4:
diff --git a/bfd/coff-ppc.c b/bfd/coff-ppc.c
index 9dca30c..66a78e7 100644
--- a/bfd/coff-ppc.c
+++ b/bfd/coff-ppc.c
@@ -1131,10 +1131,9 @@ coff_ppc_relocate_section (bfd *output_bfd,
 		      {
 			_bfd_error_handler
 			  /* xgettext: c-format */
-			  (_("%B: Relocation for %s of %lx exceeds "
+			  (_("%B: Relocation for %s of %#Lx exceeds "
 			     "Toc size limit"),
-			   input_bfd, name,
-			   (unsigned long) our_toc_offset);
+			   input_bfd, name, our_toc_offset);
 			bfd_set_error (bfd_error_bad_value);
 			return FALSE;
 		      }
@@ -1186,8 +1185,8 @@ coff_ppc_relocate_section (bfd *output_bfd,
 	      {
 		_bfd_error_handler
 		  /* xgettext: c-format */
-		  (_("%B: Relocation exceeds allocated TOC (%lx)"),
-		   input_bfd, (unsigned long) toc_section->size);
+		  (_("%B: Relocation exceeds allocated TOC (%#Lx)"),
+		   input_bfd, toc_section->size);
 		bfd_set_error (bfd_error_bad_value);
 		return FALSE;
 	      }
@@ -1242,10 +1241,9 @@ coff_ppc_relocate_section (bfd *output_bfd,
 	    _bfd_error_handler
 	      /* xgettext: c-format */
 	      (_("Warning: unsupported reloc %s <file %B, section %A>\n"
-		 "sym %ld (%s), r_vaddr %ld (%lx)"),
+		 "sym %ld (%s), r_vaddr %Ld (%#Lx)"),
 	       howto->name, input_bfd, input_section,
-	       rel->r_symndx, my_name, (long) rel->r_vaddr,
-	       (unsigned long) rel->r_vaddr);
+	       rel->r_symndx, my_name, rel->r_vaddr, rel->r_vaddr);
 	  }
 	  break;
 	case IMAGE_REL_PPC_IMGLUE:
diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c
index 3c5042f..025c424 100644
--- a/bfd/coff-rs6000.c
+++ b/bfd/coff-rs6000.c
@@ -2830,7 +2830,7 @@ xcoff_reloc_type_toc (bfd *input_bfd,
 	{
 	  _bfd_error_handler
 	    /* xgettext: c-format */
-	    (_("%B: TOC reloc at 0x%x to symbol `%s' with no TOC entry"),
+	    (_("%B: TOC reloc at %#Lx to symbol `%s' with no TOC entry"),
 	     input_bfd, rel->r_vaddr, h->root.root.string);
 	  bfd_set_error (bfd_error_bad_value);
 	  return FALSE;
diff --git a/bfd/coff-sh.c b/bfd/coff-sh.c
index 26d296b..1c483cb 100644
--- a/bfd/coff-sh.c
+++ b/bfd/coff-sh.c
@@ -775,8 +775,8 @@ sh_relax_section (bfd *abfd,
       if (laddr >= sec->size)
 	{
 	  /* xgettext: c-format */
-	  _bfd_error_handler (_("%B: 0x%lx: warning: bad R_SH_USES offset"),
-			      abfd, (unsigned long) irel->r_vaddr);
+	  _bfd_error_handler (_("%B: %#Lx: warning: bad R_SH_USES offset"),
+			      abfd, irel->r_vaddr);
 	  continue;
 	}
       insn = bfd_get_16 (abfd, contents + laddr);
@@ -786,8 +786,8 @@ sh_relax_section (bfd *abfd,
 	{
 	  _bfd_error_handler
 	    /* xgettext: c-format */
-	    (_("%B: 0x%lx: warning: R_SH_USES points to unrecognized insn 0x%x"),
-	     abfd, (unsigned long) irel->r_vaddr, insn);
+	    (_("%B: %#Lx: warning: R_SH_USES points to unrecognized insn %#x"),
+	     abfd, irel->r_vaddr, insn);
 	  continue;
 	}
 
@@ -804,8 +804,8 @@ sh_relax_section (bfd *abfd,
 	{
 	  _bfd_error_handler
 	    /* xgettext: c-format */
-	    (_("%B: 0x%lx: warning: bad R_SH_USES load offset"),
-	     abfd, (unsigned long) irel->r_vaddr);
+	    (_("%B: %#Lx: warning: bad R_SH_USES load offset"),
+	     abfd, irel->r_vaddr);
 	  continue;
 	}
 
@@ -829,8 +829,8 @@ sh_relax_section (bfd *abfd,
 	{
 	  _bfd_error_handler
 	    /* xgettext: c-format */
-	    (_("%B: 0x%lx: warning: could not find expected reloc"),
-	     abfd, (unsigned long) paddr);
+	    (_("%B: %#Lx: warning: could not find expected reloc"),
+	     abfd, paddr);
 	  continue;
 	}
 
@@ -846,8 +846,8 @@ sh_relax_section (bfd *abfd,
 	{
 	  _bfd_error_handler
 	    /* xgettext: c-format */
-	    (_("%B: 0x%lx: warning: symbol in unexpected section"),
-	     abfd, (unsigned long) paddr);
+	    (_("%B: %#Lx: warning: symbol in unexpected section"),
+	     abfd, paddr);
 	  continue;
 	}
 
@@ -972,8 +972,8 @@ sh_relax_section (bfd *abfd,
 	{
 	  _bfd_error_handler
 	    /* xgettext: c-format */
-	    (_("%B: 0x%lx: warning: could not find expected COUNT reloc"),
-	     abfd, (unsigned long) paddr);
+	    (_("%B: %#Lx: warning: could not find expected COUNT reloc"),
+	     abfd, paddr);
 	  continue;
 	}
 
@@ -982,8 +982,8 @@ sh_relax_section (bfd *abfd,
       if (irelcount->r_offset == 0)
 	{
 	  /* xgettext: c-format */
-	  _bfd_error_handler (_("%B: 0x%lx: warning: bad count"),
-			      abfd, (unsigned long) paddr);
+	  _bfd_error_handler (_("%B: %#Lx: warning: bad count"),
+			      abfd, paddr);
 	  continue;
 	}
 
@@ -1354,8 +1354,8 @@ sh_relax_delete_bytes (bfd *abfd,
 	    {
 	      _bfd_error_handler
 		/* xgettext: c-format */
-		(_("%B: 0x%lx: fatal: reloc overflow while relaxing"),
-		 abfd, (unsigned long) irel->r_vaddr);
+		(_("%B: %#Lx: fatal: reloc overflow while relaxing"),
+		 abfd, irel->r_vaddr);
 	      bfd_set_error (bfd_error_bad_value);
 	      return FALSE;
 	    }
@@ -2642,8 +2642,8 @@ sh_swap_insns (bfd *      abfd,
 	    {
 	      _bfd_error_handler
 		/* xgettext: c-format */
-		(_("%B: 0x%lx: fatal: reloc overflow while relaxing"),
-		 abfd, (unsigned long) irel->r_vaddr);
+		(_("%B: %#Lx: fatal: reloc overflow while relaxing"),
+		 abfd, irel->r_vaddr);
 	      bfd_set_error (bfd_error_bad_value);
 	      return FALSE;
 	    }
diff --git a/bfd/coff-tic80.c b/bfd/coff-tic80.c
index ec1d1fd..253ea94 100644
--- a/bfd/coff-tic80.c
+++ b/bfd/coff-tic80.c
@@ -667,8 +667,8 @@ coff_tic80_relocate_section (bfd *output_bfd,
 	case bfd_reloc_outofrange:
 	  _bfd_error_handler
 	    /* xgettext: c-format */
-	    (_("%B: bad reloc address 0x%lx in section `%A'"),
-	     input_bfd, (unsigned long) rel->r_vaddr, input_section);
+	    (_("%B: bad reloc address %#Lx in section `%A'"),
+	     input_bfd, rel->r_vaddr, input_section);
 	  return FALSE;
 	case bfd_reloc_overflow:
 	  {
diff --git a/bfd/coffcode.h b/bfd/coffcode.h
index 4aa9741..898327b 100644
--- a/bfd/coffcode.h
+++ b/bfd/coffcode.h
@@ -1311,7 +1311,7 @@ styp_to_sec_flags (bfd *abfd,
 	{
 	  _bfd_error_handler
 	    /* xgettext:c-format */
-	    (_("%B (%s): Section flag %s (0x%x) ignored"),
+	    (_("%B (%s): Section flag %s (%#lx) ignored"),
 	     abfd, name, unhandled, flag);
 	  result = FALSE;
 	}
@@ -3765,7 +3765,7 @@ coff_write_object_contents (bfd * abfd)
 		  _bfd_error_handler
 		    /* xgettext:c-format */
 		    (_("%B: section %A: string table overflow at offset %ld"),
-		    abfd, current, string_size);
+		    abfd, current, (unsigned long) string_size);
 		  return FALSE;
 		}
 
@@ -4607,7 +4607,7 @@ coff_slurp_line_table (bfd *abfd, asection *asect)
       if (cache_ptr->line_number == 0)
 	{
 	  combined_entry_type * ent;
-	  bfd_vma symndx;
+	  unsigned long symndx;
 	  coff_symbol_type *sym;
 
 	  have_func = FALSE;
@@ -4617,7 +4617,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"),
-		 abfd, (long) symndx, counter);
+		 abfd, symndx, counter);
 	      cache_ptr->line_number = -1;
 	      ret = FALSE;
 	      continue;
@@ -4631,7 +4631,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"),
-		 abfd, (long) symndx, counter);
+		 abfd, symndx, counter);
 	      cache_ptr->line_number = -1;
 	      ret = FALSE;
 	      continue;
@@ -5319,7 +5319,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"),
-		 abfd, (long) dst.r_symndx);
+		 abfd, dst.r_symndx);
 	      cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
 	      ptr = NULL;
 	    }
@@ -5358,8 +5358,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 0x%lx"),
-	     abfd, dst.r_type, (long) dst.r_vaddr);
+	    (_("%B: illegal relocation type %d at address %#Lx"),
+	     abfd, dst.r_type, dst.r_vaddr);
 	  bfd_set_error (bfd_error_bad_value);
 	  return FALSE;
 	}
diff --git a/bfd/coffgen.c b/bfd/coffgen.c
index 31c2c5a..d7cdf8f 100644
--- a/bfd/coffgen.c
+++ b/bfd/coffgen.c
@@ -1645,7 +1645,7 @@ _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 %lu symbols"),
+      _bfd_error_handler (_("%B: Not enough memory to allocate space for %Lu symbols"),
 			  abfd, size);
       return FALSE;
     }
@@ -1713,7 +1713,7 @@ _bfd_coff_read_string_table (bfd *abfd)
     {
       _bfd_error_handler
 	/* xgettext: c-format */
-	(_("%B: bad string table size %lu"), abfd, (unsigned long) strsize);
+	(_("%B: bad string table size %Lu"), abfd, strsize);
       bfd_set_error (bfd_error_bad_value);
       return NULL;
     }
diff --git a/bfd/cofflink.c b/bfd/cofflink.c
index aa84a35..32d62bd 100644
--- a/bfd/cofflink.c
+++ b/bfd/cofflink.c
@@ -2727,7 +2727,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: 0x%lx > 0xffff"),
+		  (_("%B: %A: reloc overflow: %#x > 0xffff"),
 		   output_bfd, sec, sec->reloc_count);
 
 	      if (sec->lineno_count > 0xffff
@@ -2735,7 +2735,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: 0x%lx > 0xffff"),
+		  (_("%B: warning: %A: line number overflow: %#x > 0xffff"),
 		   output_bfd, sec, sec->lineno_count);
 
 	      auxp->x_scn.x_nreloc = sec->reloc_count;
@@ -3120,8 +3120,8 @@ _bfd_coff_generic_relocate_section (bfd *output_bfd,
 	case bfd_reloc_outofrange:
 	  _bfd_error_handler
 	    /* xgettext: c-format */
-	    (_("%B: bad reloc address 0x%lx in section `%A'"),
-	     input_bfd, (unsigned long) rel->r_vaddr, input_section);
+	    (_("%B: bad reloc address %#Lx in section `%A'"),
+	     input_bfd, rel->r_vaddr, input_section);
 	  return FALSE;
 	case bfd_reloc_overflow:
 	  {
diff --git a/bfd/compress.c b/bfd/compress.c
index ef549f9..a9dcbc0 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, (long) sz);
+		  (_("error: %B(%A) is too large (%#Lx bytes)"),
+		  abfd, sec, sz);
 	      return FALSE;
 	    }
 	}
diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c
index 04a2585..22d6d56 100644
--- a/bfd/dwarf2.c
+++ b/bfd/dwarf2.c
@@ -573,9 +573,9 @@ read_section (bfd *           abfd,
   if (offset != 0 && offset >= *section_size)
     {
       /* xgettext: c-format */
-      _bfd_error_handler (_("Dwarf Error: Offset (%lu)"
-			    " greater than or equal to %s size (%lu)."),
-			  (long) offset, section_name, *section_size);
+      _bfd_error_handler (_("Dwarf Error: Offset (%llu)"
+			    " greater than or equal to %s size (%Lu)."),
+			  (long long) offset, section_name, *section_size);
       bfd_set_error (bfd_error_bad_value);
       return FALSE;
     }
@@ -1943,8 +1943,8 @@ read_formatted_entries (struct comp_unit *unit, bfd_byte **bufp,
 	      break;
 	    default:
 	      _bfd_error_handler
-		(_("Dwarf Error: Unknown format content type %lu."),
-		 (unsigned long) content_type);
+		(_("Dwarf Error: Unknown format content type %Lu."),
+		 content_type);
 	      bfd_set_error (bfd_error_bad_value);
 	      return FALSE;
 	    }
@@ -2047,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)"),
-	 (long) stash->dwarf_line_size);
+	(_("Dwarf Error: Line info section is too small (%Ld)"),
+	 stash->dwarf_line_size);
       bfd_set_error (bfd_error_bad_value);
       return NULL;
     }
@@ -2077,8 +2077,8 @@ decode_line_info (struct comp_unit *unit, struct dwarf2_debug *stash)
     {
       _bfd_error_handler
 	/* xgettext: c-format */
-	(_("Dwarf Error: Line info data is bigger (0x%lx) than the section (0x%lx)"),
-	 (long) lh.total_length, (long) stash->dwarf_line_size);
+	(_("Dwarf Error: Line info data is bigger (%#Lx) than the section (%#Lx)"),
+	 lh.total_length, stash->dwarf_line_size);
       bfd_set_error (bfd_error_bad_value);
       return NULL;
     }
@@ -2854,7 +2854,8 @@ find_abstract_instance_name (struct comp_unit *unit,
       if (info_ptr == NULL)
 	{
 	  _bfd_error_handler
-	    (_("Dwarf Error: Unable to read alt ref %u."), die_ref);
+	    (_("Dwarf Error: Unable to read alt ref %llu."),
+	     (long long) die_ref);
 	  bfd_set_error (bfd_error_bad_value);
 	  return NULL;
 	}
diff --git a/bfd/ecoff.c b/bfd/ecoff.c
index ef5dc5e..4bda9dc 100644
--- a/bfd/ecoff.c
+++ b/bfd/ecoff.c
@@ -961,7 +961,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 (%d)\n"),
+	(_("%B: 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);
     }
diff --git a/bfd/elf-m10300.c b/bfd/elf-m10300.c
index e59f083..97301c8 100644
--- a/bfd/elf-m10300.c
+++ b/bfd/elf-m10300.c
@@ -2094,10 +2094,10 @@ mn10300_elf_relocate_section (bfd *output_bfd,
 
 	    _bfd_error_handler
 	      /* xgettext:c-format */
-	      (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
+	      (_("%B(%A+%#Lx): unresolvable %s relocation against symbol `%s'"),
 	       input_bfd,
 	       input_section,
-	       (long) rel->r_offset,
+	       rel->r_offset,
 	       howto->name,
 	       h->root.root.root.string);
 	}
diff --git a/bfd/elf.c b/bfd/elf.c
index dcb0638..a937930 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -354,8 +354,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, (unsigned long) hdr->sh_size,
+	(_("%B: invalid string offset %u >= %Lu for section `%s'"),
+	 abfd, strindex, hdr->sh_size,
 	 (shindex == shstrndx && strindex == hdr->sh_name
 	  ? ".shstrtab"
 	  : bfd_elf_string_from_elf_section (abfd, shstrndx, hdr->sh_name)));
diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c
index 6903ad7..93b21de 100644
--- a/bfd/elf32-arc.c
+++ b/bfd/elf32-arc.c
@@ -888,9 +888,9 @@ 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 (0x%lx) fields than "
-	       "previous modules (0x%lx)"),
-	     ibfd, (long) in_flags, (long) out_flags);
+	    (_("%B: uses different e_flags (%#x) fields than "
+	       "previous modules (%#x)"),
+	     ibfd, in_flags, out_flags);
 	  if (in_flags && out_flags)
 	    return FALSE;
 	  /* MWDT doesnt set the eflags hence make sure we choose the
@@ -1116,26 +1116,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+0x%lx): CMEM relocation to `%s' is invalid, "
-		 "16 MSB should be 0x%04x (value is 0x%lx)"),
+	      (_("%B(%A+%#Lx): CMEM relocation to `%s' is invalid, "
+		 "16 MSB should be %#x (value is %#Lx)"),
 	       reloc_data.input_section->owner,
 	       reloc_data.input_section,
 	       reloc_data.reloc_offset,
 	       reloc_data.symbol_name,
 	       NPS_CMEM_HIGH_VALUE,
-	       (relocation));
+	       relocation);
 	  else
 	    _bfd_error_handler
 	      /* xgettext:c-format */
-	      (_("%B(%A+0x%lx): CMEM relocation to `%s+0x%lx' is invalid, "
-		 "16 MSB should be 0x%04x (value is 0x%lx)"),
+	      (_("%B(%A+%#Lx): CMEM relocation to `%s+%#Lx' is invalid, "
+		 "16 MSB should be %#x (value is %#Lx)"),
 	       reloc_data.input_section->owner,
 	       reloc_data.input_section,
 	       reloc_data.reloc_offset,
 	       reloc_data.symbol_name,
 	       reloc_data.reloc_addend,
 	       NPS_CMEM_HIGH_VALUE,
-	       (relocation));
+	       relocation);
 	  return bfd_reloc_overflow;
 	}
       break;
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index b9f5d04..4277168 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -4140,7 +4140,7 @@ arm_type_of_stub (struct bfd_link_info *info,
 	      _bfd_error_handler
 		(_("%B(%s): warning: interworking not enabled.\n"
 		   "  first occurrence: %B: ARM call to Thumb"),
-		 sym_sec->owner, input_bfd, name);
+		 sym_sec->owner, name, input_bfd);
 	    }
 
 	  /* We have an extra 2-bytes reach because of
@@ -8615,12 +8615,12 @@ bfd_elf32_arm_stm32l4xx_erratum_scan (bfd *abfd,
 			  {
 			    _bfd_error_handler
 			      /* xgettext:c-format */
-			      (_("%B(%A+0x%lx): error: multiple load detected"
+			      (_("%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"),
-			       abfd, sec, (long) i);
+			       abfd, sec, i);
 			  }
 			else
 			  {
@@ -9720,8 +9720,8 @@ 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+0x%lx): unexpected Thumb instruction '0x%x' in TLS trampoline"),
-	     input_bfd, input_sec, (unsigned long)rel->r_offset, insn);
+	    (_("%B(%A+%#Lx): unexpected Thumb instruction '%#lx' in TLS trampoline"),
+	     input_bfd, input_sec, rel->r_offset, insn);
 	  return bfd_reloc_notsupported;
 	}
       break;
@@ -9760,8 +9760,8 @@ elf32_arm_tls_relax (struct elf32_arm_link_hash_table *globals,
 	{
 	  _bfd_error_handler
 	    /* xgettext:c-format */
-	    (_("%B(%A+0x%lx): unexpected ARM instruction '0x%x' in TLS trampoline"),
-	     input_bfd, input_sec, (unsigned long)rel->r_offset, insn);
+	    (_("%B(%A+%#Lx): unexpected ARM instruction '%#lx' in TLS trampoline"),
+	     input_bfd, input_sec, rel->r_offset, insn);
 	  return bfd_reloc_notsupported;
 	}
       break;
@@ -11524,9 +11524,8 @@ elf32_arm_final_link_relocate (reloc_howto_type *           howto,
 		  {
 		    _bfd_error_handler
 		      /* xgettext:c-format */
-		      (_("%B(%A+0x%lx): unexpected Thumb instruction '0x%x' referenced by TLS_GOTDESC"),
-		       input_bfd, input_section,
-		       (unsigned long)rel->r_offset, insn);
+		      (_("%B(%A+%#Lx): unexpected Thumb instruction '%#lx' referenced by TLS_GOTDESC"),
+		       input_bfd, input_section, rel->r_offset, insn);
 		    return bfd_reloc_notsupported;
 		  }
 	      }
@@ -11548,9 +11547,8 @@ elf32_arm_final_link_relocate (reloc_howto_type *           howto,
 		  default:
 		    _bfd_error_handler
 		      /* xgettext:c-format */
-		      (_("%B(%A+0x%lx): unexpected ARM instruction '0x%x' referenced by TLS_GOTDESC"),
-		       input_bfd, input_section,
-		       (unsigned long)rel->r_offset, insn);
+		      (_("%B(%A+%#Lx): unexpected ARM instruction '%#lx' referenced by TLS_GOTDESC"),
+		       input_bfd, input_section, rel->r_offset, insn);
 		    return bfd_reloc_notsupported;
 		  }
 	      }
@@ -11578,9 +11576,8 @@ elf32_arm_final_link_relocate (reloc_howto_type *           howto,
 	{
 	  _bfd_error_handler
 	    /* xgettext:c-format */
-	    (_("%B(%A+0x%lx): R_ARM_TLS_LE32 relocation not permitted in shared object"),
-	     input_bfd, input_section,
-	     (long) rel->r_offset, howto->name);
+	    (_("%B(%A+%#Lx): %s relocation not permitted in shared object"),
+	     input_bfd, input_section, rel->r_offset, howto->name);
 	  return bfd_reloc_notsupported;
 	}
       else
@@ -11792,9 +11789,8 @@ elf32_arm_final_link_relocate (reloc_howto_type *           howto,
 	      {
 		_bfd_error_handler
 		  /* xgettext:c-format */
-		  (_("%B(%A+0x%lx): Only ADD or SUB instructions are allowed for ALU group relocations"),
-		  input_bfd, input_section,
-		  (long) rel->r_offset, howto->name);
+		  (_("%B(%A+%#Lx): Only ADD or SUB instructions are allowed for ALU group relocations"),
+		  input_bfd, input_section, rel->r_offset);
 		return bfd_reloc_overflow;
 	      }
 
@@ -11833,10 +11829,9 @@ elf32_arm_final_link_relocate (reloc_howto_type *           howto,
 	  {
 	    _bfd_error_handler
 	      /* xgettext:c-format */
-	      (_("%B(%A+0x%lx): Overflow whilst splitting 0x%lx for group relocation %s"),
-	      input_bfd, input_section,
-	       (long) rel->r_offset, signed_value < 0 ? - signed_value : signed_value,
-	       howto->name);
+	      (_("%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);
 	    return bfd_reloc_overflow;
 	  }
 
@@ -11924,9 +11919,9 @@ elf32_arm_final_link_relocate (reloc_howto_type *           howto,
 	  {
 	    _bfd_error_handler
 	      /* xgettext:c-format */
-	      (_("%B(%A+0x%lx): Overflow whilst splitting 0x%lx for group relocation %s"),
-	       input_bfd, input_section,
-	       (long) rel->r_offset, labs (signed_value), howto->name);
+	      (_("%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);
 	    return bfd_reloc_overflow;
 	  }
 
@@ -12010,9 +12005,9 @@ elf32_arm_final_link_relocate (reloc_howto_type *           howto,
 	  {
 	    _bfd_error_handler
 	      /* xgettext:c-format */
-	      (_("%B(%A+0x%lx): Overflow whilst splitting 0x%lx for group relocation %s"),
-	       input_bfd, input_section,
-	       (long) rel->r_offset, labs (signed_value), howto->name);
+	      (_("%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);
 	    return bfd_reloc_overflow;
 	  }
 
@@ -12098,9 +12093,9 @@ elf32_arm_final_link_relocate (reloc_howto_type *           howto,
 	  {
 	    _bfd_error_handler
 	      /* xgettext:c-format */
-	      (_("%B(%A+0x%lx): Overflow whilst splitting 0x%lx for group relocation %s"),
-	      input_bfd, input_section,
-	      (long) rel->r_offset, labs (signed_value), howto->name);
+	      (_("%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);
 	    return bfd_reloc_overflow;
 	  }
 
@@ -12362,9 +12357,9 @@ elf32_arm_relocate_section (bfd *                  output_bfd,
 			{
 			  _bfd_error_handler
 			    /* xgettext:c-format */
-			    (_("%B(%A+0x%lx): %s relocation against SEC_MERGE section"),
+			    (_("%B(%A+%#Lx): %s relocation against SEC_MERGE section"),
 			     input_bfd, input_section,
-			     (long) rel->r_offset, howto->name);
+			     rel->r_offset, howto->name);
 			  return FALSE;
 			}
 
@@ -12474,12 +12469,12 @@ elf32_arm_relocate_section (bfd *                  output_bfd,
 	  _bfd_error_handler
 	    ((sym_type == STT_TLS
 	      /* xgettext:c-format */
-	      ? _("%B(%A+0x%lx): %s used with TLS symbol %s")
+	      ? _("%B(%A+%#Lx): %s used with TLS symbol %s")
 	      /* xgettext:c-format */
-	      : _("%B(%A+0x%lx): %s used with non-TLS symbol %s")),
+	      : _("%B(%A+%#Lx): %s used with non-TLS symbol %s")),
 	     input_bfd,
 	     input_section,
-	     (long) rel->r_offset,
+	     rel->r_offset,
 	     howto->name,
 	     name);
 	}
@@ -12529,10 +12524,10 @@ elf32_arm_relocate_section (bfd *                  output_bfd,
 	{
 	  _bfd_error_handler
 	    /* xgettext:c-format */
-	    (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
+	    (_("%B(%A+%#Lx): unresolvable %s relocation against symbol `%s'"),
 	     input_bfd,
 	     input_section,
-	     (long) rel->r_offset,
+	     rel->r_offset,
 	     howto->name,
 	     h->root.root.string);
 	  return FALSE;
@@ -14541,7 +14536,7 @@ elf32_arm_check_relocs (bfd *abfd, struct bfd_link_info *info,
       Elf_Internal_Sym *isym;
       struct elf_link_hash_entry *h;
       struct elf32_arm_link_hash_entry *eh;
-      unsigned long r_symndx;
+      unsigned int r_symndx;
       int r_type;
 
       r_symndx = ELF32_R_SYM (rel->r_info);
@@ -18593,11 +18588,11 @@ elf32_arm_write_section (bfd *output_bfd,
 		      branch_to_veneer - (1 << 24) : 0;
 
 		    _bfd_error_handler
-		      (_("%B(%#x): error: Cannot create STM32L4XX veneer. "
-			 "Jump out of range by %ld bytes. "
+		      (_("%B(%#Lx): error: Cannot create STM32L4XX veneer. "
+			 "Jump out of range by %Ld bytes. "
 			 "Cannot encode branch instruction. "),
 		       output_bfd,
-		       (long) (stm32l4xx_errnode->vma - 4),
+		       stm32l4xx_errnode->vma - 4,
 		       out_of_range);
 		    continue;
 		  }
diff --git a/bfd/elf32-bfin.c b/bfd/elf32-bfin.c
index b3e09bd..09e50ce 100644
--- a/bfd/elf32-bfin.c
+++ b/bfd/elf32-bfin.c
@@ -1578,9 +1578,9 @@ bfin_relocate_section (bfd * output_bfd,
 	{
 	  _bfd_error_handler
 	    /* xgettext:c-format */
-	    (_("%B(%A+0x%lx): unresolvable relocation against symbol `%s'"),
+	    (_("%B(%A+%#Lx): unresolvable relocation against symbol `%s'"),
 	     input_bfd,
-	     input_section, (long) rel->r_offset, h->root.root.string);
+	     input_section, rel->r_offset, h->root.root.string);
 	  return FALSE;
 	}
 
@@ -1609,9 +1609,8 @@ bfin_relocate_section (bfd * output_bfd,
 	    {
 	      _bfd_error_handler
 		/* xgettext:c-format */
-		(_("%B(%A+0x%lx): reloc against `%s': error %d"),
-		 input_bfd, input_section,
-		 (long) rel->r_offset, name, (int) r);
+		(_("%B(%A+%#Lx): reloc against `%s': error %d"),
+		 input_bfd, input_section, rel->r_offset, name, (int) r);
 	      return FALSE;
 	    }
 	}
@@ -2703,7 +2702,7 @@ bfinfdpic_relocate_section (bfd * output_bfd,
 	    {
 	      _bfd_error_handler
 		/* xgettext:c-format */
-		(_("%B: relocation at `%A+0x%x' references symbol `%s' with nonzero addend"),
+		(_("%B: relocation at `%A+%#Lx' references symbol `%s' with nonzero addend"),
 		 input_bfd, input_section, rel->r_offset, name);
 	      return FALSE;
 
@@ -4874,8 +4873,8 @@ bfinfdpic_check_relocs (bfd *abfd, struct bfd_link_info *info,
 	bad_reloc:
 	  _bfd_error_handler
 	    /* xgettext:c-format */
-	    (_("%B: unsupported relocation type %i"),
-	     abfd, ELF32_R_TYPE (rel->r_info));
+	    (_("%B: unsupported relocation type %d"),
+	     abfd, (int) ELF32_R_TYPE (rel->r_info));
 	  return FALSE;
         }
     }
@@ -4949,7 +4948,7 @@ elf32_bfin_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
   if (0)
 #endif
   _bfd_error_handler
-    ("old_flags = 0x%.8lx, new_flags = 0x%.8lx, init = %s, filename = %B",
+    ("old_flags = 0x%.8x, new_flags = 0x%.8x, init = %s, filename = %B",
      old_flags, new_flags, elf_flags_init (obfd) ? "yes" : "no", ibfd);
 
   if (!elf_flags_init (obfd))			/* First call, no flags set.  */
diff --git a/bfd/elf32-cris.c b/bfd/elf32-cris.c
index 83c4101..2661f2b 100644
--- a/bfd/elf32-cris.c
+++ b/bfd/elf32-cris.c
@@ -1301,7 +1301,7 @@ 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 %d"
+		    (_("%B, section %A: relocation %s with non-zero addend %Ld"
 		       " against local symbol"),
 		     input_bfd,
 		     input_section,
@@ -1310,7 +1310,7 @@ cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
 		else
 		  _bfd_error_handler
 		    /* xgettext:c-format */
-		    (_("%B, section %A: relocation %s with non-zero addend %d"
+		    (_("%B, section %A: relocation %s with non-zero addend %Ld"
 		       " against symbol `%s'"),
 		     input_bfd,
 		     input_section,
@@ -1657,7 +1657,7 @@ 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 %d"
+		(_("%B, section %A: relocation %s with non-zero addend %Ld"
 		   " against symbol `%s'"),
 		 input_bfd,
 		 input_section,
@@ -1810,7 +1810,7 @@ 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 %d"
+		(_("%B, section %A: relocation %s with non-zero addend %Ld"
 		   " against symbol `%s'"),
 		 input_bfd,
 		 input_section,
@@ -3230,7 +3230,7 @@ cris_elf_check_relocs (bfd *abfd,
 		{
 		  _bfd_error_handler
 		    /* xgettext:c-format */
-		    (_("%B, section %A:\n  v10/v32 compatible object %s"
+		    (_("%B, section %A:\n  v10/v32 compatible object"
 		       " must not contain a PIC relocation"),
 		     abfd, sec);
 		  return FALSE;
diff --git a/bfd/elf32-frv.c b/bfd/elf32-frv.c
index ef609ff..971073c 100644
--- a/bfd/elf32-frv.c
+++ b/bfd/elf32-frv.c
@@ -6355,7 +6355,7 @@ frv_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
 
 #ifdef DEBUG
   _bfd_error_handler
-    ("old_flags = 0x%.8lx, new_flags = 0x%.8lx, init = %s, filename = %s",
+    ("old_flags = 0x%.8x, new_flags = 0x%.8x, init = %s, filename = %s",
      old_flags, new_flags, elf_flags_init (obfd) ? "yes" : "no",
      bfd_get_filename (ibfd));
 #endif
@@ -6574,9 +6574,9 @@ 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 (0x%lx) fields"
-	       " than previous modules (0x%lx)"),
-	     ibfd, (long) new_partial, (long) old_partial);
+	    (_("%B: uses different unknown e_flags (%#x) fields"
+	       " than previous modules (%#x)"),
+	     ibfd, new_partial, old_partial);
 	}
     }
 
diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c
index 0087c71..1f2466e 100644
--- a/bfd/elf32-hppa.c
+++ b/bfd/elf32-hppa.c
@@ -836,10 +836,10 @@ hppa_build_one_stub (struct bfd_hash_entry *bh, void *in_arg)
 	{
 	  _bfd_error_handler
 	    /* xgettext:c-format */
-	    (_("%B(%A+0x%lx): cannot reach %s, recompile with -ffunction-sections"),
+	    (_("%B(%A+%#Lx): cannot reach %s, recompile with -ffunction-sections"),
 	     hsh->target_section->owner,
 	     stub_sec,
-	     (long) hsh->stub_offset,
+	     hsh->stub_offset,
 	     hsh->bh_root.string);
 	  bfd_set_error (bfd_error_bad_value);
 	  return FALSE;
@@ -3430,10 +3430,10 @@ final_link_relocate (asection *input_section,
 		   error.  */
 		_bfd_error_handler
 		  /* xgettext:c-format */
-		  (_("%B(%A+0x%lx): %s fixup for insn 0x%x is not supported in a non-shared link"),
+		  (_("%B(%A+%#Lx): %s fixup for insn %#x is not supported in a non-shared link"),
 		   input_bfd,
 		   input_section,
-		   (long) offset,
+		   offset,
 		   howto->name,
 		   insn);
 	    }
@@ -3596,10 +3596,10 @@ final_link_relocate (asection *input_section,
     {
       _bfd_error_handler
 	/* xgettext:c-format */
-	(_("%B(%A+0x%lx): cannot reach %s, recompile with -ffunction-sections"),
+	(_("%B(%A+%#Lx): cannot reach %s, recompile with -ffunction-sections"),
 	 input_bfd,
 	 input_section,
-	 (long) offset,
+	 offset,
 	 hsh->bh_root.string);
       bfd_set_error (bfd_error_bad_value);
       return bfd_reloc_notsupported;
@@ -4287,10 +4287,10 @@ elf32_hppa_relocate_section (bfd *output_bfd,
 	    {
 	      _bfd_error_handler
 		/* xgettext:c-format */
-		(_("%B(%A+0x%lx): cannot handle %s for %s"),
+		(_("%B(%A+%#Lx): cannot handle %s for %s"),
 		 input_bfd,
 		 input_section,
-		 (long) rela->r_offset,
+		 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 4c40b79..f305515 100644
--- a/bfd/elf32-i370.c
+++ b/bfd/elf32-i370.c
@@ -356,8 +356,8 @@ i370_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
     {
       _bfd_error_handler
 	/* xgettext:c-format */
-	(_("%B: uses different e_flags (0x%lx) fields than previous modules (0x%lx)"),
-	 ibfd, (long) new_flags, (long) old_flags);
+	(_("%B: uses different e_flags (%#x) fields than previous modules (%#x)"),
+	 ibfd, new_flags, old_flags);
 
       bfd_set_error (bfd_error_bad_value);
       return FALSE;
@@ -1053,9 +1053,9 @@ 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, %ld relocations%s",
+  _bfd_error_handler ("i370_elf_relocate_section called for %B section %A, %u relocations%s",
 		      input_bfd, input_section,
-		      (long) input_section->reloc_count,
+		      input_section->reloc_count,
 		      (bfd_link_relocatable (info)) ? " (relocatable)" : "");
 #endif
 
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index df16775..9d9c8ab 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -1708,10 +1708,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 0x%lx "
+	(_("%B: TLS transition from %s to %s against `%s' at %#Lx "
 	   "in section `%A' failed"),
 	 abfd, from->name, to->name, name,
-	 (unsigned long) rel->r_offset, sec);
+	 rel->r_offset, sec);
       bfd_set_error (bfd_error_bad_value);
       return FALSE;
     }
@@ -2037,7 +2037,7 @@ elf_i386_check_relocs (bfd *abfd,
   for (rel = relocs; rel < rel_end; rel++)
     {
       unsigned int r_type;
-      unsigned long r_symndx;
+      unsigned int r_symndx;
       struct elf_link_hash_entry *h;
       struct elf_i386_link_hash_entry *eh;
       Elf_Internal_Sym *isym;
@@ -5369,10 +5369,10 @@ disallow_got32:
 	{
 	  _bfd_error_handler
 	    /* xgettext:c-format */
-	    (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
+	    (_("%B(%A+%#Lx): unresolvable %s relocation against symbol `%s'"),
 	     input_bfd,
 	     input_section,
-	     (long) rel->r_offset,
+	     rel->r_offset,
 	     howto->name,
 	     h->root.root.string);
 	  return FALSE;
@@ -5409,9 +5409,9 @@ check_relocation_error:
 	    {
 	      _bfd_error_handler
 		/* xgettext:c-format */
-		(_("%B(%A+0x%lx): reloc against `%s': error %d"),
+		(_("%B(%A+%#Lx): reloc against `%s': error %d"),
 		 input_bfd, input_section,
-		 (long) rel->r_offset, name, (int) r);
+		 rel->r_offset, name, (int) r);
 	      return FALSE;
 	    }
 	}
diff --git a/bfd/elf32-ip2k.c b/bfd/elf32-ip2k.c
index 9c37c1c..bf4f5cc 100644
--- a/bfd/elf32-ip2k.c
+++ b/bfd/elf32-ip2k.c
@@ -1295,7 +1295,7 @@ 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 0x%08lx (dest = 0x%08lx)."),
+	    _bfd_error_handler (_("ip2k linker: missing page instruction at %#Lx (dest = %#Lx)"),
 				BASEADDR (input_section) + rel->r_offset,
 				relocation + rel->r_addend);
         }
@@ -1312,7 +1312,7 @@ 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 0x%08lx (dest = 0x%08lx)."),
+	    _bfd_error_handler (_("ip2k linker: redundant page instruction at %#Lx (dest = %#Lx)"),
 				page_addr,
 				relocation + rel->r_addend);
         }
diff --git a/bfd/elf32-iq2000.c b/bfd/elf32-iq2000.c
index c17097d..0260cc3 100644
--- a/bfd/elf32-iq2000.c
+++ b/bfd/elf32-iq2000.c
@@ -843,8 +843,8 @@ iq2000_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
 
 	  _bfd_error_handler
 	    /* xgettext:c-format */
-	    (_("%B: uses different e_flags (0x%lx) fields than previous modules (0x%lx)"),
-	     ibfd, (long)new_flags, (long)old_flags);
+	    (_("%B: 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 aabf49f..656f48b 100644
--- a/bfd/elf32-lm32.c
+++ b/bfd/elf32-lm32.c
@@ -1497,7 +1497,7 @@ 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 %d != relocs %d",
+            ("LINKER BUG: .rofixup section size mismatch: size/4 %Ld != relocs %d",
             lm32fdpic_fixup32_section (info)->size/4,
             lm32fdpic_fixup32_section (info)->reloc_count);
           return FALSE;
@@ -1519,7 +1519,7 @@ 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: %Ld != %Ld", hend->u.def.value, value);
               return FALSE;
             }
         }
diff --git a/bfd/elf32-m32c.c b/bfd/elf32-m32c.c
index 9658d17..2cb28b2 100644
--- a/bfd/elf32-m32c.c
+++ b/bfd/elf32-m32c.c
@@ -826,7 +826,7 @@ m32c_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
 
 #ifdef DEBUG
   _bfd_error_handler
-    ("old_flags = 0x%.8lx, new_flags = 0x%.8lx, init = %s, filename = %s",
+    ("old_flags = 0x%.8x, new_flags = 0x%.8x, init = %s, filename = %s",
      old_flags, new_flags, elf_flags_init (obfd) ? "yes" : "no",
      bfd_get_filename (ibfd));
 #endif
@@ -887,9 +887,9 @@ 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 (0x%lx) fields"
-	       " than previous modules (0x%lx)"),
-	     ibfd, (long) new_flags, (long) old_flags);
+	    (_("%B: 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 9040823..d4e4423 100644
--- a/bfd/elf32-m32r.c
+++ b/bfd/elf32-m32r.c
@@ -2537,10 +2537,11 @@ m32r_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
 		{
 		  _bfd_error_handler
 		    /* xgettext:c-format */
-		    (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
+		    (_("%B(%A+%#Lx): unresolvable %s relocation "
+		       "against symbol `%s'"),
 		     input_bfd,
 		     input_section,
-		     (long) rel->r_offset,
+		     rel->r_offset,
 		     howto->name,
 		     h->root.root.string);
 		}
diff --git a/bfd/elf32-m68hc1x.c b/bfd/elf32-m68hc1x.c
index 96fc96f..cc6eb2d 100644
--- a/bfd/elf32-m68hc1x.c
+++ b/bfd/elf32-m68hc1x.c
@@ -1385,8 +1385,8 @@ _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 (0x%lx) fields than previous modules (0x%lx)"),
-	 ibfd, (unsigned long) new_flags, (unsigned long) old_flags);
+	(_("%B: 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 6f58720..5b64589 100644
--- a/bfd/elf32-m68k.c
+++ b/bfd/elf32-m68k.c
@@ -3887,9 +3887,8 @@ elf_m68k_relocate_section (bfd *output_bfd,
 	    {
 	      _bfd_error_handler
 		/* xgettext:c-format */
-		(_("%B(%A+0x%lx): R_68K_TLS_LE32 relocation not permitted "
-		   "in shared object"),
-		 input_bfd, input_section, (long) rel->r_offset, howto->name);
+		(_("%B(%A+%#Lx): %s relocation not permitted in shared object"),
+		 input_bfd, input_section, rel->r_offset, howto->name);
 
 	      return FALSE;
 	    }
@@ -4081,10 +4080,10 @@ elf_m68k_relocate_section (bfd *output_bfd,
 	{
 	  _bfd_error_handler
 	    /* xgettext:c-format */
-	    (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
+	    (_("%B(%A+%#Lx): unresolvable %s relocation against symbol `%s'"),
 	     input_bfd,
 	     input_section,
-	     (long) rel->r_offset,
+	     rel->r_offset,
 	     howto->name,
 	     h->root.root.string);
 	  return FALSE;
@@ -4117,12 +4116,12 @@ elf_m68k_relocate_section (bfd *output_bfd,
 	      _bfd_error_handler
 		((sym_type == STT_TLS
 		  /* xgettext:c-format */
-		  ? _("%B(%A+0x%lx): %s used with TLS symbol %s")
+		  ? _("%B(%A+%#Lx): %s used with TLS symbol %s")
 		  /* xgettext:c-format */
-		  : _("%B(%A+0x%lx): %s used with non-TLS symbol %s")),
+		  : _("%B(%A+%#Lx): %s used with non-TLS symbol %s")),
 		 input_bfd,
 		 input_section,
-		 (long) rel->r_offset,
+		 rel->r_offset,
 		 howto->name,
 		 name);
 	    }
@@ -4157,9 +4156,9 @@ elf_m68k_relocate_section (bfd *output_bfd,
 	    {
 	      _bfd_error_handler
 		/* xgettext:c-format */
-		(_("%B(%A+0x%lx): reloc against `%s': error %d"),
+		(_("%B(%A+%#Lx): reloc against `%s': error %d"),
 		 input_bfd, input_section,
-		 (long) rel->r_offset, name, (int) r);
+		 rel->r_offset, name, (int) r);
 	      return FALSE;
 	    }
 	}
diff --git a/bfd/elf32-mcore.c b/bfd/elf32-mcore.c
index 0037129..5ecf1c6 100644
--- a/bfd/elf32-mcore.c
+++ b/bfd/elf32-mcore.c
@@ -408,10 +408,10 @@ mcore_elf_relocate_section (bfd * output_bfd,
 
 #ifdef DEBUG
   _bfd_error_handler
-    ("mcore_elf_relocate_section called for %B section %A, %ld relocations%s",
+    ("mcore_elf_relocate_section called for %B section %A, %u relocations%s",
      input_bfd,
      input_section,
-     (long) input_section->reloc_count,
+     input_section->reloc_count,
      (bfd_link_relocatable (info)) ? " (relocatable)" : "");
 #endif
 
diff --git a/bfd/elf32-mep.c b/bfd/elf32-mep.c
index 32305c5..7d0e454 100644
--- a/bfd/elf32-mep.c
+++ b/bfd/elf32-mep.c
@@ -585,7 +585,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%.8lx, new_flags = 0x%.8lx, init = %s",
+  _bfd_error_handler ("%B: 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-metag.c b/bfd/elf32-metag.c
index 94eda953..a62cfa0 100644
--- a/bfd/elf32-metag.c
+++ b/bfd/elf32-metag.c
@@ -1873,7 +1873,7 @@ elf_metag_relocate_section (bfd *output_bfd,
 			/* PR 20675 */
 			if (bfd_link_pic (info))
 			  _bfd_error_handler (_("%B(%A): multiple TLS models are not supported"),
-					      input_bfd, input_section, name);
+					      input_bfd, input_section);
 			else
 			  _bfd_error_handler (_("%B(%A): shared library symbol %s encountered whilst performing a static link"),
 					      input_bfd, input_section, name);
@@ -1928,9 +1928,8 @@ elf_metag_relocate_section (bfd *output_bfd,
 	    {
 	      _bfd_error_handler
 		/* xgettext:c-format */
-		(_("%B(%A+0x%lx): R_METAG_TLS_LE/IENONPIC relocation not permitted in shared object"),
-		 input_bfd, input_section,
-		 (long) rel->r_offset, howto->name);
+		(_("%B(%A+%#Lx): %s relocation not permitted in shared object"),
+		 input_bfd, input_section, rel->r_offset, howto->name);
 	      return FALSE;
 	    }
 	  else
diff --git a/bfd/elf32-mt.c b/bfd/elf32-mt.c
index db89f8c..b4625d4 100644
--- a/bfd/elf32-mt.c
+++ b/bfd/elf32-mt.c
@@ -524,7 +524,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%.8lx, new_flags = 0x%.8lx, init = %s",
+  _bfd_error_handler ("%B: 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 94fb037..d6b58aa 100644
--- a/bfd/elf32-nds32.c
+++ b/bfd/elf32-nds32.c
@@ -8986,7 +8986,7 @@ relax_range_measurement (bfd *abfd)
 
 static const char * unrecognized_reloc_msg =
   /* xgettext:c-format */
-  N_("%B: warning: %s points to unrecognized reloc at 0x%lx.");
+  N_("%B: warning: %s points to unrecognized reloc at %#Lx");
 
 /* Relax LONGCALL1 relocation for nds32_elf_relax_section.  */
 
@@ -9039,7 +9039,7 @@ 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",
-			  (long) irel->r_offset);
+			  irel->r_offset);
       return FALSE;
     }
 
@@ -9120,7 +9120,7 @@ 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",
-			  (long) irel->r_offset);
+			  irel->r_offset);
       return FALSE;
     }
 
@@ -9226,7 +9226,7 @@ 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",
-			  (long) irel->r_offset);
+			  irel->r_offset);
       return FALSE;
     }
 
@@ -9360,7 +9360,7 @@ nds32_elf_relax_longjump1 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel,
   if (hi_irelfn == irelend || lo_irelfn == irelend)
     {
       _bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LONGJUMP1",
-			  (long) irel->r_offset);
+			  irel->r_offset);
       return FALSE;
     }
 
@@ -9566,7 +9566,7 @@ 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",
-			  (long) irel->r_offset);
+			  irel->r_offset);
       return FALSE;
     }
 
@@ -9758,7 +9758,7 @@ 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",
-			  (long) irel->r_offset);
+			  irel->r_offset);
       return FALSE;
     }
 
@@ -9938,7 +9938,7 @@ 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",
-			  (long) irel->r_offset);
+			  irel->r_offset);
       return FALSE;
     }
 
@@ -9968,7 +9968,7 @@ 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",
-			  (long) irel->r_offset);
+			  irel->r_offset);
       return FALSE;
     }
   /* Check these is enough space to insert jal in R_NDS32_EMPTY.  */
@@ -10039,7 +10039,7 @@ nds32_elf_relax_longcall5 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel,
   if (cond_irel == irelend)
     {
       _bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LONGCALL5",
-			  (long) irel->r_offset);
+			  irel->r_offset);
       return FALSE;
     }
 
@@ -10117,7 +10117,7 @@ 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",
-			  (long) irel->r_offset);
+			  irel->r_offset);
       return FALSE;
     }
 
@@ -10155,7 +10155,7 @@ nds32_elf_relax_longcall6 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel,
       if (cond_irel == irelend)
 	{
 	  _bfd_error_handler (unrecognized_reloc_msg, abfd,
-			      "R_NDS32_LONGCALL6", (long) irel->r_offset);
+			      "R_NDS32_LONGCALL6", irel->r_offset);
 	  return FALSE;
 	}
       cond_irel->r_addend = 1;
@@ -10204,7 +10204,7 @@ nds32_elf_relax_longcall6 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel,
       if (cond_irel == irelend)
 	{
 	  _bfd_error_handler (unrecognized_reloc_msg, abfd,
-			      "R_NDS32_LONGCALL6", (long) irel->r_offset);
+			      "R_NDS32_LONGCALL6", irel->r_offset);
 	  return FALSE;
 	}
       cond_irel->r_addend = 1;
@@ -10254,7 +10254,7 @@ 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",
-			  (long) irel->r_offset);
+			  irel->r_offset);
       return FALSE;
     }
 
@@ -10276,7 +10276,7 @@ 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",
-			  (long) irel->r_offset);
+			  irel->r_offset);
       return FALSE;
     }
 
@@ -10350,7 +10350,7 @@ nds32_elf_relax_longjump5 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel,
   if (cond_irel == irelend)
     {
       _bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LONGJUMP5",
-			  (long) irel->r_offset);
+			  irel->r_offset);
       return FALSE;
     }
 
@@ -10479,7 +10479,7 @@ 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",
-			  (long) irel->r_offset);
+			  irel->r_offset);
       return FALSE;
     }
 
@@ -10649,7 +10649,7 @@ nds32_elf_relax_longjump7 (bfd *abfd, asection *sec, Elf_Internal_Rela *irel,
   if (cond_irel == irelend)
     {
       _bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LONGJUMP7",
-			  (long) irel->r_offset);
+			  irel->r_offset);
       return FALSE;
     }
 
@@ -10754,7 +10754,7 @@ 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",
-			  (long) irel->r_offset);
+			  irel->r_offset);
 	return FALSE;
     }
 
@@ -11228,7 +11228,7 @@ 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",
-			  (long) irel->r_offset);
+			  irel->r_offset);
       return FALSE;
     }
 
@@ -15433,8 +15433,8 @@ nds32_elf_ex9_build_hash_table (bfd *abfd, asection *sec,
 			  /* Incorrect alignment.  */
 			  _bfd_error_handler
 			    /* xgettext:c-format */
-			    (_("%B: warning: unaligned small data access. "
-			       "For entry: {%d, %d, %d}, addr = 0x%x, align = 0x%x."),
+			    (_("%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;
@@ -15466,7 +15466,7 @@ nds32_elf_ex9_build_hash_table (bfd *abfd, asection *sec,
 	  if (entry == NULL)
 	    {
 	      _bfd_error_handler
-		(_("%P%F: failed creating ex9.it %s hash table: %E\n"), code);
+		(_("failed creating ex9.it %s hash table entry"), code);
 	      return FALSE;
 	    }
 	  if (h)
diff --git a/bfd/elf32-nios2.c b/bfd/elf32-nios2.c
index 50a09ea..860a3d7 100644
--- a/bfd/elf32-nios2.c
+++ b/bfd/elf32-nios2.c
@@ -4369,10 +4369,10 @@ nios2_elf32_relocate_section (bfd *output_bfd,
 		{
 		  _bfd_error_handler
 		    /* xgettext:c-format */
-		    (_("%B(%A+0x%lx): R_NIOS2_TLS_LE16 relocation not "
+		    (_("%B(%A+%#Lx): %s relocation not "
 		       "permitted in shared object"),
 		     input_bfd, input_section,
-		     (long) rel->r_offset, howto->name);
+		     rel->r_offset, howto->name);
 		  return FALSE;
 		}
 	      else
diff --git a/bfd/elf32-rx.c b/bfd/elf32-rx.c
index bb2b307..f81988b 100644
--- a/bfd/elf32-rx.c
+++ b/bfd/elf32-rx.c
@@ -683,7 +683,7 @@ rx_elf_relocate_section
 	  && strcmp (name, "__romdatastart") != 0			\
 	  && !saw_subtract)						\
 	/* xgettext:c-format */						\
-	_bfd_error_handler (_("%B(%A): unsafe PID relocation %s at 0x%08lx (against %s in %s)"), \
+	_bfd_error_handler (_("%B(%A): unsafe PID relocation %s at %#Lx (against %s in %s)"), \
 			    input_bfd, input_section, howto->name,	\
 			    input_section->output_section->vma + input_section->output_offset + rel->r_offset, \
 			    name, sec->name);				\
diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c
index c26bdcf..ddbeb97 100644
--- a/bfd/elf32-s390.c
+++ b/bfd/elf32-s390.c
@@ -945,7 +945,7 @@ elf_s390_check_relocs (bfd *abfd,
   for (rel = relocs; rel < rel_end; rel++)
     {
       unsigned int r_type;
-      unsigned long r_symndx;
+      unsigned int r_symndx;
       struct elf_link_hash_entry *h;
 
       r_symndx = ELF32_R_SYM (rel->r_info);
@@ -2307,10 +2307,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+0x%lx): invalid instruction for TLS relocation %s"),
+    (_("%B(%A+%#Lx): invalid instruction for TLS relocation %s"),
      input_bfd,
      input_section,
-     (long) rel->r_offset,
+     rel->r_offset,
      howto->name);
   bfd_set_error (bfd_error_bad_value);
 }
@@ -3369,10 +3369,10 @@ elf_s390_relocate_section (bfd *output_bfd,
 				      rel->r_offset) != (bfd_vma) -1)
 	_bfd_error_handler
 	  /* xgettext:c-format */
-	  (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
+	  (_("%B(%A+%#Lx): unresolvable %s relocation against symbol `%s'"),
 	   input_bfd,
 	   input_section,
-	   (long) rel->r_offset,
+	   rel->r_offset,
 	   howto->name,
 	   h->root.root.string);
 
@@ -3426,9 +3426,9 @@ elf_s390_relocate_section (bfd *output_bfd,
 	    {
 	      _bfd_error_handler
 		/* xgettext:c-format */
-		(_("%B(%A+0x%lx): reloc against `%s': error %d"),
+		(_("%B(%A+%#Lx): reloc against `%s': error %d"),
 		 input_bfd, input_section,
-		 (long) rel->r_offset, name, (int) r);
+		 rel->r_offset, name, (int) r);
 	      return FALSE;
 	    }
 	}
diff --git a/bfd/elf32-score.c b/bfd/elf32-score.c
index 3dfe806..5fc10b3 100644
--- a/bfd/elf32-score.c
+++ b/bfd/elf32-score.c
@@ -2880,8 +2880,8 @@ s3_bfd_score_elf_check_relocs (bfd *abfd,
             {
 	      _bfd_error_handler
 		/* xgettext:c-format */
-                (_("%B: CALL15 reloc at 0x%lx not against global symbol"),
-                 abfd, (unsigned long) rel->r_offset);
+                (_("%B: CALL15 reloc at %#Lx not against global symbol"),
+                 abfd, rel->r_offset);
               bfd_set_error (bfd_error_bad_value);
               return FALSE;
             }
diff --git a/bfd/elf32-score7.c b/bfd/elf32-score7.c
index 66e7945..5554ccc 100644
--- a/bfd/elf32-score7.c
+++ b/bfd/elf32-score7.c
@@ -2685,8 +2685,8 @@ s7_bfd_score_elf_check_relocs (bfd *abfd,
             {
 	      _bfd_error_handler
 		/* xgettext:c-format */
-                (_("%B: CALL15 reloc at 0x%lx not against global symbol"),
-                 abfd, (unsigned long) rel->r_offset);
+                (_("%B: CALL15 reloc at %#Lx not against global symbol"),
+                 abfd, rel->r_offset);
               bfd_set_error (bfd_error_bad_value);
               return FALSE;
             }
diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c
index 3df13b5..dfc16a2 100644
--- a/bfd/elf32-sh.c
+++ b/bfd/elf32-sh.c
@@ -577,8 +577,8 @@ sh_elf_relax_section (bfd *abfd, asection *sec,
       if (laddr >= sec->size)
 	{
 	  /* xgettext:c-format */
-	  _bfd_error_handler (_("%B: 0x%lx: warning: bad R_SH_USES offset"),
-			      abfd, (unsigned long) irel->r_offset);
+	  _bfd_error_handler (_("%B: %#Lx: warning: bad R_SH_USES offset"),
+			      abfd, irel->r_offset);
 	  continue;
 	}
       insn = bfd_get_16 (abfd, contents + laddr);
@@ -589,8 +589,8 @@ sh_elf_relax_section (bfd *abfd, asection *sec,
 	{
 	  _bfd_error_handler
 	    /* xgettext:c-format */
-	    (_("%B: 0x%lx: warning: R_SH_USES points to unrecognized insn 0x%x"),
-	     abfd, (unsigned long) irel->r_offset, insn);
+	    (_("%B: %#Lx: warning: R_SH_USES points to unrecognized insn 0x%x"),
+	     abfd, irel->r_offset, insn);
 	  continue;
 	}
 
@@ -607,8 +607,8 @@ sh_elf_relax_section (bfd *abfd, asection *sec,
 	{
 	  _bfd_error_handler
 	    /* xgettext:c-format */
-	    (_("%B: 0x%lx: warning: bad R_SH_USES load offset"),
-	     abfd, (unsigned long) irel->r_offset);
+	    (_("%B: %#Lx: warning: bad R_SH_USES load offset"),
+	     abfd, irel->r_offset);
 	  continue;
 	}
 
@@ -623,8 +623,8 @@ sh_elf_relax_section (bfd *abfd, asection *sec,
 	{
 	  _bfd_error_handler
 	    /* xgettext:c-format */
-	    (_("%B: 0x%lx: warning: could not find expected reloc"),
-	     abfd, (unsigned long) paddr);
+	    (_("%B: %#Lx: warning: could not find expected reloc"),
+	     abfd, paddr);
 	  continue;
 	}
 
@@ -652,8 +652,8 @@ sh_elf_relax_section (bfd *abfd, asection *sec,
 	    {
 	      _bfd_error_handler
 		/* xgettext:c-format */
-		(_("%B: 0x%lx: warning: symbol in unexpected section"),
-		 abfd, (unsigned long) paddr);
+		(_("%B: %#Lx: warning: symbol in unexpected section"),
+		 abfd, paddr);
 	      continue;
 	    }
 
@@ -782,8 +782,8 @@ sh_elf_relax_section (bfd *abfd, asection *sec,
 	{
 	  _bfd_error_handler
 	    /* xgettext:c-format */
-	    (_("%B: 0x%lx: warning: could not find expected COUNT reloc"),
-	     abfd, (unsigned long) paddr);
+	    (_("%B: %#Lx: warning: could not find expected COUNT reloc"),
+	     abfd, paddr);
 	  continue;
 	}
 
@@ -792,8 +792,8 @@ sh_elf_relax_section (bfd *abfd, asection *sec,
       if (irelcount->r_addend == 0)
 	{
 	  /* xgettext:c-format */
-	  _bfd_error_handler (_("%B: 0x%lx: warning: bad count"),
-			      abfd, (unsigned long) paddr);
+	  _bfd_error_handler (_("%B: %#Lx: warning: bad count"),
+			      abfd, paddr);
 	  continue;
 	}
 
@@ -1196,8 +1196,8 @@ sh_elf_relax_delete_bytes (bfd *abfd, asection *sec, bfd_vma addr,
 	    {
 	      _bfd_error_handler
 		/* xgettext:c-format */
-		(_("%B: 0x%lx: fatal: reloc overflow while relaxing"),
-		 abfd, (unsigned long) irel->r_offset);
+		(_("%B: %#Lx: fatal: reloc overflow while relaxing"),
+		 abfd, irel->r_offset);
 	      bfd_set_error (bfd_error_bad_value);
 	      return FALSE;
 	    }
@@ -1567,8 +1567,8 @@ sh_elf_swap_insns (bfd *abfd, asection *sec, void *relocs,
 	    {
 	      _bfd_error_handler
 		/* xgettext:c-format */
-		(_("%B: 0x%lx: fatal: reloc overflow while relaxing"),
-		 abfd, (unsigned long) irel->r_offset);
+		(_("%B: %#Lx: fatal: reloc overflow while relaxing"),
+		 abfd, irel->r_offset);
 	      bfd_set_error (bfd_error_bad_value);
 	      return FALSE;
 	    }
@@ -4006,9 +4006,9 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
 		{
 		  _bfd_error_handler
 		    /* xgettext:c-format */
-		    (_("%B(%A+0x%lx): %s relocation against SEC_MERGE section"),
+		    (_("%B(%A+%#Lx): %s relocation against SEC_MERGE section"),
 		     input_bfd, input_section,
-		     (long) rel->r_offset, howto->name);
+		     rel->r_offset, howto->name);
 		  return FALSE;
 		}
 
@@ -4124,10 +4124,10 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
 		{
 		  _bfd_error_handler
 		    /* xgettext:c-format */
-		    (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
+		    (_("%B(%A+%#Lx): unresolvable %s relocation against symbol `%s'"),
 		     input_bfd,
 		     input_section,
-		     (long) rel->r_offset,
+		     rel->r_offset,
 		     howto->name,
 		     h->root.root.string);
 		  return FALSE;
@@ -4203,9 +4203,9 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
 		{
 		  _bfd_error_handler
 		    /* xgettext:c-format */
-		    (_("%B: 0x%lx: fatal: unaligned branch target for relax-support relocation"),
+		    (_("%B: %#Lx: fatal: unaligned branch target for relax-support relocation"),
 		     input_section->owner,
-		     (unsigned long) rel->r_offset);
+		     rel->r_offset);
 		  bfd_set_error (bfd_error_bad_value);
 		  return FALSE;
 		}
@@ -4237,10 +4237,10 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
 	    {
 	      _bfd_error_handler
 		/* xgettext:c-format */
-		(_("%B: 0x%lx: fatal: unaligned %s relocation 0x%lx"),
+		(_("%B: %#Lx: fatal: unaligned %s relocation %#Lx"),
 		 input_section->owner,
-		 (unsigned long) rel->r_offset, howto->name,
-		 (unsigned long) relocation);
+		 rel->r_offset, howto->name,
+		 relocation);
 	      bfd_set_error (bfd_error_bad_value);
 	      return FALSE;
 	    }
@@ -4253,10 +4253,10 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
 	    {
 	      _bfd_error_handler
 		/* xgettext:c-format */
-		(_("%B: 0x%lx: fatal: unaligned %s relocation 0x%lx"),
+		(_("%B: %#Lx: fatal: unaligned %s relocation %#Lx"),
 		 input_section->owner,
-		 (unsigned long) rel->r_offset, howto->name,
-		 (unsigned long) relocation);
+		 rel->r_offset, howto->name,
+		 relocation);
 	      bfd_set_error (bfd_error_bad_value);
 	      return FALSE;
 	    }
@@ -4268,10 +4268,10 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
 	    {
 	      _bfd_error_handler
 		/* xgettext:c-format */
-		(_("%B: 0x%lx: fatal: R_SH_PSHA relocation %d not in range -32..32"),
+		(_("%B: %#Lx: fatal: R_SH_PSHA relocation %Ld not in range -32..32"),
 		 input_section->owner,
-		 (unsigned long) rel->r_offset,
-		 (unsigned long) relocation);
+		 rel->r_offset,
+		 relocation);
 	      bfd_set_error (bfd_error_bad_value);
 	      return FALSE;
 	    }
@@ -4283,10 +4283,10 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
 	    {
 	      _bfd_error_handler
 		/* xgettext:c-format */
-		(_("%B: 0x%lx: fatal: R_SH_PSHL relocation %d not in range -32..32"),
+		(_("%B: %#Lx: fatal: R_SH_PSHL relocation %Ld not in range -32..32"),
 		 input_section->owner,
-		 (unsigned long) rel->r_offset,
-		 (unsigned long) relocation);
+		 rel->r_offset,
+		 relocation);
 	      bfd_set_error (bfd_error_bad_value);
 	      return FALSE;
 	    }
@@ -4428,10 +4428,10 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
 		  {
 		    _bfd_error_handler
 		      /* xgettext:c-format */
-		      (_("%B(%A+0x%lx): cannot emit fixup to `%s' in read-only section"),
+		      (_("%B(%A+%#Lx): cannot emit fixup to `%s' in read-only section"),
 		       input_bfd,
 		       input_section,
-		       (long) rel->r_offset,
+		       rel->r_offset,
 		       symname);
 		    return FALSE;
 		  }
@@ -4900,10 +4900,10 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
 		  {
 		    _bfd_error_handler
 		      /* xgettext:c-format */
-		      (_("%B(%A+0x%lx): cannot emit fixup to `%s' in read-only section"),
+		      (_("%B(%A+%#Lx): cannot emit fixup to `%s' in read-only section"),
 		       input_bfd,
 		       input_section,
-		       (long) rel->r_offset,
+		       rel->r_offset,
 		       symname);
 		    return FALSE;
 		  }
@@ -5002,8 +5002,8 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
 	    {
 	      _bfd_error_handler
 		/* xgettext:c-format */
-		(_("%B(%A+0x%lx): %s relocation against external symbol \"%s\""),
-		 input_bfd, input_section, (long) rel->r_offset, howto->name,
+		(_("%B(%A+%#Lx): %s relocation against external symbol \"%s\""),
+		 input_bfd, input_section, rel->r_offset, howto->name,
 		 h->root.root.string);
 	      return FALSE;
 	    }
diff --git a/bfd/elf32-sh64.c b/bfd/elf32-sh64.c
index de7ce95d..87033f7 100644
--- a/bfd/elf32-sh64.c
+++ b/bfd/elf32-sh64.c
@@ -597,9 +597,9 @@ shmedia_prepare_reloc (struct bfd_link_info *info, bfd *abfd,
     {
       _bfd_error_handler
 	/* xgettext:c-format */
-	(_("%B: error: unaligned relocation type %d at %08x reloc %p\n"),
-	 input_section->owner, ELF32_R_TYPE (rel->r_info),
-	 (unsigned) rel->r_offset, relocation);
+	(_("%B: error: unaligned relocation type %d at %#Lx reloc %#Lx"),
+	 input_section->owner, (int) ELF32_R_TYPE (rel->r_info),
+	 rel->r_offset, *relocation);
       return FALSE;
     }
 
diff --git a/bfd/elf32-spu.c b/bfd/elf32-spu.c
index cbb026e..f7c18d9 100644
--- a/bfd/elf32-spu.c
+++ b/bfd/elf32-spu.c
@@ -5040,10 +5040,10 @@ spu_elf_relocate_section (bfd *output_bfd,
 	{
 	  _bfd_error_handler
 	    /* xgettext:c-format */
-	    (_("%B(%s+0x%lx): unresolvable %s relocation against symbol `%s'"),
+	    (_("%B(%s+%#Lx): unresolvable %s relocation against symbol `%s'"),
 	     input_bfd,
 	     bfd_get_section_name (input_bfd, input_section),
-	     (long) rel->r_offset,
+	     rel->r_offset,
 	     howto->name,
 	     sym_name);
 	  ret = FALSE;
diff --git a/bfd/elf32-tic6x.c b/bfd/elf32-tic6x.c
index e2a2961..bcce800 100644
--- a/bfd/elf32-tic6x.c
+++ b/bfd/elf32-tic6x.c
@@ -2632,7 +2632,7 @@ 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 %d"
+		  (_("%B, section %A: relocation %s with non-zero addend %Ld"
 		     " against local symbol"),
 		   input_bfd,
 		   input_section,
@@ -2641,7 +2641,7 @@ elf32_tic6x_relocate_section (bfd *output_bfd,
 	      else
 		_bfd_error_handler
 		  /* xgettext:c-format */
-		  (_("%B, section %A: relocation %s with non-zero addend %d"
+		  (_("%B, section %A: relocation %s with non-zero addend %Ld"
 		     " against symbol `%s'"),
 		   input_bfd,
 		   input_section,
@@ -2801,7 +2801,7 @@ elf32_tic6x_check_relocs (bfd *abfd, struct bfd_link_info *info,
   for (rel = relocs; rel < rel_end; rel++)
     {
       unsigned int r_type;
-      unsigned long r_symndx;
+      unsigned int r_symndx;
       struct elf_link_hash_entry *h;
       Elf_Internal_Sym *isym;
 
diff --git a/bfd/elf32-tilepro.c b/bfd/elf32-tilepro.c
index d333203..976ce30 100644
--- a/bfd/elf32-tilepro.c
+++ b/bfd/elf32-tilepro.c
@@ -1478,7 +1478,7 @@ tilepro_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
   for (rel = relocs; rel < rel_end; rel++)
     {
       unsigned int r_type;
-      unsigned long r_symndx;
+      unsigned int r_symndx;
       struct elf_link_hash_entry *h;
       int tls_type;
 
@@ -3566,10 +3566,10 @@ 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+0x%lx): unresolvable %s relocation against symbol `%s'"),
+	  (_("%B(%A+%#Lx): unresolvable %s relocation against symbol `%s'"),
 	   input_bfd,
 	   input_section,
-	   (long) rel->r_offset,
+	   rel->r_offset,
 	   howto->name,
 	   h->root.root.string);
 
diff --git a/bfd/elf32-v850.c b/bfd/elf32-v850.c
index 8db7507..a9c56cb 100644
--- a/bfd/elf32-v850.c
+++ b/bfd/elf32-v850.c
@@ -3602,9 +3602,9 @@ v850_elf_relax_section (bfd *abfd,
 		{
 		  _bfd_error_handler
 		    /* xgettext:c-format */
-		    (_("%B: 0x%lx: warning: R_V850_LONGCALL points to "
+		    (_("%B: %#Lx: warning: R_V850_LONGCALL points to "
 		       "unrecognized insns"),
-		     abfd, (unsigned long) irel->r_offset);
+		     abfd, irel->r_offset);
 		  continue;
 		}
 
@@ -3612,10 +3612,10 @@ v850_elf_relax_section (bfd *abfd,
 		{
 		  _bfd_error_handler
 		    /* xgettext:c-format */
-		    (_("%B: 0x%lx: warning: R_V850_LONGCALL points to "
-		       "unrecognized insn 0x%x"),
+		    (_("%B: %#Lx: warning: R_V850_LONGCALL points to "
+		       "unrecognized insn %#x"),
 		     abfd,
-		     (unsigned long) irel->r_offset + no_match,
+		     irel->r_offset + no_match,
 		     insn[no_match]);
 		  continue;
 		}
@@ -3657,9 +3657,9 @@ v850_elf_relax_section (bfd *abfd,
 		{
 		  _bfd_error_handler
 		    /* xgettext:c-format */
-		    (_("%B: 0x%lx: warning: R_V850_LONGCALL points to "
+		    (_("%B: %#Lx: warning: R_V850_LONGCALL points to "
 		       "unrecognized reloc"),
-		     abfd, (unsigned long) irel->r_offset);
+		     abfd, irel->r_offset);
 
 		  continue;
 		}
@@ -3697,9 +3697,9 @@ v850_elf_relax_section (bfd *abfd,
 		{
 		  _bfd_error_handler
 		    /* xgettext:c-format */
-		    (_("%B: 0x%lx: warning: R_V850_LONGCALL points to "
-		       "unrecognized reloc 0x%lx"),
-		     abfd, (unsigned long) irel->r_offset,
+		    (_("%B: %#Lx: warning: R_V850_LONGCALL points to "
+		       "unrecognized reloc %#Lx"),
+		     abfd, irel->r_offset,
 		     irelcall->r_offset);
 		  continue;
 		}
@@ -3840,9 +3840,9 @@ v850_elf_relax_section (bfd *abfd,
 		{
 		  _bfd_error_handler
 		    /* xgettext:c-format */
-		    (_("%B: 0x%lx: warning: R_V850_LONGJUMP points to "
+		    (_("%B: %#Lx: warning: R_V850_LONGJUMP points to "
 		       "unrecognized insns"),
-		     abfd, (unsigned long) irel->r_offset);
+		     abfd, irel->r_offset);
 		  continue;
 		}
 
@@ -3850,10 +3850,10 @@ v850_elf_relax_section (bfd *abfd,
 		{
 		  _bfd_error_handler
 		    /* xgettext:c-format */
-		    (_("%B: 0x%lx: warning: R_V850_LONGJUMP points to "
-		       "unrecognized insn 0x%x"),
+		    (_("%B: %#Lx: warning: R_V850_LONGJUMP points to "
+		       "unrecognized insn %#x"),
 		     abfd,
-		     (unsigned long) irel->r_offset + no_match,
+		     irel->r_offset + no_match,
 		     insn[no_match]);
 		  continue;
 		}
@@ -3884,9 +3884,9 @@ v850_elf_relax_section (bfd *abfd,
 		{
 		  _bfd_error_handler
 		    /* xgettext:c-format */
-		    (_("%B: 0x%lx: warning: R_V850_LONGJUMP points to "
+		    (_("%B: %#Lx: warning: R_V850_LONGJUMP points to "
 		       "unrecognized reloc"),
-		     abfd, (unsigned long) irel->r_offset);
+		     abfd, irel->r_offset);
 		  continue;
 		}
 
diff --git a/bfd/elf32-vax.c b/bfd/elf32-vax.c
index 367e415..368de9c 100644
--- a/bfd/elf32-vax.c
+++ b/bfd/elf32-vax.c
@@ -632,8 +632,8 @@ 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"),
+		      (_("%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);
 
@@ -1508,7 +1508,7 @@ elf_vax_relocate_section (bfd *output_bfd,
 	  else if (rel->r_addend != 0)
 	    _bfd_error_handler
 	      /* xgettext:c-format */
-	      (_("%B: warning: PLT addend of %d to `%s'"
+	      (_("%B: warning: PLT addend of %Ld to `%s'"
 		 " from %A section ignored"),
 	       input_bfd, rel->r_addend, h->root.root.string, input_section);
 	  rel->r_addend = 0;
@@ -1640,7 +1640,7 @@ elf_vax_relocate_section (bfd *output_bfd,
 		  else
 		    _bfd_error_handler
 		      /* xgettext:c-format */
-		      (_("%B: warning: %s relocation to 0x%x from %A section"),
+		      (_("%B: warning: %s relocation to %#Lx from %A section"),
 		      input_bfd, howto->name, outrel.r_addend,
 		      input_section);
 		}
diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c
index 64e40d3..b3ddbf1 100644
--- a/bfd/elf32-xtensa.c
+++ b/bfd/elf32-xtensa.c
@@ -1001,7 +1001,7 @@ elf_xtensa_check_relocs (bfd *abfd,
   for (rel = relocs; rel < rel_end; rel++)
     {
       unsigned int r_type;
-      unsigned long r_symndx;
+      unsigned r_symndx;
       struct elf_link_hash_entry *h = NULL;
       struct elf_xtensa_link_hash_entry *eh;
       int tls_type, old_tls_type;
@@ -2787,7 +2787,7 @@ elf_xtensa_relocate_section (bfd *output_bfd,
 	{
 	  _bfd_error_handler
 	    /* xgettext:c-format */
-	    (_("%B(%A+0x%lx): relocation offset out of range (size=0x%x)"),
+	    (_("%B(%A+%#Lx): relocation offset out of range (size=%#Lx)"),
 	     input_bfd, input_section, rel->r_offset, input_size);
 	  bfd_set_error (bfd_error_bad_value);
 	  return FALSE;
@@ -2813,12 +2813,12 @@ elf_xtensa_relocate_section (bfd *output_bfd,
 	  _bfd_error_handler
 	    ((sym_type == STT_TLS
 	      /* xgettext:c-format */
-	      ? _("%B(%A+0x%lx): %s used with TLS symbol %s")
+	      ? _("%B(%A+%#Lx): %s used with TLS symbol %s")
 	      /* xgettext:c-format */
-	      : _("%B(%A+0x%lx): %s used with non-TLS symbol %s")),
+	      : _("%B(%A+%#Lx): %s used with non-TLS symbol %s")),
 	     input_bfd,
 	     input_section,
-	     (long) rel->r_offset,
+	     rel->r_offset,
 	     howto->name,
 	     name);
 	}
@@ -3071,10 +3071,10 @@ elf_xtensa_relocate_section (bfd *output_bfd,
 	{
 	  _bfd_error_handler
 	    /* xgettext:c-format */
-	    (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
+	    (_("%B(%A+%#Lx): unresolvable %s relocation against symbol `%s'"),
 	     input_bfd,
 	     input_section,
-	     (long) rel->r_offset,
+	     rel->r_offset,
 	     howto->name,
 	     name);
 	  return FALSE;
@@ -6549,7 +6549,8 @@ extend_ebb_bounds_forward (ebb_t *ebb)
 	{
 	  _bfd_error_handler
 	    /* xgettext:c-format */
-	    (_("%B(%A+0x%lx): could not decode instruction; possible configuration mismatch"),
+	    (_("%B(%A+%#Lx): could not decode instruction; "
+	       "possible configuration mismatch"),
 	     ebb->sec->owner, ebb->sec, ebb->end_offset + insn_block_len);
 	  return FALSE;
 	}
@@ -6626,7 +6627,8 @@ extend_ebb_bounds_backward (ebb_t *ebb)
 	{
 	  _bfd_error_handler
 	    /* xgettext:c-format */
-	    (_("%B(%A+0x%lx): could not decode instruction; possible configuration mismatch"),
+	    (_("%B(%A+%#Lx): could not decode instruction; "
+	       "possible configuration mismatch"),
 	     ebb->sec->owner, ebb->sec, ebb->end_offset + insn_block_len);
 	  return FALSE;
 	}
@@ -7740,7 +7742,9 @@ compute_text_actions (bfd *abfd,
 	{
 	  _bfd_error_handler
 	    /* xgettext:c-format */
-	    (_("%B(%A+0x%lx): could not decode instruction for XTENSA_ASM_SIMPLIFY relocation; possible configuration mismatch"),
+	    (_("%B(%A+%#Lx): could not decode instruction for "
+	       "XTENSA_ASM_SIMPLIFY relocation; "
+	       "possible configuration mismatch"),
 	     sec->owner, sec, r_offset);
 	  continue;
 	}
@@ -7999,7 +8003,8 @@ compute_ebb_proposed_actions (ebb_constraint *ebb_table)
  decode_error:
   _bfd_error_handler
     /* xgettext:c-format */
-    (_("%B(%A+0x%lx): could not decode instruction; possible configuration mismatch"),
+    (_("%B(%A+%#Lx): could not decode instruction; "
+       "possible configuration mismatch"),
      ebb->sec->owner, ebb->sec, offset);
   return FALSE;
 }
@@ -10776,7 +10781,7 @@ do_fix_for_relocatable_link (Elf_Internal_Rela *rel,
 	{
 	  _bfd_error_handler
 	    /* xgettext:c-format */
-	    (_("%B(%A+0x%lx): unexpected fix for %s relocation"),
+	    (_("%B(%A+%#Lx): unexpected fix for %s relocation"),
 	     input_bfd, input_section, rel->r_offset,
 	     elf_howto_table[r_type].name);
 	  return FALSE;
diff --git a/bfd/elf64-alpha.c b/bfd/elf64-alpha.c
index ada26f5..3e88787 100644
--- a/bfd/elf64-alpha.c
+++ b/bfd/elf64-alpha.c
@@ -3081,9 +3081,8 @@ elf64_alpha_relax_got_load (struct alpha_relax_info *info, bfd_vma symval,
       reloc_howto_type *howto = elf64_alpha_howto_table + r_type;
       _bfd_error_handler
 	/* xgettext:c-format */
-	(_("%B: %A+0x%lx: warning: %s relocation against unexpected insn"),
-	 info->abfd, info->sec,
-	 (unsigned long) irel->r_offset, howto->name);
+	(_("%B: %A+%#Lx: warning: %s relocation against unexpected insn"),
+	 info->abfd, info->sec, irel->r_offset, howto->name);
       return TRUE;
     }
 
@@ -3277,9 +3276,8 @@ elf64_alpha_relax_with_lituse (struct alpha_relax_info *info,
     {
       _bfd_error_handler
 	/* xgettext:c-format */
-	(_("%B: %A+0x%lx: warning: LITERAL relocation against unexpected insn"),
-	 abfd, info->sec,
-	 (unsigned long) irel->r_offset);
+	(_("%B: %A+%#Lx: warning: LITERAL relocation against unexpected insn"),
+	 abfd, info->sec, irel->r_offset);
       return TRUE;
     }
 
diff --git a/bfd/elf64-hppa.c b/bfd/elf64-hppa.c
index 834855a..9fefe0e 100644
--- a/bfd/elf64-hppa.c
+++ b/bfd/elf64-hppa.c
@@ -2079,8 +2079,8 @@ elf64_hppa_finish_dynamic_symbol (bfd *output_bfd,
 	{
 	  _bfd_error_handler
 	    /* xgettext:c-format */
-	    (_("stub entry for %s cannot load .plt, dp offset = %ld"),
-	     hh->eh.root.root.string, (long) value);
+	    (_("stub entry for %s cannot load .plt, dp offset = %Ld"),
+	     hh->eh.root.root.string, value);
 	  return FALSE;
 	}
 
@@ -3284,7 +3284,7 @@ elf_hppa_final_link_relocate (Elf_Internal_Rela *rel,
 	  {
 	    _bfd_error_handler
 	      /* xgettext:c-format */
-	      (_("%B(%A+0x%" BFD_VMA_FMT "x): cannot reach %s"),
+	      (_("%B(%A+%#Lx): cannot reach %s"),
 	      input_bfd,
 	      input_section,
 	      offset,
diff --git a/bfd/elf64-ia64-vms.c b/bfd/elf64-ia64-vms.c
index 4dff255..8140dc5 100644
--- a/bfd/elf64-ia64-vms.c
+++ b/bfd/elf64-ia64-vms.c
@@ -584,9 +584,9 @@ elf64_ia64_relax_section (bfd *abfd, asection *sec,
 	    {
 	      _bfd_error_handler
 		/* xgettext:c-format */
-		(_("%B: Can't relax br at 0x%lx in section `%A'."
+		(_("%B: Can't relax br at %#Lx in section `%A'."
 		   " Please use brl or indirect branch."),
-		 sec->owner, (unsigned long) roff, sec);
+		 sec->owner, roff, sec);
 	      bfd_set_error (bfd_error_bad_value);
 	      goto error_return;
 	    }
@@ -3279,8 +3279,8 @@ elf64_ia64_choose_gp (bfd *abfd, struct bfd_link_info *info, bfd_boolean final)
 overflow:
 	  _bfd_error_handler
 	    /* xgettext:c-format */
-	    (_("%B: short data segment overflowed (0x%lx >= 0x400000)"),
-	     abfd, (unsigned long) (max_short_vma - min_short_vma));
+	    (_("%B: short data segment overflowed (%#Lx >= 0x400000)"),
+	     abfd, max_short_vma - min_short_vma);
 	  return FALSE;
 	}
       else if ((gp_val > min_short_vma
@@ -3948,7 +3948,7 @@ elf64_ia64_relocate_section (bfd *output_bfd,
 		_bfd_error_handler
 		  /* xgettext:c-format */
 		  (_("%B: missing TLS section for relocation %s against `%s'"
-		     " at 0x%lx in section `%A'."),
+		     " at %#Lx in section `%A'."),
 		   input_bfd, howto->name, name,
 		   rel->r_offset, input_section);
 		break;
@@ -3964,8 +3964,8 @@ elf64_ia64_relocate_section (bfd *output_bfd,
 		       that the section is too big to relax.  */
 		    _bfd_error_handler
 		      /* xgettext:c-format */
-		      (_("%B: Can't relax br (%s) to `%s' at 0x%lx in section"
-			 " `%A' with size 0x%lx (> 0x1000000)."),
+		      (_("%B: Can't relax br (%s) to `%s' at %#Lx in section"
+			 " `%A' with size %#Lx (> 0x1000000)."),
 		       input_bfd, howto->name, name, rel->r_offset,
 		       input_section, input_section->size);
 		    break;
@@ -5159,9 +5159,8 @@ error_free_dyn:
 		_bfd_error_handler
 		  /* xgettext:c-format */
 		  (_("Warning: size of symbol `%s' changed"
-		     " from %lu in %B to %lu in %B"),
-		   name, (unsigned long) h->size, old_bfd,
-		   (unsigned long) isym->st_size, abfd);
+		     " from %Lu in %B to %Lu in %B"),
+		   name, h->size, old_bfd, isym->st_size, abfd);
 
 	      h->size = isym->st_size;
 	    }
diff --git a/bfd/elf64-mmix.c b/bfd/elf64-mmix.c
index b4ff5a3..8c8e06d 100644
--- a/bfd/elf64-mmix.c
+++ b/bfd/elf64-mmix.c
@@ -1193,12 +1193,10 @@ mmix_elf_perform_relocation (asection *isec, reloc_howto_type *howto,
 	    _bfd_error_handler
 	      /* xgettext:c-format */
 	      (_("%B: Internal inconsistency error for value for\n\
- linker-allocated global register: linked: 0x%lx%08lx != relaxed: 0x%lx%08lx\n"),
+ linker-allocated global register: linked: %#Lx != relaxed: %#Lx"),
 	       isec->owner,
-	       (unsigned long) (value >> 32), (unsigned long) value,
-	       (unsigned long) (gregdata->reloc_request[bpo_index].value
-				>> 32),
-	       (unsigned long) gregdata->reloc_request[bpo_index].value);
+	       value,
+	       gregdata->reloc_request[bpo_index].value);
 	    bfd_set_error (bfd_error_bad_value);
 	    return bfd_reloc_overflow;
 	  }
@@ -1740,9 +1738,9 @@ mmix_final_link_relocate (reloc_howto_type *howto, asection *input_section,
 	    /* FIXME: Better error message.  */
 	    _bfd_error_handler
 	      /* xgettext:c-format */
-	      (_("%B: LOCAL directive: Register $%ld is not a local register."
-		 "  First global register is $%ld."),
-	       input_section->owner, (long) srel, (long) first_global);
+	      (_("%B: LOCAL directive: Register $%Ld is not a local register."
+		 "  First global register is $%Ld."),
+	       input_section->owner, srel, first_global);
 
 	    return bfd_reloc_overflow;
 	  }
@@ -2444,10 +2442,10 @@ _bfd_mmix_after_linker_allocation (bfd *abfd ATTRIBUTE_UNUSED,
     {
       _bfd_error_handler
 	/* xgettext:c-format */
-	(_("Internal inconsistency: remaining %u != max %u.\n\
+	(_("Internal inconsistency: remaining %lu != max %lu.\n\
   Please report this bug."),
-	 gregdata->n_remaining_bpo_relocs_this_relaxation_round,
-	 gregdata->n_bpo_relocs);
+	 (unsigned long) gregdata->n_remaining_bpo_relocs_this_relaxation_round,
+	 (unsigned long) gregdata->n_bpo_relocs);
       return FALSE;
     }
 
diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c
index f85f8cd..62e3cca 100644
--- a/bfd/elf64-s390.c
+++ b/bfd/elf64-s390.c
@@ -863,7 +863,7 @@ elf_s390_check_relocs (bfd *abfd,
   for (rel = relocs; rel < rel_end; rel++)
     {
       unsigned int r_type;
-      unsigned long r_symndx;
+      unsigned int r_symndx;
       struct elf_link_hash_entry *h;
       Elf_Internal_Sym *isym;
 
@@ -2254,10 +2254,10 @@ invalid_tls_insn (bfd *input_bfd,
   howto = elf_howto_table + ELF64_R_TYPE (rel->r_info);
   _bfd_error_handler
     /* xgettext:c-format */
-    (_("%B(%A+0x%lx): invalid instruction for TLS relocation %s"),
+    (_("%B(%A+%#Lx): invalid instruction for TLS relocation %s"),
      input_bfd,
      input_section,
-     (long) rel->r_offset,
+     rel->r_offset,
      howto->name);
   bfd_set_error (bfd_error_bad_value);
 }
@@ -3293,10 +3293,10 @@ elf_s390_relocate_section (bfd *output_bfd,
 				      rel->r_offset) != (bfd_vma) -1)
 	_bfd_error_handler
 	  /* xgettext:c-format */
-	  (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
+	  (_("%B(%A+%#Lx): unresolvable %s relocation against symbol `%s'"),
 	   input_bfd,
 	   input_section,
-	   (long) rel->r_offset,
+	   rel->r_offset,
 	   howto->name,
 	   h->root.root.string);
 
@@ -3350,9 +3350,9 @@ elf_s390_relocate_section (bfd *output_bfd,
 	    {
 	      _bfd_error_handler
 		/* xgettext:c-format */
-		(_("%B(%A+0x%lx): reloc against `%s': error %d"),
+		(_("%B(%A+%#Lx): reloc against `%s': error %d"),
 		 input_bfd, input_section,
-		 (long) rel->r_offset, name, (int) r);
+		 rel->r_offset, name, (int) r);
 	      return FALSE;
 	    }
 	}
diff --git a/bfd/elf64-sh64.c b/bfd/elf64-sh64.c
index bc8e9e1..1cffb2e 100644
--- a/bfd/elf64-sh64.c
+++ b/bfd/elf64-sh64.c
@@ -1536,9 +1536,9 @@ sh_elf64_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
 		{
 		  _bfd_error_handler
 		    /* xgettext:c-format */
-		    (_("%B(%A+0x%lx): %s relocation against SEC_MERGE section"),
+		    (_("%B(%A+%#Lx): %s relocation against SEC_MERGE section"),
 		     input_bfd, input_section,
-		     (long) rel->r_offset, howto->name);
+		     rel->r_offset, howto->name);
 		  return FALSE;
 		}
 
@@ -1633,10 +1633,10 @@ sh_elf64_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
 		{
 		  _bfd_error_handler
 		    /* xgettext:c-format */
-		    (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
+		    (_("%B(%A+%#Lx): unresolvable %s relocation against symbol `%s'"),
 		     input_bfd,
 		     input_section,
-		     (long) rel->r_offset,
+		     rel->r_offset,
 		     howto->name,
 		     h->root.root.string);
 		}
@@ -1677,9 +1677,9 @@ sh_elf64_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
 	{
 	  _bfd_error_handler
 	    /* xgettext:c-format */
-	    (_("%B: error: unaligned relocation type %d at %08x reloc %08x\n"),
-	     input_bfd, (int) r_type, (unsigned) rel->r_offset,
-	     (unsigned) relocation);
+	    (_("%B: error: unaligned relocation type %d at %08Lx reloc %08Lx"),
+	     input_bfd, (int) r_type, rel->r_offset,
+	     relocation);
 	  bfd_set_error (bfd_error_bad_value);
 	  return FALSE;
 	}
diff --git a/bfd/elf64-sparc.c b/bfd/elf64-sparc.c
index 3e0772d..a7ad2bc 100644
--- a/bfd/elf64-sparc.c
+++ b/bfd/elf64-sparc.c
@@ -724,8 +724,8 @@ elf64_sparc_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
           error = TRUE;
 	  _bfd_error_handler
 	    /* xgettext:c-format */
-            (_("%B: uses different e_flags (0x%lx) fields than previous modules (0x%lx)"),
-             ibfd, (long) new_flags, (long) old_flags);
+            (_("%B: uses different e_flags (%#x) fields than previous modules (%#x)"),
+             ibfd, new_flags, old_flags);
         }
 
       elf_elfheader (obfd)->e_flags = old_flags;
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index 8cef9f5..f93cfd2 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -1885,10 +1885,9 @@ elf_x86_64_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 0x%lx "
+	(_("%B: TLS transition from %s to %s against `%s' at %#Lx "
 	   "in section `%A' failed"),
-	 abfd, from->name, to->name, name,
-	 (unsigned long) rel->r_offset, sec);
+	 abfd, from->name, to->name, name, rel->r_offset, sec);
       bfd_set_error (bfd_error_bad_value);
       return FALSE;
     }
@@ -2428,7 +2427,7 @@ elf_x86_64_check_relocs (bfd *abfd, struct bfd_link_info *info,
   for (rel = relocs; rel < rel_end; rel++)
     {
       unsigned int r_type;
-      unsigned long r_symndx;
+      unsigned int r_symndx;
       struct elf_link_hash_entry *h;
       struct elf_x86_64_link_hash_entry *eh;
       Elf_Internal_Sym *isym;
@@ -4574,7 +4573,7 @@ do_ifunc_pointer:
 		  _bfd_error_handler
 		    /* xgettext:c-format */
 		    (_("%B: relocation %s against STT_GNU_IFUNC "
-		       "symbol `%s' has non-zero addend: %d"),
+		       "symbol `%s' has non-zero addend: %Ld"),
 		     input_bfd, howto->name, name, rel->r_addend);
 		  bfd_set_error (bfd_error_bad_value);
 		  return FALSE;
@@ -5116,22 +5115,13 @@ direct:
 			  else
 			    name = bfd_elf_sym_name (input_bfd, symtab_hdr,
 						     sym, NULL);
-			  if (addend < 0)
-			    _bfd_error_handler
-			      /* xgettext:c-format */
-			      (_("%B: addend -0x%x in relocation %s against "
-				 "symbol `%s' at 0x%lx in section `%A' is "
-				 "out of range"),
-			       input_bfd, addend, howto->name, name,
-			       (unsigned long) rel->r_offset, input_section);
-			  else
-			    _bfd_error_handler
-			      /* xgettext:c-format */
-			      (_("%B: addend 0x%x in relocation %s against "
-				 "symbol `%s' at 0x%lx in section `%A' is "
-				 "out of range"),
-			       input_bfd, addend, howto->name, name,
-			       (unsigned long) rel->r_offset, input_section);
+			  _bfd_error_handler
+			    /* xgettext:c-format */
+			    (_("%B: addend %s%#x in relocation %s against "
+			       "symbol `%s' at %#Lx in section `%A' is "
+			       "out of range"),
+			     input_bfd, addend < 0 ? "-" : "", addend,
+			     howto->name, name, rel->r_offset, input_section);
 			  bfd_set_error (bfd_error_bad_value);
 			  return FALSE;
 			}
@@ -5750,10 +5740,10 @@ direct:
 	{
 	  _bfd_error_handler
 	    /* xgettext:c-format */
-	    (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
+	    (_("%B(%A+%#Lx): unresolvable %s relocation against symbol `%s'"),
 	     input_bfd,
 	     input_section,
-	     (long) rel->r_offset,
+	     rel->r_offset,
 	     howto->name,
 	     h->root.root.string);
 	  return FALSE;
@@ -5790,9 +5780,9 @@ check_relocation_error:
 	    {
 	      _bfd_error_handler
 		/* xgettext:c-format */
-		(_("%B(%A+0x%lx): reloc against `%s': error %d"),
+		(_("%B(%A+%#Lx): reloc against `%s': error %d"),
 		 input_bfd, input_section,
-		 (long) rel->r_offset, name, (int) r);
+		 rel->r_offset, name, (int) r);
 	      return FALSE;
 	    }
 	}
diff --git a/bfd/elfcode.h b/bfd/elfcode.h
index cbc534f..6114b11 100644
--- a/bfd/elfcode.h
+++ b/bfd/elfcode.h
@@ -1190,9 +1190,9 @@ elf_slurp_symbol_table (bfd *abfd, asymbol **symptrs, bfd_boolean dynamic)
 	{
 	  _bfd_error_handler
 	    /* xgettext:c-format */
-	    (_("%B: version count (%ld) does not match symbol count (%ld)"),
+	    (_("%B: version count (%Ld) does not match symbol count (%ld)"),
 	     abfd,
-	     (long) (verhdr->sh_size / sizeof (Elf_External_Versym)),
+	     verhdr->sh_size / sizeof (Elf_External_Versym),
 	     symcount);
 
 	  /* Slurp in the symbols without the version information,
diff --git a/bfd/elfcore.h b/bfd/elfcore.h
index d871bc1..b1b60ec 100644
--- a/bfd/elfcore.h
+++ b/bfd/elfcore.h
@@ -297,9 +297,9 @@ elf_core_file_p (bfd *abfd)
 	  {
 	    _bfd_error_handler
 	      /* xgettext:c-format */
-	      (_("Warning: %B is truncated: expected core file "
-		 "size >= %lu, found: %lu."),
-	       abfd, (unsigned long) high, (unsigned long) statbuf.st_size);
+	      (_("warning: %B is truncated: expected core file "
+		 "size >= %Lu, found: %llu"),
+	       abfd, high, (unsigned long long) statbuf.st_size);
 	  }
       }
   }
diff --git a/bfd/elflink.c b/bfd/elflink.c
index bb1a30a..6010b61 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -2394,9 +2394,9 @@ elf_link_read_relocs_from_section (bfd *abfd,
 	    {
 	      _bfd_error_handler
 		/* xgettext:c-format */
-		(_("%B: bad reloc symbol index (%#lx >= %#lx)"
+		(_("%B: bad reloc symbol index (%#Lx >= %#lx)"
 		   " for offset %#Lx in section `%A'"),
-		 abfd, (unsigned long) r_symndx, (unsigned long) nsyms,
+		 abfd, r_symndx, (unsigned long) nsyms,
 		 irela->r_offset, sec);
 	      bfd_set_error (bfd_error_bad_value);
 	      return FALSE;
@@ -2406,10 +2406,10 @@ elf_link_read_relocs_from_section (bfd *abfd,
 	{
 	  _bfd_error_handler
 	    /* xgettext:c-format */
-	    (_("%B: non-zero symbol index (%#lx)"
+	    (_("%B: non-zero symbol index (%#Lx)"
 	       " for offset %#Lx in section `%A'"
 	       " when the object file has no symbol table"),
-	     abfd, (unsigned long) r_symndx, (unsigned long) nsyms,
+	     abfd, r_symndx,
 	     irela->r_offset, sec);
 	  bfd_set_error (bfd_error_bad_value);
 	  return FALSE;
@@ -8616,8 +8616,7 @@ elf_link_adjust_relocs (bfd *abfd,
 			      abfd, sec,
 			      (*rel_hash)->root.root.string);
 	  _bfd_error_handler (_("%B:%A: error: try relinking with --gc-keep-exported enabled."),
-			      abfd, sec,
-			      (*rel_hash)->root.root.string);
+			      abfd, sec);
 	  bfd_set_error (bfd_error_invalid_operation);
 	  return FALSE;
 	}
diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
index 86bae0e..b28e8d8 100644
--- a/bfd/elfnn-aarch64.c
+++ b/bfd/elfnn-aarch64.c
@@ -5016,7 +5016,7 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto,
 	      _bfd_error_handler
 		/* xgettext:c-format */
 		(_("%B: relocation %s against STT_GNU_IFUNC "
-		   "symbol `%s' has non-zero addend: %d"),
+		   "symbol `%s' has non-zero addend: %Ld"),
 		 input_bfd, howto->name, name, rel->r_addend);
 	      bfd_set_error (bfd_error_bad_value);
 	      return FALSE;
@@ -6162,11 +6162,11 @@ elfNN_aarch64_relocate_section (bfd *output_bfd,
 	  _bfd_error_handler
 	    ((sym_type == STT_TLS
 	      /* xgettext:c-format */
-	      ? _("%B(%A+0x%lx): %s used with TLS symbol %s")
+	      ? _("%B(%A+%#Lx): %s used with TLS symbol %s")
 	      /* xgettext:c-format */
-	      : _("%B(%A+0x%lx): %s used with non-TLS symbol %s")),
+	      : _("%B(%A+%#Lx): %s used with non-TLS symbol %s")),
 	     input_bfd,
-	     input_section, (long) rel->r_offset, howto->name, name);
+	     input_section, rel->r_offset, howto->name, name);
 	}
 
       /* We relax only if we can see that there can be a valid transition
@@ -6434,8 +6434,8 @@ elfNN_aarch64_relocate_section (bfd *output_bfd,
 	{
 	  _bfd_error_handler
 	    /* xgettext:c-format */
-	    (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
-	     input_bfd, input_section, (long) rel->r_offset, howto->name,
+	    (_("%B(%A+%#Lx): unresolvable %s relocation against symbol `%s'"),
+	     input_bfd, input_section, rel->r_offset, howto->name,
 	     h->root.root.string);
 	  return FALSE;
 	}
@@ -7101,7 +7101,7 @@ elfNN_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *info,
   for (rel = relocs; rel < rel_end; rel++)
     {
       struct elf_link_hash_entry *h;
-      unsigned long r_symndx;
+      unsigned int r_symndx;
       unsigned int r_type;
       bfd_reloc_code_real_type bfd_r_type;
       Elf_Internal_Sym *isym;
diff --git a/bfd/elfnn-ia64.c b/bfd/elfnn-ia64.c
index 7f90c93..2e70db6 100644
--- a/bfd/elfnn-ia64.c
+++ b/bfd/elfnn-ia64.c
@@ -617,9 +617,9 @@ elfNN_ia64_relax_section (bfd *abfd, asection *sec,
 	    {
 	      _bfd_error_handler
 		/* xgettext:c-format */
-		(_("%B: Can't relax br at 0x%lx in section `%A'."
+		(_("%B: Can't relax br at %#Lx in section `%A'."
 		   " Please use brl or indirect branch."),
-		 sec->owner, (unsigned long) roff, sec);
+		 sec->owner, roff, sec);
 	      bfd_set_error (bfd_error_bad_value);
 	      goto error_return;
 	    }
@@ -3685,8 +3685,8 @@ elfNN_ia64_choose_gp (bfd *abfd, struct bfd_link_info *info, bfd_boolean final)
 overflow:
 	  _bfd_error_handler
 	    /* xgettext:c-format */
-	    (_("%B: short data segment overflowed (0x%lx >= 0x400000)"),
-	     abfd, (unsigned long) (max_short_vma - min_short_vma));
+	    (_("%B: short data segment overflowed (%#Lx >= 0x400000)"),
+	     abfd, max_short_vma - min_short_vma);
 	  return FALSE;
 	}
       else if ((gp_val > min_short_vma
@@ -4473,7 +4473,7 @@ missing_tls_sec:
 		_bfd_error_handler
 		  /* xgettext:c-format */
 		  (_("%B: missing TLS section for relocation %s against `%s'"
-		     " at 0x%lx in section `%A'."),
+		     " at %#Lx in section `%A'."),
 		   input_bfd, howto->name, name,
 		   rel->r_offset, input_section);
 		break;
@@ -4489,8 +4489,8 @@ missing_tls_sec:
 		       that the section is too big to relax.  */
 		    _bfd_error_handler
 		      /* xgettext:c-format */
-		      (_("%B: Can't relax br (%s) to `%s' at 0x%lx"
-			 " in section `%A' with size 0x%lx (> 0x1000000)."),
+		      (_("%B: Can't relax br (%s) to `%s' at %#Lx"
+			 " in section `%A' with size %#Lx (> 0x1000000)."),
 		       input_bfd, howto->name, name, rel->r_offset,
 		       input_section, input_section->size);
 		    break;
diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
index 6d297ce..973f471 100644
--- a/bfd/elfnn-riscv.c
+++ b/bfd/elfnn-riscv.c
@@ -515,7 +515,7 @@ riscv_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
   for (rel = relocs; rel < relocs + sec->reloc_count; rel++)
     {
       unsigned int r_type;
-      unsigned long r_symndx;
+      unsigned int r_symndx;
       struct elf_link_hash_entry *h;
 
       r_symndx = ELFNN_R_SYM (rel->r_info);
@@ -2233,10 +2233,10 @@ riscv_elf_relocate_section (bfd *output_bfd,
 				      rel->r_offset) != (bfd_vma) -1)
 	{
 	  (*_bfd_error_handler)
-	    (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
+	    (_("%B(%A+%#Lx): unresolvable %s relocation against symbol `%s'"),
 	     input_bfd,
 	     input_section,
-	     (long) rel->r_offset,
+	     rel->r_offset,
 	     howto->name,
 	     h->root.root.string);
 	  continue;
diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
index 2eb3dd3..f270cdb 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -8456,8 +8456,8 @@ _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
 	    {
 	      _bfd_error_handler
 		/* xgettext:c-format */
-		(_("%B: GOT reloc at 0x%lx not expected in executables"),
-		 abfd, (unsigned long) rel->r_offset);
+		(_("%B: GOT reloc at %#Lx not expected in executables"),
+		 abfd, rel->r_offset);
 	      bfd_set_error (bfd_error_bad_value);
 	      return FALSE;
 	    }
@@ -8594,8 +8594,8 @@ _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
 	    {
 	      _bfd_error_handler
 		/* xgettext:c-format */
-		(_("%B: CALL16 reloc at 0x%lx not against global symbol"),
-		 abfd, (unsigned long) rel->r_offset);
+		(_("%B: CALL16 reloc at %#Lx not against global symbol"),
+		 abfd, rel->r_offset);
 	      bfd_set_error (bfd_error_bad_value);
 	      return FALSE;
 	    }
@@ -10137,7 +10137,7 @@ _bfd_mips_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
 		      _bfd_error_handler
 			/* xgettext:c-format */
 			(_("%B: Can't find matching LO16 reloc against `%s'"
-			   " for %s at 0x%lx in section `%A'"),
+			   " for %s at %#Lx in section `%A'"),
 			 input_bfd, name,
 			 howto->name, rel->r_offset, input_section);
 		    }
@@ -10680,11 +10680,11 @@ _bfd_mips_elf_finish_dynamic_symbol (bfd *output_bfd,
 		{
 		  _bfd_error_handler
 		    /* xgettext:c-format */
-		    (_("%B: `%A' offset of %ld from `%A' "
+		    (_("%B: `%A' offset of %Ld from `%A' "
 		       "beyond the range of ADDIUPC"),
 		     output_bfd,
 		     htab->root.sgotplt->output_section,
-		     (long) gotpc_offset,
+		     gotpc_offset,
 		     htab->root.splt->output_section);
 		  bfd_set_error (bfd_error_no_error);
 		  return FALSE;
@@ -11248,10 +11248,10 @@ mips_finish_exec_plt (bfd *output_bfd, struct bfd_link_info *info)
 	{
 	  _bfd_error_handler
 	    /* xgettext:c-format */
-	    (_("%B: `%A' offset of %ld from `%A' beyond the range of ADDIUPC"),
+	    (_("%B: `%A' offset of %Ld from `%A' beyond the range of ADDIUPC"),
 	     output_bfd,
 	     htab->root.sgotplt->output_section,
-	     (long) gotpc_offset,
+	     gotpc_offset,
 	     htab->root.splt->output_section);
 	  bfd_set_error (bfd_error_no_error);
 	  return FALSE;
@@ -15124,10 +15124,9 @@ mips_elf_merge_obj_e_flags (bfd *ibfd, struct bfd_link_info *info)
     {
       /* xgettext:c-format */
       _bfd_error_handler
-	(_("%B: uses different e_flags (0x%lx) fields than previous modules "
-	   "(0x%lx)"),
-	 ibfd, (unsigned long) new_flags,
-	 (unsigned long) old_flags);
+	(_("%B: uses different e_flags (%#x) fields than previous modules "
+	   "(%#x)"),
+	 ibfd, new_flags, old_flags);
       ok = FALSE;
     }
 
@@ -15427,7 +15426,7 @@ _bfd_mips_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
 	_bfd_error_handler
 	  (_("%B: warning: Unexpected flag in the flags2 field of "
 	     ".MIPS.abiflags (0x%lx)"), ibfd,
-	   (unsigned long) in_abiflags.flags2);
+	   in_abiflags.flags2);
     }
   else
     {
diff --git a/bfd/elfxx-sparc.c b/bfd/elfxx-sparc.c
index b50d34b..ef6e50c 100644
--- a/bfd/elfxx-sparc.c
+++ b/bfd/elfxx-sparc.c
@@ -1426,7 +1426,7 @@ _bfd_sparc_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
   for (rel = relocs; rel < rel_end; rel++)
     {
       unsigned int r_type;
-      unsigned long r_symndx;
+      unsigned int r_symndx;
       struct elf_link_hash_entry *h;
       struct _bfd_sparc_elf_link_hash_entry *eh;
       Elf_Internal_Sym *isym;
@@ -4083,10 +4083,10 @@ _bfd_sparc_elf_relocate_section (bfd *output_bfd,
 				      rel->r_offset) != (bfd_vma) -1)
 	_bfd_error_handler
 	  /* xgettext:c-format */
-	  (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
+	  (_("%B(%A+%#Lx): unresolvable %s relocation against symbol `%s'"),
 	   input_bfd,
 	   input_section,
-	   (long) rel->r_offset,
+	   rel->r_offset,
 	   howto->name,
 	   h->root.root.string);
 
diff --git a/bfd/elfxx-tilegx.c b/bfd/elfxx-tilegx.c
index ec88ab3..50543b9 100644
--- a/bfd/elfxx-tilegx.c
+++ b/bfd/elfxx-tilegx.c
@@ -1695,7 +1695,7 @@ tilegx_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
   for (rel = relocs; rel < rel_end; rel++)
     {
       unsigned int r_type;
-      unsigned long r_symndx;
+      unsigned int r_symndx;
       struct elf_link_hash_entry *h;
       int tls_type;
 
@@ -3973,10 +3973,10 @@ tilegx_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+0x%lx): unresolvable %s relocation against symbol `%s'"),
+	  (_("%B(%A+%#Lx): unresolvable %s relocation against symbol `%s'"),
 	   input_bfd,
 	   input_section,
-	   (long) rel->r_offset,
+	   rel->r_offset,
 	   howto->name,
 	   h->root.root.string);
 
diff --git a/bfd/ieee.c b/bfd/ieee.c
index 958a40b..9dce4a8 100644
--- a/bfd/ieee.c
+++ b/bfd/ieee.c
@@ -156,7 +156,7 @@ ieee_write_id (bfd *abfd, const char *id)
     {
       _bfd_error_handler
 	/* xgettext:c-format */
-	(_("%B: string too long (%d chars, max 65535)"), abfd, length);
+	(_("%B: string too long (%ld chars, max 65535)"), abfd, (long) length);
       bfd_set_error (bfd_error_invalid_operation);
       return FALSE;
     }
@@ -224,7 +224,7 @@ read_id (common_header_type *ieee)
   if (ieee->input_p + length >= ieee->end_p)
     {
       _bfd_error_handler (_("IEEE parser: string length: %#lx longer than buffer: %#lx"),
-			  length, (long) (ieee->end_p - ieee->input_p));
+			  (long) length, (long) (ieee->end_p - ieee->input_p));
       bfd_set_error (bfd_error_invalid_operation);
       return NULL;
     }
@@ -859,8 +859,8 @@ ieee_slurp_external_symbols (bfd *abfd)
 		  {
 		    _bfd_error_handler
 		      /* xgettext:c-format */
-		      (_("%B: unexpected ATN type %d in external part"),
-			 abfd, (int) value);
+		      (_("%B: unexpected ATN type %Ld in external part"),
+			 abfd, value);
 		    bfd_set_error (bfd_error_bad_value);
 		    return FALSE;
 		  }
diff --git a/bfd/ihex.c b/bfd/ihex.c
index a0c704a..5ec8ce7 100644
--- a/bfd/ihex.c
+++ b/bfd/ihex.c
@@ -825,13 +825,10 @@ ihex_write_object_contents (bfd *abfd)
 		  extbase = where & 0xffff0000;
 		  if (where > extbase + 0xffff)
 		    {
-		      char buf[20];
-
-		      sprintf_vma (buf, where);
 		      _bfd_error_handler
 			/* xgettext:c-format */
-			(_("%B: address 0x%s out of range for Intel Hex file"),
-			 abfd, buf);
+			(_("%B: address %#Lx out of range for Intel Hex file"),
+			 abfd, where);
 		      bfd_set_error (bfd_error_bad_value);
 		      return FALSE;
 		    }
diff --git a/bfd/mach-o.c b/bfd/mach-o.c
index 2c1973c..be2fb17 100644
--- a/bfd/mach-o.c
+++ b/bfd/mach-o.c
@@ -2528,8 +2528,8 @@ bfd_mach_o_write_contents (bfd *abfd)
 	break;
       default:
 	_bfd_error_handler
-	  (_("unable to allocate data for load command 0x%lx"),
-	   (unsigned long) cmd->type);
+	  (_("unable to allocate data for load command %#x"),
+	   cmd->type);
 	break;
       }
 
@@ -2633,8 +2633,8 @@ bfd_mach_o_write_contents (bfd *abfd)
 	  break;
 	default:
 	  _bfd_error_handler
-	    (_("unable to write unknown load command 0x%lx"),
-	     (unsigned long) cmd->type);
+	    (_("unable to write unknown load command %#x"),
+	     cmd->type);
 	  return FALSE;
 	}
     }
@@ -2817,8 +2817,8 @@ bfd_mach_o_build_exec_seg_command (bfd *abfd, bfd_mach_o_segment_command *seg)
 	{
 	  _bfd_error_handler
 	    /* xgettext:c-format */
-	    (_("section address (%lx) below start of segment (%lx)"),
-	       (unsigned long) s->addr, (unsigned long) vma);
+	    (_("section address (%#Lx) below start of segment (%#Lx)"),
+	       s->addr, vma);
 	  return FALSE;
 	}
 
@@ -2958,8 +2958,8 @@ bfd_mach_o_layout_commands (bfd_mach_o_data_struct *mdata)
 	  break;
 	default:
 	  _bfd_error_handler
-	    (_("unable to layout unknown load command 0x%lx"),
-	     (unsigned long) cmd->type);
+	    (_("unable to layout unknown load command %#x"),
+	     cmd->type);
 	  ret = FALSE;
 	  break;
 	}
@@ -3494,7 +3494,7 @@ bfd_mach_o_read_section_32 (bfd *abfd, unsigned long prot)
   if (section->align > 64)
     {
       _bfd_error_handler
-	(_("bfd_mach_o_read_section_32: overlarge alignment value: 0x%x, "
+	(_("bfd_mach_o_read_section_32: overlarge alignment value: %#lx, "
 	   "using 32 instead"), section->align);
       section->align = 32;
     }
@@ -3537,7 +3537,7 @@ bfd_mach_o_read_section_64 (bfd *abfd, unsigned long prot)
   if (section->align > 64)
     {
       _bfd_error_handler
-	(_("bfd_mach_o_read_section_64: overlarge alignment value: 0x%x, "
+	(_("bfd_mach_o_read_section_64: overlarge alignment value: %#lx, "
 	   "using 32 instead"), section->align);
       section->align = 32;
     }
@@ -3588,8 +3588,8 @@ bfd_mach_o_read_symtab_symbol (bfd *abfd,
     {
       _bfd_error_handler
 	/* xgettext:c-format */
-        (_("bfd_mach_o_read_symtab_symbol: unable to read %d bytes at %lu"),
-         symwidth, (unsigned long) symoff);
+        (_("bfd_mach_o_read_symtab_symbol: unable to read %d bytes at %u"),
+         symwidth, symoff);
       return FALSE;
     }
 
@@ -3607,9 +3607,9 @@ bfd_mach_o_read_symtab_symbol (bfd *abfd,
     {
       _bfd_error_handler
 	/* xgettext:c-format */
-        (_("bfd_mach_o_read_symtab_symbol: name out of range (%lu >= %lu)"),
-         (unsigned long) stroff,
-         (unsigned long) sym->strsize);
+        (_("bfd_mach_o_read_symtab_symbol: name out of range (%lu >= %u)"),
+         stroff,
+         sym->strsize);
       return FALSE;
     }
 
@@ -4756,8 +4756,8 @@ bfd_mach_o_read_command (bfd *abfd, bfd_mach_o_load_command *command)
       break;
     default:
       command->len = 0;
-      _bfd_error_handler (_("%B: unknown load command 0x%lx"),
-			  abfd, (unsigned long) command->type);
+      _bfd_error_handler (_("%B: unknown load command %#x"),
+			  abfd, command->type);
       return FALSE;
     }
 
@@ -5052,8 +5052,8 @@ bfd_mach_o_header_p (bfd *abfd,
   if (! (header.byteorder == BFD_ENDIAN_BIG
 	 || header.byteorder == BFD_ENDIAN_LITTLE))
     {
-      _bfd_error_handler (_("unknown header byte-order value 0x%lx"),
-			  (unsigned long) header.byteorder);
+      _bfd_error_handler (_("unknown header byte-order value %#x"),
+			  header.byteorder);
       goto wrong;
     }
 
diff --git a/bfd/merge.c b/bfd/merge.c
index 553de8e..a1792a8 100644
--- a/bfd/merge.c
+++ b/bfd/merge.c
@@ -861,8 +861,8 @@ _bfd_merged_section_offset (bfd *output_bfd ATTRIBUTE_UNUSED, asection **psec,
       if (offset > sec->rawsize)
 	_bfd_error_handler
 	  /* xgettext:c-format */
-	  (_("%B: access beyond end of merged section (%ld)"),
-	   sec->owner, (long) offset);
+	  (_("%B: access beyond end of merged section (%Ld)"),
+	   sec->owner, offset);
       return secinfo->first_str ? sec->size : 0;
     }
 
diff --git a/bfd/mmo.c b/bfd/mmo.c
index 99a591b..03995e8 100644
--- a/bfd/mmo.c
+++ b/bfd/mmo.c
@@ -956,8 +956,8 @@ mmo_write_loc_chunk (bfd *abfd, bfd_vma vma, const bfd_byte *loc,
 	  _bfd_error_handler
 	    /* xgettext:c-format */
 	    (_("%B: attempt to emit contents at non-multiple-of-4"
-	       " address 0x%lx\n"),
-	     abfd, (unsigned long) vma);
+	       " address %#Lx"),
+	     abfd, vma);
 	  bfd_set_error (bfd_error_bad_value);
 	  return FALSE;
 	}
@@ -1602,7 +1602,7 @@ mmo_scan (bfd *abfd)
   bfd_size_type nbytes_read = 0;
   /* Buffer with room to read a 64-bit value.  */
   bfd_byte buf[8];
-  long stab_loc = -1;
+  file_ptr stab_loc = -1;
   char *file_names[256];
 
   abfd->symcount = 0;
@@ -2033,7 +2033,7 @@ mmo_scan (bfd *abfd)
 			 " not equal to the number of tetras to the preceding"
 			 " lop_stab (%ld)\n"),
 		       abfd, (long) (y * 256 + z),
-		       (curpos - stab_loc - 4)/4);
+		       (long) (curpos - stab_loc - 4)/4);
 		    bfd_set_error (bfd_error_bad_value);
 		    goto error_return;
 		  }
@@ -3239,15 +3239,14 @@ mmo_write_object_contents (bfd *abfd)
 	       global registers.  */
 	    _bfd_error_handler
 	      /* xgettext:c-format */
-	      (_("%B: too many initialized registers; section length %ld\n"),
-	       abfd, (long) sec->size);
+	      (_("%B: too many initialized registers; section length %Ld"),
+	       abfd, sec->size);
 	  else
 	    _bfd_error_handler
 	      /* xgettext:c-format */
 	      (_("%B: invalid start address for initialized registers of"
-		 " length %ld: 0x%lx%08lx\n"),
-	       abfd, (long) sec->size,
-	       (unsigned long) (sec->vma >> 32), (unsigned long) (sec->vma));
+		 " length %Ld: %#Lx"),
+	       abfd, sec->size, sec->vma);
 
 	  return FALSE;
 	}
diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c
index a18e0b2..d24c5f8 100644
--- a/bfd/peXXigen.c
+++ b/bfd/peXXigen.c
@@ -529,7 +529,7 @@ _bfd_XXi_swap_aouthdr_in (bfd * abfd,
       {
 	/* xgettext:c-format */
 	_bfd_error_handler
-	  (_("%B: aout header specifies an invalid number of data-directory entries: %d"),
+	  (_("%B: aout header specifies an invalid number of data-directory entries: %ld"),
 	   abfd, a->NumberOfRvaAndSizes);
 	bfd_set_error (bfd_error_bad_value);
 
@@ -2985,7 +2985,7 @@ _bfd_XX_bfd_copy_private_bfd_data_common (bfd * ibfd, bfd * obfd)
 	      > bfd_get_section_size (section))
 	    {
 	      /* xgettext:c-format */
-	      _bfd_error_handler (_("%B: Data Directory size (%lx) exceeds space left in section (%lx)"),
+	      _bfd_error_handler (_("%B: Data Directory size (%lx) exceeds space left in section (%Lx)"),
 				  obfd, ope->pe_opthdr.DataDirectory[PE_DEBUG_DATA].Size,
 				  bfd_get_section_size (section) - (addr - section->vma));
 	      return FALSE;
diff --git a/bfd/stabs.c b/bfd/stabs.c
index 3139bf5..5a3686f 100644
--- a/bfd/stabs.c
+++ b/bfd/stabs.c
@@ -276,7 +276,7 @@ _bfd_link_section_stabs (bfd *abfd,
 	{
 	  _bfd_error_handler
 	    /* xgettext:c-format */
-	    (_("%B(%A+0x%lx): Stabs entry has invalid string index."),
+	    (_("%B(%A+%#lx): Stabs entry has invalid string index."),
 	     abfd, stabsec, (long) (sym - stabbuf));
 	  bfd_set_error (bfd_error_bad_value);
 	  goto error_return;
diff --git a/bfd/xcofflink.c b/bfd/xcofflink.c
index 8121c7e..d80e98d 100644
--- a/bfd/xcofflink.c
+++ b/bfd/xcofflink.c
@@ -1499,7 +1499,7 @@ xcoff_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
 	    {
 	      _bfd_error_handler
 		/* xgettext:c-format */
-		(_("%B: bad XTY_ER symbol `%s': class %d scnum %d scnlen %d"),
+		(_("%B: bad XTY_ER symbol `%s': class %d scnum %d scnlen %Ld"),
 		 abfd, name, sym.n_sclass, sym.n_scnum,
 		 aux.x_csect.x_scnlen.l);
 	      bfd_set_error (bfd_error_bad_value);
@@ -1529,7 +1529,7 @@ xcoff_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
 		{
 		  _bfd_error_handler
 		    /* xgettext:c-format */
-		    (_("%B: XMC_TC0 symbol `%s' is class %d scnlen %d"),
+		    (_("%B: XMC_TC0 symbol `%s' is class %d scnlen %Ld"),
 		     abfd, name, sym.n_sclass, aux.x_csect.x_scnlen.l);
 		  bfd_set_error (bfd_error_bad_value);
 		  goto error_return;
@@ -2105,7 +2105,7 @@ xcoff_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
 		{
 		  _bfd_error_handler
 		    /* xgettext:c-format */
-		    (_("%B: reloc %s:%d not in csect"),
+		    (_("%B: reloc %s:%Ld not in csect"),
 		     abfd, o->name, i);
 		  bfd_set_error (bfd_error_bad_value);
 		  goto error_return;
@@ -5112,9 +5112,9 @@ xcoff_find_tc0 (bfd *output_bfd, struct xcoff_final_link_info *flinfo)
       if (best_address > toc_start + 0x8000)
 	{
 	  _bfd_error_handler
-	    (_("TOC overflow: 0x%lx > 0x10000; try -mminimal-toc "
+	    (_("TOC overflow: %#Lx > 0x10000; try -mminimal-toc "
 	       "when compiling"),
-	     (unsigned long) (toc_end - toc_start));
+	     toc_end - toc_start);
 	  bfd_set_error (bfd_error_file_too_big);
 	  return FALSE;
 	}
diff --git a/ld/testsuite/ld-arc/nps-1b.err b/ld/testsuite/ld-arc/nps-1b.err
index a7d2996..4b13145 100644
--- a/ld/testsuite/ld-arc/nps-1b.err
+++ b/ld/testsuite/ld-arc/nps-1b.err
@@ -1,2 +1,2 @@
-.*\.o\(\.text\+0x0\): CMEM relocation to `foo' is invalid, 16 MSB should be 0x57f0 \(value is 0x56f03000\)
+.*\.o\(\.text\+0\): CMEM relocation to `foo' is invalid, 16 MSB should be 0x57f0 \(value is 0x56f03000\)
 #...
diff --git a/ld/testsuite/ld-x86-64/ilp32-11.d b/ld/testsuite/ld-x86-64/ilp32-11.d
index f6fc86c..bc6c8a8 100644
--- a/ld/testsuite/ld-x86-64/ilp32-11.d
+++ b/ld/testsuite/ld-x86-64/ilp32-11.d
@@ -1,3 +1,3 @@
 #as: --x32
 #ld: -shared -melf32_x86_64
-#error: .*addend 0x7fffffff in relocation R_X86_64_64 against symbol `func' at 0x0 in section `.data.rel.local' is out of range
+#error: .*addend 0x7fffffff in relocation R_X86_64_64 against symbol `func' at 0 in section `.data.rel.local' is out of range

-- 
Alan Modra
Australia Development Lab, IBM


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]