Package: gnu-efi
Version: 3.0e-3
Severity: wishlist

Hi Nigel,

Attached is a patch to add support for kfreebsd-amd64 to the gnu-efi
package, and FreeBSD x86_64 support to upstream. FreeBSD i386 doesn't
need any changes.

Upstream changes:
 - add gnuefi/elf_x86_64_fbsd_efi.lds, this is the x86_64 linker
   script with the OUTPUT_FORMAT set to elf-x86-64-freebsd
 - patch Makefiles to use and install this linker script on anything
   that's FreeBSD on amd64 - works for both FreeBSD and kFreeBSD

Debian changes:
 - debian/control:
   + add kfreebsd-amd64 as a supported architecture
   + build-dep gcc-multilib on kfreebsd-amd64 too
   + bump Standards-Version to 3.8.2
 - debian/rules:
   + add support for kfreebsd amd64 & i386 by modifying the i386 &
     amd64 conditional parts (use findstring)
   + add support for kfreebsd amd64, that is, install the proper
     linker script
   + cleanup: do not install ia64 headers on i386/amd64, do not
     install i386/amd64 headers on ia64

Unfortunately, kfreebsd-i386 doesn't have a bi-arch gcc, so it can't
be enabled just yet. I hope we'll get a bi-arch compiler there soon,
too.

I've run the test apps and they work. Speaking of testing, TianoCore
have EFI firmwares for qemu now, both ia32 and x64. They call that
OVMF, it's part of the edkII project. You might want to check that
out, it's great to run the test apps =) The EFI ROMs come with the EFI
shell integrated, so you only need a small disk image to copy the test
apps to.

The patch contains an debian/changelog entry, too.

You may want to make that gnu-efi 3.0i upstream and I'd be happy to
sponsor the 3.0i-1 upload :)

Thanks,

JB.

-- 
 Julien BLACHE <[email protected]>  |  Debian, because code matters more 
 Debian & GNU/Linux Developer        |       <http://www.debian.org>
 Public key available on <http://www.jblache.org> - KeyID: F5D6 5169 
 GPG Fingerprint : 935A 79F1 C8B3 3521 FD62 7CC7 CD61 4FD7 F5D6 5169 

diff -ruN orig/gnu-efi-3.0e/Make.defaults gnu-efi-3.0e/Make.defaults
--- orig/gnu-efi-3.0e/Make.defaults	2009-07-04 14:39:53.000000000 +0200
+++ gnu-efi-3.0e/Make.defaults	2009-07-04 14:25:48.000000000 +0200
@@ -31,6 +31,7 @@
 
 HOSTARCH   = $(shell uname -m | sed s,i[3456789]86,ia32,)
 ARCH	   := $(shell uname -m | sed s,i[3456789]86,ia32,)
+OS	   = $(shell uname -s)
 INCDIR	   = -I$(SRCDIR) -I$(TOPDIR)/inc -I$(TOPDIR)/inc/$(ARCH) -I$(TOPDIR)/inc/protocol 
 CPPFLAGS   = -DCONFIG_$(ARCH)
 CFLAGS	   = $(ARCH3264) -O2 -fpic -Wall -fshort-wchar -fno-strict-aliasing -fno-merge-constants
diff -ruN orig/gnu-efi-3.0e/apps/Makefile gnu-efi-3.0e/apps/Makefile
--- orig/gnu-efi-3.0e/apps/Makefile	2009-07-04 14:39:53.000000000 +0200
+++ gnu-efi-3.0e/apps/Makefile	2009-07-04 14:26:09.000000000 +0200
@@ -33,7 +33,14 @@
 LINUX_HEADERS	= /usr/src/sys/build
 CPPFLAGS	+= -D__KERNEL__ -I$(LINUX_HEADERS)/include
 CRTOBJS		= ../gnuefi/crt0-efi-$(ARCH).o
+
 LDSCRIPT	= $(TOPDIR)/gnuefi/elf_$(ARCH)_efi.lds
+ifeq ($(ARCH),x86_64)
+ ifneq (,$(findstring FreeBSD,$(OS)))
+LDSCRIPT	= $(TOPDIR)/gnuefi/elf_$(ARCH)_fbsd_efi.lds
+ endif
+endif
+
 LDFLAGS		+= -T $(LDSCRIPT) -shared -Bsymbolic -L../lib -L../gnuefi $(CRTOBJS)
 LOADLIBES	= -lefi -lgnuefi $(shell $(CC) $(ARCH3264) -print-libgcc-file-name)
 FORMAT		= efi-app-$(ARCH)
