qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC v2 2/4] elf-ops.h: Add get_elf_note_type()


From: Liam Merwick
Subject: Re: [Qemu-devel] [RFC v2 2/4] elf-ops.h: Add get_elf_note_type()
Date: Tue, 8 Jan 2019 14:47:51 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0



On 02/01/2019 13:12, Stefan Hajnoczi wrote:
On Fri, Dec 21, 2018 at 08:03:50PM +0000, Liam Merwick wrote:
+    while (note_type != elf_note_type) {
+        nhdr_namesz = nhdr->n_namesz;
+        nhdr_descsz = nhdr->n_descsz;
+
+        elf_note_entry_offset = nhdr_size +
+            QEMU_ALIGN_UP(nhdr_namesz, phdr_align) +
+            QEMU_ALIGN_UP(nhdr_descsz, phdr_align);
+
+        /* If the offset calculated in this iteration exceeds the
+        * supplied size, we are done and no matching note was found.
+        */

Indentation is off here.  QEMU uses 4-space indentation.

+        if (elf_note_entry_offset > note_size) {
+            return NULL;
+        }
+
+        /* skip to the next ELF Note entry */
+        nhdr = (void *)nhdr + elf_note_entry_offset;
+        note_type = nhdr->n_type;
+    }
+
+    return nhdr;
+}
+
  static int glue(load_elf, SZ)(const char *name, int fd,
                                uint64_t (*elf_note_fn)(void *, void *, bool),
                                uint64_t (*translate_fn)(void *, uint64_t),
@@ -512,6 +555,13 @@ static int glue(load_elf, SZ)(const char *name, int fd,
                  }
              }
+ /* Search the ELF notes to find one with a type matching the
+            * value passed in via 'translate_opaque'
+            */
+            nhdr = (struct elf_note *)data;

Ah, I see data gets used here!  It would be clearer to move loading of
data into this patch.


Moved.


+           assert(translate_opaque != NULL);
+            nhdr = glue(get_elf_note_type, SZ)(nhdr, file_size, ph->p_align,
+                                               *(uint64_t *)translate_opaque);

Indentation is off in this hunk.  QEMU uses 4-space indentation.


A few stray tabs had snuck in - I've fixed all those.

Regards,
Liam



reply via email to

[Prev in Thread] Current Thread [Next in Thread]