aboutsummaryrefslogtreecommitdiff
path: root/pc-bios/optionrom/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'pc-bios/optionrom/Makefile')
-rw-r--r--pc-bios/optionrom/Makefile13
1 files changed, 10 insertions, 3 deletions
diff --git a/pc-bios/optionrom/Makefile b/pc-bios/optionrom/Makefile
index 24e175e0eb..8aef152262 100644
--- a/pc-bios/optionrom/Makefile
+++ b/pc-bios/optionrom/Makefile
@@ -9,8 +9,17 @@ $(call set-vpath, $(SRC_PATH)/pc-bios/optionrom)
.PHONY : all clean build-all
+# Compiling with no optimization creates ROMs that are too large
+ifeq ($(filter -O%, $(CFLAGS)),)
+override CFLAGS += -O2
+endif
+ifeq ($(filter -O%, $(CFLAGS)),-O0)
+override CFLAGS += -O2
+endif
+
# Drop -fstack-protector and the like
QEMU_CFLAGS := $(filter -W%, $(QEMU_CFLAGS)) $(CFLAGS_NOPIE) -ffreestanding
+QEMU_CFLAGS += $(call cc-option, $(QEMU_CFLAGS), -fno-stack-protector)
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 <= ??)
@@ -24,8 +33,6 @@ 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,
@@ -52,7 +59,7 @@ endif
endif
%.img: %.o
- $(call quiet-command,$(LD) $(LDFLAGS_NOPIE) -m $(LD_EMULATION) -Ttext 0 -e _start -s -o $@ $<," Building $(TARGET_DIR)$@")
+ $(call quiet-command,$(LD) $(LDFLAGS_NOPIE) -m $(LD_EMULATION) -T $(SRC_PATH)/pc-bios/optionrom/flat.lds -s -o $@ $<," Building $(TARGET_DIR)$@")
%.raw: %.img
$(call quiet-command,$(OBJCOPY) -O binary -j .text $< $@," Building $(TARGET_DIR)$@")