This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 1/3] PR4886: Extract build-id from debuginfo file.


Hi,

Update the previous patch for checking build-id. It will cover kernel and external module. For non-build-id case, it will run as normal. Only does work in case of LD >=2.18 and kernel >=2.6.23.

The patch will provide sanity checking through validating debuginfo based-on build-id. The build-id information will be stored into _stp_module.
---
runtime/sym.h | 10 ++++++++++
translate.cxx | 39 +++++++++++++++++++++++++++++++++++++++
2 files changed, 49 insertions(+), 0 deletions(-)


diff --git a/runtime/sym.h b/runtime/sym.h
index 5888d2c..f8034d6 100644
--- a/runtime/sym.h
+++ b/runtime/sym.h
@@ -45,6 +45,16 @@ struct _stp_module {
        uint32_t unwind_data_len;
        uint32_t unwind_hdr_len;
        uint32_t unwind_is_ehframe; /* unwind data comes from .eh_frame */
+       /* build-id information */
+       unsigned char *build_id_bits;
+       unsigned long  build_id_offset;
+       unsigned long  notes_sect; /* kernel: 1 - no build-id
+                                             2 - has build-id
+                                     module: 0 - unloaded
+                                             1 - loaded and no build-id
+                                             Other - note address
+                                  */
+       int build_id_len;
 };


diff --git a/translate.cxx b/translate.cxx index e92c848..a9695f1 100644 --- a/translate.cxx +++ b/translate.cxx @@ -4413,6 +4413,23 @@ dump_unwindsyms (Dwfl_Module *m, int syments = dwfl_module_getsymtab(m); assert(syments);

+ //extract build-id from debuginfo file
+ int build_id_len = 0;
+ unsigned char *build_id_bits;
+ GElf_Addr build_id_vaddr;
+
+ if ((build_id_len=dwfl_module_build_id(m,
+ (const unsigned char **)&build_id_bits,
+ &build_id_vaddr)) > 0)
+ {
+ if (c->session.verbose > 1) {
+ clog << "Found build-id in " << name
+ << ", length " << build_id_len;
+ clog << ", end at 0x" << hex << build_id_vaddr
+ << dec << endl;
+ }
+ }
+
// Look up the relocation basis for symbols
int n = dwfl_module_relocations (m);


@@ -4581,6 +4598,28 @@ dump_unwindsyms (Dwfl_Module *m,
c->output << ".num_sections = sizeof(_stp_module_" << stpmod_idx << "_sections)/"
<< "sizeof(struct _stp_section), " << endl;


+ if (build_id_len > 0) {
+ c->output << ".build_id_bits = \"" ;
+ for (int j=0; j<build_id_len;j++)
+ c->output << "\\x" << hex
+ << (unsigned short) *(build_id_bits+j) << dec;
+
+ c->output << "\", " << endl;
+ c->output << ".build_id_len = " << build_id_len << ", " << endl;
+
+ if (modname == "kernel")
+ c->output << ".build_id_offset = 0x" << hex << build_id_vaddr
+ << dec << ", " << endl;
+ else
+ c->output << ".build_id_offset = 0x" << hex
+ << build_id_vaddr - base
+ << dec << ", " << endl;
+ } else
+ c->output << ".build_id_len = 0, " << endl;
+
+ //initialize the note section representing unloaded
+ c->output << ".notes_sect = 0," << endl;
+
c->output << "};" << endl << endl;


   c->undone_unwindsym_modules.erase (modname);
--
1.5.6


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]