From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21495 invoked by alias); 4 Apr 2011 03:08:12 -0000 Received: (qmail 21478 invoked by uid 22791); 4 Apr 2011 03:08:11 -0000 X-SWARE-Spam-Status: No, hits=-6.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,TW_CP,TW_FX,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 04 Apr 2011 03:08:07 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p34387Rl015322 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 3 Apr 2011 23:08:07 -0400 Received: from psique (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p34383SF013064; Sun, 3 Apr 2011 23:08:04 -0400 From: Sergio Durigan Junior To: gdb-patches@sourceware.org Cc: binutils@sourceware.org, Tom Tromey Subject: [PATCH 1/6] Make BFD read `.stapsdt' section from binary Date: Mon, 04 Apr 2011 03:08:00 -0000 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-IsSubscribed: yes Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2011-04/txt/msg00018.txt.bz2 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 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 + + * elf-bfd.h (struct sdt_note): New struct. + (struct elf_obj_tdata) : 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 * 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