Skip to content

Commit

Permalink
[bfd] Extract and store GNU Infinity notes we find
Browse files Browse the repository at this point in the history
  • Loading branch information
Gary Benson committed Nov 16, 2015
1 parent e18716e commit 8360d52
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
13 changes: 13 additions & 0 deletions bfd/elf-bfd.h
Original file line number Diff line number Diff line change
Expand Up @@ -1591,6 +1591,14 @@ struct sdt_note
bfd_byte data[1];
};

/* A GNU Infinity note. */
struct elf_infinity_note
{
struct elf_infinity_note *next;
size_t size;
bfd_byte data[0];
};

/* tdata information grabbed from an elf core file. */
struct core_elf_obj_tdata
{
Expand Down Expand Up @@ -1742,6 +1750,11 @@ struct elf_obj_tdata
in the list. */
struct sdt_note *sdt_note_head;

/* Linked list containing information about every GNU 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;

Expand Down
22 changes: 22 additions & 0 deletions bfd/elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -9249,6 +9249,25 @@ elfobj_grok_gnu_build_id (bfd *abfd, Elf_Internal_Note *note)
return TRUE;
}

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->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)
{
Expand All @@ -9259,6 +9278,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);
}
}

Expand Down

0 comments on commit 8360d52

Please sign in to comment.