Date: Wed, 5 Jan 2022 02:05:02 GMT From: Ed Maste <emaste@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: dfe7186f287f - stable/12 - readelf: add Go Build ID ELF note support Message-ID: <202201050205.205252m0068416@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/12 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=dfe7186f287fcdfa2dbd5b3b9eadcc0c3052148f commit dfe7186f287fcdfa2dbd5b3b9eadcc0c3052148f Author: Ed Maste <emaste@FreeBSD.org> AuthorDate: 2021-12-10 20:11:45 +0000 Commit: Ed Maste <emaste@FreeBSD.org> 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:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202201050205.205252m0068416>