title: Linux /proc/kallsyms file, where does kernel save core symbols list?
body: <p>To display symbols in <code>/proc/kallsyms</code>, for the module symbols, kernel loops over module objects headed by <code>modules</code> 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:</p>
  
  <pre><code>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] &gt;= 0)
          return kallsyms_offsets[idx];
  
      /* ...and negative offsets are relative to kallsyms_relative_base - 1 */
      return kallsyms_relative_base - 1 - kallsyms_offsets[idx];
  }
  </code></pre>
  
  <p>Questions are:</p>
  
  <ol>
  <li>where are kallsyms_addresses and kallsyms_offsets arrays defined? I tried to grep in kernel source but only find references, no definitions.</li>
  <li>where are they initialized?</li>
  <li>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.</li>
  </ol>