DistroBaker 8109be
commit e4d985a3c1c873f77d20fa0cd421458cc2824996
DistroBaker 8109be
Author: Andreas Krebbel <krebbel@linux.ibm.com>
DistroBaker 8109be
Date:   Thu Nov 19 20:32:24 2020 +0100
DistroBaker 8109be
DistroBaker 8109be
    IBM Z: Fix endianess problem in pid_memory_read
DistroBaker 8109be
    
DistroBaker 8109be
    The cached reads lack the big endian adjustments done in the fallback
DistroBaker 8109be
    path.
DistroBaker 8109be
    
DistroBaker 8109be
    Signed-off-by: Andreas Krebbel <krebbel@linux.ibm.com>
DistroBaker 8109be
DistroBaker 8109be
diff --git a/libdwfl/linux-pid-attach.c b/libdwfl/linux-pid-attach.c
DistroBaker 8109be
index 3a6af997..b23139d9 100644
DistroBaker 8109be
--- a/libdwfl/linux-pid-attach.c
DistroBaker 8109be
+++ b/libdwfl/linux-pid-attach.c
DistroBaker 8109be
@@ -193,14 +193,22 @@ pid_memory_read (Dwfl *dwfl, Dwarf_Addr addr, Dwarf_Word *result, void *arg)
DistroBaker 8109be
 {
DistroBaker 8109be
   struct __libdwfl_pid_arg *pid_arg = arg;
DistroBaker 8109be
   pid_t tid = pid_arg->tid_attached;
DistroBaker 8109be
+  Dwfl_Process *process = dwfl->process;
DistroBaker 8109be
   assert (tid > 0);
DistroBaker 8109be
 
DistroBaker 8109be
 #ifdef HAVE_PROCESS_VM_READV
DistroBaker 8109be
   if (read_cached_memory (pid_arg, addr, result))
DistroBaker 8109be
+    {
DistroBaker 8109be
+#if SIZEOF_LONG == 8
DistroBaker 8109be
+# if BYTE_ORDER == BIG_ENDIAN
DistroBaker 8109be
+      if (ebl_get_elfclass (process->ebl) == ELFCLASS32)
DistroBaker 8109be
+	*result >>= 32;
DistroBaker 8109be
+# endif
DistroBaker 8109be
+#endif
DistroBaker 8109be
     return true;
DistroBaker 8109be
+    }
DistroBaker 8109be
 #endif
DistroBaker 8109be
 
DistroBaker 8109be
-  Dwfl_Process *process = dwfl->process;
DistroBaker 8109be
   if (ebl_get_elfclass (process->ebl) == ELFCLASS64)
DistroBaker 8109be
     {
DistroBaker 8109be
 #if SIZEOF_LONG == 8