30#ifndef GDB_OSABI_DEFAULT
31#define GDB_OSABI_DEFAULT GDB_OSABI_UNKNOWN
68 {
"GNU/Linux",
"linux(-gnu[^-]*)?" },
72 {
"WindowsCE", NULL },
74 {
"QNX-Neutrino", NULL },
81 {
"LynxOS178", NULL },
152 const struct bfd_arch_info *arch_info = bfd_lookup_arch (arch, machine);
153 const char **name_ptr;
159 (_(
"gdbarch_register_osabi: An attempt to register a handler for "
160 "OS ABI \"%s\" for architecture %s was made. The handler will "
161 "not be registered"),
163 bfd_printable_arch_mach (arch, machine));
167 gdb_assert (arch_info);
170 handler_p = &(*handler_p)->
next)
172 if ((*handler_p)->arch_info == arch_info
173 && (*handler_p)->osabi == osabi)
176 (_(
"gdbarch_register_osabi: A handler for OS ABI \"%s\" "
177 "has already been registered for architecture %s"),
179 arch_info->printable_name);
181 (*handler_p)->init_osabi = init_osabi;
187 (*handler_p)->next = NULL;
188 (*handler_p)->arch_info = arch_info;
189 (*handler_p)->osabi = osabi;
190 (*handler_p)->init_osabi = init_osabi;
259 if ((
sniffer->arch == bfd_arch_unknown
260 ||
sniffer->arch == bfd_get_arch (abfd))
261 &&
sniffer->flavour == bfd_get_flavour (abfd))
263 osabi = (*
sniffer->sniffer) (abfd);
267 (_(
"gdbarch_lookup_osabi: invalid OS ABI (%d) from sniffer "
268 "for architecture %s flavour %d"),
270 bfd_printable_arch_mach (bfd_get_arch (abfd), 0),
271 (
int) bfd_get_flavour (abfd));
281 if ((match_specific &&
sniffer->arch != bfd_arch_unknown)
282 || (!match_specific &&
sniffer->arch == bfd_arch_unknown))
285 (_(
"gdbarch_lookup_osabi: multiple %sspecific OS ABI "
286 "match for architecture %s flavour %d: first "
287 "match \"%s\", second match \"%s\""),
288 match_specific ?
"" :
"non-",
289 bfd_printable_arch_mach (bfd_get_arch (abfd), 0),
290 (int) bfd_get_flavour (abfd),
294 else if (
sniffer->arch != bfd_arch_unknown)
303 if (
sniffer->arch != bfd_arch_unknown)
328 return (a == b || a->compatible (a, b) == a);
341 handler = handler->
next)
343 if (handler->
osabi != info.osabi)
389 if (handler !=
nullptr)
403 (
"A handler for the OS ABI \"%s\" is not built into this configuration\n"
404 "of GDB. Attempting to continue with the default %s settings.\n",
406 info.bfd_arch_info->printable_name);
410#define MAX_NOTESZ 128
417check_note (bfd *abfd, asection *sect,
char *note,
unsigned int *sectsize,
418 const char *
name,
unsigned long descsz,
unsigned long type)
420 unsigned long notesz;
424 if (!bfd_get_section_contents (abfd, sect, note, 0, *sectsize))
430 notesz = strlen (
name) + 1;
431 notesz = ((notesz + 3) & ~3);
433 notesz = ((notesz + 3) & ~3);
439 if (notesz > bfd_section_size (sect))
443 if (bfd_h_get_32 (abfd, note) != (strlen (
name) + 1)
444 || strcmp (note + 12,
name) != 0)
448 if (bfd_h_get_32 (abfd, note + 4) != descsz)
452 if (bfd_h_get_32 (abfd, note + 8) !=
type)
465 unsigned int sectsize;
467 name = bfd_section_name (sect);
468 sectsize = bfd_section_size (sect);
482 if (strcmp (
name,
".note.ABI-tag") == 0)
485 if (
check_note (abfd, sect, note, §size,
"GNU", 16, NT_GNU_ABI_TAG))
487 unsigned int abi_tag = bfd_h_get_32 (abfd, note + 16);
491 case GNU_ABI_TAG_LINUX:
495 case GNU_ABI_TAG_HURD:
499 case GNU_ABI_TAG_SOLARIS:
503 case GNU_ABI_TAG_FREEBSD:
507 case GNU_ABI_TAG_NETBSD:
512 warning (_(
"GNU ABI tag value %u unrecognized."), abi_tag);
519 if (
check_note (abfd, sect, note, §size,
"FreeBSD", 4,
531 if (strcmp (
name,
".note.netbsd.ident") == 0
532 &&
check_note (abfd, sect, note, §size,
"NetBSD", 4, NT_NETBSD_IDENT))
540 if (strcmp (
name,
".note.openbsd.ident") == 0
541 &&
check_note (abfd, sect, note, §size,
"OpenBSD", 4,
550 if (strcmp (
name,
".note.netbsdcore.procinfo") == 0)
560 unsigned int elfosabi;
563 elfosabi = elf_elfheader (abfd)->e_ident[EI_OSABI];
586 case ELFOSABI_FREEBSD:
590 case ELFOSABI_NETBSD:
594 case ELFOSABI_SOLARIS:
598 case ELFOSABI_OPENVMS:
608 if (memcmp (&elf_elfheader (abfd)->e_ident[8],
609 "FreeBSD",
sizeof (
"FreeBSD")) == 0)
642 internal_error (_(
"Invalid OS ABI \"%s\" passed to command handler."),
650 internal_error (_(
"Updating OS ABI failed."));
659 _(
"The current OS ABI is \"auto\" "
660 "(currently \"%s\").\n"),
663 gdb_printf (file, _(
"The current OS ABI is \"%s\".\n"),
667 gdb_printf (file, _(
"The default OS ABI is \"%s\".\n"),
677 (_(
"_initialize_gdb_osabi: gdb_osabi_names[] is inconsistent"));
681 bfd_target_elf_flavour,
690 _(
"Set OS ABI of target."),
691 _(
"Show OS ABI of target."),
int gdbarch_update_p(struct gdbarch_info info)
struct gdbarch * get_current_arch(void)
struct cmd_list_element * showlist
struct cmd_list_element * setlist
set_show_commands add_setshow_enum_cmd(const char *name, enum command_class theclass, const char *const *enumlist, const char **var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
static gdb_bfd_section_range gdb_bfd_sections(bfd *abfd)
enum gdb_osabi gdbarch_osabi(struct gdbarch *gdbarch)
static const char * set_osabi_string
static void set_osabi(const char *args, int from_tty, struct cmd_list_element *c)
void gdbarch_register_osabi(enum bfd_architecture arch, unsigned long machine, enum gdb_osabi osabi, void(*init_osabi)(struct gdbarch_info, struct gdbarch *))
static struct gdb_osabi_handler * gdbarch_osabi_handler(struct gdbarch_info info)
void gdbarch_init_osabi(struct gdbarch_info info, struct gdbarch *gdbarch)
static enum gdb_osabi generic_elf_osabi_sniffer(bfd *abfd)
static enum @145 user_osabi_state
void generic_elf_osabi_sniff_abi_tag_sections(bfd *abfd, asection *sect, enum gdb_osabi *osabi)
const char * osabi_triplet_regexp(enum gdb_osabi osabi)
static enum gdb_osabi user_selected_osabi
bool has_gdb_osabi_handler(struct gdbarch_info info)
void _initialize_gdb_osabi()
#define GDB_OSABI_DEFAULT
static struct gdb_osabi_handler * gdb_osabi_handler_list
static void show_osabi(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
void gdbarch_register_osabi_sniffer(enum bfd_architecture arch, enum bfd_flavour flavour, enum gdb_osabi(*sniffer_fn)(bfd *))
static const char * gdb_osabi_available_names[GDB_OSABI_INVALID+3]
enum gdb_osabi gdbarch_lookup_osabi(bfd *abfd)
const char * gdbarch_osabi_name(enum gdb_osabi osabi)
static int can_run_code_for(const struct bfd_arch_info *a, const struct bfd_arch_info *b)
static const struct osabi_names gdb_osabi_names[]
enum gdb_osabi osabi_from_tdesc_string(const char *name)
static struct gdb_osabi_sniffer * gdb_osabi_sniffer_list
static int check_note(bfd *abfd, asection *sect, char *note, unsigned int *sectsize, const char *name, unsigned long descsz, unsigned long type)
const struct bfd_arch_info * arch_info
struct gdb_osabi_handler * next
void(* init_osabi)(struct gdbarch_info, struct gdbarch *)
enum bfd_architecture arch
struct gdb_osabi_sniffer * next
enum gdb_osabi(* sniffer)(bfd *)
void gdb_printf(struct ui_file *stream, const char *format,...)