]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
IBM Z: Fix endianess problem in pid_memory_read
authorAndreas Krebbel <krebbel@linux.ibm.com>
Thu, 19 Nov 2020 19:32:24 +0000 (20:32 +0100)
committerMark Wielaard <mark@klomp.org>
Thu, 19 Nov 2020 21:50:08 +0000 (22:50 +0100)
The cached reads lack the big endian adjustments done in the fallback
path.

Signed-off-by: Andreas Krebbel <krebbel@linux.ibm.com>
libdwfl/ChangeLog
libdwfl/linux-pid-attach.c

index 59ef37aa188def734ba0a5fd89eab636e0f233c2..ecd87d3a96952c01b3aadc7b9fe79911b86dfdbc 100644 (file)
@@ -1,3 +1,8 @@
+2020-11-19  Andreas Krebbel  <krebbel@linux.ibm.com>
+
+       * linux-pid-attach.c (pid_memory_read): Shift the upper 4 bytes
+       down on big endian 64 bit targets.
+
 2020-11-12  Timm Bäder <tbaeder@redhat.com>
 
        * dwfl_segment_report_module.c (dwfl_segment_report_module): Remove
index 3a6af9973844932ac9adf402d40cabde4c852eb9..b23139d96f67e2b7a92c77f6aa3001a854cdeb18 100644 (file)
@@ -193,14 +193,22 @@ pid_memory_read (Dwfl *dwfl, Dwarf_Addr addr, Dwarf_Word *result, void *arg)
 {
   struct __libdwfl_pid_arg *pid_arg = arg;
   pid_t tid = pid_arg->tid_attached;
+  Dwfl_Process *process = dwfl->process;
   assert (tid > 0);
 
 #ifdef HAVE_PROCESS_VM_READV
   if (read_cached_memory (pid_arg, addr, result))
+    {
+#if SIZEOF_LONG == 8
+# if BYTE_ORDER == BIG_ENDIAN
+      if (ebl_get_elfclass (process->ebl) == ELFCLASS32)
+       *result >>= 32;
+# endif
+#endif
     return true;
+    }
 #endif
 
-  Dwfl_Process *process = dwfl->process;
   if (ebl_get_elfclass (process->ebl) == ELFCLASS64)
     {
 #if SIZEOF_LONG == 8