diff -ruN orig/gnu-efi-3.0e/debian/changelog gnu-efi-3.0e/debian/changelog
--- orig/gnu-efi-3.0e/debian/changelog	2009-07-04 14:39:53.000000000 +0200
+++ gnu-efi-3.0e/debian/changelog	2009-07-04 14:47:43.000000000 +0200
@@ -1,3 +1,16 @@
+gnu-efi (3.0e-4) unstable; urgency=low
+
+  * debian/control:
+    + Make kfreebsd-amd64 a supported architecture.
+    + Build-depend on gcc-multilib on kfreebsd-amd64 too.
+  * debian/rules:
+    + Add support for both kfreebsd-{i386,amd64}.
+    + Install FreeBSD x86_64 linker script on kfreebsd-amd64.
+    + Do not install ia64-specific headers on i386/amd64, do not install
+      i386/amd64-specific headers on ia64.
+
+ -- Julien Blache <[email protected]>  Sat, 04 Jul 2009 14:45:03 +0200
+
 gnu-efi (3.0e-3) unstable; urgency=low
 
   * Non-maintainer upload with maintainer's consent.
diff -ruN orig/gnu-efi-3.0e/debian/control gnu-efi-3.0e/debian/control
--- orig/gnu-efi-3.0e/debian/control	2009-07-04 14:39:53.000000000 +0200
+++ gnu-efi-3.0e/debian/control	2009-07-04 14:29:50.000000000 +0200
@@ -3,11 +3,11 @@
 Priority: optional
 Maintainer: Nigel Croxon <[email protected]>
 Uploaders: Bdale Garbee <[email protected]>
-Build-Depends: debhelper (>> 5), binutils (>= 2.17.50.0.14), gcc-multilib [i386 amd64]
-Standards-Version: 3.8.1
+Build-Depends: debhelper (>> 5), binutils (>= 2.17.50.0.14), gcc-multilib [i386 amd64 kfreebsd-amd64]
+Standards-Version: 3.8.2
 
 Package: gnu-efi
-Architecture: i386 ia64 amd64 
+Architecture: i386 ia64 amd64 kfreebsd-amd64
 Suggests: elilo
 Description: Library for developing EFI applications
  GNU toolchain for building applications that can run in the environment
diff -ruN orig/gnu-efi-3.0e/debian/rules gnu-efi-3.0e/debian/rules
--- orig/gnu-efi-3.0e/debian/rules	2009-07-04 14:39:53.000000000 +0200
+++ gnu-efi-3.0e/debian/rules	2009-07-04 14:44:13.000000000 +0200
@@ -1,26 +1,24 @@
 #!/usr/bin/make -f
 
 buildarch := $(shell dpkg-architecture -qDEB_BUILD_ARCH)
-ifeq ($(buildarch),i386)
+ifneq (,$(findstring i386,$(buildarch)))
 	efiarch := ia32
-else
-  ifeq ($(buildarch),amd64)
+else ifneq (,$(findstring amd64,$(buildarch)))
 	efiarch := x86_64
-  else
+else
 	efiarch := $(buildarch)
-  endif
 endif
 
 build: build-stamp
 build-stamp:
 	dh_testdir
 
-ifeq ($(buildarch),amd64)
+ifneq (,$(findstring amd64,$(buildarch)))
 	mkdir build-ia32
 	$(MAKE) -C build-ia32 -f ../Makefile SRCDIR=.. ARCH=ia32
 endif
 
-ifeq ($(buildarch),i386)
+ifneq (,$(findstring i386,$(buildarch)))
 	mkdir build-x86_64
 	$(MAKE) -C build-x86_64 -f ../Makefile SRCDIR=.. ARCH=x86_64
 endif
@@ -52,12 +50,22 @@
 	rm debian/gnu-efi/usr/include/efi/protocol/make.inf
 	rm debian/gnu-efi/usr/include/efi/protocol/makefile.hdr
 	rm debian/gnu-efi/usr/include/efi/protocol/readme.txt
