public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/1] IBM Z: Fix endianess problem in pid_memory_read
@ 2020-11-19 19:32 Andreas Krebbel
  2020-11-20  0:33 ` Mark Wielaard
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Krebbel @ 2020-11-19 19:32 UTC (permalink / raw)
  To: elfutils-devel

The cached reads lack the big endian adjustments done in the fallback
path.

Signed-off-by: Andreas Krebbel <krebbel@linux.ibm.com>
---
 libdwfl/ChangeLog          |  5 +++++
 libdwfl/linux-pid-attach.c | 10 +++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index 59ef37aa..ecd87d3a 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -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
diff --git a/libdwfl/linux-pid-attach.c b/libdwfl/linux-pid-attach.c
index 3a6af997..b23139d9 100644
--- a/libdwfl/linux-pid-attach.c
+++ b/libdwfl/linux-pid-attach.c
@@ -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
-- 
2.25.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] IBM Z: Fix endianess problem in pid_memory_read
  2020-11-19 19:32 [PATCH 1/1] IBM Z: Fix endianess problem in pid_memory_read Andreas Krebbel
@ 2020-11-20  0:33 ` Mark Wielaard
  2020-11-20  6:20   ` Andreas Krebbel
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Wielaard @ 2020-11-20  0:33 UTC (permalink / raw)
  To: Andreas Krebbel; +Cc: elfutils-devel

Hi Andreas,

On Thu, Nov 19, 2020 at 08:32:24PM +0100, Andreas Krebbel via Elfutils-devel wrote:
> The cached reads lack the big endian adjustments done in the fallback
> path.

Thanks for finding this. Did you find this by code inspection or by
having a 31bit binary backtrace on a 64bit system fail?

We actually have a testcase for 31-bit-on-64-bit backtrace
(run-backtrace-native-biarch.sh) but the s390x buildbot worker doesn't
support creating 31bit executables, so the testcase is SKIPPED.

I pushed you patch.

Thanks,

Mark


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] IBM Z: Fix endianess problem in pid_memory_read
  2020-11-20  0:33 ` Mark Wielaard
@ 2020-11-20  6:20   ` Andreas Krebbel
  0 siblings, 0 replies; 3+ messages in thread
From: Andreas Krebbel @ 2020-11-20  6:20 UTC (permalink / raw)
  To: Mark Wielaard; +Cc: elfutils-devel

On 20.11.20 01:33, Mark Wielaard wrote:
> Hi Andreas,
> 
> On Thu, Nov 19, 2020 at 08:32:24PM +0100, Andreas Krebbel via Elfutils-devel wrote:
>> The cached reads lack the big endian adjustments done in the fallback
>> path.
> 
> Thanks for finding this. Did you find this by code inspection or by
> having a 31bit binary backtrace on a 64bit system fail?
> 
> We actually have a testcase for 31-bit-on-64-bit backtrace
> (run-backtrace-native-biarch.sh) but the s390x buildbot worker doesn't
> support creating 31bit executables, so the testcase is SKIPPED.

The problem was reported for strace. But then we noticed that the testcase you mentioned fails on Z
currently. It is fixed with the patch.

> I pushed you patch.

Thanks!

Andreas

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-11-20  6:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-19 19:32 [PATCH 1/1] IBM Z: Fix endianess problem in pid_memory_read Andreas Krebbel
2020-11-20  0:33 ` Mark Wielaard
2020-11-20  6:20   ` Andreas Krebbel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).