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: 10060299 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 4C7B860231 for ; Wed, 15 Nov 2017 21:35:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3932F2A118 for ; Wed, 15 Nov 2017 21:35:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2DE2A2A312; Wed, 15 Nov 2017 21:35:28 +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=-4.2 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AC8BE2A118 for ; Wed, 15 Nov 2017 21:35:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=t9P8sJLStIwj8jp6PzKx+9PVpioeTu+w5KaZe+4WbOA=; b=BeulZJceWVzR0kxnTsBHrFe8i5 o4HLloGxzBot8zG3kZ8wGuZNfaA+q2sSk8DfTeXpWMSN+cinSSybf+x0dLohLOXSL9mS7IExImM7n 9b/vipbccxVVryxW747j/goddo6zqSkLGYeSSbs62XW7hgcfKGR+yJIduJTUoJykk+/v/pv3sykWM ptNL9N/z6o2oU34oBLBO3YW1wFjisHQsMp176zihMmyeF9XijONBtdLytDz3Pb9hTWZvt9UemMOLL Or2vmw2ONfPkNwf8wze7wu/sYnjIrHKjeTDqoA1/OrHTprCY5ZV22qHdegtjfsebHeepY7LpdtcL3 u+AyJYXA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eF5LC-0001Ev-Vw; Wed, 15 Nov 2017 21:35:27 +0000 Received: from mail-it0-x243.google.com ([2607:f8b0:4001:c0b::243]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eF5Ko-00088E-Qp for linux-arm-kernel@lists.infradead.org; Wed, 15 Nov 2017 21:35:04 +0000 Received: by mail-it0-x243.google.com with SMTP id 72so3478738itl.5 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=OSUhGNcpEuqRQIu8IPDfl6rRXwI1vV/bHB9y7hSPEiLjOAps0TvmvZoqTMBPh9cO5t CyP2IfnRtTc5u9g7JJAgXPrlTUAEf1wTRuZ+N0AMt5+yOSy0PNHEjTo+5+Fk1bhU2zc0 Tc81CGmiWZgVgiP7GWjN9bS0ne53HGhD/T62Q+i0hlQN5nxsQoZ30W8GJrKmtMFhAa9y AtQAaQF4EBEiB57xI5tNh6ljYGYVJrr6ZEq4G7aT1wjRVx7q3eyiIJw5GomC1REiNt6/ RguWhjXvMe5Xd29kJXecDTEbgPXMu8l0X8geSmeCmQyXA0qcSbZTRCYBcS5WU2de7862 3tBQ== X-Gm-Message-State: AJaThX6s75nK+PcRArGNwQUIGMd7T4qKPbXaGbwZgDiXot58zcYl1kB6 uPO64VvML8GYni7w6DZODtaA7g== 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171115_133502_950884_287A7E38 X-CRM114-Status: UNSURE ( 9.30 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sami Tolvanen MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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)