[sysprof] elf: skip past /sysroot/ when symbol resolving



commit 605cdfc3f165c2847351208945945d09475fc769
Author: Christian Hergert <chergert redhat com>
Date:   Wed Mar 17 12:56:38 2021 -0700

    elf: skip past /sysroot/ when symbol resolving
    
    The /sysroot/ convention is something we see on OSTree-based systems
    such as Silverblue or CoreOS which contains the running image. We can
    skip that part of the path so that symbol resolving continues as normal.
    
    We are starting to come into a situation where we need more advanced
    path translations because we keep having to do things like this. Until
    Linux figures out file-system namespaces at a higher level at least.

 src/libsysprof/sysprof-elf-symbol-resolver.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
---
diff --git a/src/libsysprof/sysprof-elf-symbol-resolver.c b/src/libsysprof/sysprof-elf-symbol-resolver.c
index 2049e24..4135ae5 100644
--- a/src/libsysprof/sysprof-elf-symbol-resolver.c
+++ b/src/libsysprof/sysprof-elf-symbol-resolver.c
@@ -146,13 +146,24 @@ sysprof_elf_symbol_resolver_load (SysprofSymbolResolver *resolver,
         {
           const SysprofCaptureMap *ev = sysprof_capture_reader_read_map (reader);
           SysprofMapLookaside *lookaside = g_hash_table_lookup (self->lookasides, GINT_TO_POINTER 
(ev->frame.pid));
+          const char *filename;
           SysprofMap map;
 
+          /* Some systems using OSTree will have /sysroot/ as a prefix for
+           * filenames, which we want to skip over so that we can resolve the
+           * files as we see them inside the user-space view of the system.
+           */
+
+          if (memcmp (ev->filename, "/sysroot/", 9) == 0)
+            filename = ev->filename + 9;
+          else
+            filename = ev->filename;
+
           map.start = ev->start;
           map.end = ev->end;
           map.offset = ev->offset;
           map.inode = ev->inode;
-          map.filename = ev->filename;
+          map.filename = filename;
 
           if (lookaside == NULL)
             {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]