From: Roland McGrath Date: Wed, 14 Apr 2010 18:54:06 +0000 (-0700) Subject: Fix readelf core note bitmask printing. X-Git-Tag: elfutils-0.146~9 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=62b28b63dc2495f3ce360ef2abd8112414cbe95c;p=thirdparty%2Felfutils.git Fix readelf core note bitmask printing. --- diff --git a/src/ChangeLog b/src/ChangeLog index fe6a6e3b2..53415428b 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2010-04-14 Roland McGrath + + * readelf.c (handle_core_item): Fix bitmask printing. + 2010-04-06 Roland McGrath * ld.c (options): Fix some typos in messages. diff --git a/src/readelf.c b/src/readelf.c index 428d24d18..52558602e 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -6731,16 +6731,25 @@ handle_core_item (Elf *core, const Ebl_Core_Item *item, const void *desc, { 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) - p += sprintf (p, "-%u,%u", lastbit - bias, bit - bias); - else if (lastbit == 0) - p += sprintf (p, "%u", bit - bias); + if (lastbit + 1 == bit) + ++run; + else + { + if (lastbit == 0) + p += sprintf (p, "%u", bit - bias); + else if (run == 0) + p += sprintf (p, ",%u", bit - bias); + else + p += sprintf (p, "-%u,%u", lastbit - bias, bit - bias); + run = 0; + } lastbit = bit; }