diff --git a/.travis.yml b/.travis.yml index 3f6984a..8bc8358 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,8 +24,8 @@ jobs: env: ARCH=riscv LLVM_IAS=1 - name: "ARCH=s390 BOOT=0" env: ARCH=s390 - - name: "ARCH=x86" - env: ARCH=x86 + - name: "ARCH=x86 LD=ld.lld" + env: ARCH=x86 LD=ld.lld - name: "ARCH=x86_64 LD=ld.lld" env: ARCH=x86_64 LD=ld.lld # linux (cron only) @@ -64,8 +64,8 @@ jobs: - name: "ARCH=s390 BOOT=0 REPO=linux-next" env: ARCH=s390 REPO=linux-next if: type = cron - - name: "ARCH=x86 REPO=linux-next" - env: ARCH=x86 REPO=linux-next + - name: "ARCH=x86 LD=ld.lld REPO=linux-next" + env: ARCH=x86 LD=ld.lld REPO=linux-next if: type = cron - name: "ARCH=x86_64 LD=ld.lld REPO=linux-next" env: ARCH=x86_64 LD=ld.lld REPO=linux-next diff --git a/patches/llvm-all/linux-next/x86/x86-boot-allow-a-relocatable-kernel-to-be-linked-with-lld.patch b/patches/llvm-all/linux-next/x86/x86-boot-allow-a-relocatable-kernel-to-be-linked-with-lld.patch new file mode 100644 index 0000000..feb3d02 --- /dev/null +++ b/patches/llvm-all/linux-next/x86/x86-boot-allow-a-relocatable-kernel-to-be-linked-with-lld.patch @@ -0,0 +1,101 @@ +From patchwork Fri May 1 08:42:13 2020 +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +X-Patchwork-Submitter: Dmitry Golovin +X-Patchwork-Id: 1234153 +Return-Path: +Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) + by smtp.lore.kernel.org (Postfix) with ESMTP id 70BCAC4724C + for ; Fri, 1 May 2020 08:50:07 +0000 (UTC) +Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) + by mail.kernel.org (Postfix) with ESMTP id 504532076D + for ; Fri, 1 May 2020 08:50:07 +0000 (UTC) +Authentication-Results: mail.kernel.org; + dkim=pass (1024-bit key) header.d=golovin.in header.i=@golovin.in + header.b="ARiE+ETt" +Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand + id S1728554AbgEAIuG (ORCPT + ); + Fri, 1 May 2020 04:50:06 -0400 +Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35236 "EHLO + lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org + with ESMTP id S1728217AbgEAIuF (ORCPT + ); + Fri, 1 May 2020 04:50:05 -0400 +X-Greylist: delayed 439 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; + Fri, 01 May 2020 01:50:04 PDT +Received: from forward103j.mail.yandex.net (forward103j.mail.yandex.net + [IPv6:2a02:6b8:0:801:2::106]) + by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80D87C035494 + for ; + Fri, 1 May 2020 01:50:04 -0700 (PDT) +Received: from mxback27j.mail.yandex.net (mxback27j.mail.yandex.net + [IPv6:2a02:6b8:0:1619::227]) + by forward103j.mail.yandex.net (Yandex) with ESMTP id 17D8367418E1; + Fri, 1 May 2020 11:42:42 +0300 (MSK) +Received: from sas8-b61c542d7279.qloud-c.yandex.net + (sas8-b61c542d7279.qloud-c.yandex.net [2a02:6b8:c1b:2912:0:640:b61c:542d]) + by mxback27j.mail.yandex.net (mxback/Yandex) with ESMTP id + SUQtlbkE3G-gf7WPW96; + Fri, 01 May 2020 11:42:42 +0300 +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=golovin.in; s=mail; + t=1588322562; + bh=gan9a/JARj/+uZ3h35bsl+BDo6XiSEqZSpSCQqcjDAA=; + h=Subject:To:From:Cc:Date:Message-Id; + b=ARiE+ETtWtuGINV5klL98d9ZvWL/iVptFaDgh8qjjv1/oUOxXqzTHCVJqIOVRjbHd + rAVoHhk0TEx3w2Hp15CKf34pPinyFErR3+iBSdGlzbD0VsUR/93i2VR9L2rHmNdC1c + wOpYREBHQDZlP/bAoldT9LcbSHdFGCM4/cfGQmVY= +Authentication-Results: mxback27j.mail.yandex.net; + dkim=pass header.i=@golovin.in +Received: by sas8-b61c542d7279.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA + id 8KmUsRmuq5-ge5iAngf; + Fri, 01 May 2020 11:42:40 +0300 + (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) + (Client certificate not present) +From: Dmitry Golovin +To: clang-built-linux@googlegroups.com +Cc: Dmitry Golovin , + Thomas Gleixner , + Ingo Molnar , Borislav Petkov , + x86@kernel.org, "H. Peter Anvin" , + Nick Desaulniers , + Ard Biesheuvel , + Masahiro Yamada , + Daniel Kiper , + linux-kernel@vger.kernel.org +Subject: [PATCH] x86/boot: allow a relocatable kernel to be linked with lld +Date: Fri, 1 May 2020 08:42:13 +0000 +Message-Id: <20200501084215.242-1-dima@golovin.in> +X-Mailer: git-send-email 2.25.1 +MIME-Version: 1.0 +Sender: linux-kernel-owner@vger.kernel.org +Precedence: bulk +List-ID: +X-Mailing-List: linux-kernel@vger.kernel.org + +LLD by default disallows relocations in read-only segments. For a +relocatable kernel, we pass -z notext to the linker to explicitly +allow relocations. This behavior is the default for BFD. + +Link: https://github.com/ClangBuiltLinux/linux/issues/579 +Signed-off-by: Dmitry Golovin +Tested-by: Nathan Chancellor +--- + arch/x86/boot/compressed/Makefile | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile +index 5f7c262bcc99..7214751e1671 100644 +--- a/arch/x86/boot/compressed/Makefile ++++ b/arch/x86/boot/compressed/Makefile +@@ -57,6 +57,9 @@ else + KBUILD_LDFLAGS += $(shell $(LD) --help 2>&1 | grep -q "\-z noreloc-overflow" \ + && echo "-z noreloc-overflow -pie --no-dynamic-linker") + endif ++ifeq ($(CONFIG_RELOCATABLE), y) ++KBUILD_LDFLAGS += -z notext ++endif + LDFLAGS_vmlinux := -T + + hostprogs := mkpiggy diff --git a/patches/llvm-all/linux/x86/x86-boot-allow-a-relocatable-kernel-to-be-linked-with-lld.patch b/patches/llvm-all/linux/x86/x86-boot-allow-a-relocatable-kernel-to-be-linked-with-lld.patch new file mode 100644 index 0000000..feb3d02 --- /dev/null +++ b/patches/llvm-all/linux/x86/x86-boot-allow-a-relocatable-kernel-to-be-linked-with-lld.patch @@ -0,0 +1,101 @@ +From patchwork Fri May 1 08:42:13 2020 +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +X-Patchwork-Submitter: Dmitry Golovin +X-Patchwork-Id: 1234153 +Return-Path: +Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) + by smtp.lore.kernel.org (Postfix) with ESMTP id 70BCAC4724C + for ; Fri, 1 May 2020 08:50:07 +0000 (UTC) +Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) + by mail.kernel.org (Postfix) with ESMTP id 504532076D + for ; Fri, 1 May 2020 08:50:07 +0000 (UTC) +Authentication-Results: mail.kernel.org; + dkim=pass (1024-bit key) header.d=golovin.in header.i=@golovin.in + header.b="ARiE+ETt" +Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand + id S1728554AbgEAIuG (ORCPT + ); + Fri, 1 May 2020 04:50:06 -0400 +Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35236 "EHLO + lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org + with ESMTP id S1728217AbgEAIuF (ORCPT + ); + Fri, 1 May 2020 04:50:05 -0400 +X-Greylist: delayed 439 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; + Fri, 01 May 2020 01:50:04 PDT +Received: from forward103j.mail.yandex.net (forward103j.mail.yandex.net + [IPv6:2a02:6b8:0:801:2::106]) + by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80D87C035494 + for ; + Fri, 1 May 2020 01:50:04 -0700 (PDT) +Received: from mxback27j.mail.yandex.net (mxback27j.mail.yandex.net + [IPv6:2a02:6b8:0:1619::227]) + by forward103j.mail.yandex.net (Yandex) with ESMTP id 17D8367418E1; + Fri, 1 May 2020 11:42:42 +0300 (MSK) +Received: from sas8-b61c542d7279.qloud-c.yandex.net + (sas8-b61c542d7279.qloud-c.yandex.net [2a02:6b8:c1b:2912:0:640:b61c:542d]) + by mxback27j.mail.yandex.net (mxback/Yandex) with ESMTP id + SUQtlbkE3G-gf7WPW96; + Fri, 01 May 2020 11:42:42 +0300 +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=golovin.in; s=mail; + t=1588322562; + bh=gan9a/JARj/+uZ3h35bsl+BDo6XiSEqZSpSCQqcjDAA=; + h=Subject:To:From:Cc:Date:Message-Id; + b=ARiE+ETtWtuGINV5klL98d9ZvWL/iVptFaDgh8qjjv1/oUOxXqzTHCVJqIOVRjbHd + rAVoHhk0TEx3w2Hp15CKf34pPinyFErR3+iBSdGlzbD0VsUR/93i2VR9L2rHmNdC1c + wOpYREBHQDZlP/bAoldT9LcbSHdFGCM4/cfGQmVY= +Authentication-Results: mxback27j.mail.yandex.net; + dkim=pass header.i=@golovin.in +Received: by sas8-b61c542d7279.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA + id 8KmUsRmuq5-ge5iAngf; + Fri, 01 May 2020 11:42:40 +0300 + (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) + (Client certificate not present) +From: Dmitry Golovin +To: clang-built-linux@googlegroups.com +Cc: Dmitry Golovin , + Thomas Gleixner , + Ingo Molnar , Borislav Petkov , + x86@kernel.org, "H. Peter Anvin" , + Nick Desaulniers , + Ard Biesheuvel , + Masahiro Yamada , + Daniel Kiper , + linux-kernel@vger.kernel.org +Subject: [PATCH] x86/boot: allow a relocatable kernel to be linked with lld +Date: Fri, 1 May 2020 08:42:13 +0000 +Message-Id: <20200501084215.242-1-dima@golovin.in> +X-Mailer: git-send-email 2.25.1 +MIME-Version: 1.0 +Sender: linux-kernel-owner@vger.kernel.org +Precedence: bulk +List-ID: +X-Mailing-List: linux-kernel@vger.kernel.org + +LLD by default disallows relocations in read-only segments. For a +relocatable kernel, we pass -z notext to the linker to explicitly +allow relocations. This behavior is the default for BFD. + +Link: https://github.com/ClangBuiltLinux/linux/issues/579 +Signed-off-by: Dmitry Golovin +Tested-by: Nathan Chancellor +--- + arch/x86/boot/compressed/Makefile | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile +index 5f7c262bcc99..7214751e1671 100644 +--- a/arch/x86/boot/compressed/Makefile ++++ b/arch/x86/boot/compressed/Makefile +@@ -57,6 +57,9 @@ else + KBUILD_LDFLAGS += $(shell $(LD) --help 2>&1 | grep -q "\-z noreloc-overflow" \ + && echo "-z noreloc-overflow -pie --no-dynamic-linker") + endif ++ifeq ($(CONFIG_RELOCATABLE), y) ++KBUILD_LDFLAGS += -z notext ++endif + LDFLAGS_vmlinux := -T + + hostprogs := mkpiggy diff --git a/usage.txt b/usage.txt index 75ee30e..6265fc0 100644 --- a/usage.txt +++ b/usage.txt @@ -16,7 +16,7 @@ Environment variables: ARCH (required): If no ARCH value is specified, it's an error; there is no default. Currently, arm32_v7, arm32_v6, arm32_v5, arm64, mips, mipsel, ppc32, - ppc64, ppc64le, s390, riscv, and x86_64 are supported. + ppc64, ppc64le, s390, riscv, x86, and x86_64 are supported. CC: If no CC value is specified, the script will attempt to set CC to clang-10, clang-9, clang-8, clang-7, then clang if they are found