xref: /aosp_15_r20/external/elfutils/backends/loongarch_init.c (revision 7304104da70ce23c86437a01be71edd1a2d7f37e)
1 /* Initialization of LoongArch specific backend library.
2    Copyright (C) 2022 Hengqi Chen
3    Copyright (C) 2023 OpenAnolis community LoongArch SIG.
4    Copyright (C) 2023 Loongson Technology Corporation Limted.
5    This file is part of elfutils.
6 
7    This file is free software; you can redistribute it and/or modify
8    it under the terms of either
9 
10      * the GNU Lesser General Public License as published by the Free
11        Software Foundation; either version 3 of the License, or (at
12        your option) any later version
13 
14    or
15 
16      * the GNU General Public License as published by the Free
17        Software Foundation; either version 2 of the License, or (at
18        your option) any later version
19 
20    or both in parallel, as here.
21 
22    elfutils is distributed in the hope that it will be useful, but
23    WITHOUT ANY WARRANTY; without even the implied warranty of
24    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
25    General Public License for more details.
26 
27    You should have received copies of the GNU General Public License and
28    the GNU Lesser General Public License along with this program.  If
29    not, see <http://www.gnu.org/licenses/>.  */
30 
31 #ifdef HAVE_CONFIG_H
32 # include <config.h>
33 #endif
34 
35 #define BACKEND		loongarch_
36 #define RELOC_PREFIX	R_LARCH_
37 #include "libebl_CPU.h"
38 
39 /* This defines the common reloc hooks based on loongarch_reloc.def.  */
40 #include "common-reloc.c"
41 
42 
43 Ebl *
loongarch_init(Elf * elf,GElf_Half machine,Ebl * eh)44 loongarch_init (Elf *elf __attribute__ ((unused)),
45 	        GElf_Half machine __attribute__ ((unused)),
46 	        Ebl *eh)
47 {
48   loongarch_init_reloc (eh);
49   HOOK (eh, reloc_simple_type);
50   HOOK (eh, machine_flag_check);
51   HOOK (eh, register_info);
52   HOOK (eh, core_note);
53   HOOK (eh, abi_cfi);
54   /* gcc/config/ #define DWARF_FRAME_REGISTERS.  */
55   eh->frame_nregs = 74;
56   HOOK (eh, check_special_symbol);
57   HOOK (eh, set_initial_registers_tid);
58   HOOK (eh, return_value_location);
59   HOOK (eh, unwind);
60 
61   return eh;
62 }
63