svn commit: r261787 - head/contrib/gdb/gdb

John-Mark Gurney jmg at FreeBSD.org
Wed Feb 12 02:03:38 UTC 2014


Author: jmg
Date: Wed Feb 12 02:03:37 2014
New Revision: 261787
URL: http://svnweb.freebsd.org/changeset/base/261787

Log:
  recognize the FreeBSD ARCH tag that is put on binaries like on armeb
  EABI binaries...
  
  MFC after:	1 week

Modified:
  head/contrib/gdb/gdb/osabi.c

Modified: head/contrib/gdb/gdb/osabi.c
==============================================================================
--- head/contrib/gdb/gdb/osabi.c	Wed Feb 12 00:53:38 2014	(r261786)
+++ head/contrib/gdb/gdb/osabi.c	Wed Feb 12 02:03:37 2014	(r261787)
@@ -365,11 +365,11 @@ check_note (bfd *abfd, asection *sect, c
 	    const char *name, unsigned long descsz, unsigned long type)
 {
   unsigned long notesz;
+  unsigned long rdescsz;
 
   /* Calculate the size of this note.  */
-  notesz = strlen (name) + 1;
-  notesz = ((notesz + 3) & ~3);
-  notesz += descsz;
+  notesz = 4 * 3;	/* namelen, optlen, type */
+  notesz += strlen (name) + 1;
   notesz = ((notesz + 3) & ~3);
 
   /* If this assertion triggers, increase MAX_NOTESZ.  */
@@ -385,7 +385,15 @@ check_note (bfd *abfd, asection *sect, c
     return 0;
 
   /* Check the descriptor size.  */
-  if (bfd_h_get_32 (abfd, note + 4) != descsz)
+  rdescsz = bfd_h_get_32 (abfd, note + 4);
+  if (descsz != (unsigned long)-1 && rdescsz != descsz)
+    return 0;
+
+  notesz += rdescsz;
+  notesz = ((notesz + 3) & ~3);
+
+  /* Check whether SECT is big enough to comtain the complete note.  */
+  if (notesz > bfd_section_size (abfd, sect))
     return 0;
 
   /* Check the note type.  */
@@ -480,6 +488,12 @@ generic_elf_osabi_sniff_abi_tag_sections
 	  *osabi = GDB_OSABI_FREEBSD_ELF;
 	  return;
 	}
+      if (check_note (abfd, sect, note, "FreeBSD", -1, NT_FREEBSD_ARCH_TAG))
+	{
+	  /* There is no need to check the version yet.  */
+	  *osabi = GDB_OSABI_FREEBSD_ELF;
+	  return;
+	}
 
       return;
     }


More information about the svn-src-all mailing list