This is the mail archive of the binutils-cvs@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]

[binutils-gdb] readelf: Correct version flag formatting


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

commit 7bb1ad1738d3ff45452b136fdfc3fc19195ae55f
Author: Maciej W. Rozycki <macro@imgtec.com>
Date:   Thu Feb 23 18:18:51 2017 +0000

    readelf: Correct version flag formatting
    
    Remove a trailing space or a leading pipe character from version flags
    printed with `readelf --version-info'.
    
    For example with the `mips-linux' target we get:
    
    $ cat ver_def.s
    	.data
    	.globl	new_foo
    	.type	new_foo, %object
    new_foo:
    	.symver	new_foo, foo@@ver_foo
    $ cat ver_def.ver
    { global: *foo*; local: *; };
    $ as -o ver_def.o ver_def.s
    $ ld -e 0 --export-dynamic --version-script=ver_def.ver -o ver_def ver_def.o
    $ readelf -V ver_def
    
    Version symbols section '.gnu.version' contains 4 entries:
     Addr: 000000000000007e  Offset: 0x01007e  Link: 2 (.dynsym)
      000:   0 (*local*)       2 (ver_foo)       1 (*global*)      2 (ver_foo)
    
    Version definition section '.gnu.version_d' contains 2 entries:
      Addr: 0x0000000000000088  Offset: 0x010088  Link: 3 (.dynstr)
      000000: Rev: 1  Flags: BASE   Index: 1  Cnt: 1  Name: ver_def
      0x001c: Rev: 1  Flags: none  Index: 2  Cnt: 1  Name: ver_foo
    $
    
    which includes an unnecessary space after `BASE'; both call sites
    already provide suitable separation from output that follows.  Also if
    only unknown flags were present, then lone `| <unknown>' would be
    printed.
    
    	binutils/
    	* readelf.c (get_ver_flags): Tidy the formatting of the string
    	returned

Diff:
---
 binutils/ChangeLog |  5 +++++
 binutils/readelf.c | 17 +++++++++++------
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 1ab1c2c..7a79ee9 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,5 +1,10 @@
 2017-02-24  Maciej W. Rozycki  <macro@imgtec.com>
 
+	* readelf.c (get_ver_flags): Tidy the formatting of the string
+	returned
+
+2017-02-24  Maciej W. Rozycki  <macro@imgtec.com>
+
 	* readelf.c (process_version_sections) <SHT_GNU_verdef>: Make
 	`isum' unsigned.
 	<SHT_GNU_verneed>: Likewise.
diff --git a/binutils/readelf.c b/binutils/readelf.c
index 6edb364..0603381 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -9947,26 +9947,31 @@ get_ver_flags (unsigned int flags)
     return _("none");
 
   if (flags & VER_FLG_BASE)
-    strcat (buff, "BASE ");
+    strcat (buff, "BASE");
 
   if (flags & VER_FLG_WEAK)
     {
       if (flags & VER_FLG_BASE)
-	strcat (buff, "| ");
+	strcat (buff, " | ");
 
-      strcat (buff, "WEAK ");
+      strcat (buff, "WEAK");
     }
 
   if (flags & VER_FLG_INFO)
     {
       if (flags & (VER_FLG_BASE|VER_FLG_WEAK))
-	strcat (buff, "| ");
+	strcat (buff, " | ");
 
-      strcat (buff, "INFO ");
+      strcat (buff, "INFO");
     }
 
   if (flags & ~(VER_FLG_BASE | VER_FLG_WEAK | VER_FLG_INFO))
-    strcat (buff, _("| <unknown>"));
+    {
+      if (flags & (VER_FLG_BASE | VER_FLG_WEAK | VER_FLG_INFO))
+	strcat (buff, " | ");
+
+      strcat (buff, _("<unknown>"));
+    }
 
   return buff;
 }


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