public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: Di Chen <dichen@redhat.com>
To: systemtap@sourceware.org
Subject: [PATCH] PR29997: Fix the symbol aliases search failure when symbol version is missing
Date: Sun, 5 Nov 2023 11:59:36 +0800	[thread overview]
Message-ID: <CAN-Pu7SWRFvM12Q8PPjj_WLkQs8fTdVCyZuAjd22=wDR=uRm7A@mail.gmail.com> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 2858 bytes --]

From 9273dc95658b109f048e4ec9b0fcde96e34f3419 Mon Sep 17 00:00:00 2001
From: Di Chen <dichen@redhat.com>
Date: Sun, 5 Nov 2023 11:23:50 +0800
Subject: [PATCH] PR29997: Fix the symbol aliases search failure when symbol
 version is missing

After calling module_info::update_symtab, function aliases will be
populated. Then the updated symtab will be used for symbol searching.

For the _IO_new_fopen familty with the aliases:

  $ eu-readelf -s /lib64/libc.so.6  | grep 0000000000077440
    247: 0000000000077440     14 FUNC    WEAK   DEFAULT       16 fopen64@
@GLIBC_2.2.5
   1014: 0000000000077440     14 FUNC    GLOBAL DEFAULT       16 fopen@
@GLIBC_2.2.5
   1028: 0000000000077440     14 FUNC    GLOBAL DEFAULT       16 _IO_fopen@
@GLIBC_2.2.5
   1556: 0000000000077440     14 FUNC    LOCAL  DEFAULT       16 _IO_fopen64
   3471: 0000000000077440     14 FUNC    LOCAL  DEFAULT       16 __new_fopen
   4765: 0000000000077440     14 FUNC    LOCAL  DEFAULT       16
_IO_new_fopen
   5110: 0000000000077440     14 FUNC    WEAK   DEFAULT       16 fopen64
   7198: 0000000000077440     14 FUNC    GLOBAL DEFAULT       16 fopen@
@GLIBC_2.2.5
   7433: 0000000000077440     14 FUNC    GLOBAL DEFAULT       16 _IO_fopen@
@GLIBC_2.2.5

  a) fopen@@GLIBC_2.2.5 exists in the updated symtab
  b) fopen does not exist in the updated symtab

This PR is to add a version info padding when symbol cannot be found in
the updated symtab.

Signed-off-by: Di Chen <dichen@redhat.com>
---
 dwflpp.cxx | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/dwflpp.cxx b/dwflpp.cxx
index a4f66440f..22e1479c9 100644
--- a/dwflpp.cxx
+++ b/dwflpp.cxx
@@ -1052,6 +1052,15 @@ dwflpp::iterate_over_functions<void>(int
(*callback)(Dwarf_Die*, void*),
     }

   auto range = v->equal_range(function);
