+static void
+nto_sniff_abi_note_section (bfd *abfd, asection *sect, void *obj)
+{
+ const char *sectname;
+ unsigned int sectsize;
+ /* Buffer holding the section contents. */
+ char *note;
+ unsigned int namelen;
+ const char *name;
+ const unsigned sizeof_Elf_Nhdr = 12;
+
+ sectname = bfd_section_name (sect);
+ sectsize = bfd_section_size (sect);
+
+ if (sectsize > 128)
+ sectsize = 128;
+
+ if (sectname != NULL && strstr (sectname, QNX_INFO_SECT_NAME) != NULL)
+ *(enum gdb_osabi *) obj = GDB_OSABI_QNXNTO;
+ else if (sectname != NULL && strstr (sectname, "note") != NULL
+ && sectsize > sizeof_Elf_Nhdr)
+ {
+ note = XNEWVEC (char, sectsize);
+ bfd_get_section_contents (abfd, sect, note, 0, sectsize);
+ namelen = (unsigned int) bfd_h_get_32 (abfd, note);
+ name = note + sizeof_Elf_Nhdr;
+ if (sectsize >= namelen + sizeof_Elf_Nhdr
+ && namelen == sizeof (QNX_NOTE_NAME)
+ && 0 == strcmp (name, QNX_NOTE_NAME))
+ *(enum gdb_osabi *) obj = GDB_OSABI_QNXNTO;
+
+ XDELETEVEC (note);
+ }
+}
+