[1/2,LD] Add new %pU vfinfo format for printing linker script name

Message ID 20200116115012.4302666b@jozef-kubuntu
State New
Headers show
Series
  • Fix alignment of __*_array_start symbols in default linker script
Related show

Commit Message

Jozef Lawrynowicz Jan. 16, 2020, 11:50 a.m.
On Thu, 16 Jan 2020 11:48:27 +0000
Jozef Lawrynowicz <jozef.l@mittosystems.com> wrote:
> 

> To support warning when the __*array_start symbols are misaligned, without

> knowing the location of the symbols within the linker script, a new format

> specifier "%pU" has been added to vfinfo. This prints the name of the linker

> script, without trying to print the line number (the "%pS" specifier will print

> both).

>

Patch

From 23768021b791fa8e30a2faeb5656edf6fc0097fb Mon Sep 17 00:00:00 2001
From: Jozef Lawrynowicz <jozef.l@mittosystems.com>
Date: Thu, 16 Jan 2020 10:06:05 +0000
Subject: [PATCH 1/2] LD: Add new %pU vfinfo format for printing linker script
 name

ld/ChangeLog:

2020-01-16  Jozef Lawrynowicz  <jozef.l@mittosystems.com>

	* ldmisc.c (vfinfo): Support new "%pU" format specifier.
---
 ld/ldmisc.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/ld/ldmisc.c b/ld/ldmisc.c
index b714b97105..5f6fa767d8 100644
--- a/ld/ldmisc.c
+++ b/ld/ldmisc.c
@@ -59,6 +59,7 @@ 
  %pR info about a relent
  %pS print script file and linenumber from etree_type.
  %pT symbol name
+ %pU print script file without linenumber from etree_type.
  %s arbitrary string, like printf
  %u integer, like printf
  %v hex bfd_vma, no leading zeros
@@ -489,9 +490,9 @@  vfinfo (FILE *fp, const char *fmt, va_list ap, bfd_boolean is_warning)
 			  relent->addend,
 			  relent->howto->name);
 		}
-	      else if (*fmt == 'S')
+	      else if (*fmt == 'S' || *fmt == 'U')
 		{
-		  /* Print script file and linenumber.  */
+		  /* Print script file and maybe the associated linenumber.  */
 		  etree_type node;
 		  etree_type *tp = (etree_type *) args[arg_no].p;
 
@@ -503,8 +504,10 @@  vfinfo (FILE *fp, const char *fmt, va_list ap, bfd_boolean is_warning)
 		      tp->type.filename = ldlex_filename ();
 		      tp->type.lineno = lineno;
 		    }
-		  if (tp->type.filename != NULL)
+		  if (tp->type.filename != NULL && fmt[-1] == 'S')
 		    fprintf (fp, "%s:%u", tp->type.filename, tp->type.lineno);
+		  else if (tp->type.filename != NULL && fmt[-1] == 'U')
+		    fprintf (fp, "%s", tp->type.filename);
 		}
 	      else if (*fmt == 'T')
 		{
-- 
2.17.1