arc-newlib-tdep.c 2.2 KB

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