diff options
-rw-r--r-- | includes/sys/sdt.h | 3 | ||||
-rw-r--r-- | tapsets.cxx | 18 |
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) { |