From patchwork Wed Feb 8 11:55:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 93611 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp2648513qgi; Wed, 8 Feb 2017 04:04:29 -0800 (PST) X-Received: by 10.99.152.65 with SMTP id l1mr26955606pgo.28.1486555469136; Wed, 08 Feb 2017 04:04:29 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y1si1704114plb.306.2017.02.08.04.04.29; Wed, 08 Feb 2017 04:04:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; 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-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754310AbdBHMEY (ORCPT + 2 others); Wed, 8 Feb 2017 07:04:24 -0500 Received: from mail-wr0-f169.google.com ([209.85.128.169]:32932 "EHLO mail-wr0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753153AbdBHMET (ORCPT ); Wed, 8 Feb 2017 07:04:19 -0500 Received: by mail-wr0-f169.google.com with SMTP id i10so59287292wrb.0 for ; Wed, 08 Feb 2017 04:03:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=h01jl4h5+6rqqV1YOcmGNstoQ+p0VtSbBR0atMg53sw=; b=KbPtpOwoURsZRX0WSI3CkDOkfeus0ptp0SHjlfGSRXizo+S1xAJJIsxD5tdVKTt/tA 6KTf5laCUchkhuPOUF/H6AB12kCbpJOtEjurj1oa8QOcOSGpexmHjaoh89R2sPOPgvmx bniJGBztsnds/CRsIX0ekOdke+TQCBgcAE43c= 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=h01jl4h5+6rqqV1YOcmGNstoQ+p0VtSbBR0atMg53sw=; b=FtaL9zc9kFTus6+z44r1C2bPN5/tUvYq9onxba4XaZIANhta+L0tzdmELDRncUq4Uf aey+icsa2bQiQiJenU6JHcAI/CG11bDcyttKAoVqNM0bpVflYDwkV+1QyyNFo0lw0d3Z ylWuUiACrTXQ6pxV8LP4EW/D7ikISBvk6WDlkhrXDsoj/aYCFZs6zZXoLTmp6wA9g6xW 9d+J7yejnXXDYUu+GJGl1T8BN0jGLPneDgsMLeWgVJVZ9CX+axpaKcIeBh3lOUlTUTdn Q6ofajmnyjVyMi++ur8x63vi9WHviQNr7CAUqC5HQAGmAMp55qeYz3jd49blDPbDKz8Q lOOg== X-Gm-Message-State: AMke39lOqgTdRvFEGIBKDbAwG5vFABrcgwWGUZAtyMQAcOo+goshlHdF9vDIWaYnZtN7t9f2 X-Received: by 10.223.130.170 with SMTP id 39mr4529784wrc.34.1486554985864; Wed, 08 Feb 2017 03:56:25 -0800 (PST) Received: from localhost.localdomain ([160.169.163.122]) by smtp.gmail.com with ESMTPSA id 123sm2974815wml.6.2017.02.08.03.56.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 08 Feb 2017 03:56:25 -0800 (PST) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, mark.rutland@arm.com, leif.lindholm@linaro.org Cc: catalin.marinas@arm.com, linux@armlinux.org.uk, kernel-hardening@lists.openwall.com, labbott@fedoraproject.org, Ard Biesheuvel , Dave Martin Subject: [PATCH v2 09/14] arm: compressed: put zImage header and EFI header in dedicated section Date: Wed, 8 Feb 2017 11:55:42 +0000 Message-Id: <1486554947-3964-10-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1486554947-3964-1-git-send-email-ard.biesheuvel@linaro.org> References: <1486554947-3964-1-git-send-email-ard.biesheuvel@linaro.org> Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org To align the PE/COFF and the ELF headers of the decompressor binary, put the zImage header and the EFI header in a separate .head.text section, and emit it at the start of the Image. This change is necessary for UEFI based debug tooling to be able to use the vmlinux ELF binary, since it gets confused if the PE/COFF .text section and the ELF .text section live at different offsets. This requires a tweak of the initial jump, because (b)adr does not reach across a section boundary. Other than that, and a few bytes of padding at the beginning of .start, this change does not affect the binary image. Cc: Dave Martin Signed-off-by: Ard Biesheuvel --- arch/arm/boot/compressed/efi-header.S | 2 -- arch/arm/boot/compressed/head.S | 14 +++++++++----- arch/arm/boot/compressed/vmlinux.lds.S | 5 ++++- 3 files changed, 13 insertions(+), 8 deletions(-) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-efi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/arm/boot/compressed/efi-header.S b/arch/arm/boot/compressed/efi-header.S index 9d5dc4fda3c1..1d26a9d0a9e8 100644 --- a/arch/arm/boot/compressed/efi-header.S +++ b/arch/arm/boot/compressed/efi-header.S @@ -23,8 +23,6 @@ .macro __EFI_HEADER #ifdef CONFIG_EFI_STUB - b __efi_start - .set start_offset, __efi_start - start .org start + 0x3c @ diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S index fc6d541549a2..42ba2f557791 100644 --- a/arch/arm/boot/compressed/head.S +++ b/arch/arm/boot/compressed/head.S @@ -114,7 +114,7 @@ #endif .endm - .section ".start", #alloc, #execinstr + .section ".head.text", #alloc, #execinstr /* * sort out different calling conventions */ @@ -132,17 +132,21 @@ start: .endr ARM( mov r0, r0 ) ARM( b 1f ) - THUMB( badr r12, 1f ) - THUMB( bx r12 ) +AR_CLASS(THUMB( sub pc, pc, #3 )) @ A/R: switch to Thumb2 mode + M_CLASS( nop.w ) @ M: already in Thumb2 mode + THUMB( .thumb ) + THUMB( b.w 1f ) .word _magic_sig @ Magic numbers to help the loader .word _magic_start @ absolute load/run zImage address .word _magic_end @ zImage end address .word 0x04030201 @ endianness flag - THUMB( .thumb ) -1: __EFI_HEADER + __EFI_HEADER + .section ".start", #alloc, #execinstr + .align +1: ARM_BE8( setend be ) @ go BE8 if compiled for BE8 AR_CLASS( mrs r9, cpsr ) #ifdef CONFIG_ARM_VIRT_EXT diff --git a/arch/arm/boot/compressed/vmlinux.lds.S b/arch/arm/boot/compressed/vmlinux.lds.S index 81c493156ce8..5d50daea466a 100644 --- a/arch/arm/boot/compressed/vmlinux.lds.S +++ b/arch/arm/boot/compressed/vmlinux.lds.S @@ -34,8 +34,11 @@ SECTIONS . = TEXT_START; _text = .; - .text : { + .head.text : { _start = .; + *(.head.text) + } + .text : { *(.start) *(.text) *(.text.*)