We talked about it in the key already, but never actually emitted
it.
---
 toys/other/readelf.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
From 5a1a839ad89b542178fc1b0381f291e1638ff787 Mon Sep 17 00:00:00 2001
From: Elliott Hughes <[email protected]>
Date: Fri, 14 Nov 2025 16:56:42 -0500
Subject: [PATCH] readelf: fix -S 'x'.

We talked about it in the key already, but never actually emitted
it.
---
 toys/other/readelf.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/toys/other/readelf.c b/toys/other/readelf.c
index c1fbba60..1572a1ac 100644
--- a/toys/other/readelf.c
+++ b/toys/other/readelf.c
@@ -548,9 +548,16 @@ static void scan_elf()
     }
 
     if (FLAG(S)) {
-      char sh_flags[12] = {}, *p = sh_flags;
+      char sh_flags[13] = {}, *p = sh_flags;
+      unsigned long long flags = s.flags;
 
-      for (j=0; j<12; j++) if (s.flags&(1<<j)) *p++ = "WAXxMSILOGTC"[j];
+      for (j=0; j<12; j++) {
+        if (flags&(1<<j)) {
+          *p++ = "WAXxMSILOGTC"[j];
+          flags &= ~(1<<j);
+        }
+      }
+      if (flags) *p++ = 'x';
       printf("  [%2d] %-17s %-15s %0*llx %06llx %06llx %02llx %3s %2d %2d %2lld\n",
              i, s.name, sh_type(s.type), w, s.addr, s.offset, s.size,
              s.entsize, sh_flags, s.link, s.info, s.addralign);
-- 
2.52.0.rc1.455.g30608eb744-goog

_______________________________________________
Toybox mailing list
[email protected]
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to