1. 28 6月, 2020 1 次提交
  2. 17 6月, 2020 4 次提交
    • M
      scripts: Fix typo in headers_install.sh · 0f50d21a
      Masanari Iida 提交于
      This patch fixes a spelling typo in scripts/headers_install.sh
      Signed-off-by: NMasanari Iida <standby24x7@gmail.com>
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      0f50d21a
    • M
      kconfig: unify cc-option and as-option · 4d0831e8
      Masahiro Yamada 提交于
      cc-option and as-option are almost the same; both pass the flag to
      $(CC). The main difference is the cc-option stops before the assemble
      stage (-S option) whereas as-option stops after (-c option).
      
      I chose -S because it is slightly faster, but $(cc-option,-gz=zlib)
      returns a wrong result (https://lkml.org/lkml/2020/6/9/1529).
      It has been fixed by commit 7b169944 ("Makefile: Improve compressed
      debug info support detection"), but the assembler should always be
      invoked for more reliable compiler option tests.
      
      However, you cannot simply replace -S with -c because the following
      code in lib/Kconfig.debug would break:
      
          depends on $(cc-option,-gsplit-dwarf)
      
      The combination of -c and -gsplit-dwarf does not accept /dev/null as
      output.
      
        $ cat /dev/null | gcc -gsplit-dwarf -S -x c - -o /dev/null
        $ echo $?
        0
      
        $ cat /dev/null | gcc -gsplit-dwarf -c -x c - -o /dev/null
        objcopy: Warning: '/dev/null' is not an ordinary file
        $ echo $?
        1
      
        $ cat /dev/null | gcc -gsplit-dwarf -c -x c - -o tmp.o
        $ echo $?
        0
      
      There is another flag that creates an separate file based on the
      object file path:
      
        $ cat /dev/null | gcc -ftest-coverage -c -x c - -o /dev/null
        <stdin>:1: error: cannot open /dev/null.gcno
      
      So, we cannot use /dev/null to sink the output.
      
      Align the cc-option implementation with scripts/Kbuild.include.
      
      With -c option used in cc-option, as-option is unneeded.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      Acked-by: NWill Deacon <will@kernel.org>
      4d0831e8
    • S
      recordmcount: support >64k sections · 4ef57b21
      Sami Tolvanen 提交于
      When compiling a kernel with Clang and LTO, we need to run
      recordmcount on vmlinux.o with a large number of sections, which
      currently fails as the program doesn't understand extended
      section indexes. This change adds support for processing binaries
      with >64k sections.
      
      Link: https://lkml.kernel.org/r/20200424193046.160744-1-samitolvanen@google.com
      Link: https://lore.kernel.org/lkml/CAK7LNARbZhoaA=Nnuw0=gBrkuKbr_4Ng_Ei57uafujZf7Xazgw@mail.gmail.com/
      
      Cc: Kees Cook <keescook@chromium.org>
      Reviewed-by: NMatt Helsley <mhelsley@vmware.com>
      Signed-off-by: NSami Tolvanen <samitolvanen@google.com>
      Signed-off-by: NSteven Rostedt (VMware) <rostedt@goodmis.org>
      4ef57b21
    • M
      kbuild: improve cc-option to clean up all temporary files · f2f02ebd
      Masahiro Yamada 提交于
      When cc-option and friends evaluate compiler flags, the temporary file
      $$TMP is created as an output object, and automatically cleaned up.
      The actual file path of $$TMP is .<pid>.tmp, here <pid> is the process
      ID of $(shell ...) invoked from cc-option. (Please note $$$$ is the
      escape sequence of $$).
      
      Such garbage files are cleaned up in most cases, but some compiler flags
      create additional output files.
      
      For example, -gsplit-dwarf creates a .dwo file.
      
      When CONFIG_DEBUG_INFO_SPLIT=y, you will see a bunch of .<pid>.dwo files
      left in the top of build directories. You may not notice them unless you
      do 'ls -a', but the garbage files will increase every time you run 'make'.
      
      This commit changes the temporary object path to .tmp_<pid>/tmp, and
      removes .tmp_<pid> directory when exiting. Separate build artifacts such
      as *.dwo will be cleaned up all together because their file paths are
      usually determined based on the base name of the object.
      
      Another example is -ftest-coverage, which outputs the coverage data into
      <base-name-of-object>.gcno
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      f2f02ebd
  3. 16 6月, 2020 1 次提交
  4. 12 6月, 2020 3 次提交
  5. 11 6月, 2020 5 次提交
  6. 10 6月, 2020 1 次提交
  7. 09 6月, 2020 1 次提交
    • M
      scripts/dtc: use pkg-config to include <yaml.h> in non-standard path · f8d8b46c
      Masahiro Yamada 提交于
      Commit 067c650c ("dtc: Use pkg-config to locate libyaml") added
      'pkg-config --libs' to link libyaml installed in a non-standard
      location.
      
      yamltree.c includes <yaml.h>, but that commit did not add the search
      path for <yaml.h>. If /usr/include/yaml.h does not exist, it fails to
      build. A user can explicitly pass HOSTCFLAGS to work around it, but
      the policy is not consistent.
      
      There are two ways to deal with libraries in a non-default location.
      
      [1] Use HOSTCFLAGS and HOSTLDFLAGS for additional search paths for
          headers and libraries.
          They are documented in Documentation/kbuild/kbuild.rst
      
          $ make HOSTCFLAGS='-I <prefix>/include' HOSTLDFLAGS='-L <prefix>/lib'
      
      [2] Use pkg-config
      
          'pkg-config --cflags' for querying the header search path
          'pkg-config --libs'   for querying the lib and its path
      
      If we go with pkg-config, use [2] consistently. Do not mix up
      [1] and [2].
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      Signed-off-by: NRob Herring <robh@kernel.org>
      f8d8b46c
  8. 08 6月, 2020 1 次提交
  9. 06 6月, 2020 23 次提交
    • D
      kbuild: add variables for compression tools · 8dfb61dc
      Denis Efremov 提交于
      Allow user to use alternative implementations of compression tools,
      such as pigz, pbzip2, pxz. For example, multi-threaded tools to
      speed up the build:
      $ make GZIP=pigz BZIP2=pbzip2
      
      Variables _GZIP, _BZIP2, _LZOP are used internally because original env
      vars are reserved by the tools. The use of GZIP in gzip tool is obsolete
      since 2015. However, alternative implementations (e.g., pigz) still rely
      on it. BZIP2, BZIP, LZOP vars are not obsolescent.
      
      The credit goes to @grsecurity.
      
      As a sidenote, for multi-threaded lzma, xz compression one can use:
      $ export XZ_OPT="--threads=0"
      Signed-off-by: NDenis Efremov <efremov@linux.com>
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      8dfb61dc
    • A
      mksysmap: Fix the mismatch of '.L' symbols in System.map · 72d24acc
      ashimida 提交于
      When System.map was generated, the kernel used mksysmap to
      filter the kernel symbols, but all the symbols with the
      second letter 'L' in the kernel were filtered out, not just
      the symbols starting with 'dot + L'.
      
      For example:
      ashimida@ubuntu:~/linux$ cat System.map |grep ' .L'
      ashimida@ubuntu:~/linux$ nm -n vmlinux |grep ' .L'
      ffff0000088028e0 t bLength_show
      ......
      ffff0000092e0408 b PLLP_OUTC_lock
      ffff0000092e0410 b PLLP_OUTA_lock
      
      The original intent should be to filter out all local symbols
      starting with '.L', so the dot should be escaped.
      
      Fixes: 00902e98 ("mksysmap: Add h8300 local symbol pattern")
      Signed-off-by: Nashimida <ashimida@linux.alibaba.com>
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      72d24acc
    • M
      modpost: change elf_info->size to size_t · 3b09efc4
      Masahiro Yamada 提交于
      Align with the mmap / munmap APIs.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      3b09efc4
    • M
      modpost: remove is_vmlinux() helper · 4de7b629
      Masahiro Yamada 提交于
      Now that is_vmlinux() is called only in new_module(), we can inline
      the function call.
      
      modname is the basename with '.o' is stripped. No need to compare it
      with 'vmlinux.o'.
      
      vmlinux is always located at the current working directory. No need
      to strip the directory path.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      4de7b629
    • M
      modpost: strip .o from modname before calling new_module() · a82f794c
      Masahiro Yamada 提交于
      new_module() conditionally strips the .o because the modname has .o
      suffix when it is called from read_symbols(), but no .o when it is
      called from read_dump().
      
      It is clearer to strip .o in read_symbols().
      
      I also used flexible-array for mod->name.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      a82f794c
    • M
      modpost: set have_vmlinux in new_module() · 858b937d
      Masahiro Yamada 提交于
      Set have_vmlinux flag in a single place.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      858b937d
    • M
      modpost: remove mod->skip struct member · 0b19d54c
      Masahiro Yamada 提交于
      The meaning of 'skip' is obscure since it does not explain
      "what to skip".
      
      mod->skip is set when it is vmlinux or the module info came from
      a dump file.
      
      So, mod->skip is equivalent to (mod->is_vmlinux || mod->from_dump).
      
      For the check in write_namespace_deps_files(), mod->is_vmlinux is
      unneeded because the -d option is not passed in the first pass of
      modpost.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      0b19d54c
    • M
      modpost: add mod->is_vmlinux struct member · 5a438af9
      Masahiro Yamada 提交于
      is_vmlinux() is called in several places to check whether the current
      module is vmlinux or not.
      
      It is faster and clearer to check mod->is_vmlinux flag.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      5a438af9
    • M
      modpost: remove is_vmlinux() call in check_for_{gpl_usage,unused}() · 1be5fa6c
      Masahiro Yamada 提交于
      check_exports() is never called for vmlinux because mod->skip is set
      for vmlinux.
      
      Hence, check_for_gpl_usage() and check_for_unused() are not called
      for vmlinux, either. is_vmlinux() is always false here.
      
      Remove the is_vmlinux() calls, and hard-code the ".ko" suffix.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      1be5fa6c
    • M
      modpost: remove mod->is_dot_o struct member · 3379576d
      Masahiro Yamada 提交于
      Previously, there were two cases where mod->is_dot_o is unset:
      
      [1] the executable 'vmlinux' in the second pass of modpost
      [2] modules loaded by read_dump()
      
      I think [1] was intended usage to distinguish 'vmlinux.o' and 'vmlinux'.
      Now that modpost does not parse the executable 'vmlinux', this case
      does not happen.
      
      [2] is obscure, maybe a bug. Module.symver stores module paths without
      extension. So, none of modules loaded by read_dump() has the .o suffix,
      and new_module() unsets ->is_dot_o. Anyway, it is not a big deal because
      handle_symbol() is not called for the case.
      
      To sum up, all the parsed ELF files are .o files.
      
      mod->is_dot_o is unneeded.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      3379576d
    • M
      modpost: move -d option in scripts/Makefile.modpost · 859c926a
      Masahiro Yamada 提交于
      Collect options for modules into a single place.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      859c926a
    • M
      modpost: remove -s option · 467b82d7
      Masahiro Yamada 提交于
      The -s option was added by commit 8d8d8289 ("kbuild: do not do
      section mismatch checks on vmlinux in 2nd pass").
      
      Now that the second pass does not parse vmlinux, this option is
      unneeded.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      467b82d7
    • M
      modpost: remove get_next_text() and make {grab,release_}file static · 75893572
      Masahiro Yamada 提交于
      get_next_line() is no longer used. Remove.
      
      grab_file() and release_file() are only used in modpost.c. Make them
      static.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      75893572
    • M
      modpost: use read_text_file() and get_line() for reading text files · 70f30cfe
      Masahiro Yamada 提交于
      grab_file() mmaps a file, but it is not so efficient here because
      get_next_line() copies every line to the temporary buffer anyway.
      
      read_text_file() and get_line() are simpler. get_line() exploits the
      library function strchr().
      
      Going forward, the missing *.symvers or *.cmd is a fatal error.
      This should not happen because scripts/Makefile.modpost guards the
      -i option files with $(wildcard $(input-symdump)).
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      70f30cfe
    • M
      modpost: avoid false-positive file open error · 7c8f5662
      Masahiro Yamada 提交于
      One problem of grab_file() is that it cannot distinguish the following
      two cases:
      
       - It cannot read the file (the file does not exist, or read permission
         is not set)
      
       - It can read the file, but the file size is zero
      
      This is because grab_file() calls mmap(), which requires the mapped
      length is greater than 0. Hence, grab_file() fails for both cases.
      
      If an empty header file were included for checksum calculation, the
      following warning would be printed:
      
        WARNING: modpost: could not open ...: Invalid argument
      
      An empty file is a valid source file, so it should not fail.
      
      Use read_text_file() instead. It can read a zero-length file.
      Then, parse_file() will succeed with doing nothing.
      
      Going forward, the first case (it cannot read the file) is a fatal
      error. If the source file from which an object was compiled is missing,
      something went wrong.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      7c8f5662
    • M
      modpost: fix potential mmap'ed file overrun in get_src_version() · f531c1b5
      Masahiro Yamada 提交于
      I do not know how reliably this function works, but it looks dangerous
      to me.
      
          strchr(sources, '\n');
      
      ... continues searching until it finds '\n' or it reaches the '\0'
      terminator. In other words, 'sources' should be a null-terminated
      string.
      
      However, grab_file() just mmaps a file, so 'sources' is not terminated
      with null byte. If the file does not contain '\n' at all, strchr() will
      go beyond the mmap'ed memory.
      
      Use read_text_file(), which loads the file content into a malloc'ed
      buffer, appending null byte.
      
      Here we are interested only in the first line of *.mod files. Use
      get_line() helper to get the first line.
      
      This also makes missing *.mod file a fatal error.
      
      Commit 4be40e22 ("kbuild: do not emit src version warning for
      non-modules") ignored missing *.mod files.
      
      I do not fully understand what that commit addressed, but commit
      91341d4b ("kbuild: introduce new option to enhance section mismatch
      analysis") introduced partial section checks by using modpost. built-in.o
      was parsed by modpost. Even modules had a problem because *.mod files
      were created after the modpost check.
      
      Commit b7dca6dd ("kbuild: create *.mod with full directory path and
      remove MODVERDIR") stopped doing that. Now that modpost is only invoked
      after the directory descend, *.mod files should always exist at the
      modpost stage.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      f531c1b5
    • M
      modpost: add read_text_file() and get_line() helpers · ac5100f5
      Masahiro Yamada 提交于
      modpost uses grab_file() to open a file, but it is not suitable for
      a text file because the mmap'ed file is not terminated by null byte.
      Actually, I see some issues for the use of grab_file().
      
      The new helper, read_text_file() loads the whole file content into a
      malloc'ed buffer, and appends a null byte. Then, get_line() reads
      each line.
      
      To handle text files, I intend to replace as follows:
      
        grab_file()    -> read_text_file()
        get_new_line() -> get_line()
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      ac5100f5
    • M
      modpost: do not call get_modinfo() for vmlinux(.o) · 4ddea2f8
      Masahiro Yamada 提交于
      The three calls of get_modinfo() ("license", "import_ns", "version")
      always return NULL for vmlinux(.o) because the built-in module info is
      prefixed with __MODULE_INFO_PREFIX.
      
      It is harmless to call get_modinfo(), but there is no point to search
      for what apparently does not exist.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      4ddea2f8
    • M
      modpost: drop RCS/CVS $Revision handling in MODULE_VERSION() · f6931535
      Masahiro Yamada 提交于
      As far as I understood, this code gets rid of '$Revision$' or '$Revision:'
      of CVS, RCS or whatever in MODULE_VERSION() tags.
      
      Remove the primeval code.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      f6931535
    • M
      modpost: show warning if any of symbol dump files is missing · 48a0f727
      Masahiro Yamada 提交于
      If modpost fails to load a symbol dump file, it cannot check unresolved
      symbols, hence module dependency will not be added. Nor CRCs can be added.
      
      Currently, external module builds check only $(objtree)/Module.symvers,
      but it should check files specified by KBUILD_EXTRA_SYMBOLS as well.
      
      Move the warning message from the top Makefile to scripts/Makefile.modpost
      and print the warning if any dump file is missing.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      48a0f727
    • M
      modpost: show warning if vmlinux is not found when processing modules · 7e8a3235
      Masahiro Yamada 提交于
      check_exports() does not print warnings about unresolved symbols if
      vmlinux is missing because there would be too many.
      
      This situation happens when you do 'make modules' from the clean
      tree, or compile external modules against a kernel tree that has
      not been completely built.
      
      It is dangerous to not check unresolved symbols because you might be
      building useless modules. At least it should be warned.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      7e8a3235
    • M
      modpost: invoke modpost only when input files are updated · 436b2ac6
      Masahiro Yamada 提交于
      Currently, the second pass of modpost is always invoked when you run
      'make' or 'make modules' even if none of modules is changed.
      
      Use if_changed to invoke it only when it is necessary.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      436b2ac6
    • M
      modpost: generate vmlinux.symvers and reuse it for the second modpost · 269a535c
      Masahiro Yamada 提交于
      The full build runs modpost twice, first for vmlinux.o and second for
      modules.
      
      The first pass dumps all the vmlinux symbols into Module.symvers, but
      the second pass parses vmlinux again instead of reusing the dump file,
      presumably because it needs to avoid accumulating stale symbols.
      
      Loading symbol info from a dump file is faster than parsing an ELF object.
      Besides, modpost deals with various issues to parse vmlinux in the second
      pass.
      
      A solution is to make the first pass dumps symbols into a separate file,
      vmlinux.symvers. The second pass reads it, and parses module .o files.
      The merged symbol information is dumped into Module.symvers in the same
      way as before.
      
      This makes further modpost cleanups possible.
      
      Also, it fixes the problem of 'make vmlinux', which previously overwrote
      Module.symvers, throwing away module symbols.
      
      I slightly touched scripts/link-vmlinux.sh so that vmlinux is re-linked
      when you cross this commit. Otherwise, vmlinux.symvers would not be
      generated.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      269a535c