]> xenbits.xensource.com Git - people/royger/xen-test-framework.git/commitdiff
Create hvm64 test binaries as elf32, take 2
authorAndrew Cooper <andrew.cooper3@citrix.com>
Sun, 6 Dec 2015 18:30:46 +0000 (18:30 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Sun, 6 Dec 2015 18:31:13 +0000 (18:31 +0000)
Experimentally, gcc/binutils from Debian Jessie (4.9.2/2.25) and CentOS
7.1 (4.8.3/2.23) don't make valid binaries when linking x86-64 object
files as elf32-x86-64.

Issues include corrupt DWARF debugging information (as confirmed by
gdb/readelf), and erroneously merged strings in .rodata (as confirmed by
strings).

Instead, link all binaries in their natural width, and objcopy hvm64
binaries to elf32-x86-64 after the fact.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
arch/x86/link.lds.S
config/gen.mk

index e9c11b9d7be7c7b7e961a1ef8ce1b1c9867d42df..de4eab21320a4537b154dcefa6bc7bc3c5937c3b 100644 (file)
@@ -9,20 +9,7 @@
 
 #if defined(__x86_64__)
 
-#if defined(CONFIG_ENV_hvm64)
-
-/*
- * All HVM guests start in 32bit mode in a stub
- * which switches to the desired running mode.
- */
-OUTPUT_FORMAT("elf32-x86-64")
-
-#else
-
 OUTPUT_FORMAT("elf64-x86-64")
-
-#endif
-
 OUTPUT_ARCH(i386:x86-64)
 
 #elif defined(__i386__)
index 712e0ed30fc4302e66bf7e7eada2a775df0df654..edca00514d14751620a87cb21aeb0238b7f861c2 100644 (file)
@@ -21,8 +21,17 @@ install: install-each-env
 
 define PERENV_build
 
+ifneq ($(1),hvm64)
+# Generic link line for most environments
 test-$(1)-$(NAME): $$(DEPS-$(1)) $$(link-$(1))
        $$(LD) $$(LDFLAGS_$(1)) $$(DEPS-$(1)) -o $$@
+else
+# hvm64 needs linking normally, then converting to elf32-x86-64
+test-$(1)-$(NAME): $$(DEPS-$(1)) $$(link-$(1))
+       $$(LD) $$(LDFLAGS_$(1)) $$(DEPS-$(1)) -o $$@.tmp
+       objcopy $$@.tmp -O elf32-x86-64 $$@
+       rm -f $$@.tmp
+endif
 
 cfg-$(1) ?= $(defcfg-$(1))