+  // version info padding if the symbol is not found
+  if (range.first == range.second)
+    {
+    std::string function_with_ver = function + "@";
+    for (auto it = v->begin(); it != v->end(); ++it)
+      if (it->first.find(function_with_ver) == 0)
+        function_with_ver = it->first;
+    range = v->equal_range(function_with_ver);
+    }
   if (range.first != range.second)
     {
       for (auto it = range.first; it != range.second; ++it)
@@ -1138,6 +1147,15 @@ dwflpp::iterate_single_function<void>(int
(*callback)(Dwarf_Die*, void*),
     }

   auto range = v->equal_range(function);
+  // version info padding if the symbol is not found
+  if (range.first == range.second)
+    {
+    std::string function_with_ver = function + "@";
+    for (auto it = v->begin(); it != v->end(); ++it)
+      if (it->first.find(function_with_ver) == 0)
+        function_with_ver = it->first;
+    range = v->equal_range(function_with_ver);
+    }
   if (range.first != range.second)
     {
       for (auto it = range.first; it != range.second; ++it)
-- 
2.41.0

[-- Attachment #2: 0001-PR29997-Fix-the-symbol-aliases-search-failure-when-s.patch --]
[-- Type: text/x-patch, Size: 2856 bytes --]

From 9273dc95658b109f048e4ec9b0fcde96e34f3419 Mon Sep 17 00:00:00 2001
From: Di Chen <dichen@redhat.com>
Date: Sun, 5 Nov 2023 11:23:50 +0800
Subject: [PATCH] PR29997: Fix the symbol aliases search failure when symbol
 version is missing

After calling module_info::update_symtab, function aliases will be
populated. Then the updated symtab will be used for symbol searching.

For the _IO_new_fopen familty with the aliases:

  $ eu-readelf -s /lib64/libc.so.6  | grep 0000000000077440
    247: 0000000000077440     14 FUNC    WEAK   DEFAULT       16 fopen64@@GLIBC_2.2.5
   1014: 0000000000077440     14 FUNC    GLOBAL DEFAULT       16 fopen@@GLIBC_2.2.5
   1028: 0000000000077440     14 FUNC    GLOBAL DEFAULT       16 _IO_fopen@@GLIBC_2.2.5
   1556: 0000000000077440     14 FUNC    LOCAL  DEFAULT       16 _IO_fopen64
   3471: 0000000000077440     14 FUNC    LOCAL  DEFAULT       16 __new_fopen
   4765: 0000000000077440     14 FUNC    LOCAL  DEFAULT       16 _IO_new_fopen
   5110: 0000000000077440     14 FUNC    WEAK   DEFAULT       16 fopen64
   7198: 0000000000077440     14 FUNC    GLOBAL DEFAULT       16 fopen@@GLIBC_2.2.5
   7433: 0000000000077440     14 FUNC    GLOBAL DEFAULT       16 _IO_fopen@@GLIBC_2.2.5

  a) fopen@@GLIBC_2.2.5 exists in the updated symtab
  b) fopen does not exist in the updated symtab

This PR is to add a version info padding when symbol cannot be found in
the updated symtab.

Signed-off-by: Di Chen <dichen@redhat.com>
---
 dwflpp.cxx | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/dwflpp.cxx b/dwflpp.cxx
index a4f66440f..22e1479c9 100644
--- a/dwflpp.cxx
+++ b/dwflpp.cxx
@@ -1052,6 +1052,15 @@ dwflpp::iterate_over_functions<void>(int (*callback)(Dwarf_Die*, void*),
     }
 
   auto range = v->equal_range(function);
+  // version info padding if the symbol is not found
+  if (range.first == range.second)
+    {
+    std::string function_with_ver = function + "@";
+    for (auto it = v->begin(); it != v->end(); ++it)
+      if (it->first.find(function_with_ver) == 0)
+        function_with_ver = it->first;
+    range = v->equal_range(function_with_ver);
+    }
   if (range.first != range.second)
     {
       for (auto it = range.first; it != range.second; ++it)
@@ -1138,6 +1147,15 @@ dwflpp::iterate_single_function<void>(int (*callback)(Dwarf_Die*, void*),
     }
 
   auto range = v->equal_range(function);
+  // version info padding if the symbol is not found
+  if (range.first == range.second)
+    {
+    std::string function_with_ver = function + "@";
+    for (auto it = v->begin(); it != v->end(); ++it)
+      if (it->first.find(function_with_ver) == 0)
+        function_with_ver = it->first;
+    range = v->equal_range(function_with_ver);
+    }
   if (range.first != range.second)
     {
       for (auto it = range.first; it != range.second; ++it)
-- 
2.41.0


             reply	other threads:[~2023-11-05  3:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-05  3:59 Di Chen [this message]
2023-11-20 16:05 ` Aaron Merey
2023-12-20  2:56   ` Di Chen
2024-01-18  0:15     ` Aaron Merey
2024-01-31  2:45       ` Di Chen
2024-01-31 22:38         ` Aaron Merey

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='CAN-Pu7SWRFvM12Q8PPjj_WLkQs8fTdVCyZuAjd22=wDR=uRm7A@mail.gmail.com' \
    --to=dichen@redhat.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).