summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Wielaard <mjw@redhat.com>2009-05-14 19:07:10 +0200
committerMark Wielaard <mjw@redhat.com>2009-05-14 19:12:45 +0200
commit01a419e428f33d115a72fa8eac1d808825d2cae5 (patch)
tree6ee203741edf7f30dee6c8791edb0fb868a99c9b
parent9af6145187da9e21a606f9737ddb4aa45ac6282d (diff)
downloadsystemtap-steved-01a419e428f33d115a72fa8eac1d808825d2cae5.tar.gz
systemtap-steved-01a419e428f33d115a72fa8eac1d808825d2cae5.tar.xz
systemtap-steved-01a419e428f33d115a72fa8eac1d808825d2cae5.zip
PR10139 Mark .probes section SHF_ALLOC.
* includes/sys/sdt.h (STAP_PROBE_DATA_): Mark .probes section SHF_ALLOC. * tapsets.cxx (dwarf_builder::build): Search in either dwarf or main elf file for .probes section.
-rw-r--r--includes/sys/sdt.h3
-rw-r--r--tapsets.cxx18
2 files changed, 19 insertions, 2 deletions
diff --git a/includes/sys/sdt.h b/includes/sys/sdt.h
index f89b736a..5899549c 100644
--- a/includes/sys/sdt.h
+++ b/includes/sys/sdt.h
@@ -19,8 +19,9 @@
#define STAP_PROBE_ADDR "\t.long "
#endif
+/* An allocated section .probes that holds the probe names and addrs. */
#define STAP_PROBE_DATA_(probe) \
- __asm__ volatile (".section .probes\n" \
+ __asm__ volatile (".section .probes, \"a\"\n" \
"\t.align 8\n" \
"1:\n\t.asciz " #probe "\n" \
"\t.align 4\n" \
diff --git a/tapsets.cxx b/tapsets.cxx
index 0e419e96..a027c083 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -5642,12 +5642,12 @@ dwarf_builder::build(systemtap_session & sess,
Elf_Scn *probe_scn = NULL;
dwfl_assert ("getshstrndx", elf_getshstrndx (elf, &shstrndx));
+ GElf_Shdr shdr_mem;
GElf_Shdr *shdr = NULL;
// Is there a .probes section?
while ((probe_scn = elf_nextscn (elf, probe_scn)))
{
- GElf_Shdr shdr_mem;
shdr = gelf_getshdr (probe_scn, &shdr_mem);
assert (shdr != NULL);
@@ -5658,6 +5658,22 @@ dwarf_builder::build(systemtap_session & sess,
}
}
+ // Older versions put .probes section in the debuginfo dwarf file,
+ // so check if it actually exists, if not take the main elf file
+ if (probe_type == probes_and_dwarf && shdr->sh_type == SHT_NOBITS)
+ {
+ elf = dwfl_module_getelf (dw->module, &bias);
+ dwfl_assert ("getshstrndx", elf_getshstrndx (elf, &shstrndx));
+ probe_scn = NULL;
+ while ((probe_scn = elf_nextscn (elf, probe_scn)))
+ {
+ shdr = gelf_getshdr (probe_scn, &shdr_mem);
+ if (strcmp (elf_strptr (elf, shstrndx, shdr->sh_name),
+ ".probes") == 0)
+ break;
+ }
+ }
+
// We got our .probes section, extract data.
if (probe_type == probes_and_dwarf)
{