On Tue, Jul 5, 2016 at 12:16 PM, Rob Landley <[email protected]> wrote: > On 07/04/2016 08:31 AM, Ed Maste wrote: >> On 2 July 2016 at 16:01, enh <[email protected]> wrote: >>> Read any PT_NOTE sections to look for NT_GNU_BUILD_ID or Android API >>> level notes. I deliberately didn't NT_GNU_ABI_TAG because it's noisy -- >>> every Linux executable has one -- but not something most command-line >>> users will have any use for. (And you can ask readelf(1) anyway.) >> >> + if (n_type == 3 /*NT_GNU_BUILD_ID*/) { >> + printf(", BuildID[%s]=", (n_descsz==20)?"sha1":"md5"); >> + for (j = 0; j < n_descsz; ++j) printf("%02x", note[16 + j]); >> + } >> >> There are build ID notes that are not 20 bytes long, and are not md5. >> Specifically, a 16 byte build ID may be a UUID, LLVM's lld can >> generate 8-byte fnv1, and the user may specify an arbitrary number of >> hex bytes for build ID. > > FYI this looks interesting but I'm not doing anything with it because > I'm not a regular user of this info and can't judge what's best to do > here. I leave turning this into a proper patch (or not) to... Elliott, I > guess? > >> but given that there's no requirement on exactly what's included in a >> sha1 or md5 build ID anyway I'm not sure there's much value in >> reporting the type. > > Exactly my problem: I dunno what success looks like here. > > (What does NT GNU mean anyway? GNU/Windows NT?)
NT_ is "note type" for that set of constants, similar to the ELF PT_* and DT_* constants. i agree with the "not ... much value in reporting the type". it's not actually recorded, and binutils ld lets you set the build id to *any* byte sequence you choose. (so 20 might mean sha1, or it might mean you used --build-id to encode some arbitrary 20-byte sequence.) there were only two reasons i added this in: 1. i was worried that someone might actually be grepping for BuildId[sha1]= but (a) i can find no evidence of that in the Android tree and (b) most other places in Android that output build ids just say "BuildId" anyway, so i think we can ignore that. 2. i noticed that /usr/bin on my ubuntu 14.04 box has a mix of sha1 and md5 for some reason. (but Android is sha1-only, so i don't care.) but, yeah, we really have no idea what we're looking at, so let's stop pretending. patch attached. > Rob -- Elliott Hughes - http://who/enh - http://jessies.org/~enh/ Android native code/tools questions? Mail me/drop by/add me as a reviewer.
From 87346381e959cd250c163843fdb3d5614f3ae457 Mon Sep 17 00:00:00 2001 From: Elliott Hughes <[email protected]> Date: Tue, 5 Jul 2016 13:39:42 -0700 Subject: [PATCH] Don't try to guess the build id type in file(1). They're really just arbitrary byte sequences of arbitrary length. Sure, a 20-byte sequence is _probably_ a SHA-1, but there's no way to know, so let's stop pretending... --- toys/posix/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toys/posix/file.c b/toys/posix/file.c index d3e80f4..0cd9047 100644 --- a/toys/posix/file.c +++ b/toys/posix/file.c @@ -136,7 +136,7 @@ static void do_elf_file(int fd, struct stat *sb) if (n_namesz==4 && !memcmp(note+12, "GNU", 4)) { if (n_type == 3 /*NT_GNU_BUILD_ID*/) { - printf(", BuildID[%s]=", (n_descsz==20)?"sha1":"md5"); + printf(", BuildID="); for (j = 0; j < n_descsz; ++j) printf("%02x", note[16 + j]); } } else if (n_namesz==8 && !memcmp(note+12, "Android", 8)) { -- 2.8.0.rc3.226.g39d4020
_______________________________________________ Toybox mailing list [email protected] http://lists.landley.net/listinfo.cgi/toybox-landley.net
