diff mbox

[5/5] Add support for 32-bit ARM

Message ID 1407850402-11193-6-git-send-email-ard.biesheuvel@linaro.org
State New
Headers show

Commit Message

Ard Biesheuvel Aug. 12, 2014, 1:33 p.m. UTC
This adds support for building the shim for a 32-bit ARM UEFI environment.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 Cryptlib/OpenSSL/Makefile |  3 +++
 Makefile                  | 10 ++++++++
 cert.S                    | 30 ++++++++++------------
 elf_arm_efi.lds           | 65 +++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 92 insertions(+), 16 deletions(-)
 create mode 100644 elf_arm_efi.lds
diff mbox

Patch

diff --git a/Cryptlib/OpenSSL/Makefile b/Cryptlib/OpenSSL/Makefile
index 17b5695b827c..7990b3cea5dd 100644
--- a/Cryptlib/OpenSSL/Makefile
+++ b/Cryptlib/OpenSSL/Makefile
@@ -15,6 +15,9 @@  endif
 ifeq ($(ARCH),aarch64)
 	CFLAGS	+= -O2 -DSIXTY_FOUR_BIT_LONG -ffreestanding -I$(shell $(CC) -print-file-name=include)
 endif
+ifeq ($(ARCH),arm)
+	CFLAGS	+= -O2 -DTHIRTY_TWO_BIT -ffreestanding -I$(shell $(CC) -print-file-name=include)
+endif
 LDFLAGS		= -nostdlib -znocombreloc
 
 TARGET		= libopenssl.a
diff --git a/Makefile b/Makefile
index 3529b454476a..5bc513c1853e 100644
--- a/Makefile
+++ b/Makefile
@@ -41,6 +41,10 @@  ifeq ($(ARCH),aarch64)
 	CFLAGS	+= -ffreestanding -I$(shell $(CC) -print-file-name=include)
 endif
 
+ifeq ($(ARCH),arm)
+	CFLAGS	+= -ffreestanding -I$(shell $(CC) -print-file-name=include)
+endif
+
 ifneq ($(origin VENDOR_CERT_FILE), undefined)
 	CFLAGS += -DVENDOR_CERT_FILE=\"$(VENDOR_CERT_FILE)\"
 endif
@@ -118,6 +122,12 @@  SUBSYSTEM	:= 0xa
 LDFLAGS		+= --defsym=EFI_SUBSYSTEM=$(SUBSYSTEM)
 endif
 
+ifeq ($(ARCH),arm)
+FORMAT		:= -O binary
+SUBSYSTEM	:= 0xa
+LDFLAGS		+= --defsym=EFI_SUBSYSTEM=$(SUBSYSTEM)
+endif
+
 FORMAT		?= --target efi-app-$(ARCH)
 
 %.efi: %.so
diff --git a/cert.S b/cert.S
index 3cfd665f513f..cfc4525b44c1 100644
--- a/cert.S
+++ b/cert.S
@@ -1,9 +1,7 @@ 
 	.globl cert_table
-	.data
-	.align 16
-	.type	cert_table, @object
+	.type	cert_table, %object
 	.size	cert_table, 4
-	.section .vendor_cert, "a", @progbits
+	.section .vendor_cert, "a", %progbits
 cert_table:
 #if defined(VENDOR_CERT_FILE)
 	.long	vendor_cert_priv_end - vendor_cert_priv
@@ -20,48 +18,48 @@  cert_table:
 #if defined(VENDOR_CERT_FILE)
 	.data
 	.align	1
-	.type	vendor_cert_priv, @object
+	.type	vendor_cert_priv, %object
 	.size	vendor_cert_priv, vendor_cert_priv_end-vendor_cert_priv
-	.section .vendor_cert, "a", @progbits
+	.section .vendor_cert, "a", %progbits
 vendor_cert_priv:
 .incbin VENDOR_CERT_FILE
 vendor_cert_priv_end:
 #else
 	.bss
-	.type	vendor_cert_priv, @object
+	.type	vendor_cert_priv, %object
 	.size	vendor_cert_priv, 1
-	.section .vendor_cert, "a", @progbits
+	.section .vendor_cert, "a", %progbits
 vendor_cert_priv:
 	.zero	1
 
 	.data
 	.align 4
-	.type	vendor_cert_size_priv, @object
+	.type	vendor_cert_size_priv, %object
 	.size	vendor_cert_size_priv, 4
-	.section .vendor_cert, "a", @progbits
+	.section .vendor_cert, "a", %progbits
 vendor_cert_priv_end:
 #endif
 #if defined(VENDOR_DBX_FILE)
 	.data
 	.align	1
-	.type	vendor_dbx_priv, @object
+	.type	vendor_dbx_priv, %object
 	.size	vendor_dbx_priv, vendor_dbx_priv_end-vendor_dbx_priv
-	.section .vendor_cert, "a", @progbits
+	.section .vendor_cert, "a", %progbits
 vendor_dbx_priv:
 .incbin VENDOR_DBX_FILE
 vendor_dbx_priv_end:
 #else
 	.bss
-	.type	vendor_dbx_priv, @object
+	.type	vendor_dbx_priv, %object
 	.size	vendor_dbx_priv, 1
-	.section .vendor_cert, "a", @progbits
+	.section .vendor_cert, "a", %progbits
 vendor_dbx_priv:
 	.zero	1
 
 	.data
 	.align 4
-	.type	vendor_dbx_size_priv, @object
+	.type	vendor_dbx_size_priv, %object
 	.size	vendor_dbx_size_priv, 4
-	.section .vendor_cert, "a", @progbits
+	.section .vendor_cert, "a", %progbits
 vendor_dbx_priv_end:
 #endif
diff --git a/elf_arm_efi.lds b/elf_arm_efi.lds
new file mode 100644
index 000000000000..fd1075d7415c
--- /dev/null
+++ b/elf_arm_efi.lds
@@ -0,0 +1,65 @@ 
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+ENTRY(_start)
+SECTIONS
+{
+  .text 0x0 : {
+    *(.text.head)
+    *(.text)
+    *(.text.*)
+    *(.gnu.linkonce.t.*)
+    *(.srodata)
+    *(.rodata*)
+    . = ALIGN(16);
+    _etext = .;
+  }
+  .dynamic  : { *(.dynamic) }
+  .data :
+  {
+   *(.sdata)
+   *(.data)
+   *(.data1)
+   *(.data)
+   *(.got.plt)
+   *(.got)
+
+   /* the EFI loader doesn't seem to like a .bss section, so we stick
+      it all into .data: */
+   . = ALIGN(16);
+   _bss = .;
+   *(.sbss)
+   *(.scommon)
+   *(.dynbss)
+   *(.bss)
+   *(COMMON)
+   . = ALIGN(16);
+   _bss_end = .;
+  }
+
+   . = ALIGN(4096);
+  .vendor_cert :
+  {
+    *(.vendor_cert)
+  }
+  . = ALIGN(4096);
+
+  .rel.dyn : { *(.rel.dyn) }
+  .rel.plt : { *(.rel.plt) }
+  .rel.got : { *(.rel.got) }
+  .rel.data : { *(.rel.data) *(.rel.data*) }
+  _edata = .;
+  _data_size = . - _etext;
+
+  . = ALIGN(4096);
+  .dynsym   : { *(.dynsym) }
+  . = ALIGN(4096);
+  .dynstr   : { *(.dynstr) }
+  . = ALIGN(4096);
+  /DISCARD/ :
+  {
+    *(.rel.reloc)
+    *(.eh_frame)
+    *(.note.GNU-stack)
+  }
+  .comment 0 : { *(.comment) }
+}