From patchwork Thu Oct 20 10:12:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 78472 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp698225qge; Thu, 20 Oct 2016 03:14:42 -0700 (PDT) X-Received: by 10.98.156.146 with SMTP id u18mr19947379pfk.93.1476958482769; Thu, 20 Oct 2016 03:14:42 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id 145si40932624pgc.315.2016.10.20.03.14.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Oct 2016 03:14:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bxALv-0001oq-Ar; Thu, 20 Oct 2016 10:13:35 +0000 Received: from mail-qt0-x22c.google.com ([2607:f8b0:400d:c0d::22c]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bxALn-0001fE-13 for linux-arm-kernel@lists.infradead.org; Thu, 20 Oct 2016 10:13:28 +0000 Received: by mail-qt0-x22c.google.com with SMTP id f6so48976477qtd.2 for ; Thu, 20 Oct 2016 03:13:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=d/aBrjKt2xRVPq1wwwnLgQjyl9/9BsYCYOqRZXZmhnw=; b=doT3qU3a6m8MYrDG1rg0G7OKLHlhs1kG60qzo8Pk3d9IHXsjr2cBt8FjfKgttPY2y7 MCqdOpf+ESHP97qDBvSdEuIx+1TZrf/kRPiKxb88++WVs152cHXVJ+s0MvkHRsVDg3tD eEkng0DJL6NcG1g0zt5snHdIwbVltUY+V7g4w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=d/aBrjKt2xRVPq1wwwnLgQjyl9/9BsYCYOqRZXZmhnw=; b=hgbpP4oP3anmCcutv6BytRju3CGQEQE5Ip9dk8edlsh1txoWqTGnABSAFqC1UloD6N 5UN5wq6gRGFVH6vd7eXBBvLFrPL6hIRglAkwQwyHZsWqM5pQobu16BtVkwM6n41N2TtY vAtfRS+nsaA2frKuFdnNBjmk8VmFttL7U/mWeNQ1TXGuqMZuGA1ym/RTeKgvoEOaqX2y xrcHtb8iNKkS2JC6eP/58adJosSOiISerChaDOQlMxw1nmn71jVkNyis8IV4qAGcJPe9 PuMjPHVrlDom9klqFwZfX+jB6zeIsDfIJTbZ/eSPXMwG7UeBFakPykGw0Syufiq0LgRj Vg2Q== X-Gm-Message-State: AA6/9RmfGpUki+XmufISL0bxMzDh+UU5w1TlOrkHarBQB9sY3q/B0NS8HuWsZ71V9fr342JE X-Received: by 10.28.9.141 with SMTP id 135mr8266696wmj.68.1476958385557; Thu, 20 Oct 2016 03:13:05 -0700 (PDT) Received: from localhost.localdomain ([196.66.89.52]) by smtp.gmail.com with ESMTPSA id ct1sm77376074wjd.13.2016.10.20.03.13.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Oct 2016 03:13:04 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] arm64: kernel: force ET_DYN ELF type for CONFIG_RELOCATABLE=y Date: Thu, 20 Oct 2016 11:12:57 +0100 Message-Id: <1476958377-13900-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161020_031327_272374_B6BC1EF3 X-CRM114-Status: GOOD ( 12.64 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2607:f8b0:400d:c0d:0:0:0:22c listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, catalin.marinas@arm.com, will.deacon@arm.com, Ard Biesheuvel MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org GNU ld used to set the ELF file type to ET_DYN for PIE executables, which is the same file type used for shared libraries. However, this was changed recently, and now PIE executables are emitted as ET_EXEC instead. The distinction is only relevant for ELF loaders, and so there is little reason to care about the difference when building the kernel, which is why the change has gone unnoticed until now. However, debuggers do use the ELF binary, and expect ET_EXEC type files to appear in memory at the exact offset described in the ELF metadata. This means source level debugging is no longer possible when KASLR is in effect or when executing the stub. So add the -shared LD option when building with CONFIG_RELOCATABLE=y. This forces the ELF file type to be set to ET_DYN (which is what you get when building with binutils 2.24 and earlier anyway), and has no other ill effects. Signed-off-by: Ard Biesheuvel --- The difference in output between ET_EXEC and ET_DYN file types for 'readelf -a vmlinux': -- 2.7.4 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel --- /tmp/exec 2016-10-19 17:46:51.368841538 +0100 +++ /tmp/dyn 2016-10-19 17:46:01.774879088 +0100 @@ -5,7 +5,7 @@ Version: 1 (current) OS/ABI: UNIX - System V ABI Version: 0 - Type: EXEC (Executable file) + Type: DYN (Shared object file) Machine: AArch64 Version: 0x1 Entry point address: 0xffff000008080000 @@ -239199,7 +239199,7 @@ 108973: 0000000000000000 0 FILE LOCAL DEFAULT ABS 108974: ffff0000089800a0 0 OBJECT LOCAL DEFAULT ABS _GLOBAL_OFFSET_TABLE_ 108975: ffff0000081a7c70 0 NOTYPE LOCAL DEFAULT 2 $x -108976: ffff0000081a7c74 8 FUNC LOCAL DEFAULT 2 e843419@001a_00000473_99c +108976: ffff0000081a7c74 8 FUNC LOCAL DEFAULT 2 e843419@001a_00000472_99c 108977: ffff0000081a7c74 0 NOTYPE LOCAL DEFAULT 2 $x 108978: ffff000008d7c118 136 FUNC GLOBAL DEFAULT 19 __efistub_fdt_delprop 108979: ffff000008819db8 36 FUNC GLOBAL DEFAULT 2 arch_timer_get_kvm_info @@ -269256,4 +269256,4 @@ Displaying notes found at file offset 0x00cf5740 with length 0x00000024: Owner Data size Description GNU 0x00000014 NT_GNU_BUILD_ID (unique build ID bitstring) - Build ID: a63334609e04d620ea175bb9e88bc68989dc0402 + Build ID: 7f489d756b1799111b0128ffa61546c2ac1f6e2a arch/arm64/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile index ab51aed6b6c1..3635b8662724 100644 --- a/arch/arm64/Makefile +++ b/arch/arm64/Makefile @@ -15,7 +15,7 @@ CPPFLAGS_vmlinux.lds = -DTEXT_OFFSET=$(TEXT_OFFSET) GZFLAGS :=-9 ifneq ($(CONFIG_RELOCATABLE),) -LDFLAGS_vmlinux += -pie -Bsymbolic +LDFLAGS_vmlinux += -pie -shared -Bsymbolic endif ifeq ($(CONFIG_ARM64_ERRATUM_843419),y)