Skip to content

Commit 9611f31

Browse files
committed
Extend build-id reporting to 8-byte IDs that lld can generate (Ed Maste)
1 parent 5b88266 commit 9611f31

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

Diff for: src/readelf.c

+18-4
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#include "file.h"
2828

2929
#ifndef lint
30-
FILE_RCSID("@(#)$File: readelf.c,v 1.126 2015/11/16 16:03:45 christos Exp $")
30+
FILE_RCSID("@(#)$File: readelf.c,v 1.127 2015/11/18 12:29:29 christos Exp $")
3131
#endif
3232

3333
#ifdef BUILTIN_ELF
@@ -509,12 +509,26 @@ do_bid_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type,
509509
size_t noff, size_t doff, int *flags)
510510
{
511511
if (namesz == 4 && strcmp((char *)&nbuf[noff], "GNU") == 0 &&
512-
type == NT_GNU_BUILD_ID && (descsz == 16 || descsz == 20)) {
512+
type == NT_GNU_BUILD_ID && (descsz >= 4 || descsz <= 20)) {
513513
uint8_t desc[20];
514+
const char *btype;
514515
uint32_t i;
515516
*flags |= FLAGS_DID_BUILD_ID;
516-
if (file_printf(ms, ", BuildID[%s]=", descsz == 16 ? "md5/uuid" :
517-
"sha1") == -1)
517+
switch (descsz) {
518+
case 8:
519+
btype = "xxHash";
520+
break;
521+
case 16:
522+
btype = "md5/uuid";
523+
break;
524+
case 20:
525+
btype = "sha1";
526+
break;
527+
default:
528+
btype = "unknown";
529+
break;
530+
}
531+
if (file_printf(ms, ", BuildID[%s]=", btype) == -1)
518532
return 1;
519533
(void)memcpy(desc, &nbuf[doff], descsz);
520534
for (i = 0; i < descsz; i++)

0 commit comments

Comments
 (0)