~ubuntu-branches/ubuntu/hoary/binutils/hoary

« back to all changes in this revision

Viewing changes to binutils/dlltool.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2005-03-18 13:07:52 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20050318130752-j4i37zgqclj53b94
Tags: 2.15-5ubuntu2
debian/rules: Call pkgstriptranslations if present (the package does not
use debhelper, thus it does not happen automatically).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* dlltool.c -- tool to generate stuff for PE style DLLs
2
 
   Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
 
2
   Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
3
3
   Free Software Foundation, Inc.
4
4
 
5
5
   This file is part of GNU Binutils.
49
49
 
50
50
   EXPORTS  ( (  ( <name1> [ = <name2> ] )
51
51
               | ( <name1> = <module-name> . <external-name>))
52
 
            [ @ <integer> ] [ NONAME ] [CONSTANT] [DATA] ) *
 
52
            [ @ <integer> ] [ NONAME ] [CONSTANT] [DATA] [PRIVATE] ) *
53
53
   Declares name1 as an exported symbol from the
54
54
   DLL, with optional ordinal number <integer>.
55
55
   Or declares name1 as an alias (forward) of the function <external-name>
643
643
    const char *internal_name;
644
644
    int ordinal;
645
645
    int constant;
646
 
    int noname;
 
646
    int noname;         /* Don't put name in image file.  */
 
647
    int private;        /* Don't put reference in import lib.  */
647
648
    int data;
648
649
    int hint;
649
650
    int forward;        /* Number of forward label, 0 means no forward.  */
889
890
 
890
891
void
891
892
def_exports (const char *name, const char *internal_name, int ordinal,
892
 
             int noname, int constant, int data)
 
893
             int noname, int constant, int data, int private)
893
894
{
894
895
  struct export *p = (struct export *) xmalloc (sizeof (*p));
895
896
 
898
899
  p->ordinal = ordinal;
899
900
  p->constant = constant;
900
901
  p->noname = noname;
 
902
  p->private = private;
901
903
  p->data = data;
902
904
  p->next = d_exports;
903
905
  d_exports = p;
1246
1248
          /* FIXME: The 5th arg is for the `constant' field.
1247
1249
             What should it be?  Not that it matters since it's not
1248
1250
             currently useful.  */
1249
 
          def_exports (c, 0, -1, 0, 0, ! (flags & BSF_FUNCTION));
 
1251
          def_exports (c, 0, -1, 0, 0, ! (flags & BSF_FUNCTION), 0);
1250
1252
 
1251
1253
          if (add_stdcall_alias && strchr (c, '@'))
1252
1254
            {
1255
1257
              char *atsym = strchr (exported_name, '@');
1256
1258
              *atsym = '\0';
1257
1259
              /* Note: stdcall alias symbols can never be data.  */
1258
 
              def_exports (exported_name, xstrdup (c), -1, 0, 0, 0);
 
1260
              def_exports (exported_name, xstrdup (c), -1, 0, 0, 0, 0);
1259
1261
            }
1260
1262
        }
1261
1263
      else
1294
1296
        ++symbol_name;
1295
1297
 
1296
1298
      def_exports (xstrdup (symbol_name) , 0, -1, 0, 0,
1297
 
                   ! (sym->flags & BSF_FUNCTION));
 
1299
                   ! (sym->flags & BSF_FUNCTION), 0);
1298
1300
 
1299
1301
      if (add_stdcall_alias && strchr (symbol_name, '@'))
1300
1302
        {
1303
1305
          char *atsym = strchr (exported_name, '@');
1304
1306
          *atsym = '\0';
1305
1307
          /* Note: stdcall alias symbols can never be data.  */
1306
 
          def_exports (exported_name, xstrdup (symbol_name), -1, 0, 0, 0);
 
1308
          def_exports (exported_name, xstrdup (symbol_name), -1, 0, 0, 0, 0);
1307
1309
        }
1308
1310
    }
1309
1311
}
1518
1520
  fprintf (f, "\n");
1519
1521
  for (i = 0, exp = d_exports; exp; i++, exp = exp->next)
