svn commit: r317718 - stable/11/contrib/elftoolchain/readelf

Ed Maste emaste at FreeBSD.org
Wed May 3 02:12:47 UTC 2017


Author: emaste
Date: Wed May  3 02:12:45 2017
New Revision: 317718
URL: https://svnweb.freebsd.org/changeset/base/317718

Log:
  MFC r309547 (cem): readelf: Add support for extended program header numbers
  
  Add support for extended program header numbers to elftoolchain
  'readelf -h'.

Modified:
  stable/11/contrib/elftoolchain/readelf/readelf.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/contrib/elftoolchain/readelf/readelf.c
==============================================================================
--- stable/11/contrib/elftoolchain/readelf/readelf.c	Wed May  3 02:04:38 2017	(r317717)
+++ stable/11/contrib/elftoolchain/readelf/readelf.c	Wed May  3 02:12:45 2017	(r317718)
@@ -2115,7 +2115,7 @@ dwarf_reg(unsigned int mach, unsigned in
 static void
 dump_ehdr(struct readelf *re)
 {
-	size_t		 shnum, shstrndx;
+	size_t		 phnum, shnum, shstrndx;
 	int		 i;
 
 	printf("ELF Header:\n");
@@ -2177,7 +2177,13 @@ dump_ehdr(struct readelf *re)
 	    re->ehdr.e_phentsize);
 
 	/* e_phnum. */
-	printf("%-37s%u\n", "  Number of program headers:", re->ehdr.e_phnum);
+	printf("%-37s%u", "  Number of program headers:", re->ehdr.e_phnum);
+	if (re->ehdr.e_phnum == PN_XNUM) {
+		/* Extended program header numbering is in use. */
+		if (elf_getphnum(re->elf, &phnum))
+			printf(" (%zu)", phnum);
+	}
+	putchar('\n');
 
 	/* e_shentsize. */
 	printf("%-37s%u (bytes)\n", "  Size of section headers:",


More information about the svn-src-stable mailing list