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