From owner-svn-src-all@freebsd.org Thu Jan 31 16:49:07 2019 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 145FC14AFBEE; Thu, 31 Jan 2019 16:49:07 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id AC663968E5; Thu, 31 Jan 2019 16:49:06 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 994B6A1D8; Thu, 31 Jan 2019 16:49:06 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x0VGn6ct097600; Thu, 31 Jan 2019 16:49:06 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x0VGn6ht097599; Thu, 31 Jan 2019 16:49:06 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201901311649.x0VGn6ht097599@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Thu, 31 Jan 2019 16:49:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r343613 - head/usr.bin/elfdump X-SVN-Group: head X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: head/usr.bin/elfdump X-SVN-Commit-Revision: 343613 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: AC663968E5 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_SHORT(-0.98)[-0.983,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-0.999,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Jan 2019 16:49:07 -0000 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";