lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAK7LNAS5xSQTjDuu+dsNW2fOz1-s7x0gsCLmfQOnGpb5CY06KA@mail.gmail.com>
Date:   Sat, 24 Sep 2022 11:11:04 +0900
From:   Masahiro Yamada <masahiroy@...nel.org>
To:     Nick Desaulniers <ndesaulniers@...gle.com>
Cc:     Michal Marek <michal.lkml@...kovi.net>,
        Linux Kbuild mailing list <linux-kbuild@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        clang-built-linux <llvm@...ts.linux.dev>,
        Bill Wendling <morbo@...gle.com>,
        Greg Thelen <gthelen@...gle.com>,
        Alexey Alexandrov <aalexand@...gle.com>,
        Nathan Chancellor <nathan@...nel.org>
Subject: Re: [PATCH v4] Makefile.debug: re-enable debug info for .S files

On Tue, Sep 20, 2022 at 2:45 AM Nick Desaulniers
<ndesaulniers@...gle.com> wrote:
>
> Alexey reported that the fraction of unknown filename instances in
> kallsyms grew from ~0.3% to ~10% recently; Bill and Greg tracked it down
> to assembler defined symbols, which regressed as a result of:
>
> commit b8a9092330da ("Kbuild: do not emit debug info for assembly with LLVM_IAS=1")
>
> In that commit, I allude to restoring debug info for assembler defined
> symbols in a follow up patch, but it seems I forgot to do so in
>
> commit a66049e2cf0e ("Kbuild: make DWARF version a choice")
>
> Link: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=31bf18645d98b4d3d7357353be840e320649a67d
> Fixes: b8a9092330da ("Kbuild: do not emit debug info for assembly with LLVM_IAS=1")
> Reported-by: Alexey Alexandrov <aalexand@...gle.com>
> Reported-by: Bill Wendling <morbo@...gle.com>
> Reported-by: Greg Thelen <gthelen@...gle.com>
> Reviewed-by: Nathan Chancellor <nathan@...nel.org>
> Suggested-by: Masahiro Yamada <masahiroy@...nel.org>
> Signed-off-by: Nick Desaulniers <ndesaulniers@...gle.com>
> ---
> Changes v3 -> v4:
> * Break out into its own patch.
> * Move addition of debug-flags-y to DEBUG_CFLAGS and KBUILD_AFLAGS up
>   grouping the -gdwarf-* handling together.
>
>  lib/Kconfig.debug      |  4 +++-
>  scripts/Makefile.debug | 18 +++++++++---------
>  2 files changed, 12 insertions(+), 10 deletions(-)
>
> diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> index bcbe60d6c80c..d3e5f36bb01e 100644
> --- a/lib/Kconfig.debug
> +++ b/lib/Kconfig.debug
> @@ -264,8 +264,10 @@ config DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
>  config DEBUG_INFO_DWARF4
>         bool "Generate DWARF Version 4 debuginfo"
>         select DEBUG_INFO
> +       depends on !CC_IS_CLANG || (CC_IS_CLANG && (AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502)))
>         help
> -         Generate DWARF v4 debug info. This requires gcc 4.5+ and gdb 7.0+.
> +         Generate DWARF v4 debug info. This requires gcc 4.5+, binutils 2.35.2
> +         if using clang without clang's integrated assembler, and gdb 7.0+.
>
>           If you have consumers of DWARF debug info that are not ready for
>           newer revisions of DWARF, you may wish to choose this or have your
> diff --git a/scripts/Makefile.debug b/scripts/Makefile.debug
> index 26d6a9d97a20..d6aecd78b942 100644
> --- a/scripts/Makefile.debug
> +++ b/scripts/Makefile.debug
> @@ -4,15 +4,15 @@ ifdef CONFIG_DEBUG_INFO_SPLIT
>  DEBUG_CFLAGS   += -gsplit-dwarf
>  endif
>
> -ifndef CONFIG_AS_IS_LLVM
> -KBUILD_AFLAGS  += -Wa,-gdwarf-2
> -endif
> -
> -ifndef CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
> -dwarf-version-$(CONFIG_DEBUG_INFO_DWARF4) := 4
> -dwarf-version-$(CONFIG_DEBUG_INFO_DWARF5) := 5
> -DEBUG_CFLAGS   += -gdwarf-$(dwarf-version-y)
> +debug-flags-$(CONFIG_DEBUG_INFO_DWARF4)        += -gdwarf-4
> +debug-flags-$(CONFIG_DEBUG_INFO_DWARF5)        += -gdwarf-5
> +ifeq ($(CONFIG_CC_IS_CLANG)$(CONFIG_AS_IS_GNU),yy)
> +# Clang does not pass -g or -gdwarf-* option down to GAS.




This patch still misses the debug info for *.S files
for the combination of LLVM_IAS=0 and
CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y
because, as the comment says, Clang does not pass -g down to GAS.


With "[v4] Makefile.debug: set -g unconditional on CONFIG_DEBUG_INFO_SPLIT"
and this one applied,



$ grep CONFIG_DEBUG_INFO_DWARF .config
CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y
# CONFIG_DEBUG_INFO_DWARF4 is not set
# CONFIG_DEBUG_INFO_DWARF5 is not set
$ make LLVM=1 LLVM_IAS=0 arch/x86/kernel/irqflags.o
  SYNC    include/config/auto.conf.cmd
  SYSHDR  arch/x86/include/generated/asm/unistd_32_ia32.h
  SYSHDR  arch/x86/include/generated/asm/unistd_64_x32.h
  SYSTBL  arch/x86/include/generated/asm/syscalls_64.h
  HOSTCC  arch/x86/tools/relocs_32.o
  [snip]
  AS      arch/x86/kernel/irqflags.o
$ objdump  -h arch/x86/kernel/irqflags.o | grep debug
$








I think the following fix-up is needed on top.




diff --git a/scripts/Makefile.debug b/scripts/Makefile.debug
index d6aecd78b942..8cf1cb22dd93 100644
--- a/scripts/Makefile.debug
+++ b/scripts/Makefile.debug
@@ -1,4 +1,5 @@
-DEBUG_CFLAGS   := -g
+DEBUG_CFLAGS   :=
+debug-flags-y  := -g

 ifdef CONFIG_DEBUG_INFO_SPLIT
 DEBUG_CFLAGS   += -gsplit-dwarf




Then, I can see the debug sections.



$ make LLVM=1 LLVM_IAS=0 arch/x86/kernel/irqflags.o
  CALL    scripts/checksyscalls.sh
  DESCEND objtool
  AS      arch/x86/kernel/irqflags.o
$ objdump -h arch/x86/kernel/irqflags.o | grep debug
  6 .debug_line   00000050  0000000000000000  0000000000000000  0000008f  2**0
  7 .debug_info   0000002e  0000000000000000  0000000000000000  000000f8  2**0
  8 .debug_abbrev 00000014  0000000000000000  0000000000000000  000001d0  2**0
  9 .debug_aranges 00000030  0000000000000000  0000000000000000  000001f0  2**4
 10 .debug_str    0000004d  0000000000000000  0000000000000000  00000250  2**0





If you agree, I can locally fix it up as such.





--
Best Regards
Masahiro Yamada

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