29 #ifndef GDB_OSABI_DEFAULT 30 #define GDB_OSABI_DEFAULT GDB_OSABI_UNKNOWN 66 {
"GNU/Linux",
"linux(-gnu)?" },
70 {
"WindowsCE", NULL },
72 {
"QNX-Neutrino", NULL },
79 {
"LynxOS178", NULL },
149 const struct bfd_arch_info *arch_info = bfd_lookup_arch (arch, machine);
150 const char **name_ptr;
157 _(
"gdbarch_register_osabi: An attempt to register a handler for " 158 "OS ABI \"%s\" for architecture %s was made. The handler will " 159 "not be registered"),
161 bfd_printable_arch_mach (arch, machine));
168 handler_p = &(*handler_p)->
next)
170 if ((*handler_p)->arch_info == arch_info
171 && (*handler_p)->osabi == osabi)
175 _(
"gdbarch_register_osabi: A handler for OS ABI \"%s\" " 176 "has already been registered for architecture %s"),
178 arch_info->printable_name);
180 (*handler_p)->init_osabi = init_osabi;
186 (*handler_p)->next = NULL;
187 (*handler_p)->arch_info = arch_info;
188 (*handler_p)->osabi = osabi;
189 (*handler_p)->init_osabi = init_osabi;
258 if ((
sniffer->arch == bfd_arch_unknown
259 ||
sniffer->arch == bfd_get_arch (abfd))
260 &&
sniffer->flavour == bfd_get_flavour (abfd))
262 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))
286 _(
"gdbarch_lookup_osabi: multiple %sspecific OS ABI " 287 "match for architecture %s flavour %d: first " 288 "match \"%s\", second match \"%s\""),
289 match_specific ?
"" :
"non-",
290 bfd_printable_arch_mach (bfd_get_arch (abfd), 0),
291 (
int) bfd_get_flavour (abfd),
295 else if (
sniffer->arch != bfd_arch_unknown)
304 if (
sniffer->arch != bfd_arch_unknown)
329 return (a == b || a->compatible (a, b) == a);
346 handler = handler->
next)
379 (
"A handler for the OS ABI \"%s\" is not built into this configuration\n" 380 "of GDB. Attempting to continue with the default %s settings.\n",
386 #define MAX_NOTESZ 128 393 check_note (bfd *abfd, asection *sect,
char *note,
unsigned int *sectsize,
394 const char *
name,
unsigned long descsz,
unsigned long type)
396 unsigned long notesz;
400 if (!bfd_get_section_contents (abfd, sect, note, 0, *sectsize))
406 notesz = strlen (
name) + 1;
407 notesz = ((notesz + 3) & ~3);
409 notesz = ((notesz + 3) & ~3);
415 if (notesz > bfd_section_size (abfd, sect))
419 if (bfd_h_get_32 (abfd, note) != (strlen (
name) + 1)
420 || strcmp (note + 12,
name) != 0)
424 if (bfd_h_get_32 (abfd, note + 4) != descsz)
428 if (bfd_h_get_32 (abfd, note + 8) !=
type)
441 unsigned int sectsize;
444 name = bfd_get_section_name (abfd, sect);
445 sectsize = bfd_section_size (abfd, sect);
456 note = (
char *) alloca (sectsize);
459 if (strcmp (
name,
".note.ABI-tag") == 0)
462 if (
check_note (abfd, sect, note, §size,
"GNU", 16, NT_GNU_ABI_TAG))
464 unsigned int abi_tag = bfd_h_get_32 (abfd, note + 16);
468 case GNU_ABI_TAG_LINUX:
472 case GNU_ABI_TAG_HURD:
476 case GNU_ABI_TAG_SOLARIS:
480 case GNU_ABI_TAG_FREEBSD:
484 case GNU_ABI_TAG_NETBSD:
489 warning (
_(
"GNU ABI tag value %u unrecognized."), abi_tag);
496 if (
check_note (abfd, sect, note, §size,
"FreeBSD", 4,
508 if (strcmp (
name,
".note.netbsd.ident") == 0
509 &&
check_note (abfd, sect, note, §size,
"NetBSD", 4, NT_NETBSD_IDENT))
517 if (strcmp (
name,
".note.openbsd.ident") == 0
518 &&
check_note (abfd, sect, note, §size,
"OpenBSD", 4,
527 if (strcmp (
name,
".note.netbsdcore.procinfo") == 0)
537 unsigned int elfosabi;
540 elfosabi = elf_elfheader (abfd)->e_ident[EI_OSABI];
559 bfd_map_over_sections (abfd,
564 case ELFOSABI_FREEBSD:
568 case ELFOSABI_NETBSD:
572 case ELFOSABI_SOLARIS:
576 case ELFOSABI_OPENVMS:
586 if (memcmp (&elf_elfheader (abfd)->e_ident[8],
587 "FreeBSD",
sizeof (
"FreeBSD")) == 0)
628 _(
"Invalid OS ABI \"%s\" passed to command handler."),
645 _(
"The current OS ABI is \"auto\" " 646 "(currently \"%s\").\n"),
663 _(
"_initialize_gdb_osabi: gdb_osabi_names[] is inconsistent"));
667 bfd_target_elf_flavour,
673 _(
"Set OS ABI of target."),
674 _(
"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 warning(const char *fmt,...)
static enum gdb_osabi user_selected_osabi
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 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_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
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)
enum gdb_osabi osabi_from_tdesc_string(const char *name)
void _initialize_gdb_osabi(void)
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 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
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 *))
#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)
static const struct osabi_names gdb_osabi_names[]
enum gdb_osabi gdbarch_lookup_osabi(bfd *abfd)
static int can_run_code_for(const struct bfd_arch_info *a, const struct bfd_arch_info *b)
static enum @137 user_osabi_state