From nobody Wed Jan 05 02:05:02 2022 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 6EF6E193C466; Wed, 5 Jan 2022 02:05:03 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JTCVQ66q5z4TPp; Wed, 5 Jan 2022 02:05:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B360524026; Wed, 5 Jan 2022 02:05:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 205252a1068417; Wed, 5 Jan 2022 02:05:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 205252m0068416; Wed, 5 Jan 2022 02:05:02 GMT (envelope-from git) Date: Wed, 5 Jan 2022 02:05:02 GMT Message-Id: <202201050205.205252m0068416@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: dfe7186f287f - stable/12 - readelf: add Go Build ID ELF note support List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: dfe7186f287fcdfa2dbd5b3b9eadcc0c3052148f Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1641348302; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=0ZtwhlOC+XL4bavaUBKdPgSbeu2TGXOh8OXuNI/p6jw=; b=Qj659r1jcf3QEK8pH9DyGf6Zvv8CCBB27Fn+CTOGe4Oi2wPf0W6J9NvA+6anwMOrW9bfJ6 qenB0+Kea25mAo+5ZjS3+6ppA1hbmBxCQdbarGkvhgLsA8yPUFjy6JzRmq8g7+zskwkZJH 9qgtDRol0f9ec0M94/UhecqP4GRy62c2CUpyukb2QALtHE0tGFJ5g77fCZ0IZL+OZ0JbQg 5e2t11IbYq7isrN0+mwPtEPm4NJePGlgI//5wVSAXnHwp/KeEmgIQgyfTQ7+bZAh6409r+ xex+qlCa9CMakg1jWoAU7/5u6pA6/4PLWILLiSIS1DuG7MbWJIPnxmvrpfju/A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1641348302; a=rsa-sha256; cv=none; b=pRGPWzcphQXxyGLynlvwCwfJ50voUprXSPFIrKHjVUV1fvTn2k/dXO9FHxmgjxSIMwZOj6 xpLVnTHRZcBZmbShk5+CkCsG4Fu4jcrgaCd6BlvI8bhuy8h9yHHxpP0n6XEzDX0jpNBFJJ dtRu2h3IFSxshf8/A+qqQcphfX2dZIfSu7SywnlKpi6cLj9UCn32mpng2V+Tc7XcrqHXw9 C70KxsS8fKTu9xeNIfC26vSwZ6BqwJdNGXxl/7iRCwa/fM2pbcGNlp43o39CkzBkLkuNtV K/3rju8INIFqsjG/pU3X4rKJhfy33cQCPyrMqxsycvEOGXgEHuB5GFJ7tt4oSQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=dfe7186f287fcdfa2dbd5b3b9eadcc0c3052148f commit dfe7186f287fcdfa2dbd5b3b9eadcc0c3052148f Author: Ed Maste AuthorDate: 2021-12-10 20:11:45 +0000 Commit: Ed Maste CommitDate: 2022-01-05 02:04:37 +0000 readelf: add Go Build ID ELF note support Reviewed by: markj MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D33379 (cherry picked from commit ca457394fccfc7d712cd9cc6a66e574767a0a32b) --- contrib/elftoolchain/readelf/readelf.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/contrib/elftoolchain/readelf/readelf.c b/contrib/elftoolchain/readelf/readelf.c index a647f2e7961d..f07fca31f4fe 100644 --- a/contrib/elftoolchain/readelf/readelf.c +++ b/contrib/elftoolchain/readelf/readelf.c @@ -362,8 +362,9 @@ static const char *note_type(const char *note_name, unsigned int et, unsigned int nt); static const char *note_type_freebsd(unsigned int nt); static const char *note_type_freebsd_core(unsigned int nt); -static const char *note_type_linux_core(unsigned int nt); +static const char *note_type_go(unsigned int nt); static const char *note_type_gnu(unsigned int nt); +static const char *note_type_linux_core(unsigned int nt); static const char *note_type_netbsd(unsigned int nt); static const char *note_type_openbsd(unsigned int nt); static const char *note_type_unknown(unsigned int nt); @@ -1140,6 +1141,8 @@ note_type(const char *name, unsigned int et, unsigned int nt) return note_type_freebsd(nt); else if (strcmp(name, "GNU") == 0 && et != ET_CORE) return note_type_gnu(nt); + else if (strcmp(name, "Go") == 0 && et != ET_CORE) + return note_type_go(nt); else if (strcmp(name, "NetBSD") == 0 && et != ET_CORE) return note_type_netbsd(nt); else if (strcmp(name, "OpenBSD") == 0 && et != ET_CORE) @@ -1232,6 +1235,15 @@ note_type_gnu(unsigned int nt) } } +static const char * +note_type_go(unsigned int nt) +{ + switch (nt) { + case 4: return "elfGoBuildIDTag"; + default: return (note_type_unknown(nt)); + } +} + static const char * note_type_netbsd(unsigned int nt) { @@ -3749,6 +3761,16 @@ dump_notes_data(struct readelf *re, const char *name, uint32_t type, dump_flags(note_feature_ctl_flags, ubuf[0]); return; } + } else if (strcmp(name, "Go") == 0) { + if (type == 4) { + printf(" Build ID: "); + for (i = 0; i < sz; i++) { + printf(isprint(buf[i]) ? "%c" : "<%02x>", + buf[i]); + } + printf("\n"); + return; + } } else if (strcmp(name, "GNU") == 0) { switch (type) { case NT_GNU_PROPERTY_TYPE_0: