958e1b
From c4249cf0d89f6a5ba4448eb1ff22f496387d0e50 Mon Sep 17 00:00:00 2001
958e1b
From: Laszlo Ersek <lersek@redhat.com>
958e1b
Date: Fri, 7 Nov 2014 17:18:11 +0100
958e1b
Subject: [PATCH 24/41] dump: select header bitness based on ELF class, not ELF
958e1b
 architecture
958e1b
958e1b
Message-id: <1415380693-16593-25-git-send-email-lersek@redhat.com>
958e1b
Patchwork-id: 62212
958e1b
O-Subject: [RHEL-7.1 qemu-kvm PATCH 24/26] dump: select header bitness based on ELF class, not ELF architecture
958e1b
Bugzilla: 1157798
958e1b
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
958e1b
RH-Acked-by: Luiz Capitulino <lcapitulino@redhat.com>
958e1b
RH-Acked-by: dgibson <dgibson@redhat.com>
958e1b
958e1b
The specific ELF architecture (d_machine) carries Too Much Information
958e1b
(TM) for deciding between create_header32() and create_header64(), use
958e1b
"d_class" instead (ELFCLASS32 vs. ELFCLASS64).
958e1b
958e1b
This change adapts write_dump_header() to write_elf_loads(), dump_begin()
958e1b
etc. that also rely on the ELF class of the target for bitness selection.
958e1b
958e1b
Considering the current targets that support dumping, cpu_get_dump_info()
958e1b
works as follows:
958e1b
- target-s390x/arch_dump.c: (EM_S390, ELFCLASS64) only
958e1b
- target-ppc/arch_dump.c (EM_PPC64, ELFCLASS64) only
958e1b
- target-i386/arch_dump.c: sets (EM_X86_64, ELFCLASS64) vs. (EM_386,
958e1b
  ELFCLASS32) keying off the same Long Mode Active flag.
958e1b
958e1b
Hence no observable change.
958e1b
958e1b
Approximately-suggested-by: Paolo Bonzini <pbonzini@redhat.com>
958e1b
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
958e1b
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
958e1b
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
958e1b
(cherry picked from commit 24aeeace7a9f264688e9eda77b6c04db607cbdfd)
958e1b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
958e1b
---
958e1b
 dump.c | 2 +-
958e1b
 1 file changed, 1 insertion(+), 1 deletion(-)
958e1b
958e1b
diff --git a/dump.c b/dump.c
958e1b
index f8e0fd7..450f658 100644
958e1b
--- a/dump.c
958e1b
+++ b/dump.c
958e1b
@@ -1006,7 +1006,7 @@ out:
958e1b
 
958e1b
 static int write_dump_header(DumpState *s)
958e1b
 {
958e1b
-    if (s->dump_info.d_machine == EM_386) {
958e1b
+    if (s->dump_info.d_class == ELFCLASS32) {
958e1b
         return create_header32(s);
958e1b
     } else {
958e1b
         return create_header64(s);
958e1b
-- 
958e1b
1.8.3.1
958e1b