From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56099) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bXE52-0001Ea-2p for qemu-devel@nongnu.org; Tue, 09 Aug 2016 16:56:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bXE4w-0002FB-4A for qemu-devel@nongnu.org; Tue, 09 Aug 2016 16:56:55 -0400 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:36780) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bXE4v-0002F6-TU for qemu-devel@nongnu.org; Tue, 09 Aug 2016 16:56:50 -0400 Received: by mail-wm0-x244.google.com with SMTP id i138so5624165wmf.3 for ; Tue, 09 Aug 2016 13:56:49 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Tue, 9 Aug 2016 22:56:45 +0200 Message-Id: <1470776205-94166-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH] optionrom: fix compilation with mingw docker target List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: rjones@redhat.com 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 --- pc-bios/optionrom/Makefile | 10 +++++++++- pc-bios/optionrom/flat.lds | 6 ++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 pc-bios/optionrom/flat.lds diff --git a/pc-bios/optionrom/Makefile b/pc-bios/optionrom/Makefile index 9c018ea..8aef152 100644 --- a/pc-bios/optionrom/Makefile +++ b/pc-bios/optionrom/Makefile @@ -9,6 +9,14 @@ $(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) @@ -51,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)$@") diff --git a/pc-bios/optionrom/flat.lds b/pc-bios/optionrom/flat.lds new file mode 100644 index 0000000..cee2eda --- /dev/null +++ b/pc-bios/optionrom/flat.lds @@ -0,0 +1,6 @@ +SECTIONS +{ + . = 0; + .text : { *(.text) *(.text.$) } +} +ENTRY(_start) -- 1.8.3.1