if (TC_COUNT_RELOC (fix_ptr))
if (fix_ptr->fx_done == 0 && TC_COUNT_RELOC (fix_ptr))
do_relocs_for (abfd, h, file_cursor)     bfd * abfd;     object_headers * h;     unsigned long *file_cursor;{  unsigned int nrelocs;  unsigned int idx;  unsigned long reloc_start = *file_cursor;  for (idx = SEG_E0; idx < SEG_E9; idx++)    {      if (segment_info[idx].scnhdr.s_name[0])	{	  struct external_reloc *ext_ptr;	  struct external_reloc *external_reloc_vec;	  unsigned int external_reloc_size;	  unsigned int base = segment_info[idx].scnhdr.s_paddr;	  fixS *fix_ptr = segment_info[idx].fix_root;	  nrelocs = count_entries_in_chain (idx);	  if (nrelocs)	    /* Bypass this stuff if no relocs.  This also incidentally	       avoids a SCO bug, where free(malloc(0)) tends to crash.  */	    {	      external_reloc_size = nrelocs * RELSZ;	      external_reloc_vec =		(struct external_reloc *) malloc (external_reloc_size);	      ext_ptr = external_reloc_vec;	      /* Fill in the internal coff style reloc struct from the		 internal fix list.  */	      while (fix_ptr)		{		  struct internal_reloc intr;		  /* Only output some of the relocations */		  if (TC_COUNT_RELOC (fix_ptr))		    {#ifdef TC_RELOC_MANGLE		      TC_RELOC_MANGLE (&segment_info[idx], fix_ptr, &intr,				       base);#else		      symbolS *dot;		      symbolS *symbol_ptr = fix_ptr->fx_addsy;		      intr.r_type = TC_COFF_FIX2RTYPE (fix_ptr);		      intr.r_vaddr =			base + fix_ptr->fx_frag->fr_address + fix_ptr->fx_where;#ifdef TC_KEEP_FX_OFFSET		      intr.r_offset = fix_ptr->fx_offset;#else		      intr.r_offset = 0;#endif		      /* Turn the segment of the symbol into an offset.  */		      if (symbol_ptr)			{			  dot = segment_info[S_GET_SEGMENT (symbol_ptr)].dot;			  if (dot)			    {			      intr.r_symndx = dot->sy_number;			    }			  else			    {			      intr.r_symndx = symbol_ptr->sy_number;			    }			}		      else			{			  intr.r_symndx = -1;			}#endif		      (void) bfd_coff_swap_reloc_out (abfd, &intr, ext_ptr);		      ext_ptr++;#if defined(TC_A29K)		      /* The 29k has a special kludge for the high 16 bit			 reloc.  Two relocations are emited, R_IHIHALF,			 and R_IHCONST. The second one doesn't contain a			 symbol, but uses the value for offset.  */		      if (intr.r_type == R_IHIHALF)			{			  /* now emit the second bit */			  intr.r_type = R_IHCONST;			  intr.r_symndx = fix_ptr->fx_addnumber;			  (void) bfd_coff_swap_reloc_out (abfd, &intr, ext_ptr);			  ext_ptr++;			}#endif		    }		  fix_ptr = fix_ptr->fx_next;		}	      /* Write out the reloc table */	      bfd_write ((PTR) external_reloc_vec, 1, external_reloc_size,			 abfd);	      free (external_reloc_vec);	      /* Fill in section header info.  */	      segment_info[idx].scnhdr.s_relptr = *file_cursor;	      *file_cursor += external_reloc_size;	      segment_info[idx].scnhdr.s_nreloc = nrelocs;	    }	  else	    {	      /* No relocs */	      segment_info[idx].scnhdr.s_relptr = 0;	    }	}    }  /* Set relocation_size field in file headers */  H_SET_RELOCATION_SIZE (h, *file_cursor - reloc_start, 0);}