summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Wielaard <mjw@redhat.com>2013-12-18 18:02:42 +0100
committerMark Wielaard <mjw@redhat.com>2013-12-18 18:02:42 +0100
commita3afdb212742e28c6d309ae919e81c52afb44542 (patch)
tree2703ce7c40c2c6c72010506bc11b43aa97f46bfc
parentc53094634516313fb598d67e709f51f20d6acbba (diff)
downloadelfutils-a3afdb212742e28c6d309ae919e81c52afb44542.tar.gz
backends: Avoid type-punning issue in s390_set_initial_registers_tid.
Use union to avoid type-punning when assigning a double to a Dwarf_Word. gcc complains otherwise. error: dereferencing type-punned pointer will break strict-aliasing rules. Signed-off-by: Mark Wielaard <mjw@redhat.com>
-rw-r--r--backends/ChangeLog5
-rw-r--r--backends/s390_initreg.c15
2 files changed, 18 insertions, 2 deletions
diff --git a/backends/ChangeLog b/backends/ChangeLog
index cb56d217..23329d0a 100644
--- a/backends/ChangeLog
+++ b/backends/ChangeLog
@@ -1,3 +1,8 @@
+2013-12-18 Mark Wielaard <mjw@redhat.com>
+
+ * 390_initreg.c (s390_set_initial_registers_tid): Use union
+ to avoid type-punning when assigning a double to a Dwarf_Word.
+
2013-12-18 Jan Kratochvil <jan.kratochvil@redhat.com>
unwinder: s390 and s390x
diff --git a/backends/s390_initreg.c b/backends/s390_initreg.c
index 62a1531e..8fc54bc7 100644
--- a/backends/s390_initreg.c
+++ b/backends/s390_initreg.c
@@ -68,8 +68,19 @@ s390_set_initial_registers_tid (pid_t tid __attribute__ ((unused)),
eu_static_assert (sizeof user_regs.regs.fp_regs.fprs[0]
== sizeof dwarf_regs[0]);
for (unsigned u = 0; u < 16; u++)
- dwarf_regs[u] = *((const __typeof (dwarf_regs[0]) *)
- &user_regs.regs.fp_regs.fprs[u]);
+ {
+ // Store the double bits as is in the Dwarf_Word without conversion.
+ union
+ {
+ double d;
+ Dwarf_Word w;
+ } fpr = { .d = user_regs.regs.fp_regs.fprs[u] };
+ dwarf_regs[u] = fpr.w;
+ }
+ if (! setfunc (16, 16, dwarf_regs, arg))
+ return false;
+ dwarf_regs[0] = user_regs.regs.psw.addr;
+
if (! setfunc (16, 16, dwarf_regs, arg))
return false;
dwarf_regs[0] = user_regs.regs.psw.addr;