From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756194AbdKCRMm (ORCPT ); Fri, 3 Nov 2017 13:12:42 -0400 Received: from mail-io0-f196.google.com ([209.85.223.196]:43930 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756126AbdKCRMi (ORCPT ); Fri, 3 Nov 2017 13:12:38 -0400 X-Google-Smtp-Source: ABhQp+RFBX60Is2SOx5Q0EV1WgPSzwpVdA7m9JPmqF3aK15vJGyWGyz4aYnUskTRXQ78rCI4hFKSLQ== From: Sami Tolvanen To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Greg Hackmann , Kees Cook , Matthias Kaehlcke , Nick Desaulniers , Sami Tolvanen Subject: [PATCH 01/15] kbuild: add ld-name macro and support for GNU gold Date: Fri, 3 Nov 2017 10:11:45 -0700 Message-Id: <20171103171203.107569-2-samitolvanen@google.com> X-Mailer: git-send-email 2.15.0.403.gc27cc4dac6-goog In-Reply-To: <20171103171203.107569-1-samitolvanen@google.com> References: <20171103171203.107569-1-samitolvanen@google.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org GNU gold may require different flags than GNU ld. Add a macro for detecting the linker and conditionally add gold specific flags from LDFLAGS_GOLD. Signed-off-by: Sami Tolvanen --- Makefile | 5 +++++ scripts/Kbuild.include | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/Makefile b/Makefile index 3a8868ee967e..59980d5a03d0 100644 --- a/Makefile +++ b/Makefile @@ -826,6 +826,11 @@ include scripts/Makefile.kasan include scripts/Makefile.extrawarn include scripts/Makefile.ubsan +# Add any flags specific to ld.gold +ifeq ($(ld-name),gold) +LDFLAGS += $(LDFLAGS_GOLD) +endif + # Add any arch overrides and user supplied CPPFLAGS, AFLAGS and CFLAGS as the # last assignments KBUILD_CPPFLAGS += $(ARCH_CPPFLAGS) $(KCPPFLAGS) diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 9ffd3dda3889..584d6cecd7c0 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -172,6 +172,10 @@ ld-option = $(call try-run,\ # Important: no spaces around options ar-option = $(call try-run, $(AR) rc$(1) "$$TMP",$(1),$(2)) +# ld-name +# Expands to either bfd or gold +ld-name = $(shell $(LD) -v 2>&1 | grep -q "GNU gold" && echo gold || echo bfd) + # ld-version # Note this is mainly for HJ Lu's 3 number binutil versions ld-version = $(shell $(LD) --version | $(srctree)/scripts/ld-version.sh) -- 2.15.0.403.gc27cc4dac6-goog From mboxrd@z Thu Jan 1 00:00:00 1970 From: samitolvanen@google.com (Sami Tolvanen) Date: Fri, 3 Nov 2017 10:11:45 -0700 Subject: [PATCH 01/15] kbuild: add ld-name macro and support for GNU gold In-Reply-To: <20171103171203.107569-1-samitolvanen@google.com> References: <20171103171203.107569-1-samitolvanen@google.com> Message-ID: <20171103171203.107569-2-samitolvanen@google.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org GNU gold may require different flags than GNU ld. Add a macro for detecting the linker and conditionally add gold specific flags from LDFLAGS_GOLD. Signed-off-by: Sami Tolvanen --- Makefile | 5 +++++ scripts/Kbuild.include | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/Makefile b/Makefile index 3a8868ee967e..59980d5a03d0 100644 --- a/Makefile +++ b/Makefile @@ -826,6 +826,11 @@ include scripts/Makefile.kasan include scripts/Makefile.extrawarn include scripts/Makefile.ubsan +# Add any flags specific to ld.gold +ifeq ($(ld-name),gold) +LDFLAGS += $(LDFLAGS_GOLD) +endif + # Add any arch overrides and user supplied CPPFLAGS, AFLAGS and CFLAGS as the # last assignments KBUILD_CPPFLAGS += $(ARCH_CPPFLAGS) $(KCPPFLAGS) diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 9ffd3dda3889..584d6cecd7c0 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -172,6 +172,10 @@ ld-option = $(call try-run,\ # Important: no spaces around options ar-option = $(call try-run, $(AR) rc$(1) "$$TMP",$(1),$(2)) +# ld-name +# Expands to either bfd or gold +ld-name = $(shell $(LD) -v 2>&1 | grep -q "GNU gold" && echo gold || echo bfd) + # ld-version # Note this is mainly for HJ Lu's 3 number binutil versions ld-version = $(shell $(LD) --version | $(srctree)/scripts/ld-version.sh) -- 2.15.0.403.gc27cc4dac6-goog