if (rawptr == NULL) { bfd_set_error (bfd_error_no_memory);
if (rawptr == NULL)
const bfd_target *trad_unix_core_file_p PARAMS ((bfd *abfd));char *		trad_unix_core_file_failing_command PARAMS ((bfd *abfd));int		trad_unix_core_file_failing_signal PARAMS ((bfd *abfd));boolean		trad_unix_core_file_matches_executable_p			 PARAMS ((bfd *core_bfd, bfd *exec_bfd));/* Handle 4.2-style (and perhaps also sysV-style) core dump file.  *//* ARGSUSED */const bfd_target *trad_unix_core_file_p (abfd)     bfd *abfd;{  int val;  struct user u;  struct trad_core_struct *rawptr;#ifdef TRAD_CORE_USER_OFFSET  /* If defined, this macro is the file position of the user struct.  */  if (bfd_seek (abfd, TRAD_CORE_USER_OFFSET, SEEK_SET) != 0)    return 0;#endif      val = bfd_read ((void *)&u, 1, sizeof u, abfd);  if (val != sizeof u)    {      /* Too small to be a core file */      bfd_set_error (bfd_error_wrong_format);      return 0;    }  /* Sanity check perhaps??? */  if (u.u_dsize > 0x1000000)	/* Remember, it's in pages... */    {      bfd_set_error (bfd_error_wrong_format);      return 0;    }  if (u.u_ssize > 0x1000000)    {      bfd_set_error (bfd_error_wrong_format);      return 0;    }  /* Check that the size claimed is no greater than the file size.  */  {    FILE *stream = bfd_cache_lookup (abfd);    struct stat statbuf;    if (stream == NULL)      return 0;    if (fstat (fileno (stream), &statbuf) < 0)      {	bfd_set_error (bfd_error_system_call);	return 0;      }    if (NBPG * (UPAGES + u.u_dsize#ifdef TRAD_CORE_DSIZE_INCLUDES_TSIZE		- u.u_tsize#endif		+ u.u_ssize) > statbuf.st_size)      {	bfd_set_error (bfd_error_file_truncated);	return 0;      }#ifndef TRAD_CORE_ALLOW_ANY_EXTRA_SIZE    if (NBPG * (UPAGES + u.u_dsize + u.u_ssize)#ifdef TRAD_CORE_EXTRA_SIZE_ALLOWED	/* Some systems write the file too big.  */	+ TRAD_CORE_EXTRA_SIZE_ALLOWED#endif	< statbuf.st_size)      {	/* The file is too big.  Maybe it's not a core file	   or we otherwise have bad values for u_dsize and u_ssize).  */	bfd_set_error (bfd_error_wrong_format);	return 0;      }#endif  }  /* OK, we believe you.  You're a core file (sure, sure).  */  /* Allocate both the upage and the struct core_data at once, so     a single free() will free them both.  */  rawptr = (struct trad_core_struct *)		bfd_zmalloc (sizeof (struct trad_core_struct));  if (rawptr == NULL) {    bfd_set_error (bfd_error_no_memory);    return 0;  }    abfd->tdata.trad_core_data = rawptr;  rawptr->u = u; /*Copy the uarea into the tdata part of the bfd */  /* Create the sections.  This is raunchy, but bfd_close wants to free     them separately.  */  core_stacksec(abfd) = (asection *) bfd_zmalloc (sizeof (asection));  if (core_stacksec (abfd) == NULL) {  loser:    bfd_set_error (bfd_error_no_memory);    free ((void *)rawptr);    return 0;  }  core_datasec (abfd) = (asection *) bfd_zmalloc (sizeof (asection));  if (core_datasec (abfd) == NULL) {  loser1:    free ((void *)core_stacksec (abfd));    goto loser;  }  core_regsec (abfd) = (asection *) bfd_zmalloc (sizeof (asection));  if (core_regsec (abfd) == NULL) {    free ((void *)core_datasec (abfd));    goto loser1;  }  core_stacksec (abfd)->name = ".stack";  core_datasec (abfd)->name = ".data";  core_regsec (abfd)->name = ".reg";  core_stacksec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;  core_datasec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;  core_regsec (abfd)->flags = SEC_HAS_CONTENTS;  core_datasec (abfd)->_raw_size =  NBPG * u.u_dsize#ifdef TRAD_CORE_DSIZE_INCLUDES_TSIZE    - NBPG * u.u_tsize#endif      ;  core_stacksec (abfd)->_raw_size = NBPG * u.u_ssize;  core_regsec (abfd)->_raw_size = NBPG * UPAGES; /* Larger than sizeof struct u */  /* What a hack... we'd like to steal it from the exec file,     since the upage does not seem to provide it.  FIXME.  */#ifdef HOST_DATA_START_ADDR  core_datasec (abfd)->vma = HOST_DATA_START_ADDR;#else  core_datasec (abfd)->vma = HOST_TEXT_START_ADDR + (NBPG * u.u_tsize);#endif#ifdef HOST_STACK_START_ADDR  core_stacksec (abfd)->vma = HOST_STACK_START_ADDR;#else  core_stacksec (abfd)->vma = HOST_STACK_END_ADDR - (NBPG * u.u_ssize);#endif  /* This is tricky.  As the "register section", we give them the entire     upage and stack.  u.u_ar0 points to where "register 0" is stored.     There are two tricks with this, though.  One is that the rest of the     registers might be at positive or negative (or both) displacements     from *u_ar0.  The other is that u_ar0 is sometimes an absolute address     in kernel memory, and on other systems it is an offset from the beginning     of the `struct user'.          As a practical matter, we don't know where the registers actually are,     so we have to pass the whole area to GDB.  We encode the value of u_ar0     by setting the .regs section up so that its virtual memory address     0 is at the place pointed to by u_ar0 (by setting the vma of the start     of the section to -u_ar0).  GDB uses this info to locate the regs,     using minor trickery to get around the offset-or-absolute-addr problem. */  core_regsec (abfd)->vma = 0 - (bfd_vma) u.u_ar0;  core_datasec (abfd)->filepos = NBPG * UPAGES;  core_stacksec (abfd)->filepos = (NBPG * UPAGES) + NBPG * u.u_dsize#ifdef TRAD_CORE_DSIZE_INCLUDES_TSIZE    - NBPG * u.u_tsize#endif      ;  core_regsec (abfd)->filepos = 0; /* Register segment is the upage */  /* Align to word at least */  core_stacksec (abfd)->alignment_power = 2;  core_datasec (abfd)->alignment_power = 2;  core_regsec (abfd)->alignment_power = 2;  abfd->sections = core_stacksec (abfd);  core_stacksec (abfd)->next = core_datasec (abfd);  core_datasec (abfd)->next = core_regsec (abfd);  abfd->section_count = 3;  return abfd->xvec;}