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]

[PATCH 2/3] PowerPC/BFD: Convert `%P: %H:' to `%H:' in error messages


Remove an inconsistency in BFD linker error messages across the PowerPC 
backends, where in the presence of line information the `%P: %H:' format 
sequence makes the first error message produced for any given function 
different from subsequent ones.

Taking the `ld/testsuite/ld-powerpc/tocopt7.s' test case source as an 
example and the `powerpc-linux' target we have:

$ as -gdwarf2 -o tocopt.o -a64 tocopt.s
$ ld -o tocopt -melf64ppc tocopt.o
ld: tocopt.o: In function `_start':
tocopt.s:35:(.text+0x14): toc optimization is not supported for 0x3fa00000 instruction.
ld: tocopt.s:49:(.text+0x34): toc optimization is not supported for 0x3fa00000 instruction.
$ 

where the first error message does not have the source file name 
prefixed with the linker program executable's name, i.e. `ld:', whereas 
the second error message does, as would any subsequent.

This is because with a multiple-line error message such as `%H' produces 
`%P' only prints the program executable's name on the first line and not 
any later ones.  Also the PowerPC backend is the only part of BFD which 
uses `%P' along with one of the clever `%C', `%D', `%G', `%H' format 
specifiers.  And last but not least this breaks a GNU Coding Standard's 
requirement that error messages from compilers should look like this:

source-file-name:lineno: message

also quoted in `vfinfo' code handling these specifiers.

Convert `%P: %H:' to `%H:' in error messages across the PowerPC backends 
then, yielding:

$ as -gdwarf2 -o tocopt.o -a64 tocopt.s
$ ld -o tocopt -melf64ppc tocopt.o
tocopt.o: In function `_start':
tocopt.s:35:(.text+0x14): toc optimization is not supported for 0x3fa00000 instruction.
tocopt.s:49:(.text+0x34): toc optimization is not supported for 0x3fa00000 instruction.
$ 

instead, making it consistent and matching the GNU Coding Standard's 
requirement.

	bfd/
	* elf32-ppc.c (ppc_elf_check_relocs): Use `%H:' rather than 
	`%P: %H:' with `info->callbacks->einfo'.
	(ppc_elf_relocate_section): Likewise.
	* elf64-ppc.c (ppc64_elf_check_relocs): Likewise.
	(ppc64_elf_edit_toc): Likewise.
	(ppc64_elf_relocate_section): Likewise.
---
 I hope the explanation is clear and the justification reasonable.

 OK to apply?

  Maciej

