diff --git a/configure b/configure
index 508f6a5..6d84885 100755
--- a/configure
+++ b/configure
@@ -1342,6 +1342,10 @@ EOF
if compile_prog "-fPIE -DPIE" "-pie"; then
QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
LDFLAGS="-pie $LDFLAGS"
+ if test "$targetos" = OpenBSD; then
+ CC_NOPIE="-fno-pie"
+ LD_NOPIE="-nopie"
+ fi
pie="yes"
if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
@@ -4307,6 +4311,8 @@ if test "$gcov" = "yes" ; then
echo "CONFIG_GCOV=y" >> $config_host_mak
echo "GCOV=$gcov_tool" >> $config_host_mak
fi
+echo "CC_NOPIE=$CC_NOPIE" >> $config_host_mak
+echo "LD_NOPIE=$LD_NOPIE" >> $config_host_mak
# use included Linux headers
if test "$linux" = "yes" ; then
diff --git a/pc-bios/optionrom/Makefile b/pc-bios/optionrom/Makefile
index 57d8bd0..0b35000 100644
--- a/pc-bios/optionrom/Makefile
+++ b/pc-bios/optionrom/Makefile
@@ -12,6 +12,7 @@ $(call set-vpath, $(SRC_PATH)/pc-bios/optionrom)
CFLAGS := -Wall -Wstrict-prototypes -Werror -fomit-frame-pointer -fno-builtin
CFLAGS += -I$(SRC_PATH)
CFLAGS += $(call cc-option, $(CFLAGS), -fno-stack-protector)
+CFLAGS += $(CC_NOPIE)
QEMU_CFLAGS = $(CFLAGS)
build-all: multiboot.bin linuxboot.bin kvmvapic.bin
@@ -20,7 +21,7 @@ build-all: multiboot.bin linuxboot.bin kvmvapic.bin
.SECONDARY:
%.img: %.o
- $(call quiet-command,$(LD) -Ttext 0 -e _start -s -o $@ $<," Building
$(TARGET_DIR)$@")
+ $(call quiet-command,$(LD) $(LD_NOPIE) -Ttext 0 -e _start -s -o $@ $<,"
Building $(TARGET_DIR)$@")
%.raw: %.img
$(call quiet-command,$(OBJCOPY) -O binary -j .text $< $@," Building
$(TARGET_DIR)$@")