From b2a575a1c652904600869e774e45bf4c9ed72c55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Mar=C3=AD?= Date: Mon, 23 May 2016 19:11:33 +0100 Subject: Add optionrom compatible with fw_cfg DMA version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This optionrom is based on linuxboot.S. Signed-off-by: Marc MarĂ­ Signed-off-by: Richard W.M. Jones Message-Id: <1464027093-24073-2-git-send-email-rjones@redhat.com> [Add -fno-toplevel-reorder, support clang without -m16. - Paolo] Signed-off-by: Paolo Bonzini --- pc-bios/optionrom/Makefile | 42 +++++++++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 9 deletions(-) (limited to 'pc-bios/optionrom/Makefile') diff --git a/pc-bios/optionrom/Makefile b/pc-bios/optionrom/Makefile index 2cdda87..d88ce11 100644 --- a/pc-bios/optionrom/Makefile +++ b/pc-bios/optionrom/Makefile @@ -9,22 +9,46 @@ $(call set-vpath, $(SRC_PATH)/pc-bios/optionrom) .PHONY : all clean build-all -CFLAGS := -Wall -Wstrict-prototypes -Werror -fomit-frame-pointer -fno-builtin -CFLAGS += -I$(SRC_PATH) -CFLAGS += $(call cc-option, $(CFLAGS), -fno-stack-protector) -CFLAGS += $(CFLAGS_NOPIE) -QEMU_CFLAGS = $(CFLAGS) - -build-all: multiboot.bin linuxboot.bin kvmvapic.bin +# Drop -fstack-protector and the like +QEMU_CFLAGS := $(filter -W%, $(QEMU_CFLAGS)) $(CFLAGS_NOPIE) -ffreestanding +QEMU_CFLAGS += $(call cc-option, $(QEMU_CFLAGS), -m16) +ifeq ($(filter -m16, $(QEMU_CFLAGS)),) +# Attempt to work around compilers that lack -m16 (GCC <= 4.8, clang <= ??) +# On GCC we add -fno-toplevel-reorder to keep the order of asm blocks with +# respect to the rest of the code. clang does not have -fno-toplevel-reorder, +# but it places all asm blocks at the beginning and we're relying on it for +# the option ROM header. So just force clang not to use the integrated +# assembler, which doesn't support .code16gcc. +QEMU_CFLAGS += $(call cc-option, $(QEMU_CFLAGS), -fno-toplevel-reorder) +QEMU_CFLAGS += $(call cc-option, $(QEMU_CFLAGS), -no-integrated-as) +QEMU_CFLAGS += -m32 -include $(SRC_PATH)/pc-bios/optionrom/code16gcc.h +endif + +# Drop gcov and glib flags +CFLAGS := $(filter -O% -g%, $(CFLAGS)) +QEMU_INCLUDES += -I$(SRC_PATH) + +Wa = -Wa, +ASFLAGS += -32 +QEMU_CFLAGS += $(call cc-option, $(QEMU_CFLAGS), $(Wa)-32) + +build-all: multiboot.bin linuxboot.bin linuxboot_dma.bin kvmvapic.bin # suppress auto-removal of intermediate files .SECONDARY: + %.o: %.S - $(call quiet-command,$(CPP) $(QEMU_INCLUDES) $(QEMU_DGFLAGS) $(CFLAGS) -c -o - $< | $(AS) $(ASFLAGS) -o $@," AS $(TARGET_DIR)$@") + $(call quiet-command,$(CPP) $(QEMU_INCLUDES) $(QEMU_DGFLAGS) -c -o - $< | $(AS) $(ASFLAGS) -o $@," AS $(TARGET_DIR)$@") + +ifdef CONFIG_WIN32 +LD_EMULATION = i386pe +else +LD_EMULATION = elf_i386 +endif %.img: %.o - $(call quiet-command,$(LD) $(LDFLAGS_NOPIE) -Ttext 0 -e _start -s -o $@ $<," Building $(TARGET_DIR)$@") + $(call quiet-command,$(LD) $(LDFLAGS_NOPIE) -m $(LD_EMULATION) -Ttext 0 -e _start -s -o $@ $<," Building $(TARGET_DIR)$@") %.raw: %.img $(call quiet-command,$(OBJCOPY) -O binary -j .text $< $@," Building $(TARGET_DIR)$@") -- cgit v1.1