%token SECTIONS EXPORTS IMPORTS VERSIONK BASE CONSTANT
%token READ WRITE EXECUTE SHARED NONSHARED NONAME PRIVATE
%token SINGLE MULTIPLE INITINSTANCE INITGLOBAL TERMINSTANCE TERMGLOBAL
+%token EQUAL
%token <id> ID
%token <number> NUMBER
%type <number> opt_base opt_ordinal opt_NONAME opt_CONSTANT opt_DATA opt_PRIVATE
%type <number> attr attr_list opt_number
-%type <id> opt_name opt_equal_name
+%type <id> opt_name opt_equal_name opt_import_name
%%
expline:
ID opt_equal_name opt_ordinal opt_NONAME opt_CONSTANT opt_DATA opt_PRIVATE
- { def_exports ($1, $2, $3, $4, $5, $6, $7);}
+ opt_import_name
+ { def_exports ($1, $2, $3, $4, $5, $6, $7, $8);}
;
implist:
implist impline
;
impline:
- ID '=' ID '.' ID '.' ID { def_import ($1,$3,$5,$7, 0); }
- | ID '=' ID '.' ID '.' NUMBER { def_import ($1,$3,$5, 0,$7); }
- | ID '=' ID '.' ID { def_import ($1,$3, 0,$5, 0); }
- | ID '=' ID '.' NUMBER { def_import ($1,$3, 0, 0,$5); }
- | ID '.' ID '.' ID { def_import ( 0,$1,$3,$5, 0); }
- | ID '.' ID '.' NUMBER { def_import ( 0,$1,$3, 0,$5); }
- | ID '.' ID { def_import ( 0,$1, 0,$3, 0); }
- | ID '.' NUMBER { def_import ( 0,$1, 0, 0,$3); }
+ ID '=' ID '.' ID '.' ID opt_import_name
+ { def_import ($1,$3,$5,$7, 0, $8); }
+ | ID '=' ID '.' ID '.' NUMBER opt_import_name
+ { def_import ($1,$3,$5, 0,$7, $8); }
+ | ID '=' ID '.' ID opt_import_name
+ { def_import ($1,$3, 0,$5, 0, $6); }
+ | ID '=' ID '.' NUMBER opt_import_name
+ { def_import ($1,$3, 0, 0,$5, $6); }
+ | ID '.' ID '.' ID opt_import_name
+ { def_import ( 0,$1,$3,$5, 0, $6); }
+ | ID '.' ID '.' NUMBER opt_import_name
+ { def_import ( 0,$1,$3, 0,$5, $6); }
+ | ID '.' ID opt_import_name
+ { def_import ( 0,$1, 0,$3, 0, $4); }
+ | ID '.' NUMBER opt_import_name
+ { def_import ( 0,$1, 0, 0,$3, $4); }
;
seclist:
| { $$=-1;}
;
+opt_import_name:
+ EQUAL ID { $$ = $2; }
+ | { $$ = 0; }
+ ;
+
opt_equal_name:
'=' ID { $$ = $2; }
| '=' ID '.' ID
typedef struct ifunct
{
char * name; /* Name of function being imported. */
+ char * its_name; /* Optional import table symbol name. */
int ord; /* Two-byte ordinal value associated with function. */
struct ifunct *next;
} ifunctype;
const char *name;
const char *internal_name;
const char *import_name;
+ const char *its_name;
int ordinal;
int constant;
int noname; /* Don't put name in image file. */
static const char *asm_prefix (int, const char *);
static void process_def_file (const char *);
static void new_directive (char *);
-static void append_import (const char *, const char *, int);
+static void append_import (const char *, const char *, int, const char *);
static void run (const char *, char *);
static void scan_drectve_symbols (bfd *);
static void scan_filtered_symbols (bfd *, void *, long, unsigned int);
void
def_exports (const char *name, const char *internal_name, int ordinal,
- int noname, int constant, int data, int private)
+ int noname, int constant, int data, int private,
+ const char *its_name)
{
struct export *p = (struct export *) xmalloc (sizeof (*p));
p->name = name;
p->internal_name = internal_name ? internal_name : name;
+ p->its_name = its_name;
p->import_name = name;
p->ordinal = ordinal;
p->constant = constant;
import_list. It is used by def_import. */
static void
-append_import (const char *symbol_name, const char *dll_name, int func_ordinal)
+append_import (const char *symbol_name, const char *dll_name, int func_ordinal,
+ const char *its_name)
{
iheadtype **pq;
iheadtype *q;
q->functail = q->functail->next;
q->functail->ord = func_ordinal;
q->functail->name = xstrdup (symbol_name);
+ q->functail->its_name = (its_name ? xstrdup (its_name) : NULL);
q->functail->next = NULL;
q->nfuncs++;
return;
q->functail = q->funchead;
q->next = NULL;
q->functail->name = xstrdup (symbol_name);
+ q->functail->its_name = (its_name ? xstrdup (its_name) : NULL);
q->functail->ord = func_ordinal;
q->functail->next = NULL;
void
def_import (const char *app_name, const char *module, const char *dllext,
- const char *entry, int ord_val)
+ const char *entry, int ord_val, const char *its_name)
{
const char *application_name;
char *buf;
module = buf;
}
- append_import (application_name, module, ord_val);
+ append_import (application_name, module, ord_val, its_name);
}
void
/* FIXME: The 5th arg is for the `constant' field.
What should it be? Not that it matters since it's not
currently useful. */
- def_exports (c, 0, -1, 0, 0, ! (flags & BSF_FUNCTION), 0);
+ def_exports (c, 0, -1, 0, 0, ! (flags & BSF_FUNCTION), 0, NULL);
if (add_stdcall_alias && strchr (c, '@'))
{
char *atsym = strchr (exported_name, '@');
*atsym = '\0';
/* Note: stdcall alias symbols can never be data. */
- def_exports (exported_name, xstrdup (c), -1, 0, 0, 0, 0);
+ def_exports (exported_name, xstrdup (c), -1, 0, 0, 0, 0, NULL);
}
}
else
++symbol_name;
def_exports (xstrdup (symbol_name) , 0, -1, 0, 0,
- ! (sym->flags & BSF_FUNCTION), 0);
+ ! (sym->flags & BSF_FUNCTION), 0, NULL);
if (add_stdcall_alias && strchr (symbol_name, '@'))
{
char *atsym = strchr (exported_name, '@');
*atsym = '\0';
/* Note: stdcall alias symbols can never be data. */
- def_exports (exported_name, xstrdup (symbol_name), -1, 0, 0, 0, 0);
+ def_exports (exported_name, xstrdup (symbol_name), -1, 0, 0, 0, 0, NULL);
}
}
}
fprintf (f, "\n");
for (i = 0, exp = d_exports; exp; i++, exp = exp->next)
{
- fprintf (f, "%s %d = %s %s @ %d %s%s%s%s\n",
+ fprintf (f, "%s %d = %s %s @ %d %s%s%s%s%s%s\n",
ASM_C,
i,
exp->name,
exp->noname ? "NONAME " : "",
exp->private ? "PRIVATE " : "",
exp->constant ? "CONSTANT" : "",
- exp->data ? "DATA" : "");
+ exp->data ? "DATA" : "",
+ exp->its_name ? " ==" : "",
+ exp->its_name ? exp->its_name : "");
}
}
if (strcmp (exp->name, exp->internal_name) == 0)
{
- fprintf (output_def, "\t%s%s%s @ %d%s%s%s\n",
+ fprintf (output_def, "\t%s%s%s @ %d%s%s%s%s%s\n",
quote,
exp->name,
quote,
exp->ordinal,
exp->noname ? " NONAME" : "",
exp->private ? "PRIVATE " : "",
- exp->data ? " DATA" : "");
+ exp->data ? " DATA" : "",
+ exp->its_name ? " ==" : "",
+ exp->its_name ? exp->its_name : "");
}
else
{
char * quote1 = strchr (exp->internal_name, '.') ? "\"" : "";
/* char *alias = */
- fprintf (output_def, "\t%s%s%s = %s%s%s @ %d%s%s%s\n",
+ fprintf (output_def, "\t%s%s%s = %s%s%s @ %d%s%s%s%s%s\n",
quote,
exp->name,
quote,
exp->ordinal,
exp->noname ? " NONAME" : "",
exp->private ? "PRIVATE " : "",
- exp->data ? " DATA" : "");
+ exp->data ? " DATA" : "",
+ exp->its_name ? " ==" : "",
+ exp->its_name ? exp->its_name : "");
}
}
fprintf (filvar,"funcptr%d_%d:\n", headindex, funcindex);
fprintf (filvar,"\t%s\t%d\n", ASM_SHORT,
((funcptr->ord) & 0xFFFF));
- fprintf (filvar,"\t%s\t\"%s\"\n", ASM_TEXT, funcptr->name);
+ fprintf (filvar,"\t%s\t\"%s\"\n", ASM_TEXT,
+ (funcptr->its_name ? funcptr->its_name : funcptr->name));
fprintf (filvar,"\t%s\t0\n", ASM_BYTE);
funcindex++;
}
{
if (!exp->noname || show_allnames)
fprintf (f, "n%d: %s \"%s\"\n",
- exp->ordinal, ASM_TEXT, xlate (exp->name));
+ exp->ordinal, ASM_TEXT,
+ (exp->its_name ? exp->its_name : xlate (exp->name)));
if (exp->forward != 0)
fprintf (f, "f%d: %s \"%s\"\n",
exp->forward, ASM_TEXT, exp->internal_name);
why it did that, and it does not match what I see
in programs compiled with the MS tools. */
int idx = exp->hint;
- si->size = strlen (xlate (exp->import_name)) + 3;
+ if (exp->its_name)
+ si->size = strlen (exp->its_name) + 3;
+ else
+ si->size = strlen (xlate (exp->import_name)) + 3;
si->data = xmalloc (si->size);
si->data[0] = idx & 0xff;
si->data[1] = idx >> 8;
- strcpy ((char *) si->data + 2, xlate (exp->import_name));
+ if (exp->its_name)
+ strcpy ((char *) si->data + 2, exp->its_name);
+ else
+ strcpy ((char *) si->data + 2, xlate (exp->import_name));
}
break;
case IDATA7:
if (!no_idata5)
{
- fprintf (f, "\t.section\t.idata$5\n");\r
+ fprintf (f, "\t.section\t.idata$5\n");
/* NULL terminating list. */
#ifdef DLLTOOL_MX86_64
fprintf (f,"\t%s\t0\n\t%s\t0\n", ASM_LONG, ASM_LONG);
assert (i < PREFIX_ALIAS_BASE);
alias_exp.name = make_imp_label (ext_prefix_alias, exp->name);
alias_exp.internal_name = exp->internal_name;
+ alias_exp.its_name = exp->its_name;
alias_exp.import_name = exp->name;
alias_exp.ordinal = exp->ordinal;
alias_exp.constant = exp->constant;
export_type *bp = *(export_type **) b;
const char *an = ap->name;
const char *bn = bp->name;
-
+ if (ap->its_name)
+ an = ap->its_name;
+ if (bp->its_name)
+ an = bp->its_name;
if (killat)
{
an = (an[0] == '@') ? an + 1 : an;
if (mtable[machine].how_dljtab == 0)
{
- inform (_("Warning, machine type (%d) not supported for "\r
+ inform (_("Warning, machine type (%d) not supported for "
"delayimport."), machine);
}
else