1 /* Target-dependent code for Newlib ARC.
3 Copyright (C) 2016-2024 Free Software Foundation, Inc.
4 Contributed by Synopsys Inc.
6 This file is part of GDB.
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.
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.
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/>. */
26 /* Print an "arc-newlib" debug statement. */
28 #define arc_newlib_debug_printf(fmt, ...) \
29 debug_prefixed_printf_cond (arc_debug, "arc-newlib", fmt, ##__VA_ARGS__)
31 /* Implement the 'init_osabi' method of struct gdb_osabi_handler. */
34 arc_newlib_init_osabi (struct gdbarch_info info
, struct gdbarch
*gdbarch
)
36 arc_newlib_debug_printf ("Initialization.");
38 arc_gdbarch_tdep
*tdep
= gdbarch_tdep
<arc_gdbarch_tdep
> (gdbarch
);
40 /* Offset of original PC in longjmp jump buffer (in registers). Value of PC
41 offset can be found in newlib/libc/machine/arc/setjmp.S. */
45 /* Recognize ARC Newlib object files. */
48 arc_newlib_osabi_sniffer (bfd
*abfd
)
50 arc_newlib_debug_printf ("OS/ABI sniffer.");
52 /* crt0.S in libgloss for ARC defines .ivt section for interrupt handlers.
53 If this section is not present then this is likely not a newlib - could be
54 a Linux application or some non-newlib baremetal application. */
55 if (bfd_get_section_by_name (abfd
, ".ivt") != NULL
)
56 return GDB_OSABI_NEWLIB
;
58 return GDB_OSABI_UNKNOWN
;
61 void _initialize_arc_newlib_tdep ();
63 _initialize_arc_newlib_tdep ()
65 gdbarch_register_osabi_sniffer (bfd_arch_arc
, bfd_target_elf_flavour
,
66 arc_newlib_osabi_sniffer
);
67 gdbarch_register_osabi (bfd_arch_arc
, 0, GDB_OSABI_NEWLIB
,
68 arc_newlib_init_osabi
);