Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp927309pxb; Tue, 3 Nov 2020 16:58:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJwzyF+wSJLDV2spokaBBENWLR+/BCSFmXH5z4N2HoF7+j/YwS06G6D5oiEZ1OsSYL6oMzyp X-Received: by 2002:a05:6402:a53:: with SMTP id bt19mr14064015edb.26.1604451481570; Tue, 03 Nov 2020 16:58:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604451481; cv=none; d=google.com; s=arc-20160816; b=nEWWWIAOxoj6pk4W+qrIx8MM3n0ZoBnT+KdwuRbNyLREP9BRZFTm5IXYZIKGDQ3IKA e+3eeD/hR0/gdfkDdzyhtZynZUNPeCVkxq4rQ4UD7834p52MUHcuCgYEMtkU1t5IhB3J qX8jSrDrtOFjr5vdNFUZYlFD8xSq0ggvvphskPjav9XygkwFs5vHWJqYXmeMJlDS762H 9ddl/2uiwn65KzWbjcMS4feUYiIXOTFGg958u9UYEn3NVLh1kv3m8RHCB0PDP1EnLOR9 3TQSN5+dJo9Xcx09bCmBYJPnfyGYBSdIE7KpLOfHIrA+IqzNRmUPen0r+GIT/Qg5aQMk /ULA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:sender:dkim-signature; bh=qAidyqNqiCb5KbKHSVTfkxVbZF8KiimMPZ6+hMhgskc=; b=PAZKNi5yaRFO374oSUGN7psPgovFBOstJfVpBpN8JBn/hjxWq+p0tnMpgEGDDvP9xx lBJ/Lls08C0Bci9Po04ASbkega4NndOZvdQq9yRjm0vqWP2+lOhf6dJxS+SDRAJmJztg feodbkz8Fj+Llc5tH9C+lNtn2YyhEuP638+iSxRLXs4pjhmu7tmJo8N4T0IU0pv4hbMp wWCWtysj2LirlN5RUAvZ/J8Ab11YV+ApRZJ+FzFZqOF1z7NOur5QvOl08HNNqPcVASHG nvAQppfq5v8BpJ3KxJi4K8qOlBy/0nJG/MVzwLXzwa9PTm9Iv/RbiwyIWAkq3rdTdwxw 3rmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=FYNNpzBX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lf3si387539ejb.78.2020.11.03.16.57.39; Tue, 03 Nov 2020 16:58:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=FYNNpzBX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730119AbgKDAyC (ORCPT + 99 others); Tue, 3 Nov 2020 19:54:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729711AbgKDAyC (ORCPT ); Tue, 3 Nov 2020 19:54:02 -0500 Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 095AAC040203 for ; Tue, 3 Nov 2020 16:54:02 -0800 (PST) Received: by mail-pg1-x54a.google.com with SMTP id s4so12407699pgk.17 for ; Tue, 03 Nov 2020 16:54:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=qAidyqNqiCb5KbKHSVTfkxVbZF8KiimMPZ6+hMhgskc=; b=FYNNpzBX6MFClVMxdOh7b6CkI9mB3OkTG7heA7Y2giClCmOwoSCWpJEL3OK24t9y6N EwAO3YFverf4ENM++ZVCMBeMwGSfpYOfttiyCwNXnn8ow6IbIMXIGVhAwy4dIhUyeO/t BM/m7OSt7rR0T9fRtgw6jRaRvOTC3ZJNRuDFsOfNY22XM6kmNI0Y1usVnGFt37Vxv34o UlomziDbwSsBBWbtiypBKIKWrLG8U9bElC4Vydr7rdYmm+gYhDuyYO+RawgIwx9wV+KO tOCGgbGliBQFSxGNmv2Z67qJfb6AbPTl9NdRo4b8m7GlAsYRDturv3qZoxx2uQAUsqFv LOZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=qAidyqNqiCb5KbKHSVTfkxVbZF8KiimMPZ6+hMhgskc=; b=LtX+WB24hzSAc2qcaz7nuICvIBcXVQhJ6BMWuq/cjL/42z5ULxyfpz/85vbcZnTVlY Q93ppTH1TyCFTROxEAJYxn6JMT5zKjfxIpXJExW0osj2Quq9/f8/sNZq51C8dPgzTvjn sGY1ihkesn2qZ8N+QaDcdBCBSyHd8rEefcc8v5zmiHfpTe5ZMoSvnbFAQuMF9oSd9GDy rDOz5Rd/M+8owlMBVCQw/ipemebJlINngacau2CaXE9PEN/3gOIBfsYJ8GjhtlEyQB+k W/vGivqLPMPJd+uD7SPaAP2hoZzqk4SnqXFJ1S5YSyvJLw5rDlYNciNpKjvfWTS5LqZG KNsA== X-Gm-Message-State: AOAM531YPZS9T8cY4FQDiJ6bYH8ypV29fUssCqGbMeU6pD6nufBJb+BQ TeCX6rZr/JRTBBsQqudZYSeTcGweKaX1ZGAS1V8= Sender: "ndesaulniers via sendgmr" X-Received: from ndesaulniers1.mtv.corp.google.com ([2620:15c:211:202:f693:9fff:fef4:4d25]) (user=ndesaulniers job=sendgmr) by 2002:a62:7bcc:0:b029:18b:5859:d5e1 with SMTP id w195-20020a627bcc0000b029018b5859d5e1mr503977pfc.40.1604451241501; Tue, 03 Nov 2020 16:54:01 -0800 (PST) Date: Tue, 3 Nov 2020 16:53:43 -0800 In-Reply-To: <20201104005343.4192504-1-ndesaulniers@google.com> Message-Id: <20201104005343.4192504-5-ndesaulniers@google.com> Mime-Version: 1.0 References: <20201104005343.4192504-1-ndesaulniers@google.com> X-Mailer: git-send-email 2.29.1.341.ge80a0c044ae-goog Subject: [PATCH v2 4/4] Kbuild: implement support for DWARF v5 From: Nick Desaulniers To: Masahiro Yamada Cc: Jakub Jelinek , Linux Kbuild mailing list , Linux Kernel Mailing List , linux-toolchains@vger.kernel.org, clang-built-linux , Fangrui Song , Nathan Chancellor , Sedat Dilek , Dmitry Golovin , Alistair Delva , Nick Desaulniers Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org DWARF v5 is the latest standard of the DWARF debug info format. Feature detection of DWARF5 is onerous, especially given that we've removed $(AS), so we must query $(CC) for DWARF5 assembler directive support. GNU `as` only recently gained support for specifying -gdwarf-5. The DWARF version of a binary can be validated with: $ llvm-dwarfdump vmlinux | head -n 5 | grep version or $ readelf --debug-dump=info vmlinux 2>/dev/null | grep Version DWARF5 wins significantly in terms of size when mixed with compression (CONFIG_DEBUG_INFO_COMPRESSED). 363M vmlinux.clang12.dwarf5.compressed 434M vmlinux.clang12.dwarf4.compressed 439M vmlinux.clang12.dwarf2.compressed 457M vmlinux.clang12.dwarf5 536M vmlinux.clang12.dwarf4 548M vmlinux.clang12.dwarf2 Link: http://www.dwarfstd.org/doc/DWARF5.pdf Suggested-by: Masahiro Yamada Suggested-by: Jakub Jelinek Signed-off-by: Nick Desaulniers --- Makefile | 1 + include/asm-generic/vmlinux.lds.h | 6 +++++- lib/Kconfig.debug | 8 ++++++++ scripts/test_dwarf5_support.sh | 9 +++++++++ 4 files changed, 23 insertions(+), 1 deletion(-) create mode 100755 scripts/test_dwarf5_support.sh diff --git a/Makefile b/Makefile index e23786a4c1c7..9056bac0ff85 100644 --- a/Makefile +++ b/Makefile @@ -828,6 +828,7 @@ endif dwarf-version-$(CONFIG_DEBUG_INFO_DWARF2) := 2 dwarf-version-$(CONFIG_DEBUG_INFO_DWARF4) := 4 +dwarf-version-$(CONFIG_DEBUG_INFO_DWARF5) := 5 DEBUG_CFLAGS += -gdwarf-$(dwarf-version-y) ifneq ($(dwarf-version-y)$(LLVM_IAS),21) # Binutils 2.35+ required for -gdwarf-4+ support. diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index b2b3d81b1535..76ce62c77029 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -829,7 +829,11 @@ .debug_types 0 : { *(.debug_types) } \ /* DWARF 5 */ \ .debug_macro 0 : { *(.debug_macro) } \ - .debug_addr 0 : { *(.debug_addr) } + .debug_addr 0 : { *(.debug_addr) } \ + .debug_line_str 0 : { *(.debug_line_str) } \ + .debug_loclists 0 : { *(.debug_loclists) } \ + .debug_rnglists 0 : { *(.debug_rnglists) } \ + .debug_str_offsets 0 : { *(.debug_str_offsets) } /* Stabs debugging sections. */ #define STABS_DEBUG \ diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 03c494eefabd..c5b54ba51060 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -274,6 +274,14 @@ config DEBUG_INFO_DWARF4 It makes the debug information larger, but it significantly improves the success of resolving variables in gdb on optimized code. +config DEBUG_INFO_DWARF5 + bool "Generate DWARF5 debuginfo" + depends on $(cc-option,-gdwarf-5) + depends on $(success,$(srctree)/scripts/test_dwarf5_support.sh $(CC) $(CLANG_FLAGS)) + help + Genereate dwarf5 debug info. Requires binutils 2.35+, gcc 5.1+, and + gdb 8.0+. + endchoice # "DWARF version" config DEBUG_INFO_BTF diff --git a/scripts/test_dwarf5_support.sh b/scripts/test_dwarf5_support.sh new file mode 100755 index 000000000000..156ad5ec4274 --- /dev/null +++ b/scripts/test_dwarf5_support.sh @@ -0,0 +1,9 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 + +# Test that assembler accepts -gdwarf-5 and .file 0 directives, which were bugs +# in binutils < 2.35. +# https://sourceware.org/bugzilla/show_bug.cgi?id=25612 +# https://sourceware.org/bugzilla/show_bug.cgi?id=25614 +set -e +echo '.file 0 "filename"' | $* -Wa,-gdwarf-5 -c -x assembler -o /dev/null - -- 2.29.1.341.ge80a0c044ae-goog