• Masahiro Yamada's avatar
    modpost: check static EXPORT_SYMBOL* by modpost again · 6d62b1c4
    Masahiro Yamada authored
    Commit 31cb50b5 ("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: default avatarMasahiro Yamada <masahiroy@kernel.org>
    Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
    6d62b1c4
Makefile.build 17.4 KB