From owner-svn-src-all@freebsd.org Sun Mar 8 21:10:18 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1A125276199; Sun, 8 Mar 2020 21:10:18 +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 48bDX93m8lz4SJh; Sun, 8 Mar 2020 21:10:17 +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 F1EC627F69; Sun, 8 Mar 2020 21:10:16 +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 028LAGAZ014069; Sun, 8 Mar 2020 21:10:16 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 028LAGMQ014068; Sun, 8 Mar 2020 21:10:16 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <202003082110.028LAGMQ014068@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Sun, 8 Mar 2020 21:10:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r358782 - stable/12/usr.bin/elfdump X-SVN-Group: stable-12 X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: stable/12/usr.bin/elfdump X-SVN-Commit-Revision: 358782 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: Sun, 08 Mar 2020 21:10:18 -0000 Author: emaste Date: Sun Mar 8 21:10:16 2020 New Revision: 358782 URL: https://svnweb.freebsd.org/changeset/base/358782 Log: MFC r343610: elfdump: include note type names Based on a patch submitted by Dan McGregor. - MFC r343611: elfdump: fix build after r343610 - MFC r343613: elfdump: use designated array initialization for note types This ensures the note type name is in the correct slot. Submitted by: kib - PR: 228290 Sponsored by: The FreeBSD Foundation Modified: stable/12/usr.bin/elfdump/elfdump.c Directory Properties: stable/12/ (props changed) Modified: stable/12/usr.bin/elfdump/elfdump.c ============================================================================== --- stable/12/usr.bin/elfdump/elfdump.c Sun Mar 8 21:07:21 2020 (r358781) +++ stable/12/usr.bin/elfdump/elfdump.c Sun Mar 8 21:10:16 2020 (r358782) @@ -316,6 +316,15 @@ static const char *p_flags[] = { "PF_X|PF_W|PF_R" }; +#define NT_ELEM(x) [x] = #x, +static const char *nt_types[] = { + "", + 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 */ static const char * sh_types(uint64_t machine, uint64_t sht) { @@ -1052,7 +1061,9 @@ elf_print_note(Elf32_Ehdr *e, void *sh) u_int32_t namesz; u_int32_t descsz; u_int32_t desc; + u_int32_t type; char *n, *s; + const char *nt_type; offset = elf_get_off(e, sh, SH_OFFSET); size = elf_get_size(e, sh, SH_SIZE); @@ -1062,9 +1073,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_types[type] != NULL) + 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; } }