qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

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>

+15 -1
+9 -1
pc-bios/optionrom/Makefile
··· 9 9 10 10 .PHONY : all clean build-all 11 11 12 + # Compiling with no optimization creates ROMs that are too large 13 + ifeq ($(filter -O%, $(CFLAGS)),) 14 + override CFLAGS += -O2 15 + endif 16 + ifeq ($(filter -O%, $(CFLAGS)),-O0) 17 + override CFLAGS += -O2 18 + endif 19 + 12 20 # Drop -fstack-protector and the like 13 21 QEMU_CFLAGS := $(filter -W%, $(QEMU_CFLAGS)) $(CFLAGS_NOPIE) -ffreestanding 14 22 QEMU_CFLAGS += $(call cc-option, $(QEMU_CFLAGS), -fno-stack-protector) ··· 51 59 endif 52 60 53 61 %.img: %.o 54 - $(call quiet-command,$(LD) $(LDFLAGS_NOPIE) -m $(LD_EMULATION) -Ttext 0 -e _start -s -o $@ $<," Building $(TARGET_DIR)$@") 62 + $(call quiet-command,$(LD) $(LDFLAGS_NOPIE) -m $(LD_EMULATION) -T $(SRC_PATH)/pc-bios/optionrom/flat.lds -s -o $@ $<," Building $(TARGET_DIR)$@") 55 63 56 64 %.raw: %.img 57 65 $(call quiet-command,$(OBJCOPY) -O binary -j .text $< $@," Building $(TARGET_DIR)$@")
+6
pc-bios/optionrom/flat.lds
··· 1 + SECTIONS 2 + { 3 + . = 0; 4 + .text : { *(.text) *(.text.$) } 5 + } 6 + ENTRY(_start)