aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Bottomley <JBottomley@Parallels.com>2015-01-06 10:39:40 -0800
committerJames Bottomley <JBottomley@Parallels.com>2015-01-06 13:14:36 -0800
commit251af18e14c9ff558a9183ddb0d0b4f729c9474e (patch)
treeaf008de02421be99ac4355ec0349b502d6cea91d
parent07f0007624e71d9126c21aa8918f88f9557af0ab (diff)
downloadefitools-251af18e14c9ff558a9183ddb0d0b4f729c9474e.tar.gz
Make alterations for 32 bit cross compile
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
-rw-r--r--Make.rules11
-rw-r--r--Makefile23
-rw-r--r--elf_ia32_efi.lds75
-rw-r--r--lib/Makefile5
-rw-r--r--lib/asn1/Makefile11
5 files changed, 110 insertions, 15 deletions
diff --git a/Make.rules b/Make.rules
index d51abdd..1a1ef5c 100644
--- a/Make.rules
+++ b/Make.rules
@@ -1,10 +1,15 @@
EFISIGNED = $(patsubst %.efi,%-signed.efi,$(EFIFILES))
MANPAGES = $(patsubst doc/%.1.in,doc/%.1,$(wildcard doc/*.1.in))
HELP2MAN = help2man
-ARCH = $(shell uname -m)
+ARCH = $(shell uname -m | sed s/i.86/ia32/)
+ifeq ($(ARCH),ia32)
+ARCH3264 = -m32
+else ifneq ($(ARCH),x86_64)
+$(error unknown architecture $(ARCH))
+endif
INCDIR = -I$(TOPDIR)include/ -I/usr/include/efi -I/usr/include/efi/$(ARCH) -I/usr/include/efi/protocol
CPPFLAGS = -DCONFIG_$(ARCH)
-CFLAGS = -O2 -fpic -Wall -fshort-wchar -fno-strict-aliasing -fno-merge-constants -mno-red-zone -fno-stack-protector -g
+CFLAGS = -O2 $(ARCH3264) -fpic -Wall -fshort-wchar -fno-strict-aliasing -fno-merge-constants -mno-red-zone -fno-stack-protector -g
LDFLAGS = -nostdlib
CRTOBJ = crt0-efi-$(ARCH).o
CRTPATHS = /lib /lib64 /lib/efi /lib64/efi /usr/lib /usr/lib64 /usr/lib/efi /usr/lib64/efi
@@ -14,7 +19,7 @@ CRTOBJS = $(CRTPATH)/$(CRTOBJ)
# aligned otherwise the file alignment gets screwed up
LDSCRIPT = $(TOPDIR)/elf_$(ARCH)_efi.lds
LDFLAGS += -T $(LDSCRIPT) -shared -Bsymbolic $(CRTOBJS) -L $(CRTPATH)
-LOADLIBES = -lefi -lgnuefi $(shell $(CC) -print-libgcc-file-name)
+LOADLIBES = -lefi -lgnuefi $(shell $(CC) $(ARCH3264) -print-libgcc-file-name)
FORMAT = efi-app-$(ARCH)
OBJCOPY = objcopy
MYGUID = 11111111-2222-3333-4444-123456789abc
diff --git a/Makefile b/Makefile
index 4579f9d..062c7ef 100644
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,12 @@
EFIFILES = HelloWorld.efi LockDown.efi Loader.efi ReadVars.efi UpdateVars.efi \
- KeyTool.efi HashTool.efi PreLoader.efi SetNull.efi
+ KeyTool.efi HashTool.efi SetNull.efi
BINARIES = cert-to-efi-sig-list sig-list-to-certs sign-efi-sig-list \
hash-to-efi-sig-list efi-readvar efi-updatevar cert-to-efi-hash-list
+ifeq ($(ARCH),x86_64)
+EFIFILES += PreLoader.efi
+endif
+
MSGUID = 77FA9ABD-0359-4D32-BD60-28F4E78F784B
KEYS = PK KEK DB
@@ -82,34 +86,35 @@ PreLoader.so: lib/lib-efi.a
HelloWorld.so: lib/lib-efi.a
cert-to-efi-sig-list: cert-to-efi-sig-list.o lib/lib.a
- $(CC) -o $@ $< -lcrypto lib/lib.a
+ $(CC) $(ARCH3264) -o $@ $< -lcrypto lib/lib.a
sig-list-to-certs: sig-list-to-certs.o lib/lib.a
- $(CC) -o $@ $< -lcrypto lib/lib.a
+ $(CC) $(ARCH3264) -o $@ $< -lcrypto lib/lib.a
sign-efi-sig-list: sign-efi-sig-list.o lib/lib.a
- $(CC) -o $@ $< -lcrypto lib/lib.a
+ $(CC) $(ARCH3264) -o $@ $< -lcrypto lib/lib.a
hash-to-efi-sig-list: hash-to-efi-sig-list.o lib/lib.a
- $(CC) -o $@ $< lib/lib.a
+ $(CC) $(ARCH3264) -o $@ $< lib/lib.a
cert-to-efi-hash-list: cert-to-efi-hash-list.o lib/lib.a
- $(CC) -o $@ $< -lcrypto lib/lib.a
+ $(CC) $(ARCH3264) -o $@ $< -lcrypto lib/lib.a
efi-keytool: efi-keytool.o lib/lib.a
- $(CC) -o $@ $< lib/lib.a
+ $(CC) $(ARCH3264) -o $@ $< lib/lib.a
efi-readvar: efi-readvar.o lib/lib.a
- $(CC) -o $@ $< -lcrypto lib/lib.a
+ $(CC) $(ARCH3264) -o $@ $< -lcrypto lib/lib.a
efi-updatevar: efi-updatevar.o lib/lib.a
- $(CC) -o $@ $< -lcrypto lib/lib.a
+ $(CC) $(ARCH3264) -o $@ $< -lcrypto lib/lib.a
clean:
rm -f PK.* KEK.* DB.* $(EFIFILES) $(EFISIGNED) $(BINARIES) *.o *.so
rm -f noPK.*
rm -f doc/*.1
$(MAKE) -C lib clean
+ $(MAKE) -C lib/asn1 clean
FORCE:
diff --git a/elf_ia32_efi.lds b/elf_ia32_efi.lds
new file mode 100644
index 0000000..975e36c
--- /dev/null
+++ b/elf_ia32_efi.lds
@@ -0,0 +1,75 @@
+OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
+OUTPUT_ARCH(i386)
+ENTRY(_start)
+SECTIONS
+{
+ . = 0;
+ ImageBase = .;
+ .hash : { *(.hash) } /* this MUST come first! */
+ . = ALIGN(4096);
+ .text :
+ {
+ *(.text)
+ *(.text.*)
+ *(.gnu.linkonce.t.*)
+ }
+ . = ALIGN(4096);
+ .sdata :
+ {
+ *(.got.plt)
+ *(.got)
+ *(.srodata)
+ *(.sdata)
+ *(.sbss)
+ *(.scommon)
+ }
+ . = ALIGN(4096);
+ .data :
+ {
+ *(.rodata*)
+ *(.data)
+ *(.data1)
+ *(.data.*)
+ *(.sdata)
+ *(.got.plt)
+ *(.got)
+ /* the EFI loader doesn't seem to like a .bss section, so we stick
+ it all into .data: */
+ *(.sbss)
+ *(.scommon)
+ *(.dynbss)
+ *(.bss)
+ *(COMMON)
+ }
+ . = ALIGN(4096);
+ .dynamic : { *(.dynamic) }
+ . = ALIGN(4096);
+ .rel :
+ {
+ *(.rel.data)
+ *(.rel.data.*)
+ *(.rel.got)
+ *(.rel.stab)
+ *(.data.rel.ro.local)
+ *(.data.rel.local)
+ *(.data.rel.ro)
+ *(.data.rel*)
+ }
+ . = ALIGN(4096);
+ .reloc : /* This is the PECOFF .reloc section! */
+ {
+ *(.reloc)
+ }
+ . = ALIGN(4096);
+ .dynsym : { *(.dynsym) }
+ . = ALIGN(4096);
+ .dynstr : { *(.dynstr) }
+ . = ALIGN(4096);
+ /DISCARD/ :
+ {
+ *(.rel.reloc)
+ *(.eh_frame)
+ *(.note.GNU-stack)
+ }
+ .comment 0 : { *(.comment) }
+}
diff --git a/lib/Makefile b/lib/Makefile
index 241ab26..945805c 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -1,5 +1,8 @@
FILES = simple_file.o pecoff.o guid.o sha256.o console.o \
- security_policy.o execute.o configtable.o shell.o
+ execute.o configtable.o shell.o
+ifeq ($(ARCH),x86_64)
+FILES += security_policy.o
+endif
LIBFILES = $(FILES) kernel_efivars.o
EFILIBFILES = $(patsubst %.o,%.efi.o,$(FILES)) variables.o
diff --git a/lib/asn1/Makefile b/lib/asn1/Makefile
index c900a4f..42797d0 100644
--- a/lib/asn1/Makefile
+++ b/lib/asn1/Makefile
@@ -8,7 +8,14 @@ libasn1.a: $(LIBFILES)
libasn1-efi.a: $(EFILIBFILES)
test.o: test.c ../../include/x509.h
- $(CC) -I../../include -c -o $@ $<
+ $(CC) $(ARCH3264) -I../../include -c -o $@ $<
test: test.o libasn1.a
- $(CC) -o $@ $< libasn1.a
+ $(CC) $(ARCH3264) -o $@ $< libasn1.a
+
+clean:
+ rm -f libasn1.a
+ rm -f libasn1-efi.a
+ rm -f test test.o
+ rm -f $(LIBFILES)
+ rm -f $(EFILIBFILES)