29 #ifndef GDB_OSABI_DEFAULT
30 #define GDB_OSABI_DEFAULT GDB_OSABI_UNKNOWN
66 {
"GNU/Linux",
"linux(-gnu)?" },
67 {
"FreeBSD a.out", NULL },
68 {
"FreeBSD ELF", NULL },
69 {
"NetBSD a.out", NULL },
70 {
"NetBSD ELF", NULL },
71 {
"OpenBSD ELF", NULL },
72 {
"Windows CE", NULL },
75 {
"HP/UX ELF", NULL },
76 {
"HP/UX SOM", NULL },
77 {
"QNX Neutrino", NULL },
84 {
"LynxOS178", NULL },
95 return gdb_osabi_names[osabi].
pretty;
106 return gdb_osabi_names[osabi].
regexp;
119 for (i = 0; i < ARRAY_SIZE (gdb_osabi_names); i++)
120 if (strcmp (name, gdb_osabi_names[i].
pretty) == 0)
154 const struct bfd_arch_info *arch_info = bfd_lookup_arch (arch, machine);
155 const char **name_ptr;
162 _(
"gdbarch_register_osabi: An attempt to register a handler for "
163 "OS ABI \"%s\" for architecture %s was made. The handler will "
164 "not be registered"),
166 bfd_printable_arch_mach (arch, machine));
172 for (handler_p = &gdb_osabi_handler_list; *handler_p != NULL;
173 handler_p = &(*handler_p)->
next)
175 if ((*handler_p)->arch_info == arch_info
176 && (*handler_p)->osabi == osabi)
180 _(
"gdbarch_register_osabi: A handler for OS ABI \"%s\" "
181 "has already been registered for architecture %s"),
183 arch_info->printable_name);
185 (*handler_p)->init_osabi = init_osabi;
192 (*handler_p)->next = NULL;
194 (*handler_p)->osabi =
osabi;
199 for (name_ptr = gdb_osabi_available_names; *name_ptr; name_ptr ++)
226 enum bfd_flavour flavour,
238 gdb_osabi_sniffer_list =
sniffer;
262 for (sniffer = gdb_osabi_sniffer_list; sniffer != NULL;
263 sniffer = sniffer->
next)
265 if ((sniffer->
arch == bfd_arch_unknown
266 || sniffer->
arch == bfd_get_arch (abfd))
267 && sniffer->
flavour == bfd_get_flavour (abfd))
269 osabi = (*sniffer->
sniffer) (abfd);
274 _(
"gdbarch_lookup_osabi: invalid OS ABI (%d) from sniffer "
275 "for architecture %s flavour %d"),
277 bfd_printable_arch_mach (bfd_get_arch (abfd), 0),
278 (
int) bfd_get_flavour (abfd));
288 if ((match_specific && sniffer->
arch != bfd_arch_unknown)
289 || (!match_specific && sniffer->
arch == bfd_arch_unknown))
293 _(
"gdbarch_lookup_osabi: multiple %sspecific OS ABI "
294 "match for architecture %s flavour %d: first "
295 "match \"%s\", second match \"%s\""),
296 match_specific ?
"" :
"non-",
297 bfd_printable_arch_mach (bfd_get_arch (abfd), 0),
298 (
int) bfd_get_flavour (abfd),
302 else if (sniffer->
arch != bfd_arch_unknown)
311 if (sniffer->
arch != bfd_arch_unknown)
336 return (a == b || a->compatible (a, b) == a);
352 for (handler = gdb_osabi_handler_list; handler != NULL;
353 handler = handler->
next)
386 (
"A handler for the OS ABI \"%s\" is not built into this configuration\n"
387 "of GDB. Attempting to continue with the default %s settings.\n",
393 #define MAX_NOTESZ 128
400 check_note (bfd *abfd, asection *sect,
char *note,
unsigned int *sectsize,
401 const char *
name,
unsigned long descsz,
unsigned long type)
403 unsigned long notesz;
407 if (!bfd_get_section_contents (abfd, sect, note, 0, *sectsize))
413 notesz = strlen (name) + 1;
414 notesz = ((notesz + 3) & ~3);
416 notesz = ((notesz + 3) & ~3);
422 if (notesz > bfd_section_size (abfd, sect))
426 if (bfd_h_get_32 (abfd, note) != (strlen (name) + 1)
427 || strcmp (note + 12, name) != 0)
431 if (bfd_h_get_32 (abfd, note + 4) != descsz)
435 if (bfd_h_get_32 (abfd, note + 8) != type)
448 unsigned int sectsize;
451 name = bfd_get_section_name (abfd, sect);
452 sectsize = bfd_section_size (abfd, sect);
463 note = alloca (sectsize);
466 if (strcmp (name,
".note.ABI-tag") == 0)
469 if (
check_note (abfd, sect, note, §size,
"GNU", 16, NT_GNU_ABI_TAG))
471 unsigned int abi_tag = bfd_h_get_32 (abfd, note + 16);
475 case GNU_ABI_TAG_LINUX:
479 case GNU_ABI_TAG_HURD:
483 case GNU_ABI_TAG_SOLARIS:
487 case GNU_ABI_TAG_FREEBSD:
491 case GNU_ABI_TAG_NETBSD:
496 warning (
_(
"GNU ABI tag value %u unrecognized."), abi_tag);
503 if (
check_note (abfd, sect, note, §size,
"FreeBSD", 4,
515 if (strcmp (name,
".note.netbsd.ident") == 0
516 &&
check_note (abfd, sect, note, §size,
"NetBSD", 4, NT_NETBSD_IDENT))
524 if (strcmp (name,
".note.openbsd.ident") == 0
525 &&
check_note (abfd, sect, note, §size,
"OpenBSD", 4,
534 if (strcmp (name,
".note.netbsdcore.procinfo") == 0)
544 unsigned int elfosabi;
547 elfosabi = elf_elfheader (abfd)->e_ident[EI_OSABI];
561 bfd_map_over_sections (abfd,
566 case ELFOSABI_FREEBSD:
570 case ELFOSABI_NETBSD:
574 case ELFOSABI_SOLARIS:
584 bfd_map_over_sections (abfd,
589 case ELFOSABI_OPENVMS:
599 if (memcmp (&elf_elfheader (abfd)->e_ident[8],
600 "FreeBSD",
sizeof (
"FreeBSD")) == 0)
612 if (strcmp (set_osabi_string,
"auto") == 0)
614 else if (strcmp (set_osabi_string,
"default") == 0)
619 else if (strcmp (set_osabi_string,
"none") == 0)
631 user_selected_osabi = i;
635 if (i == GDB_OSABI_INVALID)
637 _(
"Invalid OS ABI \"%s\" passed to command handler."),
654 _(
"The current OS ABI is \"auto\" "
655 "(currently \"%s\").\n"),
674 _(
"_initialize_gdb_osabi: gdb_osabi_names[] is inconsistent"));
678 bfd_target_elf_flavour,
684 _(
"Set OS ABI of target."),
685 _(
"Show OS ABI of target."),
static enum gdb_osabi generic_elf_osabi_sniffer(bfd *abfd)
void gdbarch_init_osabi(struct gdbarch_info info, struct gdbarch *gdbarch)
void 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_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
void warning(const char *fmt,...)
static enum gdb_osabi user_selected_osabi
static void set_osabi(char *args, int from_tty, struct cmd_list_element *c)
static const char * set_osabi_string
void internal_error(const char *file, int line, const char *fmt,...)
int gdbarch_update_p(struct gdbarch_info info)
const char * osabi_triplet_regexp(enum gdb_osabi osabi)
void gdbarch_register_osabi_sniffer(enum bfd_architecture arch, enum bfd_flavour flavour, enum gdb_osabi(*sniffer_fn)(bfd *))
void generic_elf_osabi_sniff_abi_tag_sections(bfd *abfd, asection *sect, void *obj)
const struct bfd_arch_info * bfd_arch_info
enum gdb_osabi(* sniffer)(bfd *)
enum gdb_osabi gdbarch_osabi(struct gdbarch *gdbarch)
initialize_file_ftype _initialize_gdb_osabi
enum gdb_osabi osabi_from_tdesc_string(const char *name)
struct cmd_list_element * setlist
enum bfd_architecture arch
static void show_osabi(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
static struct gdb_osabi_handler * gdb_osabi_handler_list
void initialize_file_ftype(void)
void fprintf_filtered(struct ui_file *stream, const char *format,...)
struct cmd_list_element * showlist
static struct gdb_osabi_sniffer * gdb_osabi_sniffer_list
struct gdbarch * get_current_arch(void)
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
#define GDB_OSABI_DEFAULT
void(* init_osabi)(struct gdbarch_info, struct gdbarch *)
struct gdb_osabi_handler * next
struct gdb_osabi_sniffer * next
void gdbarch_info_init(struct gdbarch_info *info)
static const char * gdb_osabi_available_names[GDB_OSABI_INVALID+3]
const char * gdbarch_osabi_name(enum gdb_osabi osabi)
enum gdb_osabi gdbarch_lookup_osabi(bfd *abfd)
static enum @123 user_osabi_state
void gdbarch_register_osabi(enum bfd_architecture arch, unsigned long machine, enum gdb_osabi osabi, void(*init_osabi)(struct gdbarch_info, struct gdbarch *))
static int can_run_code_for(const struct bfd_arch_info *a, const struct bfd_arch_info *b)