diff mbox

[RFC,3/5] Support ELF Infinity notes

Message ID 1496913338-22195-4-git-send-email-gbenson@redhat.com
State New
Headers show

Commit Message

Gary Benson June 8, 2017, 9:15 a.m. UTC
This commit adds support for Infinity notes in ELF .note.infinity
sections.  A list of found notes is built and its head pointer stored
as infinity_note_head in struct elf_obj_tdata.

bfd/ChangeLog:

	* elf-bfd.h (struct elf_infinity_note): New structure.
	(struct elf_obj_tdata): Add new field infinity_note_head.
	* elf.c (elfobj_grok_gnu_infinity): New function.
	(elfobj_grok_gnu_note): Call the above.
---
 bfd/ChangeLog |  7 +++++++
 bfd/elf-bfd.h | 14 ++++++++++++++
 bfd/elf.c     | 23 +++++++++++++++++++++++
 3 files changed, 44 insertions(+)
diff mbox

Patch

diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index af377ee..9da3d53 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -1694,6 +1694,15 @@  struct sdt_note
   bfd_byte data[1];
 };
 
+/* An Infinity note.  */
+struct elf_infinity_note
+{
+  struct elf_infinity_note *next;
+  bfd_vma fileoffset;
+  size_t size;
+  bfd_byte data[0];
+};
+
 /* tdata information grabbed from an elf core file.  */
 struct core_elf_obj_tdata
 {
@@ -1856,6 +1865,11 @@  struct elf_obj_tdata
      in the list.  */
   struct sdt_note *sdt_note_head;
 
+  /* Linked list containing information about every Infinity note
+     found in the object file.  Each note corresponds to one entry
+     in the list.  */
+  struct elf_infinity_note *infinity_note_head;
+
   Elf_Internal_Shdr **group_sect_ptr;
   int num_group;
 
diff --git a/bfd/elf.c b/bfd/elf.c
index 18b4bbe..420773e 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -9756,6 +9756,26 @@  elfobj_grok_gnu_build_id (bfd *abfd, Elf_Internal_Note *note)
 }
 
 static bfd_boolean
+elfobj_grok_gnu_infinity (bfd *abfd, Elf_Internal_Note *note)
+{
+  struct elf_infinity_note *cur;
+
+  if (note->descsz == 0)
+    return FALSE;
+
+  cur = bfd_alloc (abfd, sizeof (struct elf_infinity_note) + note->descsz);
+
+  cur->next = elf_tdata (abfd)->infinity_note_head;
+  cur->fileoffset = note->descpos;
+  cur->size = note->descsz;
+  memcpy (cur->data, note->descdata, note->descsz);
+
+  elf_tdata (abfd)->infinity_note_head = cur;
+
+  return TRUE;
+}
+
+static bfd_boolean
 elfobj_grok_gnu_note (bfd *abfd, Elf_Internal_Note *note)
 {
   switch (note->type)
@@ -9768,6 +9788,9 @@  elfobj_grok_gnu_note (bfd *abfd, Elf_Internal_Note *note)
 
     case NT_GNU_BUILD_ID:
       return elfobj_grok_gnu_build_id (abfd, note);
+
+    case NT_GNU_INFINITY:
+      return elfobj_grok_gnu_infinity (abfd, note);
     }
 }