--- a/build/gen.mk
+++ b/build/gen.mk
@@ -40,6 +40,8 @@ install: install-each-env info.json
@$(INSTALL_DIR) $(DESTDIR)$(xtftestdir)/$(NAME)
$(INSTALL_DATA) info.json $(DESTDIR)$(xtftestdir)/$(NAME)
+hvm64-format := $(firstword $(filter elf32-x86-64,$(shell $(OBJCOPY) --help)) elf32-i386)
+
define PERENV_build
ifneq ($(1),hvm64)
@@ -47,10 +49,10 @@ install: install-each-env info.json
test-$(1)-$(NAME): $$(DEPS-$(1)) $$(link-$(1))
$$(LD) $$(LDFLAGS_$(1)) $$(DEPS-$(1)) -o $$@
else
-# hvm64 needs linking normally, then converting to elf32-x86-64
+# hvm64 needs linking normally, then converting to elf32-x86-64 or elf32-i386
test-$(1)-$(NAME): $$(DEPS-$(1)) $$(link-$(1))
$$(LD) $$(LDFLAGS_$(1)) $$(DEPS-$(1)) -o $$@.tmp
- $$(OBJCOPY) $$@.tmp -O elf32-x86-64 $$@
+ $(OBJCOPY) $$@.tmp -O $(hvm64-format) $$@