On Thu, May 25, 2023 at 4:02 PM HAGIO KAZUHITO(萩尾 一仁) <k-hagio-ab@nec.com> wrote:
From: Kazuhito Hagio <k-hagio-ab@nec.com>

Without the patch, a __pfx symbol having the same address as its module
text pseudo symbol is located at before the pseudo symbol and it is not
displayed by "sym" command, after loading module symbols.  For example,

  crash> sym -m dm_mod | head -n 3
  ffffffffc07e8000 MODULE TEXT START: dm_mod
  ffffffffc07e8000 (T) __pfx_dm_send_uevents
  ffffffffc07e8010 (T) dm_send_uevents
  crash> mod -s dm_mod
  crash> sym -m dm_mod | head -n 3
  ffffffffc07e8000 MODULE TEXT START: dm_mod
  ffffffffc07e8010 (T) dm_send_uevents
  ffffffffc07e81a0 (T) __pfx_dm_path_uevent
  crash> set debug 1
  crash> help -s
  ...
          loaded_objfile: 54dd800
    ffffffffc07e8000  __pfx_dm_send_uevents     << out of MOD_TEXT range
    ffffffffc07e8000  _MODULE_TEXT_START_dm_mod
    ffffffffc07e8010  dm_send_uevents
    ffffffffc07e81a0  __pfx_dm_path_uevent

Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
---
 symbols.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/symbols.c b/symbols.c
index a1e54c6f9f98..7153bf9a2dc1 100644
--- a/symbols.c
+++ b/symbols.c
@@ -3433,7 +3433,8 @@ compare_syms(const void *v1, const void *v2)
                        return -1;
                if (STRNEQ(s2->name, "__insmod"))
                        return 1;
-               if (STRNEQ(s2->name, "_MODULE_START_"))
+               if (MODULE_MEM_START(s2, MOD_TEXT) ||
+                   STRNEQ(s2->name, "_MODULE_START_"))

You are right. They have different *PSEUDO* symbol names:
_MODULE_TEXT_START_xxx and _MODULE_START_xxx.

And we also need to check for similar cases in all patches.

Thanks.
Lianbo

                        return 1;
                /* Get pseudo section name. */
                if (MODULE_SECTION_START(s1))
--
2.31.1