From patchwork Wed Nov 15 21:34:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sami Tolvanen X-Patchwork-Id: 10060289 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 919CD60231 for ; Wed, 15 Nov 2017 21:34:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E75E29F9B for ; Wed, 15 Nov 2017 21:34:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 72BE029FB9; Wed, 15 Nov 2017 21:34:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 664DD29F9B for ; Wed, 15 Nov 2017 21:34:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758967AbdKOVev (ORCPT ); Wed, 15 Nov 2017 16:34:51 -0500 Received: from mail-it0-f68.google.com ([209.85.214.68]:39543 "EHLO mail-it0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758960AbdKOVep (ORCPT ); Wed, 15 Nov 2017 16:34:45 -0500 Received: by mail-it0-f68.google.com with SMTP id y15so3481649ita.4 for ; Wed, 15 Nov 2017 13:34:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=lc3nWg6pjU7fXpfIu3jU/KNHWc+1ePpSNzKJFwWxMj0=; b=TJtA7AqCsz48zB69Xw2KWZr7+vYxZ1JJTbM1RoGRiOa+ns+rHoTZ0dTZMA01cqp8Eh XBM5AStooYPvaSp4aa2TY4rbmI341hZ6ySTWCZWpRBZs2rzQUtnscgk43+7VqxzdseD4 2X9E/Hj1PaYsAK0FGZUIV++2q7cXMy/sMExJ7eI6YakaM9dsB/H3TBqz7+hpD0gb4UjV DyX9IfIEP/dhj17PuElQY5wdyAOqBs/5S9PCmQURWtfn0YAdRUfZHT4EO4a97vSdLRtp 5Haycw7ta3qvEZ9+q6OdmupbeboE9gcf83Cm4Z2eIfeBeRX877ggVcg2z77Kz2Qab+RX WnqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=lc3nWg6pjU7fXpfIu3jU/KNHWc+1ePpSNzKJFwWxMj0=; b=a+qEt13QjGnMkzqQzKtJybcn6Apf4bS3PKfwdy8BHnEPLwX8k4Ze8Fb2ue24bQVwtV /ke8vPXVYDEGGLr9RCmaIGbsewyvAf0PVc/eM7NOxXzZkyWQ3/ik+IlNVLGMB+/D9gM5 62qJdL12yYYc0f4i8n5IYXxJIa2XNw1Txu5JCJls7WaQWplbVP1sBlBIeTpU1leq9oHc kwJkduQQDk0E1SdR91ZxhCg8Kg+FBGZYXIdOX8KanUr0QsZMqgmYbljDoZWjuY2VIQwC GhMl18ReL9+QQbEQkX/cA5FRZKnogVfYfl9T7h5mtQnA2cx9cROBTZs98ruvYCUir+XV 831g== X-Gm-Message-State: AJaThX4sHs388yizY4+p87c8JFEUydkuQvQ0TO3CFHI5J8xRv9KUhIy/ H3Koz/2/H1rOxAxrE02dR+k/ZA== X-Google-Smtp-Source: AGs4zMa/Gfy3m8LsIZmvQgsC5OwW++Nb4VkQwG7XT3cbTWbQOHn3KRdq/mAFNUSlKm237I60OxLpQw== X-Received: by 10.36.57.76 with SMTP id l73mr21552137ita.17.1510781681569; Wed, 15 Nov 2017 13:34:41 -0800 (PST) Received: from samitolvanen.mtv.corp.google.com ([100.98.112.14]) by smtp.gmail.com with ESMTPSA id 68sm9735197iov.2.2017.11.15.13.34.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 15 Nov 2017 13:34:39 -0800 (PST) From: Sami Tolvanen To: Alex Matveev , Andi Kleen , Ard Biesheuvel , Greg Hackmann , Kees Cook , linux-arm-kernel@lists.infradead.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, Mark Rutland , Masahiro Yamada , Maxim Kuvyrkov , Michal Marek , Nick Desaulniers , Yury Norov , Matthias Kaehlcke Cc: Sami Tolvanen Subject: [PATCH v2 01/18] kbuild: add ld-name macro and support for GNU gold Date: Wed, 15 Nov 2017 13:34:11 -0800 Message-Id: <20171115213428.22559-2-samitolvanen@google.com> X-Mailer: git-send-email 2.15.0.448.gf294e3d99a-goog In-Reply-To: <20171115213428.22559-1-samitolvanen@google.com> References: <20171115213428.22559-1-samitolvanen@google.com> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Reviewed-by: Nick Desaulniers Signed-off-by: Sami Tolvanen Reviewed-by: Kees Cook --- Makefile | 5 +++++ scripts/Kbuild.include | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/Makefile b/Makefile index 763ab35df12a..f976af9525bf 100644 --- a/Makefile +++ b/Makefile @@ -827,6 +827,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)