1. 29 1月, 2020 2 次提交
  2. 22 1月, 2020 1 次提交
    • M
      kbuild: use -S instead of -E for precise cc-option test in Kconfig · 3bed1b7b
      Masahiro Yamada 提交于
      Currently, -E (stop after the preprocessing stage) is used to check
      whether the given compiler flag is supported.
      
      While it is faster than -S (or -c), it can be false-positive. You need
      to run the compilation proper to check the flag more precisely.
      
      For example, -E and -S disagree about the support of
      "--param asan-instrument-allocas=1".
      
      $ gcc -Werror --param asan-instrument-allocas=1 -E -x c /dev/null -o /dev/null
      $ echo $?
      0
      
      $ gcc -Werror --param asan-instrument-allocas=1 -S -x c /dev/null -o /dev/null
      cc1: error: invalid --param name ‘asan-instrument-allocas’; did you mean ‘asan-instrument-writes’?
      $ echo $?
      1
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      3bed1b7b
  3. 21 1月, 2020 1 次提交
  4. 16 1月, 2020 1 次提交
  5. 15 1月, 2020 2 次提交
    • M
      kbuild: remove *.tmp file when filechk fails · 88fe89a4
      Masahiro Yamada 提交于
      Bartosz Golaszewski reports that when "make {menu,n,g,x}config" fails
      due to missing packages, a temporary file is left over, which is not
      ignored by git.
      
      For example, if GTK+ is not installed:
      
        $ make gconfig
        *
        * Unable to find the GTK+ installation. Please make sure that
        * the GTK+ 2.0 development package is correctly installed.
        * You need gtk+-2.0 gmodule-2.0 libglade-2.0
        *
        scripts/kconfig/Makefile:208: recipe for target 'scripts/kconfig/gconf-cfg' failed
        make[1]: *** [scripts/kconfig/gconf-cfg] Error 1
        Makefile:567: recipe for target 'gconfig' failed
        make: *** [gconfig] Error 2
        $ git status
        HEAD detached at v5.4
        Untracked files:
          (use "git add <file>..." to include in what will be committed)
      
                scripts/kconfig/gconf-cfg.tmp
      
        nothing added to commit but untracked files present (use "git add" to track)
      
      This is because the check scripts are run with filechk, which misses
      to clean up the temporary file on failure.
      
      When the line
      
        { $(filechk_$(1)); } > $@.tmp;
      
      ... fails, it exits immediately due to the 'set -e'. Use trap to make
      sure to delete the temporary file on exit.
      
      For extra safety, I replaced $@.tmp with $(dot-target).tmp to make it
      a hidden file.
      Reported-by: NBartosz Golaszewski <bgolaszewski@baylibre.com>
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      88fe89a4
    • M
      modpost: assume STT_SPARC_REGISTER is defined · 5370d4ac
      Masahiro Yamada 提交于
      Commit 8d529014 ("[SPARC]: Deal with glibc changing macro names in
      modpost.c") was more than 14 years ago. STT_SPARC_REGISTER is hopefully
      defined in elf.h of recent C libraries.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      Acked-by: NDavid S. Miller <davem@davemloft.net>
      5370d4ac
  6. 14 1月, 2020 1 次提交
  7. 07 1月, 2020 5 次提交
    • M
      kbuild: create modules.builtin without Makefile.modbuiltin or tristate.conf · 8b41fc44
      Masahiro Yamada 提交于
      Commit bc081dd6 ("kbuild: generate modules.builtin") added
      infrastructure to generate modules.builtin, the list of all
      builtin modules.
      
      Basically, it works like this:
      
        - Kconfig generates include/config/tristate.conf, the list of
          tristate CONFIG options with a value in a capital letter.
      
        - scripts/Makefile.modbuiltin makes Kbuild descend into
          directories to collect the information of builtin modules.
      
      I am not a big fan of it because Kbuild ends up with traversing
      the source tree twice.
      
      I am not sure how perfectly it should work, but this approach cannot
      avoid false positives; even if the relevant CONFIG option is tristate,
      some Makefiles forces obj-m to obj-y.
      
      Some examples are:
      
        arch/powerpc/platforms/powermac/Makefile:
          obj-$(CONFIG_NVRAM:m=y)         += nvram.o
      
        net/ipv6/Makefile:
          obj-$(subst m,y,$(CONFIG_IPV6)) += inet6_hashtables.o
      
        net/netlabel/Makefile:
          obj-$(subst m,y,$(CONFIG_IPV6)) += netlabel_calipso.o
      
      Nobody has complained about (or noticed) it, so it is probably fine to
      have false positives in modules.builtin.
      
      This commit simplifies the implementation. Let's exploit the fact
      that every module has MODULE_LICENSE(). (modpost shows a warning if
      MODULE_LICENSE is missing. If so, 0-day bot would already have blocked
      such a module.)
      
      I added MODULE_FILE to <linux/module.h>. When the code is being compiled
      as builtin, it will be filled with the file path of the module, and
      collected into modules.builtin.info. Then, scripts/link-vmlinux.sh
      extracts the list of builtin modules out of it.
      
      This new approach fixes the false-positives above, but adds another
      type of false-positives; non-modular code may have MODULE_LICENSE()
      by mistake. This is not a big deal, it is just the code is always
      orphan. We can clean it up if we like. You can see cleanup examples by:
      
        $ git log --grep='make.* explicitly non-modular'
      
      To sum up, this commits deletes lots of code, but still produces almost
      equivalent results. Please note it does not increase the vmlinux size at
      all. As you can see in include/asm-generic/vmlinux.lds.h, the .modinfo
      section is discarded in the link stage.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      8b41fc44
    • M
      kbuild: pass KBUILD_MODFILE when compiling builtin objects · 1664a377
      Masahiro Yamada 提交于
      When compiling, Kbuild passes KBUILD_BASENAME (basename of the object)
      and KBUILD_MODNAME (basename of the module).
      
      This commit adds another one, KBUILD_MODFILE, which is the path of
      the module. (or, the path of the module it would end up in if it were
      compiled as a module.)
      
      The next commit will use this to generate modules.builtin without
      tristate.conf.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      1664a377
    • M
      kbuild: add stringify helper to quote a string passed to C files · 7e826c44
      Masahiro Yamada 提交于
      Make $(squote)$(quote)...$(quote)$(squote) a helper macro.
      I will reuse it in the next commit.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      7e826c44
    • M
      kbuild: use pattern rule for building built-in.a in sub-directories · a7499267
      Masahiro Yamada 提交于
      The built-in.a in a sub-directory is created by descending into that
      directory. It does not depend on the other sub-directories. Loosen
      the dependency.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      a7499267
    • M
      kbuild: do not create orphan built-in.a or obj-y objects · 56d58936
      Masahiro Yamada 提交于
      Both 'obj-y += foo/' and 'obj-m += foo/' request Kbuild to visit the
      sub-directory foo/, but the difference is that only the former combines
      foo/built-in.a into the built-in.a of the current directory because
      everything in sub-directories visited by obj-m is supposed to be modular.
      
      So, it makes sense to create built-in.a only if that sub-directory is
      reachable by the chain of obj-y. Otherwise, built-in.a will not be
      linked into vmlinux anyway. For the same reason, it is pointless to
      compile obj-y objects in the directory visited by obj-m.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      56d58936
  8. 03 1月, 2020 2 次提交
  9. 17 12月, 2019 2 次提交
  10. 14 12月, 2019 3 次提交
    • M
      scripts/kallsyms: fix offset overflow of kallsyms_relative_base · fd2ab2f6
      Masahiro Yamada 提交于
      Since commit 5e5c4fa7 ("scripts/kallsyms: shrink table before
      sorting it"), kallsyms_relative_base can be larger than _text, which
      causes overflow when building the 32-bit kernel.
      
      https://lkml.org/lkml/2019/12/7/156
      
      This is because _text is, unless --all-symbols is specified, now
      trimmed from the symbol table before record_relative_base() is called.
      
      Handle the offset signedness also for kallsyms_relative_base. Introduce
      a new helper, output_address(), to reduce the code duplication.
      
      Fixes: 5e5c4fa7 ("scripts/kallsyms: shrink table before sorting it")
      Reported-by: NOlof Johansson <olof@lixom.net>
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      fd2ab2f6
    • M
      mkcompile_h: use printf for LINUX_COMPILE_BY · c8f3dea9
      Masahiro Yamada 提交于
      Commit 858805b3 ("kbuild: add $(BASH) to run scripts with
      bash-extension") shed light on portability issues. Here is another one.
      
      Since commit f0772604 ("Fix handling of backlash character in
      LINUX_COMPILE_BY name"), we must escape a backslash contained in
      LINUX_COMPILE_BY. This is not working on such distros as Ubuntu.
      
      As the POSIX spec [1] says, if any of the operands contain a backslash
      ( '\' ) character, the results are implementation-defined.
      
      The actual shell of /bin/sh could be bash, dash, etc. depending on
      distros, and the behavior of builtin echo command is different among
      them.
      
      The bash builtin echo, unless -e is given, copies the arguments to
      stdout without expanding escape sequences (BSD-like behavior).
      
      The dash builtin echo, in contrast, adopts System V behavior, which
      does expand escape sequences without any option given.
      
      Even non-builtin /bin/echo behaves differently depending on the system.
      Due to these variations, echo is considered as a non-portable command.
      Using printf is the common solution to avoid the portability issue.
      
      [1] https://pubs.opengroup.org/onlinepubs/009695399/utilities/echo.html
      
      Fixes: 858805b3 ("kbuild: add $(BASH) to run scripts with bash-extension")
      Reported-by: NXXing Wei <xxing.wei@unisoc.com>
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      c8f3dea9
    • M
      mkcompile_h: git rid of UTS_TRUNCATE from LINUX_COMPILE_{BY,HOST} · e8193650
      Masahiro Yamada 提交于
      UTS_VERSION is set to struct uts_namespace, hence a too long string
      should be truncated so it fits in 64 characters.
      
      On the other hand, LINUX_COMPILE_BY/HOST are not set to uts_namespace.
      They are just used in the banners, which do not have specific length
      limitation.
      
      I dug into the git history, but I could not find the reason why
      these two strings must fit in 64 characters. Remove them.
      
      Now that UTS_VERSION is the only user of UTS_TRUNCATE, I squashed it.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      e8193650
  11. 06 12月, 2019 1 次提交
  12. 05 12月, 2019 3 次提交
  13. 01 12月, 2019 1 次提交
  14. 29 11月, 2019 1 次提交
    • S
      bpf: Force .BTF section start to zero when dumping from vmlinux · df786c9b
      Stanislav Fomichev 提交于
      While trying to figure out why fentry_fexit selftest doesn't pass for me
      (old pahole, broken BTF), I found out that my latest patch can break vmlinux
      .BTF generation. objcopy preserves section start when doing --only-section,
      so there is a chance (depending on where pahole inserts .BTF section) to
      have leading empty zeroes. Let's explicitly force section offset to zero.
      
      Before:
      
      $ objcopy --set-section-flags .BTF=alloc -O binary \
      	--only-section=.BTF vmlinux .btf.vmlinux.bin
      $ xxd .btf.vmlinux.bin | head -n1
      00000000: 0000 0000 0000 0000 0000 0000 0000 0000  ................
      
      After:
      
      $ objcopy --change-section-address .BTF=0 \
      	--set-section-flags .BTF=alloc -O binary \
      	--only-section=.BTF vmlinux .btf.vmlinux.bin
      $ xxd .btf.vmlinux.bin | head -n1
      00000000: 9feb 0100 1800 0000 0000 0000 80e1 1c00  ................
                ^BTF magic
      
      As part of this change, I'm also dropping '2>/dev/null' from objcopy
      invocation to be able to catch possible other issues (objcopy doesn't
      produce any warnings for me anymore, it did before with --dump-section).
      
      Fixes: da5fb182 ("bpf: Support pre-2.25-binutils objcopy for vmlinux BTF")
      Signed-off-by: NStanislav Fomichev <sdf@google.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: NJohn Fastabend <john.fastabend@gmail.com>
      Cc: Andrii Nakryiko <andriin@fb.com>
      Link: https://lore.kernel.org/bpf/20191127225759.39923-1-sdf@google.com
      df786c9b
  15. 28 11月, 2019 1 次提交
  16. 25 11月, 2019 13 次提交