public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: Victor Kamensky <kamensky@cisco.com>
To: systemtap@sourceware.org
Subject: [PATCH 6/6] sysroot: _stp_umodule_relocate needs receive target file path
Date: Mon, 05 Mar 2018 17:38:00 -0000	[thread overview]
Message-ID: <1520271479-7960-7-git-send-email-kamensky@cisco.com> (raw)
In-Reply-To: <1520271479-7960-1-git-send-email-kamensky@cisco.com>

Strip of sysroot from module name is required when
_stp_umodule_relocate call is generated. Otherwise path won't
match path on target and could will fail to calculated address
within the file. Note in another place in tapsets.cxx where
_stp_umodule_relocate is emitted path_remove_sysroot is already
applied.

Here are steps how to reproduce the issue. Note <sysroot> is produced by
yocto poky build.

[kamensky@coreos-lnx2 tests]$ cat od.stp
probe process("/usr/bin/od.coreutils").function("main").call {
  printf ("%s: flag_dump_strings=0x%x\n", ppfunc(), $flag_dump_strings)
}
[kamensky@coreos-lnx2 tests]$ /home/wd8/systemtap/20180208_2/packages/bin/stap --sysroot=/home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs -a x86_64 -r 4.9.78-yocto-standard -B CROSS_COMPILE=x86_64-poky-linux- --sysenv=PATH=/usr/bin:/bin:/usr/sbin:/sbin --sysenv=LD_LIBRARY_PATH=/lib:/usr/lib -p4 -k -m od od.stp
od.ko
Keeping temporary directory "/tmp/stapdnaaGF"
[kamensky@coreos-lnx2 tests]$ grep _stp_umodule_relocate /tmp/stapdnaaGF/od_src.c
  l->__retvalue = uderef(1, ((((int64_t) (/* pragma:vma */ ({ unsigned long addr = 0; addr = _stp_umodule_relocate ("/home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs/usr/bin/od.coreutils", 0x212212, current); addr; }))))));

Note above _stp_umodule_relocate call was emitted with file path
on the host, it will fail once executed on target.

Signed-off-by: Victor Kamensky <kamensky@cisco.com>
---
 loc2stap.cxx | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/loc2stap.cxx b/loc2stap.cxx
index 4818ee088..e2339a45e 100644
--- a/loc2stap.cxx
+++ b/loc2stap.cxx
@@ -17,6 +17,7 @@
 
 #include "loc2stap.h"
 #include "dwflpp.h"
+#include "tapsets.h"
 
 #if ! _ELFUTILS_PREREQ(0, 153)
 #define DW_OP_GNU_entry_value 0xf3
@@ -106,7 +107,7 @@ location_context::translate_address(Dwarf_Addr addr)
           c = "/* pragma:vma */ "
               "({ unsigned long addr = 0; "
               "addr = _stp_umodule_relocate (\""
-              + resolve_path(dw->module_name.c_str()) + "\", "
+              + path_remove_sysroot(dw->sess, resolve_path(dw->module_name.c_str())) + "\", "
               + lex_cast_hex (addr)
 	      + ", current); addr; })";
 	}
-- 
2.14.3

  parent reply	other threads:[~2018-03-05 17:38 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-05 17:38 [PATCH 0/6] systemtap set of --sysroot option handling fixes Victor Kamensky
2018-03-05 17:38 ` [PATCH 2/6] sysroot: fix short release -r option handling in case of sysroot pass proper kernel modules Victor Kamensky
2018-03-14 22:10   ` David Smith
2018-03-16  5:24     ` Victor Kamensky
2018-03-05 17:38 ` [PATCH 5/6] sysroot: handle symbolic links with absolute name relative to sysroot Victor Kamensky
2018-03-21 16:36   ` David Smith
2018-03-05 17:38 ` [PATCH 4/6] sysroot: delay adding sysroot path to module name in case of non absolute executable Victor Kamensky
2018-03-19 13:54   ` David Smith
2018-03-19 21:51     ` David Smith
2018-03-05 17:38 ` [PATCH 1/6] sysroot: fix short release -r option handling in case of sysroot read System.map symbols Victor Kamensky
2018-03-08 22:10   ` David Smith
2018-03-05 17:38 ` [PATCH 3/6] sysroot: debuginfo lookup with sysroot case do not remove sysroot from file_name Victor Kamensky
2018-03-08 22:50   ` David Smith
2018-03-09  7:21     ` Victor Kamensky
2018-03-09 20:20       ` Victor Kamensky
2018-03-14 21:56         ` David Smith
2018-03-05 17:38 ` Victor Kamensky [this message]
2018-03-21 16:42 ` [PATCH 0/6] systemtap set of --sysroot option handling fixes David Smith
2018-03-22  8:02   ` Victor Kamensky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1520271479-7960-7-git-send-email-kamensky@cisco.com \
    --to=kamensky@cisco.com \
    --cc=systemtap@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).