* [PATCH 1/6] Make BFD read `.stapsdt' section from binary
@ 2011-04-04 3:08 Sergio Durigan Junior
2011-04-11 21:07 ` Jan Kratochvil
0 siblings, 1 reply; 4+ messages in thread
From: Sergio Durigan Junior @ 2011-04-04 3:08 UTC (permalink / raw)
To: gdb-patches; +Cc: binutils, Tom Tromey
Hi,
The following patch implements the necessary code to make BFD read the
`.stapsdt' note section from the binary file. It basically allocates a
linked-list where each entry contains information about one SystemTap
probe.
It was regtested on the compile farm.
Thanks,
Sergio.
From 1f7a8198c27ab823f191b713dae3641d108f1212 Mon Sep 17 00:00:00 2001
From: Sergio Durigan Junior <sergiodj@redhat.com>
Date: Mon, 28 Mar 2011 20:32:20 -0300
Subject: [PATCH 1/6] patch 0: BFD patch
---
bfd/ChangeLog | 9 +++++++++
bfd/elf-bfd.h | 14 ++++++++++++++
bfd/elf.c | 37 +++++++++++++++++++++++++++++++++++++
3 files changed, 60 insertions(+), 0 deletions(-)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 1c34293..cfcffba 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,12 @@
+2011-04-04 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-01 Tristan Gingold <gingold@adacore.com>
* elfxx-ia64.c: include bfd_stdint.h
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index 21ec38f..d50823a 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -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. Used to set the osabi field in the ELF header
structure. */
diff --git a/bfd/elf.c b/bfd/elf.c
index f69abf2..3c038eb 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -8416,6 +8416,37 @@ elfobj_grok_gnu_note (bfd *abfd, Elf_Internal_Note *note)
}
}
+#define SDT_NOTE_TYPE 3
+
+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 SDT_NOTE_TYPE:
+ return elfobj_grok_stapsdt_note_1 (abfd, note);
+
+ default:
+ return TRUE;
+ }
+}
+
static bfd_boolean
elfcore_netbsd_get_lwpid (Elf_Internal_Note *note, int *lwpidp)
{
@@ -9189,6 +9220,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;
}
--
1.7.3.4
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/6] Make BFD read `.stapsdt' section from binary
2011-04-04 3:08 [PATCH 1/6] Make BFD read `.stapsdt' section from binary Sergio Durigan Junior
@ 2011-04-11 21:07 ` Jan Kratochvil
2011-04-14 20:22 ` Sergio Durigan Junior
0 siblings, 1 reply; 4+ messages in thread
From: Jan Kratochvil @ 2011-04-11 21:07 UTC (permalink / raw)
To: Sergio Durigan Junior; +Cc: gdb-patches, binutils, Tom Tromey
On Mon, 04 Apr 2011 05:08:03 +0200, Sergio Durigan Junior wrote:
> --- a/bfd/elf.c
> +++ b/bfd/elf.c
> @@ -8416,6 +8416,37 @@ elfobj_grok_gnu_note (bfd *abfd, Elf_Internal_Note *note)
> }
> }
>
> +#define SDT_NOTE_TYPE 3
I guess this should be in include/elf/common.h named for example NT_STAPSDT.
Thanks,
Jan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/6] Make BFD read `.stapsdt' section from binary
2011-04-11 21:07 ` Jan Kratochvil
@ 2011-04-14 20:22 ` Sergio Durigan Junior
2011-04-15 11:14 ` Nick Clifton
0 siblings, 1 reply; 4+ messages in thread
From: Sergio Durigan Junior @ 2011-04-14 20:22 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: gdb-patches, binutils, Tom Tromey
Jan Kratochvil <jan.kratochvil@redhat.com> writes:
> On Mon, 04 Apr 2011 05:08:03 +0200, Sergio Durigan Junior wrote:
>> --- a/bfd/elf.c
>> +++ b/bfd/elf.c
>> @@ -8416,6 +8416,37 @@ elfobj_grok_gnu_note (bfd *abfd, Elf_Internal_Note *note)
>> }
>> }
>>
>> +#define SDT_NOTE_TYPE 3
>
> I guess this should be in include/elf/common.h named for example NT_STAPSDT.
Sorry for the delay. Here goes the updated version of the patch.
Thanks for the review!
---
bfd/ChangeLog | 9 +++++++++
bfd/elf-bfd.h | 14 ++++++++++++++
bfd/elf.c | 35 +++++++++++++++++++++++++++++++++++
include/elf/ChangeLog | 4 ++++
include/elf/common.h | 3 +++
5 files changed, 65 insertions(+), 0 deletions(-)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index ce76b34..765eab8 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,12 @@
+2011-04-14 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
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index 844610d..39c7de6 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -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. */
diff --git a/bfd/elf.c b/bfd/elf.c
index 0bb0c5a..71de844 100644
--- 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;
}
diff --git a/include/elf/ChangeLog b/include/elf/ChangeLog
index 752730e..8e30979 100644
--- a/include/elf/ChangeLog
+++ b/include/elf/ChangeLog
@@ -1,3 +1,7 @@
+2011-04-14 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,
diff --git a/include/elf/common.h b/include/elf/common.h
index 52ce9a5..a937c6c 100644
--- a/include/elf/common.h
+++ b/include/elf/common.h
@@ -549,6 +549,9 @@
#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". */
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/6] Make BFD read `.stapsdt' section from binary
2011-04-14 20:22 ` Sergio Durigan Junior
@ 2011-04-15 11:14 ` Nick Clifton
0 siblings, 0 replies; 4+ messages in thread
From: Nick Clifton @ 2011-04-15 11:14 UTC (permalink / raw)
To: Sergio Durigan Junior; +Cc: Jan Kratochvil, gdb-patches, binutils, Tom Tromey
Hi Sergio,
> +2011-04-14 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-14 Sergio Durigan Junior<sergiodj@redhat.com>
> +
> + * common.h (NT_STAPSDT): New define.
> +
Approved and applied.
Cheers
Nick
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-04-15 11:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-04 3:08 [PATCH 1/6] Make BFD read `.stapsdt' section from binary Sergio Durigan Junior
2011-04-11 21:07 ` Jan Kratochvil
2011-04-14 20:22 ` Sergio Durigan Junior
2011-04-15 11:14 ` Nick Clifton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).