From 22efb79af91ce222fce6ebac71022dc30c787159 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Fri, 5 Dec 2025 19:11:57 +0000 Subject: [PATCH] readelf: support processor-specific flags. These are the arm/arm64/x86-64 ones special cased by binutils and llvm. There's also a hexagon flag, two xcore flags (whatever xcore is), and a bunch of mips flags, but none of those seem to actually produce any output, so this patch just ignores those esoterica. --- toys/other/readelf.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/toys/other/readelf.c b/toys/other/readelf.c index 1572a1ac..26b53180 100644 --- a/toys/other/readelf.c +++ b/toys/other/readelf.c @@ -53,6 +53,11 @@ struct ph { unsigned long long offset, vaddr, paddr, filesz, memsz, align; }; +#define EM_ARM 40 +#define EM_ARM64 183 +#define EM_RISCV 243 +#define EM_X86_64 62 + static long long elf_get(char **p, int len) { long long result; @@ -551,21 +556,23 @@ static void scan_elf() char sh_flags[13] = {}, *p = sh_flags; unsigned long long flags = s.flags; - for (j=0; j<12; j++) { - if (flags&(1<