diff --git a/gnu-efi-3.0/Make.defaults b/gnu-efi-3.0/Make.defaults index 38da180..0585915 100644 --- a/gnu-efi-3.0/Make.defaults +++ b/gnu-efi-3.0/Make.defaults @@ -46,6 +46,10 @@ TOPDIR := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi) HOSTARCH = $(shell uname -m | sed s,i[3456789]86,ia32,) ARCH := $(shell uname -m | sed s,i[3456789]86,ia32,) +# FreeBSD (and possibly others) reports amd64 instead of x86_64 +ifeq ($(ARCH), amd64) +ARCH = x86_64 +endif OS = $(shell uname -s) INCDIR = -I$(SRCDIR) -I$(TOPDIR)/inc -I$(TOPDIR)/inc/$(ARCH) -I$(TOPDIR)/inc/protocol GCCVERSION := $(shell gcc -dumpversion | cut -f1 -d.) @@ -56,9 +60,9 @@ CPPFLAGS = -DCONFIG_$(ARCH) ifeq ($(GCCNEWENOUGH),1) CPPFLAGS += -DGNU_EFI_USE_MS_ABI -maccumulate-outgoing-args --std=c11 endif -CFLAGS = $(ARCH3264) -O2 -fpic -Wall -fshort-wchar -fno-strict-aliasing -fno-merge-constants +CFLAGS = $(ARCH3264) -O2 -fpic -Wall -fshort-wchar -fno-strict-aliasing -fno-merge-constants -ffreestanding -fno-stack-protector -fno-stack-check ASFLAGS = $(ARCH3264) -LDFLAGS = -nostdlib +LDFLAGS = -nostdlib --no-undefined INSTALL = install prefix = /usr/bin/ diff --git a/gnu-efi-3.0/apps/Makefile b/gnu-efi-3.0/apps/Makefile index 43db2f1..773bc08 100644 --- a/gnu-efi-3.0/apps/Makefile +++ b/gnu-efi-3.0/apps/Makefile @@ -48,10 +48,8 @@ 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))) +ifneq (,$(findstring FreeBSD,$(OS))) LDSCRIPT = $(TOPDIR)/gnuefi/elf_$(ARCH)_fbsd_efi.lds - endif endif LDFLAGS += -T $(LDSCRIPT) -shared -Bsymbolic -L../lib -L../gnuefi $(CRTOBJS) diff --git a/gnu-efi-3.0/gnuefi/elf_ia32_fbsd_efi.lds b/gnu-efi-3.0/gnuefi/elf_ia32_fbsd_efi.lds new file mode 100644 index 0000000..bc25b1f --- /dev/null +++ b/gnu-efi-3.0/gnuefi/elf_ia32_fbsd_efi.lds @@ -0,0 +1,75 @@ +OUTPUT_FORMAT("elf32-i386-freebsd", "elf32-i386-freebsd", "elf32-i386-freebsd") +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/gnu-efi-3.0/gnuefi/reloc_ia32.c b/gnu-efi-3.0/gnuefi/reloc_ia32.c index be57f4f..8d50a75 100644 --- a/gnu-efi-3.0/gnuefi/reloc_ia32.c +++ b/gnu-efi-3.0/gnuefi/reloc_ia32.c @@ -33,43 +33,22 @@ SUCH DAMAGE. */ -#include -#include /* get _DYNAMIC decl and ElfW and ELFW macros */ - -#undef NULL -#define uint64_t efi_uint64_t -#define int64_t efi_int64_t -#define uint32_t efi_uint32_t -#define int32_t efi_int32_t -#define uint16_t efi_uint16_t -#define int16_t efi_int16_t -#define uint8_t efi_uint8_t -#define int8_t efi_int8_t - -#undef NULL -#define uint64_t efi_uint64_t -#define int64_t efi_int64_t -#define uint32_t efi_uint32_t -#define int32_t efi_int32_t -#define uint16_t efi_uint16_t -#define int16_t efi_int16_t -#define uint8_t efi_uint8_t -#define int8_t efi_int8_t - #include #include -EFI_STATUS _relocate (long ldbase, ElfW(Dyn) *dyn, EFI_HANDLE image, EFI_SYSTEM_TABLE *systab) +#include + +EFI_STATUS _relocate (long ldbase, Elf32_Dyn *dyn, EFI_HANDLE image, EFI_SYSTEM_TABLE *systab) { long relsz = 0, relent = 0; - ElfW(Rel) *rel = 0; + Elf32_Rel *rel = 0; unsigned long *addr; int i; for (i = 0; dyn[i].d_tag != DT_NULL; ++i) { switch (dyn[i].d_tag) { case DT_REL: - rel = (ElfW(Rel)*) + rel = (Elf32_Rel*) ((unsigned long)dyn[i].d_un.d_ptr + ldbase); break; @@ -111,7 +90,7 @@ EFI_STATUS _relocate (long ldbase, ElfW(Dyn) *dyn, EFI_HANDLE image, EFI_SYSTEM_ default: break; } - rel = (ElfW(Rel)*) ((char *) rel + relent); + rel = (Elf32_Rel*) ((char *) rel + relent); relsz -= relent; } return EFI_SUCCESS; diff --git a/gnu-efi-3.0/gnuefi/reloc_x86_64.c b/gnu-efi-3.0/gnuefi/reloc_x86_64.c index 4593125..04b4ddb 100644 --- a/gnu-efi-3.0/gnuefi/reloc_x86_64.c +++ b/gnu-efi-3.0/gnuefi/reloc_x86_64.c @@ -35,44 +35,22 @@ SUCH DAMAGE. */ -#include -#include /* get _DYNAMIC decl and ElfW and ELFW macros */ - - -#undef NULL -#define uint64_t efi_uint64_t -#define int64_t efi_int64_t -#define uint32_t efi_uint32_t -#define int32_t efi_int32_t -#define uint16_t efi_uint16_t -#define int16_t efi_int16_t -#define uint8_t efi_uint8_t -#define int8_t efi_int8_t - -#undef NULL -#define uint64_t efi_uint64_t -#define int64_t efi_int64_t -#define uint32_t efi_uint32_t -#define int32_t efi_int32_t -#define uint16_t efi_uint16_t -#define int16_t efi_int16_t -#define uint8_t efi_uint8_t -#define int8_t efi_int8_t - #include #include -EFI_STATUS _relocate (long ldbase, ElfW(Dyn) *dyn, EFI_HANDLE image, EFI_SYSTEM_TABLE *systab) +#include + +EFI_STATUS _relocate (long ldbase, Elf64_Dyn *dyn, EFI_HANDLE image, EFI_SYSTEM_TABLE *systab) { long relsz = 0, relent = 0; - ElfW(Rel) *rel = 0; + Elf64_Rel *rel = 0; unsigned long *addr; int i; for (i = 0; dyn[i].d_tag != DT_NULL; ++i) { switch (dyn[i].d_tag) { case DT_RELA: - rel = (ElfW(Rel)*) + rel = (Elf64_Rel*) ((unsigned long)dyn[i].d_un.d_ptr + ldbase); break; @@ -111,7 +89,7 @@ EFI_STATUS _relocate (long ldbase, ElfW(Dyn) *dyn, EFI_HANDLE image, EFI_SYSTEM_ default: break; } - rel = (ElfW(Rel)*) ((char *) rel + relent); + rel = (Elf64_Rel*) ((char *) rel + relent); relsz -= relent; } return EFI_SUCCESS; diff --git a/gnu-efi-3.0/gnuefi/setjmp_ia32.S b/gnu-efi-3.0/gnuefi/setjmp_ia32.S index b22ef02..5f71caf 100644 --- a/gnu-efi-3.0/gnuefi/setjmp_ia32.S +++ b/gnu-efi-3.0/gnuefi/setjmp_ia32.S @@ -55,7 +55,7 @@ */ #define EXT_C(sym) sym -#define FUNCTION(x) .globl EXT_C(x) ; .type EXT_C(x), "function" ; EXT_C(x): +#define FUNCTION(x) .globl EXT_C(x) ; .type EXT_C(x), @function ; EXT_C(x): .file "setjmp.S" diff --git a/gnu-efi-3.0/gnuefi/setjmp_x86_64.S b/gnu-efi-3.0/gnuefi/setjmp_x86_64.S index b3561e4..6ef9378 100644 --- a/gnu-efi-3.0/gnuefi/setjmp_x86_64.S +++ b/gnu-efi-3.0/gnuefi/setjmp_x86_64.S @@ -17,7 +17,7 @@ */ #define EXT_C(sym) sym -#define FUNCTION(x) .globl EXT_C(x) ; .type EXT_C(x), "function" ; EXT_C(x): +#define FUNCTION(x) .globl EXT_C(x) ; .type EXT_C(x), @function ; EXT_C(x): .file "setjmp.S" diff --git a/gnu-efi-3.0/inc/ia32/efibind.h b/gnu-efi-3.0/inc/ia32/efibind.h index 722542c..deb9d16 100644 --- a/gnu-efi-3.0/inc/ia32/efibind.h +++ b/gnu-efi-3.0/inc/ia32/efibind.h @@ -42,14 +42,14 @@ Revision History typedef unsigned char uint8_t; typedef char int8_t; #elif defined(__GNUC__) - typedef unsigned long long uint64_t __attribute__((aligned (8))); - typedef long long int64_t __attribute__((aligned (8))); + typedef int __attribute__((__mode__(__DI__))) int64_t; + typedef unsigned int __attribute__((__mode__(__DI__))) uint64_t; typedef unsigned int uint32_t; typedef int int32_t; typedef unsigned short uint16_t; typedef short int16_t; typedef unsigned char uint8_t; - typedef char int8_t; + typedef signed char int8_t; #elif defined(UNIX_LP64) /* Use LP64 programming model from C_FLAGS for integer width declarations */ @@ -76,7 +76,7 @@ Revision History typedef char int8_t; #endif #elif defined(__GNUC__) - #include + #include #endif // diff --git a/gnu-efi-3.0/inc/ia64/efibind.h b/gnu-efi-3.0/inc/ia64/efibind.h index a1bf3fb..6926876 100644 --- a/gnu-efi-3.0/inc/ia64/efibind.h +++ b/gnu-efi-3.0/inc/ia64/efibind.h @@ -63,7 +63,7 @@ Revision History typedef char int8_t; #endif #elif defined(__GNUC__) - #include + #include #endif // diff --git a/gnu-efi-3.0/inc/x86_64/efibind.h b/gnu-efi-3.0/inc/x86_64/efibind.h index 27c9638..ee620f2 100644 --- a/gnu-efi-3.0/inc/x86_64/efibind.h +++ b/gnu-efi-3.0/inc/x86_64/efibind.h @@ -51,14 +51,14 @@ Revision History typedef unsigned char uint8_t; typedef char int8_t; #elif defined(__GNUC__) - typedef unsigned long long uint64_t __attribute__((aligned (8))); - typedef long long int64_t __attribute__((aligned (8))); + typedef int __attribute__((__mode__(__DI__))) int64_t; + typedef unsigned int __attribute__((__mode__(__DI__))) uint64_t; typedef unsigned int uint32_t; typedef int int32_t; typedef unsigned short uint16_t; typedef short int16_t; typedef unsigned char uint8_t; - typedef char int8_t; + typedef signed char int8_t; #elif defined(UNIX_LP64) /* Use LP64 programming model from C_FLAGS for integer width declarations */ @@ -85,7 +85,7 @@ Revision History typedef char int8_t; #endif #elif defined(__GNUC__) - #include + #include #endif //