+ifeq ($(buildarch),ia64)
+	rm -rf debian/gnu-efi/usr/include/efi/ia32
+	rm -rf debian/gnu-efi/usr/include/efi/x84_64
+else
+	rm -rf debian/gnu-efi/usr/include/efi/ia64
+endif
 	cp gnuefi/*.a debian/gnu-efi/usr/lib/
+ifeq ($(buildarch),kfreebsd-amd64)
+	cp gnuefi/elf_$(efiarch)_fbsd_efi.lds debian/gnu-efi/usr/lib
+else
 	cp gnuefi/elf_$(efiarch)_efi.lds debian/gnu-efi/usr/lib
+endif
 	cp gnuefi/crt0-efi-$(efiarch).o debian/gnu-efi/usr/lib
 	cp lib/*.a debian/gnu-efi/usr/lib/
 
-ifeq ($(buildarch),amd64)
+ifneq (,$(findstring amd64,$(buildarch)))
 	mkdir -p debian/gnu-efi/usr/lib32
 	cp build-ia32/gnuefi/*.a debian/gnu-efi/usr/lib32/
 	cp gnuefi/elf_ia32_efi.lds debian/gnu-efi/usr/lib32/
@@ -65,10 +73,14 @@
 	cp build-ia32/lib/*.a debian/gnu-efi/usr/lib32/
 endif
 
-ifeq ($(buildarch),i386)
+ifneq (,$(findstring i386,$(buildarch)))
 	mkdir -p debian/gnu-efi/usr/lib64
 	cp build-x86_64/gnuefi/*.a debian/gnu-efi/usr/lib64/
+ifeq ($(buildarch),kfreebsd-i386)
+	cp gnuefi/elf_x86_64_fbsd_efi.lds debian/gnu-efi/usr/lib64/
+else
 	cp gnuefi/elf_x86_64_efi.lds debian/gnu-efi/usr/lib64/
+endif
 	cp build-x86_64/gnuefi/crt0-efi-x86_64.o debian/gnu-efi/usr/lib64/
 	cp build-x86_64/lib/*.a debian/gnu-efi/usr/lib64/
 endif
diff -ruN orig/gnu-efi-3.0e/gnuefi/Makefile gnu-efi-3.0e/gnuefi/Makefile
--- orig/gnu-efi-3.0e/gnuefi/Makefile	2009-07-04 14:39:53.000000000 +0200
+++ gnu-efi-3.0e/gnuefi/Makefile	2009-07-04 14:38:12.000000000 +0200
@@ -46,6 +46,14 @@
 install:
 	mkdir -p $(INSTALLROOT)/lib
 	$(INSTALL) -m 644 $(TARGETS) $(INSTALLROOT)/lib
+ifneq (,$(findstring FreeBSD,$(OS)))
+ ifeq ($(ARCH),x86_64)
+	$(INSTALL) -m 644 elf_$(ARCH)_fbsd_efi.lds $(INSTALLROOT)/lib
+ else
 	$(INSTALL) -m 644 elf_$(ARCH)_efi.lds $(INSTALLROOT)/lib
+ endif
+else
+	$(INSTALL) -m 644 elf_$(ARCH)_efi.lds $(INSTALLROOT)/lib
+endif
 
 include $(SRCDIR)/../Make.rules
diff -ruN orig/gnu-efi-3.0e/gnuefi/elf_x86_64_efi.lds gnu-efi-3.0e/gnuefi/elf_x86_64_efi.lds
--- orig/gnu-efi-3.0e/gnuefi/elf_x86_64_efi.lds	2007-05-11 19:03:05.000000000 +0200
+++ gnu-efi-3.0e/gnuefi/elf_x86_64_efi.lds	2009-07-04 14:16:29.000000000 +0200
@@ -1,3 +1,4 @@
+/* Same as elf_x86_64_fbsd_efi.lds, except for OUTPUT_FORMAT below - KEEP IN SYNC */
 OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64")
 OUTPUT_ARCH(i386:x86-64)
 ENTRY(_start)
diff -ruN orig/gnu-efi-3.0e/gnuefi/elf_x86_64_fbsd_efi.lds gnu-efi-3.0e/gnuefi/elf_x86_64_fbsd_efi.lds
--- orig/gnu-efi-3.0e/gnuefi/elf_x86_64_fbsd_efi.lds	1970-01-01 01:00:00.000000000 +0100
+++ gnu-efi-3.0e/gnuefi/elf_x86_64_fbsd_efi.lds	2009-07-04 14:15:57.000000000 +0200
@@ -0,0 +1,59 @@
+/* Same as elf_x86_64_efi.lds, except for OUTPUT_FORMAT below - KEEP IN SYNC */
+OUTPUT_FORMAT("elf64-x86-64-freebsd", "elf64-x86-64-freebsd", "elf64-x86-64-freebsd")
+OUTPUT_ARCH(i386:x86-64)
+ENTRY(_start)
+SECTIONS
+{
+  . = 0;
+  ImageBase = .;
+  .hash : { *(.hash) }	/* this MUST come first! */
+  . = ALIGN(4096);
+  .eh_frame : 
+  { 
+    *(.eh_frame)
+  }
+  . = ALIGN(4096);
+  .text :
+  {
+   *(.text)
+  }
+  .reloc :
+  {
+   *(.reloc)
+  }
+  . = ALIGN(4096);
+  .data :
+  {
+   *(.rodata*)
+   *(.got.plt)
+   *(.got)
+   *(.data*)
+   *(.sdata)
+   /* the EFI loader doesn't seem to like a .bss section, so we stick
+      it all into .data: */
+   *(.sbss)
+   *(.scommon)
+   *(.dynbss)
+   *(.bss)
+   *(COMMON)
+   *(.rel.local)
+  }
+  . = ALIGN(4096);
+  .dynamic  : { *(.dynamic) }
+  . = ALIGN(4096);
+  .rela :
+  {
+    *(.rela.data*)
+    *(.rela.got)
+    *(.rela.stab)
+  }
+  . = ALIGN(4096);
+  .dynsym   : { *(.dynsym) }
+  . = ALIGN(4096);
+  .dynstr   : { *(.dynstr) }
+  . = ALIGN(4096);
+  .ignored.reloc :
+  {
+    *(.rela.reloc)
+  }
+}

Reply via email to