1. 06 Jun, 2020 8 commits
  2. 03 Jun, 2020 6 commits
    • Masahiro Yamada's avatar
      modpost: load KBUILD_EXTRA_SYMBOLS files in order · 2beee868
      Masahiro Yamada authored
      Currently, modpost reads extra symbol dump files in the reverse order.
      If '-e foo -e bar' is given, modpost reads bar, foo, in this order.
      
      This is probably not a big deal, but there is no good reason to reverse
      the order. Read files in the given order.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      2beee868
    • Masahiro Yamada's avatar
      modpost: pass -N option only for modules modpost · 4e5ab74c
      Masahiro Yamada authored
      The built-in only code is not required to have MODULE_IMPORT_NS() to
      use symbols. So, the namespace is not checked for vmlinux(.o).
      
      Do not pass the meaningless -N option to the first pass of modpost.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      4e5ab74c
    • Masahiro Yamada's avatar
      modpost: move -T option close to the modpost command · 89d61176
      Masahiro Yamada authored
      The '-T -' option reads the file list from stdin.
      
      It is clearer to put it close to the piped command.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      89d61176
    • Masahiro Yamada's avatar
      modpost: fix -i (--ignore-errors) MAKEFLAGS detection · 91e6ee58
      Masahiro Yamada authored
      $(filter -i,$(MAKEFLAGS)) works only in limited use-cases.
      
      The representation of $(MAKEFLAGS) depends on various factors:
        - GNU Make version (version 3.8x or version 4.x)
        - The presence of other flags like -j
      
      In my experiments, $(MAKEFLAGS) is expanded as follows:
      
        * GNU Make 3.8x:
      
          * without -j option:
            --no-print-directory -Rri
      
          * with -j option:
            --no-print-directory -Rr --jobserver-fds=3,4 -j -i
      
        * GNU Make 4.x:
      
          * without -j option:
            irR --no-print-directory
      
          * with -j option:
            irR -j --jobserver-fds=3,4 --no-print-directory
      
      For GNU Make 4.x, the flags are grouped as 'irR', which does not work.
      
      For the single thread build with GNU Make 3.8x, the flags are grouped
      as '-Rri', which does not work either.
      
      To make it work for all cases, do likewise as commit 6f0fa58e
      ("kbuild: simplify silent build (-s) detection").
      
      BTW, since commit ff9b45c5 ("kbuild: modpost: read modules.order
      instead of $(MODVERDIR)/*.mod"), you also need to pass -k option to
      build final *.ko files. 'make -i -k' ignores compile errors in modules,
      and build as many remaining *.ko as possible.
      
      Please note this feature is kind of dangerous if other modules depend
      on the broken module because the generated modules will lack the correct
      module dependency or CRC. Honestly, I am not a big fan of it, but I am
      keeping this feature.
      
      Fixes: eed380f3 ("modpost: Optionally ignore secondary errors seen if a single module build fails")
      Cc: Guenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      91e6ee58
    • Masahiro Yamada's avatar
      kbuild: update modules.order only when contained modules are updated · b2c88554
      Masahiro Yamada authored
      Make modules.order depend on $(obj-m), and use if_changed to build it.
      This will avoid unneeded update of modules.order, which will be useful
      to optimize the modpost stage.
      
      Currently, the second pass of modpost is always invoked. By checking the
      timestamp of modules.order, we can avoid the unneeded modpost.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      b2c88554
    • Masahiro Yamada's avatar
      kbuild: refactor KBUILD_VMLINUX_{OBJS,LIBS} calculation · f0d50ca0
      Masahiro Yamada authored
      Do not overwrite core-y or drivers-y. Remove libs-y1 and libs-y2.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      f0d50ca0
  3. 01 Jun, 2020 6 commits
  4. 28 May, 2020 4 commits
    • Nick Desaulniers's avatar
      Makefile: support compressed debug info · 10e68b02
      Nick Desaulniers authored
      As debug information gets larger and larger, it helps significantly save
      the size of vmlinux images to compress the information in the debug
      information sections. Note: this debug info is typically split off from
      the final compressed kernel image, which is why vmlinux is what's used
      in conjunction with GDB. Minimizing the debug info size should have no
      impact on boot times, or final compressed kernel image size.
      
      All of the debug sections will have a `C` flag set.
      $ readelf -S <object file>
      
      $ bloaty vmlinux.gcc75.compressed.dwarf4 -- \
          vmlinux.gcc75.uncompressed.dwarf4
      
          FILE SIZE        VM SIZE
       --------------  --------------
        +0.0%     +18  [ = ]       0    [Unmapped]
       -73.3%  -114Ki  [ = ]       0    .debug_aranges
       -76.2% -2.01Mi  [ = ]       0    .debug_frame
       -73.6% -2.89Mi  [ = ]       0    .debug_str
       -80.7% -4.66Mi  [ = ]       0    .debug_abbrev
       -82.9% -4.88Mi  [ = ]       0    .debug_ranges
       -70.5% -9.04Mi  [ = ]       0    .debug_line
       -79.3% -10.9Mi  [ = ]       0    .debug_loc
       -39.5% -88.6Mi  [ = ]       0    .debug_info
       -18.2%  -123Mi  [ = ]       0    TOTAL
      
      $ bloaty vmlinux.clang11.compressed.dwarf4 -- \
          vmlinux.clang11.uncompressed.dwarf4
      
          FILE SIZE        VM SIZE
       --------------  --------------
        +0.0%     +23  [ = ]       0    [Unmapped]
       -65.6%    -871  [ = ]       0    .debug_aranges
       -77.4% -1.84Mi  [ = ]       0    .debug_frame
       -82.9% -2.33Mi  [ = ]       0    .debug_abbrev
       -73.1% -2.43Mi  [ = ]       0    .debug_str
       -84.8% -3.07Mi  [ = ]       0    .debug_ranges
       -65.9% -8.62Mi  [ = ]       0    .debug_line
       -86.2% -40.0Mi  [ = ]       0    .debug_loc
       -42.0% -64.1Mi  [ = ]       0    .debug_info
       -22.1%  -122Mi  [ = ]       0    TOTAL
      
      For x86_64 defconfig + LLVM=1 (before):
      Elapsed (wall clock) time (h:mm:ss or m:ss): 3:22.03
      Maximum resident set size (kbytes): 43856
      
      For x86_64 defconfig + LLVM=1 (after):
      Elapsed (wall clock) time (h:mm:ss or m:ss): 3:32.52
      Maximum resident set size (kbytes): 1566776
      
      Thanks to:
      Nick Clifton helped us to provide the minimal binutils version.
      Sedat Dilek found an increase in size of debug .deb package.
      
      Cc: Nick Clifton <nickc@redhat.com>
      Suggested-by: default avatarDavid Blaikie <blaikie@google.com>
      Reviewed-by: default avatarFangrui Song <maskray@google.com>
      Tested-by: default avatarSedat Dilek <sedat.dilek@gmail.com>
      Signed-off-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      10e68b02
    • Masahiro Yamada's avatar
      modpost: refactor sech_name() · 565587d8
      Masahiro Yamada authored
      Use sym_get_data_by_offset() helper to get access to the .shstrtab
      section data. No functional change is intended because
      elf->sechdrs[elf->secindex_strings].sh_addr is 0 for both ET_REL
      and ET_EXEC object types.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      565587d8
    • Masahiro Yamada's avatar
      modpost: fix potential segmentation fault for addend_i386_rel() · d2e4d05c
      Masahiro Yamada authored
      This may not be a practical problem, but the second pass of ARCH=i386
      modpost causes segmentation fault if the -s option is not passed.
      
          MODPOST 12 modules
        Segmentation fault (core dumped)
        make[2]: *** [scripts/Makefile.modpost:94: __modpost] Error 139
        make[1]: *** [Makefile:1339: modules] Error 2
        make[1]: *** Waiting for unfinished jobs....
      
      The segmentation fault occurs when section_rel() is called for vmlinux,
      which is untested in regular builds. The cause of the problem is
      reloc_location() returning a wrong pointer for ET_EXEC object type.
      In this case, you need to subtract sechdr->sh_addr, otherwise it would
      get access beyond the mmap'ed memory.
      
      Add sym_get_data_by_offset() helper to avoid code duplication.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      d2e4d05c
    • Masahiro Yamada's avatar
      kbuild: disallow multi-word in M= or KBUILD_EXTMOD · e9e81b63
      Masahiro Yamada authored
      $(firstword ...) in scripts/Makefile.modpost was added by commit
      3f3fd3c0 ("[PATCH] kbuild: allow multi-word $M in Makefile.modpost")
      to build multiple external module directories.
      
      It was a solution to resolve symbol dependencies when an external
      module depends on another external module.
      
      Commit 0d96fb20 ("kbuild: Add new Kbuild variable
      KBUILD_EXTRA_SYMBOLS") introduced another solution by passing symbol
      info via KBUILD_EXTRA_SYMBOLS, then broke the multi-word M= support.
      
        include $(if $(wildcard $(KBUILD_EXTMOD)/Kbuild), \
                     $(KBUILD_EXTMOD)/Kbuild, $(KBUILD_EXTMOD)/Makefile)
      
      ... does not work if KBUILD_EXTMOD contains multiple words.
      
      This feature has been broken for more than a decade. Remove the
      bitrotten code, and stop parsing if M or KBUILD_EXTMOD contains
      multiple words.
      
      As Documentation/kbuild/modules.rst explains, if your module depends
      on another one, there are two solutions:
        - add a common top-level Kbuild file
        - use KBUILD_EXTRA_SYMBOLS
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      e9e81b63
  5. 25 May, 2020 16 commits