svn commit: r343613 - head/usr.bin/elfdump
Ed Maste
emaste at FreeBSD.org
Thu Jan 31 16:49:07 UTC 2019
Author: emaste
Date: Thu Jan 31 16:49:06 2019
New Revision: 343613
URL: https://svnweb.freebsd.org/changeset/base/343613
Log:
elfdump: use designated array initialization for note types
This ensures the note type name is in the correct slot.
PR: 228290
Submitted by: kib
MFC with: 343610
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:43:35 2019 (r343612)
+++ head/usr.bin/elfdump/elfdump.c Thu Jan 31 16:49:06 2019 (r343613)
@@ -317,9 +317,13 @@ static const char *p_flags[] = {
"PF_X|PF_W|PF_R"
};
+#define NT_ELEM(x) [x] = #x,
static const char *nt_types[] = {
- "", "NT_FREEBSD_ABI_TAG", "NT_FREEBSD_NOINIT_TAG",
- "NT_FREEBSD_ARCH_TAG", "NT_FREEBSD_FEATURE_CTL"
+ "",
+ NT_ELEM(NT_FREEBSD_ABI_TAG)
+ NT_ELEM(NT_FREEBSD_NOINIT_TAG)
+ NT_ELEM(NT_FREEBSD_ARCH_TAG)
+ NT_ELEM(NT_FREEBSD_FEATURE_CTL)
};
/* http://www.sco.com/developers/gabi/latest/ch4.sheader.html#sh_type */
@@ -1079,7 +1083,7 @@ elf_print_note(Elf32_Ehdr *e, void *sh)
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))
+ if (type < nitems(nt_types) && nt_types[type] != NULL)
nt_type = nt_types[type];
else
nt_type = "Unknown type";
More information about the svn-src-all
mailing list