This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] backends: Add aarch64 abi_cfi.


While testing on aarch64 I noticed that the backend was missing the
abi_cfi hook which is needed by the dwarf_frame functions to setup
the initial register states. And the register_info would leave the
prefix string as NULL instead of the empty string, which is unlike
all other backends. The following fixes those two issues and adds
a testcase for it.

On mjw/aarch64-unwind there is also a first try of adding unwinding
support. It works somewhat, but at least on the setup I had access to
some CFI was missing causing erradic unwinding behavior (or maybe it
is a bug in my patch). Fixing this up is for after 0.158.

<- snip ->

Setup initial CIE values for aarch64 for use with dwarf_frame functions.
Register info prefix should be the empty string (not NULL) when not used.
Add an EM_AARCH64 testcase to tests/run-addrcfi.sh to check both issues.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
---
 backends/ChangeLog        |    7 ++++
 backends/Makefile.am      |    2 +-
 backends/aarch64_cfi.c    |   82 +++++++++++++++++++++++++++++++++++++++++++++
 backends/aarch64_init.c   |    1 +
 backends/aarch64_regs.c   |    2 +-
 tests/ChangeLog           |    6 +++
 tests/Makefile.am         |    2 +-
 tests/run-addrcfi.sh      |   76 +++++++++++++++++++++++++++++++++++++++++
 tests/testfileaarch64.bz2 |  Bin 0 -> 3441 bytes
 9 files changed, 175 insertions(+), 3 deletions(-)
 create mode 100644 backends/aarch64_cfi.c
 create mode 100755 tests/testfileaarch64.bz2

diff --git a/backends/ChangeLog b/backends/ChangeLog
index 24cc63d..2074cff 100644
--- a/backends/ChangeLog
+++ b/backends/ChangeLog
@@ -1,3 +1,10 @@
+2014-01-03  Mark Wielaard  <mjw@redhat.com>
+
+	* Makefile.am (aarch64_SRCS): Add aarch64_cfi.c.
+	* aarch64_cfi.c: New file.
+	* aarch64_init.c (aarch64_init): Hook abi_cfi.
+	* aarch64_regs.c (aarch64_register_info): Set *prefix to "".
+
 2013-12-19  Mark Wielaard  <mjw@redhat.com>
 
 	* aarch64_init.c (aarch64_init): Hook check_special_symbol.
diff --git a/backends/Makefile.am b/backends/Makefile.am
index 8deed2f..b8bea36 100644
--- a/backends/Makefile.am
+++ b/backends/Makefile.am
@@ -83,7 +83,7 @@ libebl_arm_pic_a_SOURCES = $(arm_SRCS)
 am_libebl_arm_pic_a_OBJECTS = $(arm_SRCS:.c=.os)
 
 aarch64_SRCS = aarch64_init.c aarch64_regs.c aarch64_symbol.c	\
-	       aarch64_corenote.c aarch64_retval.c
+	       aarch64_corenote.c aarch64_retval.c aarch64_cfi.c
 libebl_aarch64_pic_a_SOURCES = $(aarch64_SRCS)
 am_libebl_aarch64_pic_a_OBJECTS = $(aarch64_SRCS:.c=.os)
 aarch64_regs_no_Wformat = yes