1520
1522
    {
1521
 
      fprintf (f, "%s  %d = %s %s @ %d %s%s%s\n",
 
1523
      fprintf (f, "%s  %d = %s %s @ %d %s%s%s%s\n",
1522
1524
               ASM_C,
1523
1525
               i,
1524
1526
               exp->name,
1525
1527
               exp->internal_name,
1526
1528
               exp->ordinal,
1527
1529
               exp->noname ? "NONAME " : "",
 
1530
               exp->private ? "PRIVATE " : "",
1528
1531
               exp->constant ? "CONSTANT" : "",
1529
1532
               exp->data ? "DATA" : "");
1530
1533
    }
1595
1598
 
1596
1599
      if (strcmp (exp->name, exp->internal_name) == 0)
1597
1600
        {
1598
 
 
1599
 
          fprintf (output_def, "\t%s%s%s @ %d%s%s\n",
 
1601
          fprintf (output_def, "\t%s%s%s @ %d%s%s%s\n",
1600
1602
                   quote,
1601
1603
                   exp->name,
1602
1604
                   quote,
1603
1605
                   exp->ordinal,
1604
1606
                   exp->noname ? " NONAME" : "",
 
1607
                   exp->private ? "PRIVATE " : "",
1605
1608
                   exp->data ? " DATA" : "");
1606
1609
        }
1607
1610
      else
1608
1611
        {
1609
 
          char *quote1 = strchr (exp->internal_name, '.') ? "\"" : "";
 
1612
          char * quote1 = strchr (exp->internal_name, '.') ? "\"" : "";
1610
1613
          /* char *alias =  */
1611
 
          fprintf (output_def, "\t%s%s%s = %s%s%s @ %d%s%s\n",
 
1614
          fprintf (output_def, "\t%s%s%s = %s%s%s @ %d%s%s%s\n",
1612
1615
                   quote,
1613
1616
                   exp->name,
1614
1617
                   quote,
1617
1620
                   quote1,
1618
1621
                   exp->ordinal,
1619
1622
                   exp->noname ? " NONAME" : "",
 
1623
                   exp->private ? "PRIVATE " : "",
1620
1624
                   exp->data ? " DATA" : "");
1621
1625
        }
1622
1626
    }
1841
1845
 
1842
1846
      fprintf(f,"%s Export Name Table\n", ASM_C);
1843
1847
      for (i = 0; (exp = d_exports_lexically[i]); i++)
1844
 
        if (!exp->noname || show_allnames)
1845
 
          {
 
1848
        {
 
1849
          if (!exp->noname || show_allnames)
1846
1850
            fprintf (f, "n%d:   %s      \"%s\"\n",
1847
1851
                     exp->ordinal, ASM_TEXT, xlate (exp->name));
1848
 
            if (exp->forward != 0)
1849
 
              fprintf (f, "f%d: %s      \"%s\"\n",
1850
 
                       exp->forward, ASM_TEXT, exp->internal_name);
1851
 
          }
 
1852
          if (exp->forward != 0)
 
1853
            fprintf (f, "f%d:   %s      \"%s\"\n",
 
1854
                     exp->forward, ASM_TEXT, exp->internal_name);
 
1855
        }
1852
1856
 
1853
1857
      if (a_list)
1854
1858
        {
2794
2798
 
2795
2799
  for (i = 0; (exp = d_exports_lexically[i]); i++)
2796
2800
    {
2797
 
      bfd *n = make_one_lib_file (exp, i);
 
2801
      bfd *n;
 
2802
      /* Don't add PRIVATE entries to import lib.  */
 
2803
      if (exp->private)
 
2804
        continue;
 
2805
      n = make_one_lib_file (exp, i);
2798
2806
      n->next = head;
2799
2807
      head = n;
2800
2808
    }
2831
2839
      char *name;
2832
2840
 
2833
2841
      name = (char *) alloca (strlen (TMP_STUB) + 10);
2834
 
      for (i = 0, exp = d_exports; exp; i++, exp = exp->next)
 
2842
      for (i = 0; (exp = d_exports_lexically[i]); i++)
2835
2843
        {
 
2844
          /* Don't delete non-existent stubs for PRIVATE entries.  */
 
2845
          if (exp->private)
 
2846
            continue;
2836
2847
          sprintf (name, "%s%05d.o", TMP_STUB, i);
2837
2848
          if (unlink (name) < 0)
2838
2849
            /* xgettext:c-format */
2843
2854
  inform (_("Created lib file"));
2844
2855
}
2845
2856
 
2846
 
/**********************************************************************/
2847
 
 
2848
2857
/* Run through the information gathered from the .o files and the
2849
2858
   .def file and work out the best stuff.  */
 
2859
 
2850
2860
static int
2851
2861
pfunc (const void *a, const void *b)
2852
2862
{
2890
2900
}
2891
2901
 
2892
2902
static void
2893
 
dtab (export_type **ptr
2894
 
#ifndef SACDEBUG
2895
 
ATTRIBUTE_UNUSED
2896
 
#endif
2897
 
      )
 
2903
dtab (export_type **ptr ATTRIBUTE_UNUSED)
2898
2904
{
2899
2905
#ifdef SACDEBUG
2900
2906
  int i;
2922
2928
 
2923
2929
  while (more)
2924
2930
    {
2925
 
 
2926
2931
      more = 0;
2927
2932
      /* Remove duplicates.  */
2928
2933
      qsort (d_export_vec, d_nfuncs, sizeof (export_type *), nfunc);
2933
2938
          if (strcmp (d_export_vec[i]->name,
2934
2939
                      d_export_vec[i + 1]->name) == 0)
2935
2940
            {
2936
 
 
2937
2941
              export_type *a = d_export_vec[i];
2938
2942
              export_type *b = d_export_vec[i + 1];
2939
2943
 
2963
2967
        }
2964
2968
    }
2965
2969
 
2966
 
 
2967
2970
  /* Count the names.  */
2968
2971
  for (i = 0; i < d_nfuncs; i++)
2969
 
    {
2970
 
      if (!d_export_vec[i]->noname)
2971
 
        d_named_nfuncs++;
2972
 
    }
 
2972
    if (!d_export_vec[i]->noname)
 
2973
      d_named_nfuncs++;
2973
2974
}
2974
2975
 
2975
2976
static void
3008
3009
    {
3009
3010
      if (d_export_vec[i]->ordinal == -1)
3010
3011
        {
3011
 
          register int j;
 
3012
          int j;
3012
3013
 
3013
3014
          /* First try within or after any user supplied range.  */
3014
3015
          for (j = lowest; j < size; j++)
3063
3064
 
3064
3065
  int i;
3065
3066
  int hint = 0;
3066
 
  export_type **d_export_vec
3067
 
  = (export_type **) xmalloc (sizeof (export_type *) * d_nfuncs);
 
3067
  export_type **d_export_vec = xmalloc (sizeof (export_type *) * d_nfuncs);
3068
3068
 
3069
3069
  inform (_("Processing definitions"));
3070
3070
 
3101
3101
  inform (_("Processed definitions"));
3102
3102
}
3103
3103
 
3104
 
/**********************************************************************/
3105
 
 
3106
3104
static void
3107
3105
usage (FILE *file, int status)
3108
3106
{
3131
3129
  fprintf (file, _("   -f --as-flags <flags>     Pass <flags> to the assembler.\n"));
3132
3130
  fprintf (file, _("   -C --compat-implib        Create backward compatible import library.\n"));
3133
3131
  fprintf (file, _("   -n --no-delete            Keep temp files (repeat for extra preservation).\n"));
 
3132
  fprintf (file, _("   -t --temp-prefix <prefix> Use <prefix> to construct temp file names.\n"));
3134
3133
  fprintf (file, _("   -v --verbose              Be verbose.\n"));
3135
3134
  fprintf (file, _("   -V --version              Display the program version.\n"));
3136
3135
  fprintf (file, _("   -h --help                 Display this information.\n"));
3238
3237
          as_flags = optarg;
3239
3238
          break;
3240
3239
 
3241
 
          /* ignored for compatibility */
 
3240
          /* Ignored for compatibility.  */
3242
3241
        case 'u':
3243
3242
          break;
3244
3243
        case 'a':