/src/elfutils/backends/loongarch_cfi.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* LoongArch ABI-specified defaults for DWARF CFI. |
2 | | Copyright (C) 2023 OpenAnolis community LoongArch SIG. |
3 | | Copyright (C) 2023 Loongson Technology Corporation Limted. |
4 | | This file is part of elfutils. |
5 | | |
6 | | This file is free software; you can redistribute it and/or modify |
7 | | it under the terms of either |
8 | | |
9 | | * the GNU Lesser General Public License as published by the Free |
10 | | Software Foundation; either version 3 of the License, or (at |
11 | | your option) any later version |
12 | | |
13 | | or |
14 | | |
15 | | * the GNU General Public License as published by the Free |
16 | | Software Foundation; either version 2 of the License, or (at |
17 | | your option) any later version |
18 | | |
19 | | or both in parallel, as here. |
20 | | |
21 | | elfutils is distributed in the hope that it will be useful, but |
22 | | WITHOUT ANY WARRANTY; without even the implied warranty of |
23 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
24 | | General Public License for more details. |
25 | | |
26 | | You should have received copies of the GNU General Public License and |
27 | | the GNU Lesser General Public License along with this program. If |
28 | | not, see <http://www.gnu.org/licenses/>. */ |
29 | | |
30 | | #ifdef HAVE_CONFIG_H |
31 | | # include <config.h> |
32 | | #endif |
33 | | |
34 | | #include <dwarf.h> |
35 | | |
36 | | #define BACKEND loongarch_ |
37 | | #include "libebl_CPU.h" |
38 | | |
39 | | /* LoongArch ELF ABI specification: |
40 | | https://loongson.github.io/LoongArch-Documentation/LoongArch-ELF-ABI-EN.html#_register_convention |
41 | | */ |
42 | | int |
43 | | loongarch_abi_cfi (Ebl *ebl __attribute__ ((unused)), Dwarf_CIE *abi_info) |
44 | 0 | { |
45 | 0 | static const uint8_t abi_cfi[] = |
46 | 0 | { |
47 | | /* The initial Canonical Frame Address is the value of the |
48 | | Stack Pointer ($r3) as setup in the previous frame. */ |
49 | 0 | DW_CFA_def_cfa, ULEB128_7 (3), ULEB128_7 (0), |
50 | | |
51 | | /* The Stack Pointer ($r3) is restored from CFA address by default. */ |
52 | 0 | DW_CFA_val_offset, ULEB128_7 (3), ULEB128_7 (0), |
53 | |
|
54 | 0 | #define SV(n) DW_CFA_same_value, ULEB128_7 (n) |
55 | | /* The return address register contains the return address setup by |
56 | | caller. */ |
57 | 0 | SV (1), |
58 | | |
59 | | /* Callee-saved registers $s0-$s7. */ |
60 | 0 | SV (23), SV (24), SV (25), SV (26), SV (27), SV (28), |
61 | 0 | SV (29), SV (30), SV (31), |
62 | | |
63 | | /* The Frame Pointer ($fp, $r22) */ |
64 | 0 | SV(22), |
65 | | |
66 | | /* Callee-saved registers $fs0-$fs7. */ |
67 | 0 | SV (56), SV (57), SV (58), SV (59), SV (60), SV (61), |
68 | 0 | SV (62), SV (63), |
69 | 0 | #undef SV |
70 | | |
71 | | /* XXX Note: registers intentionally unused by the program, |
72 | | for example as a consequence of the procedure call standard |
73 | | should be initialized as if by DW_CFA_same_value. */ |
74 | 0 | }; |
75 | |
|
76 | 0 | abi_info->initial_instructions = abi_cfi; |
77 | 0 | abi_info->initial_instructions_end = &abi_cfi[sizeof abi_cfi]; |
78 | 0 | abi_info->data_alignment_factor = -4; |
79 | |
|
80 | 0 | abi_info->return_address_register = 1; /* ra. */ |
81 | |
|
82 | 0 | return 0; |
83 | 0 | } |