From 201e18a8841a2cb341a752ca180014a3b8fe5234 Mon Sep 17 00:00:00 2001 From: Eugeniy Meshcheryakov Date: Mon, 7 Sep 2009 11:01:14 +0200 Subject: Fix build-id check for relocatable kernel Save offset of build id relative to _stext instead of absolute address for kernel and apply relocations at run-time. This fixes Debian bug #545277 (http://bugs.debian.org/545277). --- translate.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'translate.cxx') diff --git a/translate.cxx b/translate.cxx index 9a25df61..88968d45 100644 --- a/translate.cxx +++ b/translate.cxx @@ -4928,11 +4928,12 @@ dump_unwindsyms (Dwfl_Module *m, c->output << ".build_id_len = " << build_id_len << ",\n"; /* XXX: kernel data boot-time relocation works differently from text. - This hack disables relocation altogether, but that's not necessarily + This hack assumes that offset between _stext and build id + stays constant after relocation, but that's not necessarily correct either. We may instead need a relocation basis different from _stext, such as __start_notes. */ if (modname == "kernel") - c->output << ".build_id_offset = 0x" << hex << build_id_vaddr + c->output << ".build_id_offset = 0x" << hex << build_id_vaddr - (base + extra_offset) << dec << ",\n"; else c->output << ".build_id_offset = 0x" << hex -- cgit From 89ba308506249736c6d0c8490d3c897af4e42df8 Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Tue, 8 Sep 2009 20:23:42 -0400 Subject: PR10524: reduce massive-uprobe script modules' .data consumption The general approach is to rip out task_finder_tgt's from all over the place (including the unwindsym vmcbs, and the stap_uprobe_specs), and instead have a small handful of them: one for all unwindsyms, and one per abstract probed process (PID or NAME). These are in turn shared by all new stap_unwind_specs by index. Before: probe process("./stap").function("*") -rw-r--r--. 1 fche users 11775283 2009-09-08 20:26 /var/tmp/fche/systemtap/cache/96/stap_96c0479d674db55ec98d8a8750a790e7_7989596.ko text data bss dec hex filename 445158 8351944 4306472 13103574 c7f1d6 /var/tmp/fche/systemtap/cache/96/stap_96c0479d674db55ec98d8a8750a790e7_7989596.ko After: (Note how data shrank, though text gained a bit in const-init-data.) -rw-r--r--. 1 fche users 4021569 2009-09-08 20:27 /var/tmp/fche/systemtap/cache/e4/stap_e46e88634efd850b1586e81c231c239a_8058419.ko text data bss dec hex filename 1896511 2192 4324808 6223511 5ef697 /var/tmp/fche/systemtap/cache/e4/stap_e46e88634efd850b1586e81c231c239a_8058419.ko * tapsets.cxx (uprobe_derived_probe_group): Rewrite emit_module_decls, and adjust emit_module_init. * runtime/sym.c (_stp_sym_init): Initialize unwindsyms-shared vmcb. * runtime/sym.h (_stp_module): Remove *vmcb field. * translate.cxx (emit_module_init, dump_unwindsyms): Adapt. * translate.h (assert_0_indent): Flush output before possibly assert-failing. --- translate.cxx | 36 ++++-------------------------------- 1 file changed, 4 insertions(+), 32 deletions(-) (limited to 'translate.cxx') diff --git a/translate.cxx b/translate.cxx index 88968d45..e32f932a 100644 --- a/translate.cxx +++ b/translate.cxx @@ -1161,22 +1161,12 @@ c_unparser::emit_module_init () o->newline(-1) << "}"; o->newline() << "#endif"; - // PR10228: set up symbol table-related task finders - o->newline() << "#if defined(STP_NEED_VMA_TRACKER) && defined(CONFIG_UTRACE)"; + // PR10228: set up symbol table-related task finders. + o->newline() << "#if defined(STP_NEED_VMA_TRACKER)"; o->newline() << "_stp_sym_init();"; - o->newline() << "for (i=0; i<_stp_num_modules; i++) {"; - o->newline(1) << "if (_stp_modules[i]->vmcb) {"; - o->newline(1) << "rc = stap_register_task_finder_target (_stp_modules[i]->vmcb);"; - o->newline() << "if (rc) {"; - o->newline(1) << "_stp_error (" - << "\"couldn't initialize task-finder for %s\\n\"," - << "_stp_modules[i]->vmcb->procname);"; - o->newline() << "goto out;"; - o->newline(-1) << "}"; - o->newline(-1) << "}"; - o->newline(-1) << "}"; o->newline() << "#endif"; - + // NB: we don't need per-_stp_module task_finders, since a single common one + // set up in runtime/sym.c's _stp_sym_init() will scan through all _stp_modules. o->newline() << "(void) probe_point;"; o->newline() << "(void) i;"; o->newline() << "(void) j;"; @@ -4857,27 +4847,9 @@ dump_unwindsyms (Dwfl_Module *m, mainfile = canonicalize_file_name(mainfile); - // PR10228: populate the task_finder_vmcb. - if (modname[0] == '/') // user-space module - { - // NB: runtime/sym.c - c->output << "static struct stap_task_finder_target _stp_vmcb_" << stpmod_idx << "= {\n"; - c->output << "#ifdef CONFIG_UTRACE\n"; - c->output << ".procname = " << lex_cast_qstring (mainfile) << ",\n"; - c->output << ".mmap_callback = &_stp_tf_mmap_cb,\n"; - c->output << ".munmap_callback = &_stp_tf_munmap_cb,\n"; - c->output << "#endif\n"; - c->output << "};\n"; - } - c->output << "static struct _stp_module _stp_module_" << stpmod_idx << " = {\n"; c->output << ".name = " << lex_cast_qstring (modname) << ", \n"; c->output << ".path = " << lex_cast_qstring (mainfile) << ",\n"; - - // PR10228: populate the task_finder_vmcb. - if (modname[0] == '/') // user-space module - c->output << ".vmcb = & _stp_vmcb_" << stpmod_idx << ",\n"; - c->output << ".dwarf_module_base = 0x" << hex << base << dec << ", \n"; c->output << ".eh_frame_addr = 0x" << hex << eh_addr << dec << ", \n"; -- cgit