svn commit: r343610 - head/usr.bin/elfdump

Ed Maste emaste at FreeBSD.org
Thu Jan 31 16:19:06 UTC 2019


Author: emaste
Date: Thu Jan 31 16:19:04 2019
New Revision: 343610
URL: https://svnweb.freebsd.org/changeset/base/343610

Log:
  elfdump: include note type names
  
  Based on a patch submitted by Dan McGregor.
  
  PR:		228290
  MFC after:	1 week
  Sponsored by:	The FreeBSD Foundation

Modified:
  head/usr.bin/elfdump/elfdump.c

Modified: head/usr.bin/elfdump/elfdump.c
==============================================================================
--- head/usr.bin/elfdump/elfdump.c	Thu Jan 31 16:11:15 2019	(r343609)
+++ head/usr.bin/elfdump/elfdump.c	Thu Jan 31 16:19:04 2019	(r343610)
@@ -317,6 +317,11 @@ static const char *p_flags[] = {
 	"PF_X|PF_W|PF_R"
 };
 
+static const char *nt_types[] = {
+	"", "NT_FREEBSD_ABI_TAG", "NT_FREEBSD_NOINIT_TAG",
+	"NT_FREEBSD_ARCH_TAG", "NT_FREEBSD_FEATURE_CTL"
+};
+
 /* http://www.sco.com/developers/gabi/latest/ch4.sheader.html#sh_type */
 static const char *
 sh_types(uint64_t machine, uint64_t sht) {
@@ -1071,9 +1076,14 @@ elf_print_note(Elf32_Ehdr *e, void *sh)
 	while (n < ((char *)e + offset + size)) {
 		namesz = elf_get_word(e, n, N_NAMESZ);
 		descsz = elf_get_word(e, n, N_DESCSZ);
+		type = elf_get_word(e, n, N_TYPE);
+		if (type < nitems(nt_types))
+			nt_type = nt_types[type];
+		else
+			nt_type = "Unknown type";
 		s = n + sizeof(Elf_Note);
 		desc = elf_get_word(e, n + sizeof(Elf_Note) + namesz, 0);
-		fprintf(out, "\t%s %d\n", s, desc);
+		fprintf(out, "\t%s %d (%s)\n", s, desc, nt_type);
 		n += sizeof(Elf_Note) + namesz + descsz;
 	}
 }


More information about the svn-src-head mailing list