示例#1
0
void	file_footer( FILE * h, char * nptr)
{
	char	buffer[1024];
	if ( C.genrest )
		sprintf(buffer,"occi%s",nptr);
	else	strcpy(buffer,nptr);
	fprintf(h,"\n#endif\t/* ");
	file_symbol( h, buffer );
	fprintf(h," */\n");
	return;
}
示例#2
0
void	file_header( FILE * h, char * nptr, char * iptr, const char *filter_name)
{
	char	buffer[1024];
	if ( C.genrest )
		sprintf(buffer,"occi%s",nptr);
	else	strcpy(buffer,nptr);
	if ( C.license ) { prepend_license( h, C.license ); }
	fprintf(h,"/* STRUKT WARNING : this file has been generated and should not be modified by hand */\n");
	fprintf(h,"#ifndef ");
	file_symbol( h, buffer );
	fprintf(h,"\n");
	fprintf(h,"#define ");
	file_symbol( h, buffer );
	fprintf(h,"\n");
	if ( C.genxml )
	{
		fprintf(h,"\n#include %c%s%c\n",0x0022,"element.h",0x0022);
	}
	fprintf(h,"\n#include %c%s%c\n",0x0022,iptr,0x0022);
	fprintf(h,"#include %c%s%c\n",0x0022, filter_name, 0x0022);
	return;
}
示例#3
0
/* ripped off from objdump.c, line 469 */
int compare_symbols(const void *ap, const void *bp)
{
   const asymbol *a = * (const asymbol **) ap;
  const asymbol *b = * (const asymbol **) bp;
  const char *an;
  const char *bn;
  size_t anl;
  size_t bnl;
  bfd_boolean af;
  bfd_boolean bf;
  flagword aflags;
  flagword bflags;

  if (bfd_asymbol_value (a) > bfd_asymbol_value (b))
    return 1;
  else if (bfd_asymbol_value (a) < bfd_asymbol_value (b))
    return -1;

  if (a->section > b->section)
    return 1;
  else if (a->section < b->section)
    return -1;


  an = bfd_asymbol_name (a);
  bn = bfd_asymbol_name (b);
  anl = strlen (an);
  bnl = strlen (bn);

  /* The symbols gnu_compiled and gcc2_compiled convey no real
     information, so put them after other symbols with the same value.  */
  af = (strstr (an, "gnu_compiled") != NULL
	|| strstr (an, "gcc2_compiled") != NULL);
  bf = (strstr (bn, "gnu_compiled") != NULL
	|| strstr (bn, "gcc2_compiled") != NULL);

  if (af && ! bf)
    return 1;
  if (! af && bf)
    return -1;

  /* We use a heuristic for the file name, to try to sort it after
     more useful symbols.  It may not work on non Unix systems, but it
     doesn't really matter; the only difference is precisely which
     symbol names get printed.  */

#define file_symbol(s, sn, snl)			\
  (((s)->flags & BSF_FILE) != 0			\
   || ((sn)[(snl) - 2] == '.'			\
       && ((sn)[(snl) - 1] == 'o'		\
	   || (sn)[(snl) - 1] == 'a')))

  af = file_symbol (a, an, anl);
  bf = file_symbol (b, bn, bnl);

  if (af && ! bf)
    return 1;
  if (! af && bf)
    return -1;


  aflags = a->flags;
  bflags = b->flags;

  if ((aflags & BSF_DEBUGGING) != (bflags & BSF_DEBUGGING))
    {
      if ((aflags & BSF_DEBUGGING) != 0)
	return 1;
      else
	return -1;
    }
  if ((aflags & BSF_FUNCTION) != (bflags & BSF_FUNCTION))
    {
      if ((aflags & BSF_FUNCTION) != 0)
	return -1;
      else
	return 1;
    }
  if ((aflags & BSF_LOCAL) != (bflags & BSF_LOCAL))
    {
      if ((aflags & BSF_LOCAL) != 0)
	return 1;
      else
	return -1;
    }
  if ((aflags & BSF_GLOBAL) != (bflags & BSF_GLOBAL))
    {
      if ((aflags & BSF_GLOBAL) != 0)
	return -1;
      else
	return 1;
    }

  /* Symbols that start with '.' might be section names, so sort them
     after symbols that don't start with '.'.  */
  if (an[0] == '.' && bn[0] != '.')
    return 1;
  if (an[0] != '.' && bn[0] == '.')
    return -1;

  /* Finally, if we can't distinguish them in any other way, try to
     get consistent results by sorting the symbols by name.  */
  return strcmp (an, bn);
}