mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-22 09:32:40 -06:00
optionrom: fix compilation with mingw docker target
Two fixes are needed. First, mingw does not have -D_FORTIFY_SOURCE, hence --enable-debug disables optimization. This is not acceptable for ROMs, which should override CFLAGS to force inclusion of -O2. Second, PE stores global constructors and destructors using the following linker script snippet: ___CTOR_LIST__ = .; __CTOR_LIST__ = . ; LONG (-1);*(.ctors); *(.ctor); *(SORT(.ctors.*)); LONG (0); ___DTOR_LIST__ = .; __DTOR_LIST__ = . ; LONG (-1); *(.dtors); *(.dtor); *(SORT(.dtors.*)); LONG (0); The LONG directives cause the .img files to be 16 bytes too large; the recently added check to signrom.py catches this. To fix this, replace -T and -e options with a linker script. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
b0e8f5cadc
commit
9d4cd7b4ed
2 changed files with 15 additions and 1 deletions
|
@ -9,6 +9,14 @@ $(call set-vpath, $(SRC_PATH)/pc-bios/optionrom)
|
||||||
|
|
||||||
.PHONY : all clean build-all
|
.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
|
# Drop -fstack-protector and the like
|
||||||
QEMU_CFLAGS := $(filter -W%, $(QEMU_CFLAGS)) $(CFLAGS_NOPIE) -ffreestanding
|
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), -fno-stack-protector)
|
||||||
|
@ -51,7 +59,7 @@ endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
%.img: %.o
|
%.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
|
%.raw: %.img
|
||||||
$(call quiet-command,$(OBJCOPY) -O binary -j .text $< $@," Building $(TARGET_DIR)$@")
|
$(call quiet-command,$(OBJCOPY) -O binary -j .text $< $@," Building $(TARGET_DIR)$@")
|
||||||
|
|
6
pc-bios/optionrom/flat.lds
Normal file
6
pc-bios/optionrom/flat.lds
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
SECTIONS
|
||||||
|
{
|
||||||
|
. = 0;
|
||||||
|
.text : { *(.text) *(.text.$) }
|
||||||
|
}
|
||||||
|
ENTRY(_start)
|
Loading…
Add table
Add a link
Reference in a new issue