binutils-ld-vfinfo-file-null-ppc.diff
Index: binutils/bfd/elf32-ppc.c
===================================================================
--- binutils.orig/bfd/elf32-ppc.c	2017-02-02 15:28:26.443668675 +0000
+++ binutils/bfd/elf32-ppc.c	2017-02-02 15:29:54.291787959 +0000
@@ -4298,7 +4298,7 @@ ppc_elf_check_relocs (bfd *abfd,
 		     table entry for a non-ifunc local symbol.  */
 		  info->callbacks->einfo
 		    /* xgettext:c-format */
-		    (_("%P: %H: %s reloc against local symbol\n"),
+		    (_("%H: %s reloc against local symbol\n"),
 		     abfd, sec, rel->r_offset,
 		     ppc_elf_howto_table[r_type]->name);
 		  bfd_set_error (bfd_error_bad_value);
@@ -8221,7 +8221,7 @@ ppc_elf_relocate_section (bfd *output_bf
 		  off = (p - contents) - (rel->r_offset - d_offset);
 		  if (off > 0x1fffffc || (off & 3) != 0)
 		    info->callbacks->einfo
-		      (_("%P: %H: fixup branch overflow\n"),
+		      (_("%H: fixup branch overflow\n"),
 		       input_bfd, input_section, rel->r_offset);
 
 		  bfd_put_32 (input_bfd, B | off,
@@ -8261,7 +8261,7 @@ ppc_elf_relocate_section (bfd *output_bf
 	      else
 		info->callbacks->einfo
 		  /* xgettext:c-format */
-		  (_("%P: %H: error: %s with unexpected instruction %x\n"),
+		  (_("%H: error: %s with unexpected instruction %x\n"),
 		   input_bfd, input_section, rel->r_offset,
 		   "R_PPC_ADDR16_HA", insn);
 	    }
@@ -8296,7 +8296,7 @@ ppc_elf_relocate_section (bfd *output_bf
 	      else
 		info->callbacks->einfo
 		  /* xgettext:c-format */
-		  (_("%P: %H: error: %s with unexpected instruction %x\n"),
+		  (_("%H: error: %s with unexpected instruction %x\n"),
 		   input_bfd, input_section, rel->r_offset,
 		   "R_PPC_ADDR16_LO", insn);
 	    }
@@ -8352,7 +8352,7 @@ ppc_elf_relocate_section (bfd *output_bf
 		     into .got2).  */
 		    info->callbacks->einfo
 		      /* xgettext:c-format */
-		      (_("%X%P: %H: unsupported bss-plt -fPIC ifunc %s\n"),
+		      (_("%X%H: unsupported bss-plt -fPIC ifunc %s\n"),
 		       input_bfd, input_section, rel->r_offset, sym_name);
 		}
 	      if (h == NULL && (ent->plt.offset & 1) == 0)
@@ -8690,7 +8690,7 @@ ppc_elf_relocate_section (bfd *output_bf
 	    if (addend != 0)
 	      info->callbacks->einfo
 		/* xgettext:c-format */
-		(_("%P: %H: non-zero addend on %s reloc against `%s'\n"),
+		(_("%H: non-zero addend on %s reloc against `%s'\n"),
 		 input_bfd, input_section, rel->r_offset,
 		 howto->name,
 		 sym_name);
@@ -8722,7 +8722,7 @@ ppc_elf_relocate_section (bfd *output_bf
 		 -fPIC code, so the linker won't know whether r30 is
 		 _GLOBAL_OFFSET_TABLE_ or pointing into a .got2 section.  */
 	      /* xgettext:c-format */
-	      info->callbacks->einfo (_("%X%P: %H: @local call to ifunc %s\n"),
+	      info->callbacks->einfo (_("%X%H: @local call to ifunc %s\n"),
 				      input_bfd, input_section, rel->r_offset,
 				      h->root.root.string);
 	    }
@@ -8912,7 +8912,7 @@ ppc_elf_relocate_section (bfd *output_bf
 			     indirection function to resolve the reloc.  */
 			  info->callbacks->einfo
 			    /* xgettext:c-format */
-			    (_("%P: %H: relocation %s for indirect "
+			    (_("%H: relocation %s for indirect "
 			       "function %s unsupported\n"),
 			     input_bfd, input_section, rel->r_offset,
 			     howto->name,
@@ -9609,7 +9609,7 @@ ppc_elf_relocate_section (bfd *output_bf
 		relocation ^= lobit;
 		info->callbacks->einfo
 		  /* xgettext:c-format */
-		  (_("%P: %H: error: %s against `%s' not a multiple of %u\n"),
+		  (_("%H: error: %s against `%s' not a multiple of %u\n"),
 		   input_bfd, input_section, rel->r_offset,
 		   howto->name, sym_name, mask + 1);
 		bfd_set_error (bfd_error_bad_value);
@@ -9638,7 +9638,7 @@ ppc_elf_relocate_section (bfd *output_bf
 	{
 	  info->callbacks->einfo
 	    /* xgettext:c-format */
-	    (_("%P: %H: unresolvable %s relocation against symbol `%s'\n"),
+	    (_("%H: unresolvable %s relocation against symbol `%s'\n"),
 	     input_bfd, input_section, rel->r_offset,
 	     howto->name,
 	     sym_name);
@@ -9719,7 +9719,7 @@ ppc_elf_relocate_section (bfd *output_bf
 	    {
 	      info->callbacks->einfo
 		/* xgettext:c-format */
-		(_("%P: %H: %s reloc against `%s': error %d\n"),
+		(_("%H: %s reloc against `%s': error %d\n"),
 		 input_bfd, input_section, rel->r_offset,
 		 howto->name, sym_name, (int) r);
 	      ret = FALSE;
Index: binutils/bfd/elf64-ppc.c
===================================================================
--- binutils.orig/bfd/elf64-ppc.c	2017-02-02 15:28:26.667181466 +0000
+++ binutils/bfd/elf64-ppc.c	2017-02-02 15:29:54.382044729 +0000
@@ -5554,7 +5554,7 @@ ppc64_elf_check_relocs (bfd *abfd, struc
 		 table entry for a non-ifunc local symbol.  */
 	      info->callbacks->einfo
 		/* xgettext:c-format */
-		(_("%P: %H: %s reloc against local symbol\n"),
+		(_("%H: %s reloc against local symbol\n"),
 		 abfd, sec, rel->r_offset,
 		 ppc64_elf_howto_table[r_type]->name);
 	      bfd_set_error (bfd_error_bad_value);
@@ -5602,7 +5602,7 @@ ppc64_elf_check_relocs (bfd *abfd, struc
 	      if (!ppc64_elf_howto_table[R_PPC64_ADDR32])
 		ppc_howto_init ();
 	      /* xgettext:c-format */
-	      info->callbacks->einfo (_("%P: %H: %s reloc unsupported "
+	      info->callbacks->einfo (_("%H: %s reloc unsupported "
 					"in shared libraries and PIEs.\n"),
 				      abfd, sec, rel->r_offset,
 				      ppc64_elf_howto_table[r_type]->name);
@@ -9233,7 +9233,7 @@ ppc64_elf_edit_toc (struct bfd_link_info
 			  sprintf (str, "%#08x", insn);
 			  info->callbacks->einfo
 			    /* xgettext:c-format */
-			    (_("%P: %H: toc optimization is not supported for"
+			    (_("%H: toc optimization is not supported for"
 			       " %s instruction.\n"),
 			     ibfd, sec, rel->r_offset & ~3, str);
 			}
@@ -9462,7 +9462,7 @@ ppc64_elf_edit_toc (struct bfd_link_info
 			    ppc_howto_init ();
 			  info->callbacks->einfo
 			    /* xgettext:c-format */
-			    (_("%P: %H: %s references "
+			    (_("%H: %s references "
 			       "optimized away TOC entry\n"),
 			     ibfd, sec, rel->r_offset,
 			     ppc64_elf_howto_table[r_type]->name);
@@ -13571,9 +13571,9 @@ ppc64_elf_relocate_section (bfd *output_
 	    info->callbacks->einfo
 	      (!IS_PPC64_TLS_RELOC (r_type)
 	       /* xgettext:c-format */
-	       ? _("%P: %H: %s used with TLS symbol `%T'\n")
+	       ? _("%H: %s used with TLS symbol `%T'\n")
 	       /* xgettext:c-format */
-	       : _("%P: %H: %s used with non-TLS symbol `%T'\n"),
+	       : _("%H: %s used with non-TLS symbol `%T'\n"),
 	       input_bfd, input_section, rel->r_offset,
 	       ppc64_elf_howto_table[r_type]->name,
 	       sym_name);
@@ -14203,13 +14203,13 @@ ppc64_elf_relocate_section (bfd *output_
 		      || stub_entry->stub_type == ppc_stub_plt_call_r2save)
 		    info->callbacks->einfo
 		      /* xgettext:c-format */
-		      (_("%P: %H: call to `%T' lacks nop, can't restore toc; "
+		      (_("%H: call to `%T' lacks nop, can't restore toc; "
 			 "recompile with -fPIC\n"),
 		       input_bfd, input_section, rel->r_offset, sym_name);
 		  else
 		    info->callbacks->einfo
 		      /* xgettext:c-format */
-		      (_("%P: %H: call to `%T' lacks nop, can't restore toc; "
+		      (_("%H: call to `%T' lacks nop, can't restore toc; "
 			 "(-mcmodel=small toc adjust stub)\n"),
 		       input_bfd, input_section, rel->r_offset, sym_name);
 
@@ -14886,7 +14886,7 @@ ppc64_elf_relocate_section (bfd *output_
 			{
 			  info->callbacks->einfo
 			    /* xgettext:c-format */
-			    (_("%P: %H: %s for indirect "
+			    (_("%H: %s for indirect "
 			       "function `%T' unsupported\n"),
 			     input_bfd, input_section, rel->r_offset,
 			     ppc64_elf_howto_table[r_type]->name,
@@ -15173,7 +15173,7 @@ ppc64_elf_relocate_section (bfd *output_
 	      relocation ^= relocation & mask;
 	      info->callbacks->einfo
 		/* xgettext:c-format */
-		(_("%P: %H: error: %s not a multiple of %u\n"),
+		(_("%H: error: %s not a multiple of %u\n"),
 		 input_bfd, input_section, rel->r_offset,
 		 howto->name,
 		 mask + 1);
@@ -15195,7 +15195,7 @@ ppc64_elf_relocate_section (bfd *output_
 	{
 	  info->callbacks->einfo
 	    /* xgettext:c-format */
-	    (_("%P: %H: unresolvable %s against `%T'\n"),
+	    (_("%H: unresolvable %s against `%T'\n"),
 	     input_bfd, input_section, rel->r_offset,
 	     howto->name,
 	     h->elf.root.root.string);
@@ -15292,7 +15292,7 @@ ppc64_elf_relocate_section (bfd *output_
 	    {
 	      info->callbacks->einfo
 		/* xgettext:c-format */
-		(_("%P: %H: %s against `%T': error %d\n"),
+		(_("%H: %s against `%T': error %d\n"),
 		 input_bfd, input_section, rel->r_offset,
 		 reloc_name, sym_name, (int) r);
 	      ret = FALSE;


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