Linux /proc/kallsyms file, where does kernel save core symbols list?

女生的网名这么多〃 提交于 2020-03-02 05:36:25

问题


To display symbols in /proc/kallsyms, for the module symbols, kernel loops over module objects headed by modules kernel variable, and iterate over each module's symbol table. But for the 'core' kernel built-in symbols, it uses a bunch of kernel variables, demonstrated in this function:

static unsigned long kallsyms_sym_address(int idx)
{
    if (!IS_ENABLED(CONFIG_KALLSYMS_BASE_RELATIVE))
        return kallsyms_addresses[idx];

    /* values are unsigned offsets if --absolute-percpu is not in effect */
    if (!IS_ENABLED(CONFIG_KALLSYMS_ABSOLUTE_PERCPU))
        return kallsyms_relative_base + (u32)kallsyms_offsets[idx];

    /* ...otherwise, positive offsets are absolute values */
    if (kallsyms_offsets[idx] >= 0)
        return kallsyms_offsets[idx];

    /* ...and negative offsets are relative to kallsyms_relative_base - 1 */
    return kallsyms_relative_base - 1 - kallsyms_offsets[idx];
}

Questions are:

  1. where are kallsyms_addresses and kallsyms_offsets arrays defined? I tried to grep in kernel source but only find references, no definitions.
  2. where are they initialized?
  3. what's the relation between these variables and /boot/System.map.kernel_version file? I assume they should be consistent but again I didn't find the initialization code.

来源:https://stackoverflow.com/questions/59146865/linux-proc-kallsyms-file-where-does-kernel-save-core-symbols-list

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!