1. 23 Nov, 2019 6 commits
    • Masahiro Yamada's avatar
      modpost: respect the previous export when 'exported twice' is warned · 7ef9ab3b
      Masahiro Yamada authored
      When 'exported twice' is warned, let sym_add_exported() return without
      updating the symbol info. This respects the previous export, which is
      ordered first in modules.order
      
      This simplifies the code too.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      7ef9ab3b
    • Masahiro Yamada's avatar
      modpost: do not set ->preloaded for symbols from Module.symvers · e4b26c9f
      Masahiro Yamada authored
      Now that there is no overwrap between symbols from ELF files and
      ones from Module.symvers.
      
      So, the 'exported twice' warning should be reported irrespective
      of where the symbol in question came from.
      
      The exceptional case is external module; in some cases, we build
      an external module to provide a different version/variant of the
      corresponding in-kernel module, overriding the same set of exported
      symbols.
      
      You can see this use-case in upstream; tools/testing/nvdimm/libnvdimm.ko
      replaces drivers/nvdimm/libnvdimm.ko in order to link it against mocked
      version of core kernel symbols.
      
      So, let's relax the 'exported twice' warning when building external
      modules. The multiple export from external modules is warned only
      when the previous one is from vmlinux or itself.
      
      With this refactoring, the ugly preloading goes away.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      e4b26c9f
    • Masahiro Yamada's avatar
      modpost: stop symbol preloading for modversion CRC · 1743694e
      Masahiro Yamada authored
      It is complicated to add mocked-up symbols for pre-handling CRC.
      Handle CRC after all the export symbols in the relevant module
      are registered.
      
      Call handle_modversion() after the handle_symbol() iteration.
      
      In some cases, I see atand-alone __crc_* without __ksymtab_*.
      For example, ARCH=arm allyesconfig produces __crc_ccitt_veneer and
      __crc_itu_t_veneer. I guess they come from crc_ccitt, crc_itu_t,
      respectively. Since __*_veneer are auto-generated symbols, just
      ignore them.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      1743694e
    • Masahiro Yamada's avatar
      modpost: rename handle_modversions() to handle_symbol() · 9bd2a099
      Masahiro Yamada authored
      This function handles not only modversions, but also unresolved
      symbols, export symbols, etc.
      
      Rename it to a more proper function name.
      
      While I was here, I also added the 'const' qualifier to *sym.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      9bd2a099
    • Masahiro Yamada's avatar
      modpost: refactor namespace_from_kstrtabns() to not hard-code section name · e84f9fbb
      Masahiro Yamada authored
      Currently, namespace_from_kstrtabns() relies on the fact that
      namespace strings are recorded in the __ksymtab_strings section.
      Actually, it is coded in include/linux/export.h, but modpost does
      not need to hard-code the section name.
      
      Elf_Sym::st_shndx holds the index of the relevant section. Using it is
      a more portable way to get the namespace string.
      
      Make namespace_from_kstrtabns() simply call sym_get_data(), and delete
      the info->ksymtab_strings .
      
      While I was here, I added more 'const' qualifiers to pointers.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      e84f9fbb
    • Masahiro Yamada's avatar
      modpost: add a helper to get data pointed by a symbol · afa0459d
      Masahiro Yamada authored
      When CONFIG_MODULE_REL_CRCS is enabled, the value of __crc_* is not
      an absolute value, but the address to the CRC data embedded in the
      .rodata section.
      
      Getting the data pointed by the symbol value is somewhat complex.
      Split it out into a new helper, sym_get_data().
      
      I will reuse it to refactor namespace_from_kstrtabns() in the next
      commit.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      afa0459d
  2. 14 Nov, 2019 2 commits
    • Masahiro Yamada's avatar
      kbuild: move headers_check rule to usr/include/Makefile · 7ecaf069
      Masahiro Yamada authored
      Currently, some sanity checks for uapi headers are done by
      scripts/headers_check.pl, which is wired up to the 'headers_check'
      target in the top Makefile.
      
      It is true compiling headers has better test coverage, but there
      are still several headers excluded from the compile test. I like
      to keep headers_check.pl for a while, but we can delete a lot of
      code by moving the build rule to usr/include/Makefile.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      7ecaf069
    • Masahiro Yamada's avatar
      kbuild: remove header compile test · fcbb8461
      Masahiro Yamada authored
      There are both positive and negative options about this feature.
      At first, I thought it was a good idea, but actually Linus stated a
      negative opinion (https://lkml.org/lkml/2019/9/29/227). I admit it
      is ugly and annoying.
      
      The baseline I'd like to keep is the compile-test of uapi headers.
      (Otherwise, kernel developers have no way to ensure the correctness
      of the exported headers.)
      
      I will maintain a small build rule in usr/include/Makefile.
      Remove the other header test functionality.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      fcbb8461
  3. 11 Nov, 2019 32 commits