linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: ard.biesheuvel@linaro.org (Ard Biesheuvel)
To: linux-arm-kernel@lists.infradead.org
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	[thread overview]
Message-ID: <1486554947-3964-10-git-send-email-ard.biesheuvel@linaro.org> (raw)
In-Reply-To: <1486554947-3964-1-git-send-email-ard.biesheuvel@linaro.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 <dave.martin@arm.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 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(-)

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.*)
-- 
2.7.4

  parent reply	other threads:[~2017-02-08 11:55 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-08 11:55 [PATCH v2 00/14] arm64+ARM: efi: PE/COFF cleanup/hardening Ard Biesheuvel
2017-02-08 11:55 ` [PATCH v2 01/14] include: pe.h: allow for use in assembly Ard Biesheuvel
2017-02-08 11:55 ` [PATCH v2 02/14] include: pe.h: add some missing definitions Ard Biesheuvel
2017-02-08 11:55 ` [PATCH v2 03/14] arm64: efi: move EFI header and related data to a separate .S file Ard Biesheuvel
2017-02-10 10:10   ` Mark Rutland
2017-02-08 11:55 ` [PATCH v2 04/14] arm64: efi: clean up Image header after PE header has been split off Ard Biesheuvel
2017-02-10 10:11   ` Mark Rutland
2017-02-10 14:30     ` Ard Biesheuvel
2017-02-08 11:55 ` [PATCH v2 05/14] arm64: efi: remove forbidden values from the PE/COFF header Ard Biesheuvel
2017-02-10 10:13   ` Mark Rutland
2017-02-10 14:31     ` Ard Biesheuvel
2017-02-08 11:55 ` [PATCH v2 06/14] arm64: efi: remove pointless dummy .reloc section Ard Biesheuvel
2017-02-08 11:55 ` [PATCH v2 07/14] arm64: efi: replace open coded constants with symbolic ones Ard Biesheuvel
2017-02-10 10:19   ` Mark Rutland
2017-02-08 11:55 ` [PATCH v2 08/14] arm64: efi: split Image code and data into separate PE/COFF sections Ard Biesheuvel
2017-02-10 10:49   ` Mark Rutland
2017-02-10 14:28     ` Ard Biesheuvel
2017-02-08 11:55 ` Ard Biesheuvel [this message]
2017-02-08 11:55 ` [PATCH v2 10/14] arm: efi: remove forbidden values from the PE/COFF header Ard Biesheuvel
2017-02-08 11:55 ` [PATCH v2 11/14] arm: efi: remove pointless dummy .reloc section Ard Biesheuvel
2017-02-08 11:55 ` [PATCH v2 12/14] arm: efi: replace open coded constants with symbolic ones Ard Biesheuvel
2017-02-08 11:55 ` [PATCH v2 13/14] arm: efi: split zImage code and data into separate PE/COFF sections Ard Biesheuvel
2017-02-08 11:55 ` [PATCH v2 14/14] arm: efi: add PE/COFF debug table to EFI header Ard Biesheuvel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1486554947-3964-10-git-send-email-ard.biesheuvel@linaro.org \
    --to=ard.biesheuvel@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).