mirror of https://github.com/ncroxon/gnu-efi
Sync FreeBSD
* Always use objcopy -O (--target doesn't make sense) and isn't available on freebsd * No efi-bsdrv target (but has efi-app)(bug in binutils??) * Sync linker scripts (all features are supported) * Use clang as HOSTCC (there is no default gcc) Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
This commit is contained in:
parent
3398bf0dd9
commit
13c46e46a6
|
@ -85,9 +85,17 @@ else
|
|||
endif
|
||||
|
||||
# Host/target identification
|
||||
OS := $(shell uname -s)
|
||||
HOSTARCH ?= $(shell $(HOSTCC) -dumpmachine | cut -f1 -d- | sed -e s,i[3456789]86,ia32, -e 's,armv[67].*,arm,' )
|
||||
ARCH ?= $(shell $(HOSTCC) -dumpmachine | cut -f1 -d- | sed -e s,i[3456789]86,ia32, -e 's,armv[67].*,arm,' )
|
||||
OS := $(shell uname -s)
|
||||
USING_APPLE ?= $(shell echo $(OS) | grep -q 'Darwin' && echo 1 || echo 0)
|
||||
USING_FREEBSD ?= $(shell echo $(OS) | grep -q 'FreeBSD' && echo 1 || echo 0)
|
||||
|
||||
# FreeBSD uses clang with no gcc symlink
|
||||
ifeq ($(USING_FREEBSD),1)
|
||||
override HOSTCC := $(prefix)clang
|
||||
endif
|
||||
|
||||
HOSTARCH ?= $(shell $(HOSTCC) -dumpmachine | cut -f1 -d- | sed -e s,i[3456789]86,ia32, -e 's,armv[67].*,arm,' )
|
||||
ARCH ?= $(shell $(HOSTCC) -dumpmachine | cut -f1 -d- | sed -e s,i[3456789]86,ia32, -e 's,armv[67].*,arm,' )
|
||||
|
||||
# Get ARCH from the compiler if cross compiling
|
||||
ifneq ($(CROSS_COMPILE),)
|
||||
|
@ -107,11 +115,10 @@ ifeq ($(ARCH),mips64)
|
|||
override ARCH := mips64el
|
||||
endif
|
||||
|
||||
GCCVERSION := $(shell $(CC) -dumpversion | sed -e 's/-win32/.0/' | cut -f1 -d.)
|
||||
GCCMINOR := $(shell $(CC) -dumpversion | sed -e 's/-win32/.0/' | cut -f2 -d.)
|
||||
USING_CLANG := $(shell $(CC) -v 2>&1 | grep -q 'clang version' && echo clang || echo 0)
|
||||
USING_APPLE ?= $(shell uname -s | grep -q 'Darwin' && echo 1 || echo 0)
|
||||
NO_GLIBC ?= 0
|
||||
GCCVERSION := $(shell $(CC) -dumpversion | sed -e 's/-win32/.0/' | cut -f1 -d.)
|
||||
GCCMINOR := $(shell $(CC) -dumpversion | sed -e 's/-win32/.0/' | cut -f2 -d.)
|
||||
USING_CLANG := $(shell $(CC) -v 2>&1 | grep -q 'clang version' && echo clang || echo 0)
|
||||
NO_GLIBC ?= 0
|
||||
|
||||
# Rely on GCC MS ABI support?
|
||||
GCCNEWENOUGH := $(shell ( [ $(GCCVERSION) -gt "4" ] \
|
||||
|
@ -248,7 +255,7 @@ ifeq ($(IS_MINGW32),)
|
|||
CFLAGS += -fPIE
|
||||
endif
|
||||
|
||||
ifeq (FreeBSD, $(findstring FreeBSD, $(OS)))
|
||||
ifeq ($(USING_FREEBSD),1)
|
||||
CFLAGS += $(ARCH3264) -g -O2 -Wall -Wextra -Werror \
|
||||
-fno-strict-aliasing \
|
||||
-ffreestanding -fno-stack-protector
|
||||
|
|
|
@ -61,7 +61,7 @@ ifneq ($(CRT0_LIBS),)
|
|||
CRTOBJS = $(TOPDIR)/$(ARCH)/gnuefi/crt0-efi-$(ARCH)$(CRT0_LOCAL).o
|
||||
|
||||
LDSCRIPT = $(TOPDIR)/gnuefi/elf_$(ARCH)_efi$(LDS_LOCAL).lds
|
||||
ifneq (,$(findstring FreeBSD,$(OS)))
|
||||
ifeq ($(USING_FREEBSD),1)
|
||||
LDSCRIPT = $(TOPDIR)/gnuefi/elf_$(ARCH)_fbsd_efi.lds
|
||||
endif
|
||||
LDFLAGS += -L$(TOPDIR)/$(ARCH)/lib -L$(TOPDIR)/$(ARCH)/gnuefi $(CRTOBJS)
|
||||
|
@ -82,7 +82,11 @@ TARGET_APPS += setjmp.efi debughook.efi debughook.efi.debug \
|
|||
ctors_test.efi ctors_dtors_priority_test.efi
|
||||
endif
|
||||
|
||||
ifeq ($(USING_FREEBSD),0)
|
||||
TARGET_BSDRIVERS = drv0.efi
|
||||
else
|
||||
TARGET_BSDRIVERS =
|
||||
endif
|
||||
TARGET_RTDRIVERS =
|
||||
|
||||
SUBSYSTEM := 0xa
|
||||
|
@ -91,9 +95,9 @@ $(TARGET_RTDRIVERS): SUBSYSTEM = 0xc
|
|||
|
||||
ifeq ($(SYSTEM_HAS_EFI_OBJCOPY),1)
|
||||
|
||||
FORMAT := --target efi-app-$(ARCH)
|
||||
$(TARGET_BSDRIVERS): FORMAT=--target efi-bsdrv-$(ARCH)
|
||||
$(TARGET_RTDRIVERS): FORMAT=--target efi-rtdrv-$(ARCH)
|
||||
FORMAT := -O efi-app-$(ARCH)
|
||||
$(TARGET_BSDRIVERS): FORMAT=-O efi-bsdrv-$(ARCH)
|
||||
$(TARGET_RTDRIVERS): FORMAT=-O efi-rtdrv-$(ARCH)
|
||||
|
||||
ifneq ($(IS_MINGW32),)
|
||||
LDFLAGS += -s -Wl,-dll -Wl,--subsystem,$(SUBSYSTEM)
|
||||
|
|
|
@ -8,6 +8,9 @@ SECTIONS
|
|||
/* .hash and/or .gnu.hash MUST come first! */
|
||||
.hash : { *(.hash) }
|
||||
.gnu.hash : { *(.gnu.hash) }
|
||||
.eh_frame : { *(.eh_frame) }
|
||||
.eh_frame_hdr : { *(.eh_frame_hdr) }
|
||||
.gcc_except_table : { *(.gcc_except_table*) }
|
||||
. = ALIGN(4096);
|
||||
.text :
|
||||
{
|
||||
|
@ -15,31 +18,20 @@ SECTIONS
|
|||
*(.text)
|
||||
*(.text.*)
|
||||
*(.gnu.linkonce.t.*)
|
||||
*(.plt)
|
||||
. = ALIGN(16);
|
||||
}
|
||||
_etext = .;
|
||||
_text_size = _etext - _text;
|
||||
. = ALIGN(4096);
|
||||
.sdata :
|
||||
. = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
|
||||
.data :
|
||||
{
|
||||
_data = .;
|
||||
*(.got.plt)
|
||||
*(.got)
|
||||
*(.srodata)
|
||||
*(.sdata)
|
||||
*(.sbss)
|
||||
*(.scommon)
|
||||
}
|
||||
. = ALIGN(4096);
|
||||
.data :
|
||||
{
|
||||
*(.rodata*)
|
||||
*(.data)
|
||||
*(.data1)
|
||||
*(.data.*)
|
||||
*(.sdata)
|
||||
*(.got.plt)
|
||||
*(.got)
|
||||
|
||||
/*
|
||||
* Note that these aren't the using the GNU "CONSTRUCTOR" output section
|
||||
|
@ -70,10 +62,8 @@ SECTIONS
|
|||
|
||||
/* the EFI loader doesn't seem to like a .bss section, so we stick
|
||||
it all into .data: */
|
||||
*(.sbss)
|
||||
*(.scommon)
|
||||
*(.dynbss)
|
||||
*(.bss)
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
}
|
||||
.note.gnu.build-id : { *(.note.gnu.build-id) }
|
||||
|
@ -84,9 +74,10 @@ SECTIONS
|
|||
. = ALIGN(4096);
|
||||
.rel :
|
||||
{
|
||||
*(.rel.data)
|
||||
*(.rel.data.*)
|
||||
*(.rel.text*)
|
||||
*(.rel.data*)
|
||||
*(.rel.got)
|
||||
*(.rel.dyn)
|
||||
*(.rel.stab)
|
||||
*(.rel.init_array*)
|
||||
*(.rel.fini_array*)
|
||||
|
@ -97,22 +88,26 @@ SECTIONS
|
|||
*(.data.rel.ro)
|
||||
*(.data.rel*)
|
||||
}
|
||||
. = ALIGN(4096);
|
||||
.rel.plt : { *(.rel.plt) }
|
||||
. = ALIGN(4096);
|
||||
.rodata : { *(.rodata*) }
|
||||
_edata = .;
|
||||
_data_size = _edata - _etext;
|
||||
. = ALIGN(4096);
|
||||
.reloc : /* This is the PECOFF .reloc section! */
|
||||
{
|
||||
*(.reloc)
|
||||
KEEP (*(.reloc))
|
||||
}
|
||||
. = ALIGN(4096);
|
||||
.dynsym : { *(.dynsym) }
|
||||
. = ALIGN(4096);
|
||||
.dynstr : { *(.dynstr) }
|
||||
. = ALIGN(4096);
|
||||
. = DATA_SEGMENT_END (.);
|
||||
/DISCARD/ :
|
||||
{
|
||||
*(.rel.reloc)
|
||||
*(.eh_frame)
|
||||
*(.note.GNU-stack)
|
||||
}
|
||||
.comment 0 : { *(.comment) }
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
/* 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)
|
||||
|
@ -10,23 +9,27 @@ SECTIONS
|
|||
.hash : { *(.hash) }
|
||||
.gnu.hash : { *(.gnu.hash) }
|
||||
. = ALIGN(4096);
|
||||
.eh_frame :
|
||||
{
|
||||
*(.eh_frame)
|
||||
}
|
||||
.eh_frame : { *(.eh_frame) }
|
||||
.eh_frame_hdr : { *(.eh_frame_hdr) }
|
||||
.gcc_except_table : { *(.gcc_except_table*) }
|
||||
. = ALIGN(4096);
|
||||
.text :
|
||||
{
|
||||
_text = .;
|
||||
*(.text)
|
||||
*(.text.*)
|
||||
*(.gnu.linkonce.t.*)
|
||||
*(.plt)
|
||||
. = ALIGN(16);
|
||||
}
|
||||
_etext = .;
|
||||
_text_size = _etext - _text;
|
||||
. = ALIGN(4096);
|
||||
.reloc :
|
||||
{
|
||||
*(.reloc)
|
||||
KEEP (*(.reloc))
|
||||
}
|
||||
|
||||
. = ALIGN(4096);
|
||||
.data :
|
||||
{
|
||||
|
@ -68,20 +71,24 @@ SECTIONS
|
|||
*(.sbss)
|
||||
*(.scommon)
|
||||
*(.dynbss)
|
||||
*(.bss)
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
*(.rel.local)
|
||||
}
|
||||
.note.gnu.build-id : { *(.note.gnu.build-id) }
|
||||
|
||||
_edata = .;
|
||||
_data_size = _edata - _etext;
|
||||
. = ALIGN(4096);
|
||||
_DYNAMIC = .;
|
||||
.dynamic : { *(.dynamic) }
|
||||
. = ALIGN(4096);
|
||||
.rela :
|
||||
{
|
||||
*(.rela.text*)
|
||||
*(.rela.data*)
|
||||
*(.rela.got)
|
||||
*(.rela.dyn)
|
||||
*(.rela.stab)
|
||||
*(.rela.init_array*)
|
||||
*(.rela.fini_array*)
|
||||
|
@ -89,9 +96,9 @@ SECTIONS
|
|||
*(.rela.dtors*)
|
||||
}
|
||||
. = ALIGN(4096);
|
||||
.rela.plt : { *(.rela.plt) }
|
||||
. = ALIGN(4096);
|
||||
.rodata : { *(.rodata*) }
|
||||
_edata = .;
|
||||
_data_size = _edata - _etext;
|
||||
. = ALIGN(4096);
|
||||
.dynsym : { *(.dynsym) }
|
||||
. = ALIGN(4096);
|
||||
|
@ -100,5 +107,7 @@ SECTIONS
|
|||
.ignored.reloc :
|
||||
{
|
||||
*(.rela.reloc)
|
||||
*(.note.GNU-stack)
|
||||
}
|
||||
.comment 0 : { *(.comment) }
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue