在/proc/kallsyms中重复名称 [英] Repeating names in /proc/kallsyms

查看:81
本文介绍了在/proc/kallsyms中重复名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么/proc/kallsyms中的某些符号重复?例如:我看到 _acpi_module_name __ this_module cleanup_module .LC0 重复多次.

Why do some symbols in /proc/kallsyms repeat? For eg: I see that _acpi_module_name, __this_module, cleanup_module, .LC0 repeat multiple times.

为什么会这样?为什么会有这样的符号,使一个名称解析为多个地址?我看到__acpi_module_name在/proc/kallsyms中重复了113次.

Why does this happen? Why are there symbols such that a name resolves to multiple addresses? I see __acpi_module_name repeat 113 times in /proc/kallsyms.

推荐答案

这些是不同的情况.

对于 _acpi_module_name ,它们只是静态全局变量.静态全局变量或函数仅在声明的文件中可见".它在 include/acpi/acoutput.h 中定义.

For _acpi_module_name, they are just static global variables. A static global variable or a function is "seen" only in the file it's declared in. It's defined in include/acpi/acoutput.h.

#define ACPI_MODULE_NAME(name)          static const char ACPI_UNUSED_VAR _acpi_module_name[] = name;

对于 __ this_module ,它们在每个内核模块中定义,并由 script/mod/modpost 添加.

For __this_module, they are defined in every kernel module, which is added by script/mod/modpost.

 /**
 * Header for the generated file
 **/
static void add_header(struct buffer *b, struct module *mod)
{
        buf_printf(b, "#include <linux/module.h>\n");
        buf_printf(b, "#include <linux/vermagic.h>\n");
        buf_printf(b, "#include <linux/compiler.h>\n");
        buf_printf(b, "\n");
        buf_printf(b, "MODULE_INFO(vermagic, VERMAGIC_STRING);\n");
        buf_printf(b, "MODULE_INFO(name, KBUILD_MODNAME);\n");
        buf_printf(b, "\n");
        buf_printf(b, "__visible struct module __this_module\n");
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        buf_printf(b, "__attribute__((section(\".gnu.linkonce.this_module\"))) = {\n");
        buf_printf(b, "\t.name = KBUILD_MODNAME,\n");
        if (mod->has_init)
                buf_printf(b, "\t.init = init_module,\n");
        if (mod->has_cleanup)
                buf_printf(b, "#ifdef CONFIG_MODULE_UNLOAD\n"
                              "\t.exit = cleanup_module,\n"
                              "#endif\n");
        buf_printf(b, "\t.arch = MODULE_ARCH_INIT,\n");
        buf_printf(b, "};\n");
}

对于 cleanup_module ,它在 include/linux/module.h

#define module_exit(exitfn)                                     \
        static inline exitcall_t __maybe_unused __exittest(void)                \
        { return exitfn; }                                      \
        void cleanup_module(void) __attribute__((alias(#exitfn)));
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#endif

对于 .LC0 ,它是编译器在不同的源文件中生成的标签,例如静态全局变量.

For .LC0, it's compiler generated label in different source file like static global variables.

这篇关于在/proc/kallsyms中重复名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