diff --git a/backends/aarch64_cfi.c b/backends/aarch64_cfi.c
new file mode 100644
index 0000000..acbb9b6
--- /dev/null
+++ b/backends/aarch64_cfi.c
@@ -0,0 +1,82 @@
+/* arm ABI-specified defaults for DWARF CFI.
+   Copyright (C) 2013 Red Hat, Inc.
+   This file is part of elfutils.
+
+   This file is free software; you can redistribute it and/or modify
+   it under the terms of either
+
+     * the GNU Lesser General Public License as published by the Free
+       Software Foundation; either version 3 of the License, or (at
+       your option) any later version
+
+   or
+
+     * the GNU General Public License as published by the Free
+       Software Foundation; either version 2 of the License, or (at
+       your option) any later version
+
+   or both in parallel, as here.
+
+   elfutils is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received copies of the GNU General Public License and
+   the GNU Lesser General Public License along with this program.  If
+   not, see <http://www.gnu.org/licenses/>.  */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <dwarf.h>
+
+#define BACKEND aarch64_
+#include "libebl_CPU.h"
+
+
+/* ABI-specified state of DWARF CFI based on:
+
+   "DWARF for the ARM 64 bit architecture (AArch64) 1.0"
+http://infocenter.arm.com/help/topic/com.arm.doc.ihi0057b/IHI0057B_aadwarf64.pdf
+
+   "Procedure Call Standard for the ARM 64 bit Architecture 1.0"
+http://infocenter.arm.com/help/topic/com.arm.doc.ihi0055b/IHI0055B_aapcs64.pdf
+*/
+
+int
+aarch64_abi_cfi (Ebl *ebl __attribute__ ((unused)), Dwarf_CIE *abi_info)
+{
+  static const uint8_t abi_cfi[] =
+    {
+      /* The initial Canonical Frame Address is the value of the
+         Stack Pointer (r31) as setup in the previous frame. */
+      DW_CFA_def_cfa, ULEB128_7 (30), ULEB128_7 (0),
+
+#define SV(n) DW_CFA_same_value, ULEB128_7 (n)
+      /* Callee-saved regs r19-r28.  */
+      SV (19), SV (20), SV (21), SV (22), SV (23),
+      SV (24), SV (25), SV (26), SV (27), SV (28),
+
+      /* The Frame Pointer (FP, r29) and Link Register (LR, r30).  */
+      SV (29), SV (30),
+
+      /* Callee-saved fpregs v8-v15.  v0 == 64.  */
+      SV (72), SV (73), SV (74), SV (75),
+      SV (76), SV (77), SV (78), SV (79),
+#undef SV
+
+      /* XXX Note: registers intentionally unused by the program,
+	 for example as a consequence of the procedure call standard
+	 should be initialized as if by DW_CFA_same_value.  */
+    };
+
+  abi_info->initial_instructions = abi_cfi;
+  abi_info->initial_instructions_end = &abi_cfi[sizeof abi_cfi];
+  abi_info->data_alignment_factor = -4;
+
+  abi_info->return_address_register = 30; /* lr.  */
+
+  return 0;
+}
diff --git a/backends/aarch64_init.c b/backends/aarch64_init.c
index d663d40..a1a7060 100644
--- a/backends/aarch64_init.c
+++ b/backends/aarch64_init.c
@@ -57,6 +57,7 @@ aarch64_init (elf, machine, eh, ehlen)
   HOOK (eh, reloc_simple_type);
   HOOK (eh, return_value_location);
   HOOK (eh, check_special_symbol);
+  HOOK (eh, abi_cfi);
 
   return MODVERSION;
 }
diff --git a/backends/aarch64_regs.c b/backends/aarch64_regs.c
index 5952b96..aec201f 100644
--- a/backends/aarch64_regs.c
+++ b/backends/aarch64_regs.c
@@ -57,7 +57,7 @@ aarch64_register_info (Ebl *ebl __attribute__ ((unused)),
     return s + 1;
   }
 
-  *prefix = NULL;
+  *prefix = "";
   *bits = 64;
 
   switch (regno)
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 5c80e9b..c68ae26 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,9 @@
+2014-01-03  Mark Wielaard  <mjw@redhat.com>
+
+	* run-addrcfi.sh: Add case for EM_AARCH64.
+	* testfileaarch64.bz2: New testfile.
+	* Makefile.am (EXTRA_DIST): Add testfilesaarch64.bz2.
+
 2013-12-30  Mark Wielaard  <mjw@redhat.com>
 
 	* backtrace-dwarf.c (report_pid): Explicitly call
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 52eb50a..eae64a8 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -237,7 +237,7 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \
 	     run-addr2line-i-test.sh testfile-inlines.bz2 \
 	     testfileppc32.bz2 testfileppc64.bz2 \
 	     testfiles390.bz2 testfiles390x.bz2 \
-	     testfilearm.bz2 \
+	     testfilearm.bz2 testfileaarch64.bz2 \
 	     run-varlocs.sh \
 	     testfile_const_type.c testfile_const_type.bz2 \
 	     testfile_implicit_pointer.c testfile_implicit_pointer.bz2 \
diff --git a/tests/run-addrcfi.sh b/tests/run-addrcfi.sh
index c7ab71a..a4225ac 100755
--- a/tests/run-addrcfi.sh
+++ b/tests/run-addrcfi.sh
@@ -2572,3 +2572,79 @@ dwarf_cfi_addrframe (.eh_frame): no matching address range
 	VFP reg286 (d30): undefined
 	VFP reg287 (d31): undefined
 EOF
