[committed] readelf: Restore a lost new line in version information

Maciej W. Rozycki macro@imgtec.com
Wed Feb 22 18:19:00 GMT 2017


Fix a commit 74e1a04b9787 ("More fixes for reading corrupt ELF files.") 
`readelf --version-info' output formatting regression where a dropped 
new line caused section header information from the `.gnu.version_d' 
version definition section to be printed on the same line as this 
section's first entry.

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
  Version definition past end of section
$

Add the new line then, to get:

$ 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
  Version definition past end of section
$

instead.

	binutils/
	* readelf.c (process_version_sections) <SHT_GNU_verdef>: Print a
	new line between the heading and the first version definition
	entry.
---
 No regressions against my usual targets.  I take it dropping the new line
from output was accidental and committed this change as obvious.  I have
not included a test case here, however the next patch proposed will have
one that covers this issue as a side effect.

  Maciej

binutils-readelf-verdef-newline.diff
Index: binutils/binutils/readelf.c
===================================================================
--- binutils.orig/binutils/readelf.c	2017-02-18 00:54:17.000000000 +0000
+++ binutils/binutils/readelf.c	2017-02-18 01:00:01.965828266 +0000
@@ -10002,7 +10002,7 @@ process_version_sections (FILE * file)
 
 	    printf (_("  Addr: 0x"));
 	    printf_vma (section->sh_addr);
-	    printf (_("  Offset: %#08lx  Link: %u (%s)"),
+	    printf (_("  Offset: %#08lx  Link: %u (%s)\n"),
 		    (unsigned long) section->sh_offset, section->sh_link,
 		    printable_section_name_from_index (section->sh_link));
 



More information about the Binutils mailing list