From e25d0e03aca284f04875e4710ca43c7997263b57 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Tue, 8 Aug 2023 13:33:53 -0700 Subject: [PATCH] readelf: add PAC and BTI decoding. I've added the x86 ISA requirement too, since that's the other one I see on my (host!) system, but I'm really just here for arm64 PAC/BTI. There are others, but YAGNI. Also remove incorrect TODO comments: j is implicitly non-zero from the loop (so we _could_ add `, j=1` but it seems redundant), and notematch() doesn't advance the pointer unless it matches (like strstart()). --- toys/other/readelf.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/toys/other/readelf.c b/toys/other/readelf.c index 91d92272..54e6e22c 100644 --- a/toys/other/readelf.c +++ b/toys/other/readelf.c @@ -319,11 +319,38 @@ static void show_notes(unsigned long offset, unsigned long size) printf("NT_GNU_ABI_TAG\tOS: %s, ABI: %u.%u.%u", !elf_int(&p)?"Linux":"?", elf_int(&p), elf_int(&p), elf_int(&p)), j=1; } else if (type == 3) { -// TODO should this set j=1? printf("NT_GNU_BUILD_ID\t"); for (;j 8) { // Ignore 0-padding at the end. + int pr_type = elf_int(&p); + int pr_size = elf_int(&p), k, pr_data; + + j += 8; + printf("\n Properties: "); + if (pr_size != 4) { + // Just hex dump anything we aren't familiar with. + for (k=0;k