From patchwork Sat May 22 01:26:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Desaulniers X-Patchwork-Id: 12274267 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-31.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 661B5C04FF3 for ; Sat, 22 May 2021 01:26:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 29BAC613D1 for ; Sat, 22 May 2021 01:26:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230369AbhEVB2D (ORCPT ); Fri, 21 May 2021 21:28:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230407AbhEVB2C (ORCPT ); Fri, 21 May 2021 21:28:02 -0400 Received: from mail-qv1-xf4a.google.com (mail-qv1-xf4a.google.com [IPv6:2607:f8b0:4864:20::f4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B6B3C06138A for ; Fri, 21 May 2021 18:26:31 -0700 (PDT) Received: by mail-qv1-xf4a.google.com with SMTP id w4-20020a0c8e440000b02901f0640ffdafso14159033qvb.13 for ; Fri, 21 May 2021 18:26:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=gS3/FjH30criEdlZq0ZHdAnAGJSA0ILT1HmCoVmE9Yc=; b=aV10v99JMPHFg1NGBvCWnUWFb+H8K8fj4R2z1KjHTliOlyuuNv7N+E++NFeU+qFtZp 3+FqCv1he5VC08dsXqqBEoOp6dlq+Jim+eqm8bBhg3Wa39Dqo7D3c93BffdlaEcWXif9 gKyWuMLV4UfrKS62gts+QsiUfFhgZSM0wvBZ1vwWmHDaOkAIzh5gikMRUosZD8liZYjE BLZ4d9v3A4E2C1pTRMRgb2VRbAyQMKVD/JqJSvxrxPWl8UN18mHMBEgV8ftxpiAmIuWT dmxDu6tCcGafJAMnYk82Zo6sopbp3ZB6XTbx9MrZ3STv27IcXF//ymaHhlTkLron6P5f L8Ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=gS3/FjH30criEdlZq0ZHdAnAGJSA0ILT1HmCoVmE9Yc=; b=AwiU8OY4w5lvIwRl5i7WAXua9KSWpwq2kYEaIIXAdihyWSck15nU0PbPQHllLrNLMD y77KycmDY9U1qcIdX5wHj4DhkSUoW2Tq9oNYe8bK9oxm9ku/olmDYHwqXikE0doeHg9p OaBB4VNE6SFNiANuL2D/xl8ILOhETiHHEZR6qpRvrnR70Px9FnlgjkbePvIV3aUSvUlA rSLfmHJBAlVrLbB194hmbmqyVJW8Fz3I61nIuVRiDYmmtK9L7c3261b4S9ljTYYwQTQe OS1I5C0wPkLz43m7Xc5owp9vVS6Hdb90eI+7J0n38pZf20a7V/SoHUdCPqibtSAB3Tya zpXg== X-Gm-Message-State: AOAM532DcayyEfZ30zNgdq9VqCbMUB3qeiNasxq4oVWbEyLSrxcfX2Xi jyHDqgHa1ockPh3R69zhwrY2G6wLWGN6bDDbUQc= X-Google-Smtp-Source: ABdhPJyCEvd+l3Rqhyp51TSzPr9jAnAvnyIGE5YRxodQwxa5AYSuBGV7+leKsEDF2cfme0a7brTTz1HcQqAGnDK+DBI= X-Received: from ndesaulniers1.mtv.corp.google.com ([2620:15c:211:202:e55d:7de8:da36:30e8]) (user=ndesaulniers job=sendgmr) by 2002:a0c:f64e:: with SMTP id s14mr16600523qvm.56.1621646790253; Fri, 21 May 2021 18:26:30 -0700 (PDT) Date: Fri, 21 May 2021 18:26:24 -0700 In-Reply-To: Message-Id: <20210522012626.2811297-1-ndesaulniers@google.com> Mime-Version: 1.0 References: X-Mailer: git-send-email 2.31.1.818.g46aad6cb9e-goog Subject: [PATCH v2] Makefile: fix GDB warning with CONFIG_RELR From: Nick Desaulniers To: Will Deacon Cc: Catalin Marinas , linux-arm-kernel@lists.infradead.org, Lee Jones , Masahiro Yamada , clang-built-linux , Fangrui Song , Elliot Berman , Sami Tolvanen , Peter Collingbourne , Michal Marek , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, Nick Desaulniers , Nathan Chancellor Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org GDB produces the following warning when debugging kernels built with CONFIG_RELR: BFD: /android0/linux-next/vmlinux: unknown type [0x13] section `.relr.dyn' when loading a kernel built with CONFIG_RELR into GDB. It can also prevent debugging symbols using such relocations. Peter sugguests: [That flag] means that lld will use dynamic tags and section type numbers in the OS-specific range rather than the generic range. The kernel itself doesn't care about these numbers; it determines the location of the RELR section using symbols defined by a linker script. Link: https://github.com/ClangBuiltLinux/linux/issues/1057 Suggested-by: Peter Collingbourne Reviewed-by: Nathan Chancellor Signed-off-by: Nick Desaulniers --- Changes V1 -> V2: * rebase * pick up Nathan's reviewed by tag. Makefile | 2 +- scripts/tools-support-relr.sh | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) base-commit: 45af60e7ced07ae3def41368c3d260dbf496fbce diff --git a/Makefile b/Makefile index 0ed7e061c8e9..2dbb56f831d4 100644 --- a/Makefile +++ b/Makefile @@ -1031,7 +1031,7 @@ LDFLAGS_vmlinux += $(call ld-option, -X,) endif ifeq ($(CONFIG_RELR),y) -LDFLAGS_vmlinux += --pack-dyn-relocs=relr +LDFLAGS_vmlinux += --pack-dyn-relocs=relr --use-android-relr-tags endif # We never want expected sections to be placed heuristically by the diff --git a/scripts/tools-support-relr.sh b/scripts/tools-support-relr.sh index 45e8aa360b45..cb55878bd5b8 100755 --- a/scripts/tools-support-relr.sh +++ b/scripts/tools-support-relr.sh @@ -7,7 +7,8 @@ trap "rm -f $tmp_file.o $tmp_file $tmp_file.bin" EXIT cat << "END" | $CC -c -x c - -o $tmp_file.o >/dev/null 2>&1 void *p = &p; END -$LD $tmp_file.o -shared -Bsymbolic --pack-dyn-relocs=relr -o $tmp_file +$LD $tmp_file.o -shared -Bsymbolic --pack-dyn-relocs=relr \ + --use-android-relr-tags -o $tmp_file # Despite printing an error message, GNU nm still exits with exit code 0 if it # sees a relr section. So we need to check that nothing is printed to stderr.