modpost: check static EXPORT_SYMBOL* by modpost again
authorMasahiro Yamada <masahiroy@kernel.org>
Sun, 11 Jun 2023 15:50:54 +0000 (00:50 +0900)
committerMasahiro Yamada <masahiroy@kernel.org>
Thu, 22 Jun 2023 12:21:06 +0000 (21:21 +0900)
commit6d62b1c46b1e6e1686a0cf6617c96c80d4ab5cd5
treecd7844f90eb2d83679f0d1f31fbe556c8b1ed856
parent7d59313f19df0b55db6b31c5e4d4e828aa77d584
modpost: check static EXPORT_SYMBOL* by modpost again

Commit 31cb50b5590f ("kbuild: check static EXPORT_SYMBOL* by script
instead of modpost") moved the static EXPORT_SYMBOL* check from the
mostpost to a shell script because I thought it must be checked per
compilation unit to avoid false negatives.

I came up with an idea to do this in modpost, against combined ELF
files. The relocation entries in ELF will find the correct exported
symbol even if there exist symbols with the same name in different
compilation units.

Again, the same sample code.

  Makefile:

    obj-y += foo1.o foo2.o

  foo1.c:

    #include <linux/export.h>
    static void foo(void) {}
    EXPORT_SYMBOL(foo);

  foo2.c:

    void foo(void) {}

Then, modpost can catch it correctly.

    MODPOST Module.symvers
  ERROR: modpost: vmlinux: local symbol 'foo' was exported

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
scripts/Makefile.build
scripts/check-local-export [deleted file]
scripts/mod/modpost.c