From patchwork Tue Aug 12 13:33:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 35260 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f199.google.com (mail-ob0-f199.google.com [209.85.214.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id EF9A520540 for ; Tue, 12 Aug 2014 13:33:49 +0000 (UTC) Received: by mail-ob0-f199.google.com with SMTP id wn1sf44152542obc.2 for ; Tue, 12 Aug 2014 06:33:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=cwBBNP50nOMXLBNcaoZD7mBUgdGU+mJiu+xqUU250vk=; b=akL8ne1iys29OO38t6hlee5Yi+F3OVgKcnQNtcQ/OAHWak5ioi/0Goq232Kva5E/wC M1uTbKDU8rtAtWk3/idF1D5ZPVpwNtddFvXSqWZrKMte5qOXv2cmStcNC8lnhv8R6RZi GIHbb4BeHjNfIWAbi9tr9fEPGa7PclawLcmikFTO1DDettaPT83p47u6Zguqage2rLkL xklsk0i4JYJXjn50C7QtqKcN+sU/HkGOHJeQ9BxkFVKxhC6DB2Rsof2TTQ/s8M0NHfye dq5SkDi0UHIrkZm0R2P9Bd3Dw9t/Ao+UoClQG15dEHr0t4D7TVgTtwJbm8xO3EbhVWHA qTqg== X-Gm-Message-State: ALoCoQkhRJzbwA3fti/7PIZrOQkmM6lfyfWOIwife4w192yP+eiIj5HqURXcQKe+BOcxjBa+x/fM X-Received: by 10.182.123.232 with SMTP id md8mr2240173obb.41.1407850429605; Tue, 12 Aug 2014 06:33:49 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.85.48 with SMTP id m45ls101526qgd.18.gmail; Tue, 12 Aug 2014 06:33:49 -0700 (PDT) X-Received: by 10.52.26.173 with SMTP id m13mr496898vdg.69.1407850429419; Tue, 12 Aug 2014 06:33:49 -0700 (PDT) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by mx.google.com with ESMTPS id tv2si8230216vcb.0.2014.08.12.06.33.49 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 12 Aug 2014 06:33:49 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.175 as permitted sender) client-ip=209.85.220.175; Received: by mail-vc0-f175.google.com with SMTP id ik5so13306413vcb.34 for ; Tue, 12 Aug 2014 06:33:49 -0700 (PDT) X-Received: by 10.221.47.9 with SMTP id uq9mr919801vcb.48.1407850429339; Tue, 12 Aug 2014 06:33:49 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp249195vcb; Tue, 12 Aug 2014 06:33:48 -0700 (PDT) X-Received: by 10.180.211.233 with SMTP id nf9mr32081185wic.33.1407850428031; Tue, 12 Aug 2014 06:33:48 -0700 (PDT) Received: from mail-wi0-f169.google.com (mail-wi0-f169.google.com [209.85.212.169]) by mx.google.com with ESMTPS id ck1si22420432wib.31.2014.08.12.06.33.47 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 12 Aug 2014 06:33:48 -0700 (PDT) Received-SPF: pass (google.com: domain of ard.biesheuvel@linaro.org designates 209.85.212.169 as permitted sender) client-ip=209.85.212.169; Received: by mail-wi0-f169.google.com with SMTP id n3so7011741wiv.0 for ; Tue, 12 Aug 2014 06:33:47 -0700 (PDT) X-Received: by 10.180.108.13 with SMTP id hg13mr33581031wib.28.1407850427425; Tue, 12 Aug 2014 06:33:47 -0700 (PDT) Received: from ards-macbook-pro.local ([109.227.30.102]) by mx.google.com with ESMTPSA id kw1sm9347231wjb.19.2014.08.12.06.33.45 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 12 Aug 2014 06:33:46 -0700 (PDT) From: Ard Biesheuvel To: matthew.garrett@nebula.com, pjones@redhat.com Cc: leif.lindholm@linaro.org, ilias.biris@linaro.org, patches@linaro.org, Ard Biesheuvel Subject: [PATCH 5/5] Add support for 32-bit ARM Date: Tue, 12 Aug 2014 15:33:22 +0200 Message-Id: <1407850402-11193-6-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1407850402-11193-1-git-send-email-ard.biesheuvel@linaro.org> References: <1407850402-11193-1-git-send-email-ard.biesheuvel@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.175 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This adds support for building the shim for a 32-bit ARM UEFI environment. Signed-off-by: Ard Biesheuvel --- 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 --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) } +}