New arm_abi_cfi that defines initial CFA, rules for callee-saved regs and return register.
Note the DWARF abi extension for ARM says that "registers intentionally unused" should also be initialized as if by DW_CFA_same_value. The example given is "an integer-only function might be included in one executable file for targets with VFP and another for targets without". We don't currently do this yet.
Also adds addrcfi arm testcase.
Signed-off-by: Mark Wielaard mjw@redhat.com --- backends/ChangeLog | 6 ++++ backends/Makefile.am | 2 +- backends/arm_cfi.c | 67 +++++++++++++++++++++++++++++++++++++++++++ backends/arm_init.c | 3 +- tests/ChangeLog | 6 ++++ tests/Makefile.am | 3 +- tests/run-addrcfi.sh | 76 +++++++++++++++++++++++++++++++++++++++++++++++++ tests/testfilearm.bz2 | Bin 0 -> 3545 bytes 8 files changed, 160 insertions(+), 3 deletions(-) create mode 100644 backends/arm_cfi.c create mode 100755 tests/testfilearm.bz2
diff --git a/backends/ChangeLog b/backends/ChangeLog index 64e5efd..68ab00e 100644 --- a/backends/ChangeLog +++ b/backends/ChangeLog @@ -1,3 +1,9 @@ +2013-08-29 Mark Wielaard mjw@redhat.com + + * Makefile.am (arm_SRCS): Add arm_cfi.c. + * arm_cfi.c: New file. + * arm_init.c (arm_init): Initialize abi_cfi. + 2013-08-28 Mark Wielaard mjw@redhat.com
* arm_regs.c (arm_register_info): Set *prefix to "". diff --git a/backends/Makefile.am b/backends/Makefile.am index ec022b0..557ed87 100644 --- a/backends/Makefile.am +++ b/backends/Makefile.am @@ -75,7 +75,7 @@ libebl_alpha_pic_a_SOURCES = $(alpha_SRCS) am_libebl_alpha_pic_a_OBJECTS = $(alpha_SRCS:.c=.os)
arm_SRCS = arm_init.c arm_symbol.c arm_regs.c arm_corenote.c \ - arm_auxv.c arm_attrs.c arm_retval.c + arm_auxv.c arm_attrs.c arm_retval.c arm_cfi.c libebl_arm_pic_a_SOURCES = $(arm_SRCS) am_libebl_arm_pic_a_OBJECTS = $(arm_SRCS:.c=.os)
diff --git a/backends/arm_cfi.c b/backends/arm_cfi.c new file mode 100644 index 0000000..7fb1b93 --- /dev/null +++ b/backends/arm_cfi.c @@ -0,0 +1,67 @@ +/* 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 arm_ +#include "libebl_CPU.h" + +int +arm_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 (r13) as setup in the previous frame. */ + DW_CFA_def_cfa, ULEB128_7 (13), ULEB128_7 (0), + +#define SV(n) DW_CFA_same_value, ULEB128_7 (n) + /* Callee-saved regs r4-r8, r10, r11. */ + SV (4), SV (5), SV (6), SV (7), SV (8), SV (10), SV (11), + + /* The link register contains the return address setup by caller. */ + SV (14), + + /* 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. */ +#undef SV + }; + + 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 = 14; /* Link Register. */ + + return 0; +} diff --git a/backends/arm_init.c b/backends/arm_init.c index 38bd4eb..cf661ce 100644 --- a/backends/arm_init.c +++ b/backends/arm_init.c @@ -1,5 +1,5 @@ /* Initialization of Arm specific backend library. - Copyright (C) 2002, 2005, 2009 Red Hat, Inc. + Copyright (C) 2002, 2005, 2009, 2013 Red Hat, Inc. This file is part of elfutils. Written by Ulrich Drepper drepper@redhat.com, 2002.
@@ -62,6 +62,7 @@ arm_init (elf, machine, eh, ehlen) HOOK (eh, auxv_info); HOOK (eh, check_object_attribute); HOOK (eh, return_value_location); + HOOK (eh, abi_cfi);
return MODVERSION; } diff --git a/tests/ChangeLog b/tests/ChangeLog index b934555..3f9c878 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,9 @@ +2013-08-29 Mark Wielaard mjw@redhat.com + + * run-addrcfi.sh: Add case for EM_ARM. + * testfilearm.bz2: New testfile. + * Makefile.am (EXTRA_DIST): Add testfilesarm.bz2. + 2013-08-28 Mark Wielaard mjw@redhat.com
* addrcfi.c (handle_cfi): Handle .debug_frame or .eh_frame diff --git a/tests/Makefile.am b/tests/Makefile.am index 8e4f88a..251ebc4 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -204,7 +204,8 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \ test-core.exec.bz2 run-addr2line-test.sh \ run-addr2line-i-test.sh testfile-inlines.bz2 \ testfileppc32.bz2 testfileppc64.bz2 \ - testfiles390.bz2 testfiles390x.bz2 + testfiles390.bz2 testfiles390x.bz2 \ + testfilearm.bz2
if USE_VALGRIND valgrind_cmd='valgrind -q --trace-children=yes --error-exitcode=1 --run-libc-freeres=no' diff --git a/tests/run-addrcfi.sh b/tests/run-addrcfi.sh index 38669ca..71143f0 100755 --- a/tests/run-addrcfi.sh +++ b/tests/run-addrcfi.sh @@ -2496,3 +2496,79 @@ testrun_compare ${abs_builddir}/addrcfi -e testfiles390x 0x0000000080000510 <<\E control reg65 (%pswa): same_value handle_cfi no CFI (.debug_frame): no error EOF + +# EM_ARM (function bar 0x00008510) +# Note. Only in .debug_frame, the .eh_frame is actually empty. +# Same as s390 and ppc above. +testfiles testfilearm +testrun_compare ${abs_builddir}/addrcfi -e testfilearm 0x00008510 <<\EOF +dwarf_cfi_addrframe (.eh_frame): no matching address range +.debug_frame has 0x8510 => [0x8510, 0x8524): + return address in reg14 + CFA location expression: bregx(13) + integer reg0 (r0): same_value + integer reg1 (r1): same_value + integer reg2 (r2): same_value + integer reg3 (r3): same_value + integer reg4 (r4): same_value + integer reg5 (r5): same_value + integer reg6 (r6): same_value + integer reg7 (r7): same_value + integer reg8 (r8): same_value + integer reg9 (r9): same_value + integer reg10 (r10): same_value + integer reg11 (r11): same_value + integer reg12 (r12): same_value + integer reg13 (sp): same_value + integer reg14 (lr): same_value + integer reg15 (pc): same_value + FPA reg16 (f0): same_value + FPA reg17 (f1): same_value + FPA reg18 (f2): same_value + FPA reg19 (f3): same_value + FPA reg20 (f4): same_value + FPA reg21 (f5): same_value + FPA reg22 (f6): same_value + FPA reg23 (f7): same_value + FPA reg96 (f0): same_value + FPA reg97 (f1): same_value + FPA reg98 (f2): same_value + FPA reg99 (f3): same_value + FPA reg100 (f4): same_value + FPA reg101 (f5): same_value + FPA reg102 (f6): same_value + FPA reg103 (f7): same_value + integer reg128 (spsr): same_value + VFP reg256 (d0): same_value + VFP reg257 (d1): same_value + VFP reg258 (d2): same_value + VFP reg259 (d3): same_value + VFP reg260 (d4): same_value + VFP reg261 (d5): same_value + VFP reg262 (d6): same_value + VFP reg263 (d7): same_value + VFP reg264 (d8): same_value + VFP reg265 (d9): same_value + VFP reg266 (d10): same_value + VFP reg267 (d11): same_value + VFP reg268 (d12): same_value + VFP reg269 (d13): same_value + VFP reg270 (d14): same_value + VFP reg271 (d15): same_value + VFP reg272 (d16): same_value + VFP reg273 (d17): same_value + VFP reg274 (d18): same_value + VFP reg275 (d19): same_value + VFP reg276 (d20): same_value + VFP reg277 (d21): same_value + VFP reg278 (d22): same_value + VFP reg279 (d23): same_value + VFP reg280 (d24): same_value + VFP reg281 (d25): same_value + VFP reg282 (d26): same_value + VFP reg283 (d27): same_value + VFP reg284 (d28): same_value + VFP reg285 (d29): same_value + VFP reg286 (d30): same_value + VFP reg287 (d31): same_value +EOF diff --git a/tests/testfilearm.bz2 b/tests/testfilearm.bz2 new file mode 100755 index 0000000000000000000000000000000000000000..d6cd090e3e12df1d4c9cac7d626ceb62909c0de4 GIT binary patch literal 3545 zcmV;~4JPtJT4*^jL0KkKSpxlNAOH+&|NsC0|NsC0|NsB@|MCC-|Nj2|{@3k7Zs%QB zT-|^E`_14C)9h0>p$I1Dw~u!4xf*JFoT%HQL{(ZhcDrV{7@-p)1n~e*Mv{3?45{S8 zo>TQq^huEP(rqI_=`jYLnuAYKqeIFDfuJ6yL4-3zG#Yv%LFxgap`g=GL}b%Jq7Y&< znyLO%$eu!;Q%UTo#M5eenrI$SWEh%g0iZO{8Z;iGAP-0Y0MGyc01W^D00082coJ!# z9;Sc?r~#lF0B8UJ000000000005kvq0000000D%M2q}$1dSneps0N0Os2Tz400x89 z003#GfB<L!0D78a00xZ!02%-WfH4FO4FCb5pbZR$KpHX`0MVex3=j-~rhov*(9jJ4 z0iXjw4FCW%00w};B0&&Ln3^;MnUOLR)6q?odYe(`(H^5sHj~u#00w{qAoU)jMu2E& z14A_)qfG#4003wJ0qFovMps>$x(%xUGm11398o1YR1gX`&CsGt5X(H%Vo|TNCA&z) zqN?rOp6z=>A=Qx0+7T#+E)4*V4>H{GT1dM20+`I`L=0XXnl4Yib8^|l@S_@e@Hk`x zYz}36vDW4GfhramWuZF4(@)=U>Z9NM9SrCyCIt`%VBN?2HCunFuDjma+x1%QET|<R zDL{i|=X4qw6YsC{x-OGHZ%eYI@ubWlvhn>G`Ci^%AMeebrJ&sJw)@9(XEH!pYUQAT zr{FLR;sj}s9a<p55C;CrEOjzQrr9!P2g~!9FAQh{&fCiEcDjqcN2H8Ts=R}e!5S?f z+<g4L658fBcS&6r0*)luA`wwKmwyxj1>{^j3V(+Wg8UUI;x11A3yj*yFo6&OJp-+K zU9fN?c7P|pM2=-Oy#cy<mxYhL>F-}8O{QH=vDN48V?_2JdVi7!=NrDE3(+%R=Q;v0 zs?K3nj;2|gOCt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