Commit | Line | Data |
---|---|---|
4a2f4826 AK |
1 | /* Target-dependent code for Newlib ARC. |
2 | ||
b811d2c2 | 3 | Copyright (C) 2016-2020 Free Software Foundation, Inc. |
4a2f4826 AK |
4 | Contributed by Synopsys Inc. |
5 | ||
6 | This file is part of GDB. | |
7 | ||
8 | This program is free software; you can redistribute it and/or modify | |
9 | it under the terms of the GNU General Public License as published by | |
10 | the Free Software Foundation; either version 3 of the License, or | |
11 | (at your option) any later version. | |
12 | ||
13 | This program is distributed in the hope that it will be useful, | |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | GNU General Public License for more details. | |
17 | ||
18 | You should have received a copy of the GNU General Public License | |
19 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | |
20 | ||
21 | #include "defs.h" | |
22 | ||
d55e5aa6 | 23 | #include "gdbarch.h" |
4de283e4 | 24 | #include "arc-tdep.h" |
4a2f4826 AK |
25 | #include "osabi.h" |
26 | ||
27 | /* Implement the 'init_osabi' method of struct gdb_osabi_handler. */ | |
28 | ||
29 | static void | |
30 | arc_newlib_init_osabi (struct gdbarch_info info, struct gdbarch *gdbarch) | |
31 | { | |
32 | if (arc_debug) | |
33 | debug_printf ("arc-newlib: Initialization.\n"); | |
34 | ||
35 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | |
36 | ||
37 | /* Offset of original PC in longjmp jump buffer (in registers). Value of PC | |
38 | offset can be found in newlib/libc/machine/arc/setjmp.S. */ | |
39 | tdep->jb_pc = 18; | |
40 | } | |
41 | ||
42 | /* Recognize ARC Newlib object files. */ | |
43 | ||
44 | static enum gdb_osabi | |
45 | arc_newlib_osabi_sniffer (bfd *abfd) | |
46 | { | |
47 | if (arc_debug) | |
48 | debug_printf ("arc-newlib: OS/ABI sniffer.\n"); | |
49 | ||
50 | /* crt0.S in libgloss for ARC defines .ivt section for interrupt handlers. | |
51 | If this section is not present then this is likely not a newlib - could be | |
52 | a Linux application or some non-newlib baremetal application. */ | |
53 | if (bfd_get_section_by_name (abfd, ".ivt") != NULL) | |
54 | return GDB_OSABI_NEWLIB; | |
55 | else | |
56 | return GDB_OSABI_UNKNOWN; | |
57 | } | |
58 | ||
6c265988 | 59 | void _initialize_arc_newlib_tdep (); |
4a2f4826 | 60 | void |
6c265988 | 61 | _initialize_arc_newlib_tdep () |
4a2f4826 AK |
62 | { |
63 | gdbarch_register_osabi_sniffer (bfd_arch_arc, bfd_target_elf_flavour, | |
64 | arc_newlib_osabi_sniffer); | |
65 | gdbarch_register_osabi (bfd_arch_arc, 0, GDB_OSABI_NEWLIB, | |
66 | arc_newlib_init_osabi); | |
67 | } |