+
+# EM_AARCH64 (function bar 0x400550)
+# Same as arm, 390 and ppc above.
+# Note missing coverage in .eh_frame.
+testfiles testfileaarch64
+testrun_compare ${abs_builddir}/addrcfi -e testfileaarch64 0x400550 <<\EOF
+dwarf_cfi_addrframe (.eh_frame): no matching address range
+.debug_frame has 0x400550 => [0x400550, 0x400568):
+	return address in reg30
+	CFA location expression: bregx(31)
+	integer reg0 (x0): undefined
+	integer reg1 (x1): undefined
+	integer reg2 (x2): undefined
+	integer reg3 (x3): undefined
+	integer reg4 (x4): undefined
+	integer reg5 (x5): undefined
+	integer reg6 (x6): undefined
+	integer reg7 (x7): undefined
+	integer reg8 (x8): undefined
+	integer reg9 (x9): undefined
+	integer reg10 (x10): undefined
+	integer reg11 (x11): undefined
+	integer reg12 (x12): undefined
+	integer reg13 (x13): undefined
+	integer reg14 (x14): undefined
+	integer reg15 (x15): undefined
+	integer reg16 (x16): undefined
+	integer reg17 (x17): undefined
+	integer reg18 (x18): undefined
+	integer reg19 (x19): same_value
+	integer reg20 (x20): same_value
+	integer reg21 (x21): same_value
+	integer reg22 (x22): same_value
+	integer reg23 (x23): same_value
+	integer reg24 (x24): same_value
+	integer reg25 (x25): same_value
+	integer reg26 (x26): same_value
+	integer reg27 (x27): same_value
+	integer reg28 (x28): same_value
+	integer reg29 (x29): same_value
+	integer reg30 (x30): same_value
+	integer reg31 (sp): undefined
+	integer reg33 (elr): undefined
+	FP/SIMD reg64 (v0): undefined
+	FP/SIMD reg65 (v1): undefined
+	FP/SIMD reg66 (v2): undefined
+	FP/SIMD reg67 (v3): undefined
+	FP/SIMD reg68 (v4): undefined
+	FP/SIMD reg69 (v5): undefined
+	FP/SIMD reg70 (v6): undefined
+	FP/SIMD reg71 (v7): undefined
+	FP/SIMD reg72 (v8): same_value
+	FP/SIMD reg73 (v9): same_value
+	FP/SIMD reg74 (v10): same_value
+	FP/SIMD reg75 (v11): same_value
+	FP/SIMD reg76 (v12): same_value
+	FP/SIMD reg77 (v13): same_value
+	FP/SIMD reg78 (v14): same_value
+	FP/SIMD reg79 (v15): same_value
+	FP/SIMD reg80 (v16): undefined
+	FP/SIMD reg81 (v17): undefined
+	FP/SIMD reg82 (v18): undefined
+	FP/SIMD reg83 (v19): undefined
+	FP/SIMD reg84 (v20): undefined
+	FP/SIMD reg85 (v21): undefined
+	FP/SIMD reg86 (v22): undefined
+	FP/SIMD reg87 (v23): undefined
+	FP/SIMD reg88 (v24): undefined
+	FP/SIMD reg89 (v25): undefined
+	FP/SIMD reg90 (v26): undefined
+	FP/SIMD reg91 (v27): undefined
+	FP/SIMD reg92 (v28): undefined
+	FP/SIMD reg93 (v29): undefined
+	FP/SIMD reg94 (v30): undefined
+	FP/SIMD reg95 (v31): undefined
+EOF
diff --git a/tests/testfileaarch64.bz2 b/tests/testfileaarch64.bz2
new file mode 100755
index 0000000000000000000000000000000000000000..72e5ef0de7ca8ffaab3e19d0b34ab9acfda34da2
GIT binary patch
literal 3441
zcmV-%4UY0cT4*^jL0KkKSu>catpE*pfB*mg|NsB@|NsC0|9Sua-~Rk*Z{PELNA3J<
zfBW}OfB)bNT>Fh((xXCq&v{Q~dc4|sPV(zpy?NtDpbC4~t$~stAZQcR)f#%9o+R>~
zih6oYO{SyMNX;SW)Y_UJQ$~h{ntGn0;Y?4|Ajktl)NN1I2A-M*nl(0|rhs~b)YEDK
zp`#$s^#q{=G!kryspQ0-LYi!pHccm}^&X+MG->G?9-*N0k5QlpsL=gUqd;l2hEGr$
z21bn<05ky50qOt)L(~DFiK0mIni^=+CX9pB2dK~(KmalT00E!?G|&Jv0002>00000
z000dD5}u@*O-df8gqj&1rhouFKmZ4+>ODXj0i)CdKn#EZpa1}ApaUQP0}ucMKmY^)
z003kF27olsG#VNJ8fXlF00SYBf&gd?fM{qMX`mVbpa2;FWMlvmBt#}nOsA$($sQ6k
zJtNdJNv4}ZJxu@&2AX<?nlUl}446Y88UO&$27ols4FJ#p0iXcqG?rv{R+Z^3mAzo&
z&N(FZvl*)iLaC>>>5k+>bgU?#lLHE=3OA)<M3mUj)R3aEV`FPn;BHI;GqSj{tVp>H
zIdoD}I&Wne22QOUtHFkN<|QdHL|cCLQ*lEUo{4tv*JiH+$UA0exwxK7&~&xmuKfjW
zzg0$uUnX09W$CZJCfcSq((5d7HwCk3F2wrqH1(a)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