Brad Bishop | a34c030 | 2019-09-23 22:34:48 -0400 | [diff] [blame^] | 1 | From 96e38289f2887ddb8e6d2fb91ea04bdbdf034ab5 Mon Sep 17 00:00:00 2001 |
| 2 | From: Hongxu Jia <hongxu.jia@windriver.com> |
| 3 | Date: Wed, 21 Aug 2019 17:00:30 +0800 |
| 4 | Subject: [PATCH 2/2] mips_cfi |
| 5 | |
| 6 | Upstream-Status: Pending [from debian] |
| 7 | |
| 8 | Rebase to 0.177 |
| 9 | |
| 10 | Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> |
| 11 | --- |
| 12 | backends/Makefile.am | 2 +- |
| 13 | backends/mips_cfi.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 14 | backends/mips_init.c | 1 + |
| 15 | 3 files changed, 82 insertions(+), 1 deletion(-) |
| 16 | create mode 100644 backends/mips_cfi.c |
| 17 | |
| 18 | diff --git a/backends/Makefile.am b/backends/Makefile.am |
| 19 | index aba8a4a..6ac0eec 100644 |
| 20 | --- a/backends/Makefile.am |
| 21 | +++ b/backends/Makefile.am |
| 22 | @@ -145,7 +145,7 @@ csky_SRCS = csky_attrs.c csky_init.c csky_symbol.c csky_cfi.c \ |
| 23 | libebl_csky_pic_a_SOURCES = $(csky_SRCS) |
| 24 | am_libebl_csky_pic_a_OBJECTS = $(csky_SRCS:.c=.os) |
| 25 | |
| 26 | -mips_SRCS = mips_init.c mips_symbol.c mips_regs.c mips_retval.c |
| 27 | +mips_SRCS = mips_init.c mips_symbol.c mips_regs.c mips_retval.c mips_cfi.c |
| 28 | libebl_mips_pic_a_SOURCES = $(mips_SRCS) |
| 29 | am_libebl_mips_pic_a_OBJECTS = $(mips_SRCS:.c=.os) |
| 30 | |
| 31 | diff --git a/backends/mips_cfi.c b/backends/mips_cfi.c |
| 32 | new file mode 100644 |
| 33 | index 0000000..9ffdab5 |
| 34 | --- /dev/null |
| 35 | +++ b/backends/mips_cfi.c |
| 36 | @@ -0,0 +1,80 @@ |
| 37 | +/* MIPS ABI-specified defaults for DWARF CFI. |
| 38 | + Copyright (C) 2018 Kurt Roeckx, Inc. |
| 39 | + This file is part of elfutils. |
| 40 | + |
| 41 | + This file is free software; you can redistribute it and/or modify |
| 42 | + it under the terms of either |
| 43 | + |
| 44 | + * the GNU Lesser General Public License as published by the Free |
| 45 | + Software Foundation; either version 3 of the License, or (at |
| 46 | + your option) any later version |
| 47 | + |
| 48 | + or |
| 49 | + |
| 50 | + * the GNU General Public License as published by the Free |
| 51 | + Software Foundation; either version 2 of the License, or (at |
| 52 | + your option) any later version |
| 53 | + |
| 54 | + or both in parallel, as here. |
| 55 | + |
| 56 | + elfutils is distributed in the hope that it will be useful, but |
| 57 | + WITHOUT ANY WARRANTY; without even the implied warranty of |
| 58 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 59 | + General Public License for more details. |
| 60 | + |
| 61 | + You should have received copies of the GNU General Public License and |
| 62 | + the GNU Lesser General Public License along with this program. If |
| 63 | + not, see <http://www.gnu.org/licenses/>. */ |
| 64 | + |
| 65 | +#ifdef HAVE_CONFIG_H |
| 66 | +# include <config.h> |
| 67 | +#endif |
| 68 | + |
| 69 | +#include <dwarf.h> |
| 70 | + |
| 71 | +#define BACKEND mips_ |
| 72 | +#include "libebl_CPU.h" |
| 73 | + |
| 74 | +int |
| 75 | +mips_abi_cfi (Ebl *ebl __attribute__ ((unused)), Dwarf_CIE *abi_info) |
| 76 | +{ |
| 77 | + static const uint8_t abi_cfi[] = |
| 78 | + { |
| 79 | + /* Call-saved regs. */ |
| 80 | + DW_CFA_same_value, ULEB128_7 (16), /* $16 */ |
| 81 | + DW_CFA_same_value, ULEB128_7 (17), /* $17 */ |
| 82 | + DW_CFA_same_value, ULEB128_7 (18), /* $18 */ |
| 83 | + DW_CFA_same_value, ULEB128_7 (19), /* $19 */ |
| 84 | + DW_CFA_same_value, ULEB128_7 (20), /* $20 */ |
| 85 | + DW_CFA_same_value, ULEB128_7 (21), /* $21 */ |
| 86 | + DW_CFA_same_value, ULEB128_7 (22), /* $22 */ |
| 87 | + DW_CFA_same_value, ULEB128_7 (23), /* $23 */ |
| 88 | + DW_CFA_same_value, ULEB128_7 (28), /* $28 */ |
| 89 | + DW_CFA_same_value, ULEB128_7 (29), /* $29 */ |
| 90 | + DW_CFA_same_value, ULEB128_7 (30), /* $30 */ |
| 91 | + |
| 92 | + DW_CFA_same_value, ULEB128_7 (52), /* $f20 */ |
| 93 | + DW_CFA_same_value, ULEB128_7 (53), /* $f21 */ |
| 94 | + DW_CFA_same_value, ULEB128_7 (54), /* $f22 */ |
| 95 | + DW_CFA_same_value, ULEB128_7 (55), /* $f23 */ |
| 96 | + DW_CFA_same_value, ULEB128_7 (56), /* $f24 */ |
| 97 | + DW_CFA_same_value, ULEB128_7 (57), /* $f25 */ |
| 98 | + DW_CFA_same_value, ULEB128_7 (58), /* $f26 */ |
| 99 | + DW_CFA_same_value, ULEB128_7 (59), /* $f27 */ |
| 100 | + DW_CFA_same_value, ULEB128_7 (60), /* $f28 */ |
| 101 | + DW_CFA_same_value, ULEB128_7 (61), /* $f29 */ |
| 102 | + DW_CFA_same_value, ULEB128_7 (62), /* $f30 */ |
| 103 | + DW_CFA_same_value, ULEB128_7 (63), /* $f31 */ |
| 104 | + |
| 105 | + /* The CFA is the SP. */ |
| 106 | + DW_CFA_def_cfa, ULEB128_7 (29), ULEB128_7 (0), |
| 107 | + }; |
| 108 | + |
| 109 | + abi_info->initial_instructions = abi_cfi; |
| 110 | + abi_info->initial_instructions_end = &abi_cfi[sizeof abi_cfi]; |
| 111 | + abi_info->data_alignment_factor = 4; |
| 112 | + |
| 113 | + abi_info->return_address_register = 31; /* $31 */ |
| 114 | + |
| 115 | + return 0; |
| 116 | +} |
| 117 | diff --git a/backends/mips_init.c b/backends/mips_init.c |
| 118 | index 8482e7f..bce5abe 100644 |
| 119 | --- a/backends/mips_init.c |
| 120 | +++ b/backends/mips_init.c |
| 121 | @@ -50,6 +50,7 @@ mips_init (Elf *elf __attribute__ ((unused)), |
| 122 | HOOK (eh, reloc_simple_type); |
| 123 | HOOK (eh, return_value_location); |
| 124 | HOOK (eh, register_info); |
| 125 | + HOOK (eh, abi_cfi); |
| 126 | |
| 127 | return MODVERSION; |
| 128 | } |
| 129 | -- |
| 130 | 2.7.4 |
| 131 | |