[binutils-gdb] LD: Convert `%P: %H:' to `%H:' in error messages

Maciej W.Rozycki macro@sourceware.org
Tue Nov 27 16:36:00 GMT 2018


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a5990ada637d978c43c6ff07941c56e97a3e6965

commit a5990ada637d978c43c6ff07941c56e97a3e6965
Author: Maciej W. Rozycki <macro@linux-mips.org>
Date:   Tue Nov 27 16:34:03 2018 +0000

    LD: Convert `%P: %H:' to `%H:' in error messages
    
    Similarly to commit 174d0a74a2e6 ("PowerPC/BFD: Convert `%P: %H:' to
    `%H:' in error messages") convert linker relocation error messages to
    use `%H:' rather `%P: %H:', removing inconsistent message composition
    like:
    
    $ cat reloc-j.s
    	.text
    	.globl	foo
    	.ent	foo
    foo:
    	j	bar
    	j	bar
    	.end	foo
    $ cat reloc-j.ld
    SECTIONS
    {
      bar = 0x12345678;
      .text : { *(.text) }
      /DISCARD/ : { *(*) }
    }
    $ as -o reloc-j.o reloc-j.s
    $ ld -T reloc-j.ld -o reloc-j reloc-j.o
    ld: tmpdir/reloc-j.o: in function `foo':
    (.text+0x0): relocation truncated to fit: R_MIPS_26 against `bar'
    ld: (.text+0x8): relocation truncated to fit: R_MIPS_26 against `bar'
    $
    
    where subsequent lines referring to issues within a single function have
    the name of the linker executable prepended, but the first one does not.
    
    As noted with the commit referred 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.
    
    Remove the linker name prefix then, making the messages now look like:
    
    $ ld -T reloc-j.ld -o reloc-j reloc-j.o
    tmpdir/reloc-j.o: in function `foo':
    (.text+0x0): relocation truncated to fit: R_MIPS_26 against `bar'
    (.text+0x8): relocation truncated to fit: R_MIPS_26 against `bar'
    $
    
    instead.
    
    	ld/
    	* ldmain.c (reloc_overflow): Use `%H:' rather than `%P: %H:'
    	with `einfo'.
    	(reloc_dangerous): Likewise.
    	(unattached_reloc): Likewise.

Diff:
---
 ld/ChangeLog | 7 +++++++
 ld/ldmain.c  | 6 +++---
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/ld/ChangeLog b/ld/ChangeLog
index 57579f7..667bc05 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,10 @@
+2018-11-27  Maciej W. Rozycki  <macro@linux-mips.org>
+
+	* ldmain.c (reloc_overflow): Use `%H:' rather than `%P: %H:'
+	with `einfo'.
+	(reloc_dangerous): Likewise.
+	(unattached_reloc): Likewise.
+
 2018-11-27  Tamar Christina  <tamar.christina@arm.com>
 
 	PR ld/23904
diff --git a/ld/ldmain.c b/ld/ldmain.c
index 47cbed1..24a40aa1 100644
--- a/ld/ldmain.c
+++ b/ld/ldmain.c
@@ -1421,7 +1421,7 @@ reloc_overflow (struct bfd_link_info *info,
   if (overflow_cutoff_limit == -1)
     return;
 
-  einfo ("%X%P: %H:", abfd, section, address);
+  einfo ("%X%H:", abfd, section, address);
 
   if (overflow_cutoff_limit >= 0
       && overflow_cutoff_limit-- == 0)
@@ -1474,7 +1474,7 @@ reloc_dangerous (struct bfd_link_info *info ATTRIBUTE_UNUSED,
 		 asection *section,
 		 bfd_vma address)
 {
-  einfo (_("%X%P: %H: dangerous relocation: %s\n"),
+  einfo (_("%X%H: dangerous relocation: %s\n"),
 	 abfd, section, address, message);
 }
 
@@ -1488,7 +1488,7 @@ unattached_reloc (struct bfd_link_info *info ATTRIBUTE_UNUSED,
 		  asection *section,
 		  bfd_vma address)
 {
-  einfo (_("%X%P: %H: reloc refers to symbol `%pT' which is not being output\n"),
+  einfo (_("%X%H: reloc refers to symbol `%pT' which is not being output\n"),
 	 abfd, section, address, name);
 }



More information about the Binutils-cvs mailing list