]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
src/
authorJan Kratochvil <jan.kratochvil@redhat.com>
Wed, 10 Oct 2012 17:32:05 +0000 (19:32 +0200)
committerJan Kratochvil <jan.kratochvil@redhat.com>
Wed, 30 Jan 2013 19:29:12 +0000 (20:29 +0100)
* 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 <jan.kratochvil@redhat.com>
src/ChangeLog
src/readelf.c

index 377c12415863a7c3cbd1ec1f32f39cc857819b82..4d000139b33e7fa54e67e8c02a4d2c150b93b533 100644 (file)
@@ -1,3 +1,8 @@
+2013-01-29  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       * readelf.c (handle_core_items): Limit special repeated items handling
+       to single-item formats '\n', 'b' and 'B', assert OFFSET 0 there.
+
 2012-12-18  Mark Wielaard  <mark@bordewijk.wildebeest.org>
 
        * readelf.c (ELF_INPUT_SECTION): New argp key value.
index 0b4645965903ab9f17e5582f236c732522f9412f..c25610248de6d6b3854b6fa7767155da7d1a1c27 100644 (file)
@@ -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)