* elf-bfd.h (struct sdt_note): New struct.
authorNick Clifton <nickc@redhat.com>
Fri, 15 Apr 2011 11:14:01 +0000 (11:14 +0000)
committerNick Clifton <nickc@redhat.com>
Fri, 15 Apr 2011 11:14:01 +0000 (11:14 +0000)
(struct elf_obj_tdata) <sdt_note_head>: New field.
* elf.c (elfobj_grok_stapsdt_note_1): New function.
(elfobj_grok_stapsdt_note): Likewise.
(elf_parse_notes): Added code to treat SystemTap note
sections.
* common.h (NT_STAPSDT): New define.

bfd/ChangeLog
bfd/elf-bfd.h
bfd/elf.c
include/elf/ChangeLog
include/elf/common.h

index ce76b34..8fa9ce1 100644 (file)
@@ -1,3 +1,12 @@
+2011-04-15  Sergio Durigan Junior  <sergiodj@redhat.com>
+
+       * elf-bfd.h (struct sdt_note): New struct.
+       (struct elf_obj_tdata) <sdt_note_head>: New field.
+       * elf.c (elfobj_grok_stapsdt_note_1): New function.
+       (elfobj_grok_stapsdt_note): Likewise.
+       (elf_parse_notes): Added code to treat SystemTap note
+       sections.
+
 2011-04-12  Richard Henderson  <rth@redhat.com>
 
        * elf64-alpha.c (elf64_alpha_size_dynamic_sections): Do not
index 844610d..39c7de6 100644 (file)
@@ -1476,6 +1476,15 @@ enum
   Tag_compatibility = 32
 };
 
+/* The following struct stores information about every SystemTap section
+   found in the object file.  */
+struct sdt_note
+{
+  struct sdt_note *next;
+  bfd_size_type size;
+  bfd_byte data[1];
+};
+
 /* Some private data is stashed away for future use using the tdata pointer
    in the bfd structure.  */
 
@@ -1633,6 +1642,11 @@ struct elf_obj_tdata
   bfd_size_type build_id_size;
   bfd_byte *build_id;
 
+  /* Linked-list containing information about every Systemtap section
+     found in the object file.  Each section corresponds to one entry
+     in the list.  */
+  struct sdt_note *sdt_note_head;
+
   /* True if the bfd contains symbols that have the STT_GNU_IFUNC
      symbol type or STB_GNU_UNIQUE binding.  Used to set the osabi
      field in the ELF header structure.  */
index 0bb0c5a..71de844 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -8417,6 +8417,35 @@ elfobj_grok_gnu_note (bfd *abfd, Elf_Internal_Note *note)
 }
 
 static bfd_boolean
+elfobj_grok_stapsdt_note_1 (bfd *abfd, Elf_Internal_Note *note)
+{
+  struct sdt_note *cur =
+    (struct sdt_note *) bfd_alloc (abfd, sizeof (struct sdt_note)
+                                  + note->descsz);
+
+  cur->next = (struct sdt_note *) (elf_tdata (abfd))->sdt_note_head;
+  cur->size = (bfd_size_type) note->descsz;
+  memcpy (cur->data, note->descdata, note->descsz);
+
+  elf_tdata (abfd)->sdt_note_head = cur;
+
+  return TRUE;
+}
+
+static bfd_boolean
+elfobj_grok_stapsdt_note (bfd *abfd, Elf_Internal_Note *note)
+{
+  switch (note->type)
+    {
+    case NT_STAPSDT:
+      return elfobj_grok_stapsdt_note_1 (abfd, note);
+
+    default:
+      return TRUE;
+    }
+}
+
+static bfd_boolean
 elfcore_netbsd_get_lwpid (Elf_Internal_Note *note, int *lwpidp)
 {
   char *cp;
@@ -9189,6 +9218,12 @@ elf_parse_notes (bfd *abfd, char *buf, size_t size, file_ptr offset)
              if (! elfobj_grok_gnu_note (abfd, &in))
                return FALSE;
            }
+         else if (in.namesz == sizeof "stapsdt"
+                  && strcmp (in.namedata, "stapsdt") == 0)
+           {
+             if (! elfobj_grok_stapsdt_note (abfd, &in))
+               return FALSE;
+           }
          break;
        }
 
index 752730e..a43b34d 100644 (file)
@@ -1,3 +1,7 @@
+2011-04-15  Sergio Durigan Junior  <sergiodj@redhat.com>
+
+       * common.h (NT_STAPSDT): New define.
+
 2011-03-31  Bernd Schmidt  <bernds@codesourcery.com>
 
        * tic6x.h (R_C6000_JUMP_SPLOT, R_C6000_EHTYPE,
index 52ce9a5..d48c32c 100644 (file)
@@ -1,6 +1,6 @@
 /* ELF support for BFD.
    Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
    Free Software Foundation, Inc.
 
    Written by Fred Fish @ Cygnus Support, from information published
 #define NT_LWPSINFO    17              /* Has a struct lwpsinfo_t */
 #define NT_WIN32PSTATUS        18              /* Has a struct win32_pstatus */
 
+/* Note segment for SystemTap probes.  */
+#define NT_STAPSDT     3
 
 /* Note segments for core files on NetBSD systems.  Note name
    must start with "NetBSD-CORE".  */