summaryrefslogtreecommitdiffstats
path: root/src/readelf.c
diff options
context:
space:
mode:
authorJan Kratochvil <[email protected]>2012-10-10 19:32:05 +0200
committerJan Kratochvil <[email protected]>2013-01-30 20:29:12 +0100
commitc44cce03fdeaf68f2728d448ee341dae9a334e27 (patch)
tree2e29024b9ec287d16cd93b33e2ac741a64eebcb0 /src/readelf.c
parentc2d5b263b37327186c401415ed552bba94f4fb73 (diff)
src/
* readelf.c (handle_core_items): Limit special repeated items handling to single-item formats '\n', 'b' and 'B', assert OFFSET 0 there. Signed-off-by: Jan Kratochvil <[email protected]>
Diffstat (limited to 'src/readelf.c')
-rw-r--r--src/readelf.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/src/readelf.c b/src/readelf.c
index 0b464596..c2561024 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -7851,6 +7851,24 @@ handle_core_items (Elf *core, const void *desc, size_t descsz,
{
if (nitems == 0)
return 0;
+ unsigned int colno = 0;
+
+ /* FORMAT '\n' makes sense to be present only as a single item as it
+ processes all the data of a note. FORMATs 'b' and 'B' have a special case
+ if present as a single item but they can be also processed with other
+ items below. */
+ if (nitems == 1 && (items[0].format == '\n' || items[0].format == 'b'
+ || items[0].format == 'B'))
+ {
+ assert (items[0].offset == 0);
+ size_t size = descsz;
+ colno = handle_core_item (core, items, desc, colno, &size);
+ /* If SIZE is not zero here there is some remaining data. But we do not
+ know how to process it anyway. */
+ return colno;
+ }
+ for (size_t i = 0; i < nitems; ++i)
+ assert (items[i].format != '\n');
/* Sort to collect the groups together. */
const Ebl_Core_Item *sorted_items[nitems];
@@ -7869,23 +7887,7 @@ handle_core_items (Elf *core, const void *desc, size_t descsz,
qsort (groups, ngroups, sizeof groups[0], &compare_core_item_groups);
/* Write out all the groups. */
- unsigned int colno = 0;
-
const void *last = desc;
- if (nitems == 1)
- {
- size_t size = descsz;
- /* If this note contains registers as well as items, don't pass
- &size to express that we don't wish to repeat. */
- colno = handle_core_item (core, sorted_items[0], desc, colno,
- size != 0 ? &size : NULL);
-
- if (size == 0)
- return colno;
- desc += descsz - size;
- descsz = size;
- }
-
do
{
for (size_t i = 0; i < ngroups; ++i)