[patch] readelf bitmap display fix
Jan Kratochvil
jan.kratochvil at redhat.com
Thu Oct 11 19:58:15 UTC 2012
Hi Roland,
jankratochvil/readelf-bitmap
when you insist on src/readelf.c fixes the displayed bitmaps were already very
wrong when trying to fix the handling around.
Just I haven't found it worth some thorough testcase. I used some adjustments
of the attached reproducer to produce a core file with bitmap.
Particularly
ioperm: ~<-65535>
->
ioperm: ~<0-63>
and
ioperm: ~<-0,2,4,6,8,10,12,14-65535>
->
ioperm: ~<0,2,4,6,8,10,12,14>
.
Regards,
Jan
commit 69a2852e1d5661bc042dcc90c16e9aa7777c7340
Author: Jan Kratochvil <jan.kratochvil at redhat.com>
Date: Thu Oct 11 21:47:26 2012 +0200
src/
2012-10-11 Jan Kratochvil <jan.kratochvil at redhat.com>
* readelf.c (handle_core_item) <b>: Make run an outer block variable.
Increase run only if LASTBIT != 0. Print last element only if RUN > 0.
Signed-off-by: Jan Kratochvil <jan.kratochvil at redhat.com>
diff --git a/src/readelf.c b/src/readelf.c
index 5d167eb..470af4d 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -7515,19 +7515,19 @@ handle_core_item (Elf *core, const Ebl_Core_Item *item, const void *desc,
}
unsigned int lastbit = 0;
+ unsigned int run = 0;
for (const unsigned int *i = data;
(void *) i < data + count * size; ++i)
{
unsigned int bit = ((void *) i - data) * 8;
unsigned int w = negate ? ~*i : *i;
- unsigned int run = 0;
while (w != 0)
{
int n = ffs (w);
w >>= n;
bit += n;
- if (lastbit + 1 == bit)
+ if (lastbit != 0 && lastbit + 1 == bit)
++run;
else
{
@@ -7543,8 +7543,8 @@ handle_core_item (Elf *core, const Ebl_Core_Item *item, const void *desc,
lastbit = bit;
}
}
- if (lastbit > 0 && lastbit + 1 != nbits)
- p += sprintf (p, "-%u", nbits - bias);
+ if (lastbit > 0 && run > 0 && lastbit + 1 != nbits)
+ p += sprintf (p, "-%u", lastbit - bias);
colno = print_core_item (colno, ',', ITEM_WRAP_COLUMN, 0, item->name,
4 + nbits * 4,
-------------- next part --------------
#define _GNU_SOURCE
#include <sys/io.h>
#include <assert.h>
#include <errno.h>
#include <signal.h>
int
main (void)
{
for (int j = 0; j < 0xf; j+=2)
{
int i = ioperm (j, 1, 1);
assert_perror (errno);
assert (i == 0);
}
raise (SIGSEGV);
assert (0);
return 0;
}
More information about the elfutils-devel
mailing list