+2002-11-07 Danny Smith <dannysmith@users.sourceforge.net>
+
+ * dlltool.c (add_excludes): Don't prefix excluded fastcall
+ symbols with underscore.
+ (xlate): Ignore add_underscore for decorated fastcall symbols.
+
+2002-11-07 Eric Kohl <ekohl@rz-online.de>
+
+ * deflex.l: Accept '@' as first character of an ID.
+ * dlltool.c (gen_exp_file): Use existing '@' prefix rather than
+ ASM_PREFIX for fastcall symbols.
+ (scan_drectve_symbols): Handle fastcall symbols when generating
+ undecorated aliases for symbols in drectve section.
+ (scan_filtered_symbols): Likewise, with export-all.
+ (xlate): Likewise, with --kill-at.
+ (make_imp_label): New function to handle fastcall symbols
+ correctly.
+ (make_one_lib_file): Use make_imp_label instead of make_label
+ for imp symbols.
+
2002-11-06 Svein E. Seldal <Svein.Seldal@solidas.com>
* MAINTAINERS: Add self as TIC4X maintainer.
%{/* deflex.l - Lexer for .def files */
-/* Copyright 1995, 1997, 1998, 1999 Free Software Foundation, Inc.
+/* Copyright 1995, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
This file is part of GNU Binutils.
[0-9][x0-9A-Fa-f]* { yylval.number = strtol (yytext,0,0);
return NUMBER; }
-[A-Za-z$:\-\_?][A-Za-z0-9/$:\-\_@?]* {
+(@)?[A-Za-z$:\-\_?][A-Za-z0-9/$:\-\_@?]* {
yylval.id = xstrdup (yytext);
return ID;
}
02111-1307, USA. */
-/*
- This program allows you to build the files necessary to create
+/* This program allows you to build the files necessary to create
DLLs to run on a system which understands PE format image files.
(eg, Windows NT)
# Build the dll with file1.o, file2.o and the export table
- ld -o thedll.dll thedll.exp file1.o file2.o
- */
+ ld -o thedll.dll thedll.exp file1.o file2.o */
/* .idata section description
= Array of { short, asciz } entries, one for each imported function.
The `short' is the function's ordinal number.
- .idata$7 = dll name (eg: "kernel32.dll"). (.idata$6 for ppc)
-*/
+ .idata$7 = dll name (eg: "kernel32.dll"). (.idata$6 for ppc). */
/* AIX requires this to be the first thing in the file. */
#ifndef __GNUC__
static char *deduce_name PARAMS ((const char *));
#ifdef DLLTOOL_MCORE_ELF
-static void mcore_elf_cache_filename (char *);
-static void mcore_elf_gen_out_file (void);
+static void mcore_elf_cache_filename PARAMS ((char *));
+static void mcore_elf_gen_out_file PARAMS ((void));
#endif
#ifdef HAVE_SYS_WAIT_H
#else /* ! HAVE_SYS_WAIT_H */
#if ! defined (_WIN32) || defined (__CYGWIN32__)
#ifndef WIFEXITED
-#define WIFEXITED(w) (((w)&0377) == 0)
+#define WIFEXITED(w) (((w) & 0377) == 0)
#endif
#ifndef WIFSIGNALED
-#define WIFSIGNALED(w) (((w)&0377) != 0177 && ((w)&~0377) == 0)
+#define WIFSIGNALED(w) (((w) & 0377) != 0177 && ((w) & ~0377) == 0)
#endif
#ifndef WTERMSIG
#define WTERMSIG(w) ((w) & 0177)
typedef struct ifunct
{
- char *name; /* name of function being imported */
- int ord; /* two-byte ordinal value associated with function */
+ char * name; /* Name of function being imported. */
+ int ord; /* Two-byte ordinal value associated with function. */
struct ifunct *next;
} ifunctype;
typedef struct iheadt
{
- char *dllname; /* name of dll file imported from */
- long nfuncs; /* number of functions in list */
- struct ifunct *funchead; /* first function in list */
- struct ifunct *functail; /* last function in list */
- struct iheadt *next; /* next dll file in list */
+ char *dllname; /* Name of dll file imported from. */
+ long nfuncs; /* Number of functions in list. */
+ struct ifunct *funchead; /* First function in list. */
+ struct ifunct *functail; /* Last function in list. */
+ struct iheadt *next; /* Next dll file in list. */
} iheadtype;
/* Structure containing all import information as defined in .def file
#define DRECTVE_SECTION_NAME ".drectve"
#endif
-#define PATHMAX 250 /* What's the right name for this ? */
+#define PATHMAX 250 /* What's the right name for this ? */
#define TMP_ASM "dc.s"
#define TMP_HEAD_S "dh.s"
0x00, 0x00, 0x00, 0x00 /* <address> */
};
-/* This is the glue sequence for PowerPC PE. There is a */
-/* tocrel16-tocdefn reloc against the first instruction. */
-/* We also need a IMGLUE reloc against the glue function */
-/* to restore the toc saved by the third instruction in */
-/* the glue. */
+/* This is the glue sequence for PowerPC PE. There is a
+ tocrel16-tocdefn reloc against the first instruction.
+ We also need a IMGLUE reloc against the glue function
+ to restore the toc saved by the third instruction in
+ the glue. */
static const unsigned char ppc_jtab[] =
{
0x00, 0x00, 0x62, 0x81, /* lwz r11,0(r2) */
};
#ifdef DLLTOOL_PPC
-/* the glue instruction, picks up the toc from the stw in */
-/* the above code: "lwz r2,4(r1)" */
+/* The glue instruction, picks up the toc from the stw in
+ the above code: "lwz r2,4(r1)". */
static bfd_vma ppc_glue_insn = 0x80410004;
#endif
const char *how_bfd_target;
enum bfd_architecture how_bfd_arch;
const unsigned char *how_jtab;
- int how_jtab_size; /* size of the jtab entry */
- int how_jtab_roff; /* offset into it for the ind 32 reloc into idata 5 */
+ int how_jtab_size; /* Size of the jtab entry. */
+ int how_jtab_roff; /* Offset into it for the ind 32 reloc into idata 5. */
};
static const struct mac
int noname;
int data;
int hint;
- int forward; /* number of forward label, 0 means no forward */
+ int forward; /* Number of forward label, 0 means no forward. */
struct export *next;
}
export_type;
static void dump_iat PARAMS ((FILE *, export_type *));
#endif
static char *make_label PARAMS ((const char *, const char *));
+static char *make_imp_label PARAMS ((const char *, const char *));
static bfd *make_one_lib_file PARAMS ((export_type *, int));
static bfd *make_head PARAMS ((void));
static bfd *make_tail PARAMS ((void));
static void
-inform VPARAMS ((const char *message, ...))
+inform VPARAMS ((const char * message, ...))
{
VA_OPEN (args, message);
VA_FIXEDARG (args, const char *, message);
/**********************************************************************/
-/* Communications with the parser */
+/* Communications with the parser. */
-static const char *d_name; /* Arg to NAME or LIBRARY */
-static int d_nfuncs; /* Number of functions exported */
-static int d_named_nfuncs; /* Number of named functions exported */
-static int d_low_ord; /* Lowest ordinal index */
-static int d_high_ord; /* Highest ordinal index */
-static export_type *d_exports; /*list of exported functions */
-static export_type **d_exports_lexically; /* vector of exported functions in alpha order */
-static dlist_type *d_list; /* Descriptions */
-static dlist_type *a_list; /* Stuff to go in directives */
-static int d_nforwards = 0; /* Number of forwarded exports */
+static const char *d_name; /* Arg to NAME or LIBRARY. */
+static int d_nfuncs; /* Number of functions exported. */
+static int d_named_nfuncs; /* Number of named functions exported. */
+static int d_low_ord; /* Lowest ordinal index. */
+static int d_high_ord; /* Highest ordinal index. */
+static export_type *d_exports; /* List of exported functions. */
+static export_type **d_exports_lexically; /* Vector of exported functions in alpha order. */
+static dlist_type *d_list; /* Descriptions. */
+static dlist_type *a_list; /* Stuff to go in directives. */
+static int d_nforwards = 0; /* Number of forwarded exports. */
static int d_is_dll;
static int d_is_exe;
non_fatal (_("Can't have LIBRARY and NAME"));
d_name = name;
- /* if --dllname not provided, use the one in the DEF file.
- FIXME: Is this appropriate for executables? */
+ /* If --dllname not provided, use the one in the DEF file.
+ FIXME: Is this appropriate for executables? */
if (! dll_name)
dll_name = xstrdup (name);
d_is_exe = 1;
non_fatal (_("Can't have LIBRARY and NAME"));
d_name = name;
- /* if --dllname not provided, use the one in the DEF file. */
+ /* If --dllname not provided, use the one in the DEF file. */
if (! dll_name)
dll_name = xstrdup (name);
d_is_dll = 1;
if (add_stdcall_alias && strchr (c, '@'))
{
- char *exported_name = xstrdup (c);
+ int lead_at = (*c == '@') ;
+ char *exported_name = xstrdup (c + lead_at);
char *atsym = strchr (exported_name, '@');
*atsym = '\0';
/* Note: stdcall alias symbols can never be data. */
if (add_stdcall_alias && strchr (symbol_name, '@'))
{
- char *exported_name = xstrdup (symbol_name);
+ int lead_at = (*symbol_name == '@');
+ char *exported_name = xstrdup (symbol_name + lead_at);
char *atsym = strchr (exported_name, '@');
*atsym = '\0';
/* Note: stdcall alias symbols can never be data. */
new_exclude = ((struct string_list *)
xmalloc (sizeof (struct string_list)));
new_exclude->string = (char *) xmalloc (strlen (exclude_string) + 2);
- /* FIXME: Is it always right to add a leading underscore? */
- sprintf (new_exclude->string, "_%s", exclude_string);
+ /* Don't add a leading underscore for fastcall symbols. */
+ if (*exclude_string == '@')
+ sprintf (new_exclude->string, "%s", exclude_string);
+ else
+ sprintf (new_exclude->string, "_%s", exclude_string);
new_exclude->next = excludes;
excludes = new_exclude;
else
scan_drectve_symbols (abfd);
- /* FIXME: we ought to read in and block out the base relocations */
+ /* FIXME: we ought to read in and block out the base relocations. */
/* xgettext:c-format */
inform (_("Done reading %s"), bfd_get_filename (abfd));
}
}
-/* Generate the .exp file */
+/* Generate the .exp file. */
static int
sfunc (a, b)
{
int i;
- /* Flush this page */
+ /* Flush this page. */
fprintf (f, "\t%s\t0x%08x\t%s Starting RVA for chunk\n",
ASM_LONG,
page_addr,
}
if (exp->forward == 0)
- fprintf (f, "\t%s%s%s%s\t%s %d\n", ASM_RVA_BEFORE,
- ASM_PREFIX,
- exp->internal_name, ASM_RVA_AFTER, ASM_C, exp->ordinal);
+ {
+ if (exp->internal_name[0] == '@')
+ fprintf (f, "\t%s%s%s\t%s %d\n", ASM_RVA_BEFORE,
+ exp->internal_name, ASM_RVA_AFTER, ASM_C, exp->ordinal);
+ else
+ fprintf (f, "\t%s%s%s%s\t%s %d\n", ASM_RVA_BEFORE,
+ ASM_PREFIX,
+ exp->internal_name, ASM_RVA_AFTER, ASM_C, exp->ordinal);
+ }
else
fprintf (f, "\t%sf%d%s\t%s %d\n", ASM_RVA_BEFORE,
exp->forward, ASM_RVA_AFTER, ASM_C, exp->ordinal);
}
}
- /* Dump the reloc section if a base file is provided */
+ /* Dump the reloc section if a base file is provided. */
if (base_file)
{
int addr;
fclose (f);
- /* assemble the file */
+ /* Assemble the file. */
assemble_file (TMP_ASM, exp_name);
if (dontdeltemps == 0)
xlate (name)
const char *name;
{
- if (add_underscore)
+ int lead_at = (*name == '@');
+
+ if (add_underscore && !lead_at)
{
char *copy = xmalloc (strlen (name) + 2);
+
copy[0] = '_';
strcpy (copy + 1, name);
name = copy;
if (killat)
{
char *p;
+
+ name += lead_at;
p = strchr (name, '@');
if (p)
*p = 0;
asymbol *sym;
asymbol **sympp;
int size;
- unsigned char *data;
+ unsigned char *data;
} sinfo;
#ifndef DLLTOOL_PPC
#else
-/* Sections numbered to make the order the same as other PowerPC NT */
-/* compilers. This also keeps funny alignment thingies from happening. */
+/* Sections numbered to make the order the same as other PowerPC NT
+ compilers. This also keeps funny alignment thingies from happening. */
#define TEXT 0
#define PDATA 1
#define RDATA 2
#endif
-/*
-This is what we're trying to make. We generate the imp symbols with
-both single and double underscores, for compatibility.
+/* This is what we're trying to make. We generate the imp symbols with
+ both single and double underscores, for compatibility.
.text
.global _GetFileVersionInfoSizeW@8
.asciz "GetFileVersionInfoSizeW"
-For the PowerPC, here's the variation on the above scheme:
+ For the PowerPC, here's the variation on the above scheme:
# Rather than a simple "jmp *", the code to get to the dll function
# looks like:
stw r2,4(r1)
mtctr r12
lwz r2,4(r11)
- bctr
-*/
+ bctr */
static char *
make_label (prefix, name)
{
int len = strlen (ASM_PREFIX) + strlen (prefix) + strlen (name);
char *copy = xmalloc (len +1 );
+
strcpy (copy, ASM_PREFIX);
strcat (copy, prefix);
strcat (copy, name);
return copy;
}
+static char *
+make_imp_label (prefix, name)
+ const char *prefix;
+ const char *name;
+{
+ int len;
+ char *copy;
+
+ if (name[0] == '@')
+ {
+ len = strlen (prefix) + strlen (name);
+ copy = xmalloc (len + 1);
+ strcpy (copy, prefix);
+ strcat (copy, name);
+ }
+ else
+ {
+ len = strlen (ASM_PREFIX) + strlen (prefix) + strlen (name);
+ copy = xmalloc (len + 1);
+ strcpy (copy, prefix);
+ strcat (copy, ASM_PREFIX);
+ strcat (copy, name);
+ }
+ return copy;
+}
+
static bfd *
make_one_lib_file (exp, i)
export_type *exp;
applicable = bfd_applicable_section_flags (abfd);
- /* First make symbols for the sections */
+ /* First make symbols for the sections. */
for (i = 0; i < NSECS; i++)
{
sinfo *si = secdata + i;
if (! exp->data)
{
exp_label = bfd_make_empty_symbol (abfd);
- exp_label->name = make_label ("", exp->name);
+ exp_label->name = make_imp_label ("", exp->name);
/* On PowerPC, the function name points to a descriptor in
the rdata section, the first element of which is a
pointer to the code (..function_name), and the second
- points to the .toc */
+ points to the .toc. */
#ifdef DLLTOOL_PPC
if (machine == MPPC)
exp_label->section = secdata[RDATA].sec;
if (create_compat_implib)
{
iname = bfd_make_empty_symbol (abfd);
- iname->name = make_label ("__imp_", exp->name);
+ iname->name = make_imp_label ("___imp", exp->name);
iname->section = secdata[IDATA5].sec;
iname->flags = BSF_GLOBAL;
iname->value = 0;
}
iname2 = bfd_make_empty_symbol (abfd);
- iname2->name = make_label ("_imp__", exp->name);
+ iname2->name = make_imp_label ("__imp_", exp->name);
iname2->section = secdata[IDATA5].sec;
iname2->flags = BSF_GLOBAL;
iname2->value = 0;
iname_lab->flags = 0;
iname_lab->value = 0;
-
iname_pp = ptrs + oidx;
if (create_compat_implib)
ptrs[oidx++] = iname;
ptrs[oidx++] = iname_lab;
#ifdef DLLTOOL_PPC
- /* The symbol refering to the code (.text) */
+ /* The symbol refering to the code (.text). */
{
asymbol *function_name;
ptrs[oidx++] = function_name;
}
- /* The .toc symbol */
+ /* The .toc symbol. */
{
- asymbol *toc_symbol; /* The .toc symbol */
+ asymbol *toc_symbol;
toc_symbol = bfd_make_empty_symbol (abfd);
toc_symbol->name = make_label (".", "toc");
case IDATA4:
case IDATA5:
/* An idata$4 or idata$5 is one word long, and has an
- rva to idata$6 */
+ rva to idata$6. */
si->data = xmalloc (4);
si->size = 4;
break;
case IDATA7:
si->size = 4;
- si->data =xmalloc(4);
+ si->data =xmalloc (4);
memset (si->data, 0, si->size);
rel = xmalloc (sizeof (arelent));
rpp = xmalloc (sizeof (arelent *) * 2);
#ifdef DLLTOOL_PPC
case PDATA:
{
- /* The .pdata section is 5 words long. */
- /* Think of it as: */
- /* struct */
- /* { */
- /* bfd_vma BeginAddress, [0x00] */
- /* EndAddress, [0x04] */
- /* ExceptionHandler, [0x08] */
- /* HandlerData, [0x0c] */
- /* PrologEndAddress; [0x10] */
- /* }; */
+ /* The .pdata section is 5 words long.
+ Think of it as:
+ struct
+ {
+ bfd_vma BeginAddress, [0x00]
+ EndAddress, [0x04]
+ ExceptionHandler, [0x08]
+ HandlerData, [0x0c]
+ PrologEndAddress; [0x10]
+ }; */
/* So this pdata section setups up this as a glue linkage to
a dll routine. There are a number of house keeping things
So we need a total of four relocs for this section.
3. Lastly, the HandlerData field is set to 0x03, to indicate
- that this is a glue routine.
- */
+ that this is a glue routine. */
arelent *imglue, *ba_rel, *ea_rel, *pea_rel;
- /* alignment must be set to 2**2 or you get extra stuff */
+ /* Alignment must be set to 2**2 or you get extra stuff. */
bfd_set_section_alignment(abfd, sec, 2);
si->size = 4 * 5;
- si->data =xmalloc(4 * 5);
+ si->data = xmalloc (si->size);
memset (si->data, 0, si->size);
rpp = xmalloc (sizeof (arelent *) * 5);
rpp[0] = imglue = xmalloc (sizeof (arelent));
rpp[3] = pea_rel = xmalloc (sizeof (arelent));
rpp[4] = 0;
- /* stick the toc reload instruction in the glue reloc */
+ /* Stick the toc reload instruction in the glue reloc. */
bfd_put_32(abfd, ppc_glue_insn, (char *) &imglue->address);
imglue->addend = 0;
ba_rel->howto = bfd_reloc_type_lookup (abfd, BFD_RELOC_32);
ba_rel->sym_ptr_ptr = fn_pp;
- bfd_put_32(abfd, 0x18, si->data + 0x04);
+ bfd_put_32 (abfd, 0x18, si->data + 0x04);
ea_rel->address = 4;
ea_rel->addend = 0;
ea_rel->howto = bfd_reloc_type_lookup (abfd, BFD_RELOC_32);
ea_rel->sym_ptr_ptr = fn_pp;
- /* mark it as glue */
- bfd_put_32(abfd, 0x03, si->data + 0x0c);
+ /* Mark it as glue. */
+ bfd_put_32 (abfd, 0x03, si->data + 0x0c);
- /* mark the prolog end address */
- bfd_put_32(abfd, 0x0D, si->data + 0x10);
+ /* Mark the prolog end address. */
+ bfd_put_32 (abfd, 0x0D, si->data + 0x10);
pea_rel->address = 0x10;
pea_rel->addend = 0;
pea_rel->howto = bfd_reloc_type_lookup (abfd, BFD_RELOC_32);
descriptor consisting of:
1. The address of the code.
2. The address of the appropriate .toc
- We use relocs to build this.
- */
-
+ We use relocs to build this. */
si->size = 8;
si->data = xmalloc (8);
memset (si->data, 0, si->size);
{
bfd_vma vma = 0;
- /* Size up all the sections */
+ /* Size up all the sections. */
for (i = 0; i < NSECS; i++)
{
sinfo *si = secdata + i;
/* vma += si->size;*/
}
}
- /* Write them out */
+ /* Write them out. */
for (i = 0; i < NSECS; i++)
{
sinfo *si = secdata + i;
would be to mark this section as a comdat type 2 section, so
only one would appear in the final .exe (if our linker supported
comdat, that is) or cause it to be inserted by something else (say
- crt0)
- */
+ crt0). */
fprintf (f, "\t.section .idata$3\n");
fprintf (f, "\t%s\t0\n", ASM_LONG);
#ifdef DLLTOOL_PPC
/* Other PowerPC NT compilers use idata$6 for the dllname, so I
- do too. Original, huh? */
+ do too. Original, huh? */
fprintf (f, "\t.section .idata$6\n");
#else
fprintf (f, "\t.section .idata$7\n");
assemble_file (TMP_TAIL_S, TMP_TAIL_O);
- return bfd_openr (TMP_TAIL_O, HOW_BFD_READ_TARGET);
+ return bfd_openr (TMP_TAIL_O, HOW_BFD_READ_TARGET);
}
static void
outarch->has_armap = 1;
/* Work out a reasonable size of things to put onto one line. */
-
ar_head = make_head ();
ar_tail = make_tail();
head = n;
}
- /* Now stick them all into the archive */
-
+ /* Now stick them all into the archive. */
ar_head->next = head;
ar_tail->next = ar_head;
head = ar_tail;
head = n;
}
- /* Delete all the temp files */
-
+ /* Delete all the temp files. */
if (dontdeltemps == 0)
{
unlink (TMP_HEAD_O);
/**********************************************************************/
/* Run through the information gathered from the .o files and the
- .def file and work out the best stuff */
+ .def file and work out the best stuff. */
static int
pfunc (a, b)
const void *a;
if (ap->ordinal == bp->ordinal)
return 0;
- /* unset ordinals go to the bottom */
+ /* Unset ordinals go to the bottom. */
if (ap->ordinal == -1)
return 1;
if (bp->ordinal == -1)
{
int src;
int dst;
+
for (dst = src = 0; src < d_nfuncs; src++)
{
if (ptr[src])
{
int more = 1;
int i;
+
while (more)
{
more = 0;
- /* Remove duplicates */
+ /* Remove duplicates. */
qsort (d_export_vec, d_nfuncs, sizeof (export_type *), nfunc);
dtab (d_export_vec);
fatal (_("Error, duplicate EXPORT with oridinals: %s"),
a->name);
- /* Merge attributes */
+ /* Merge attributes. */
b->ordinal = a->ordinal > 0 ? a->ordinal : b->ordinal;
b->constant |= a->constant;
b->noname |= a->noname;
}
- /* Count the names */
+ /* Count the names. */
for (i = 0; i < d_nfuncs; i++)
{
if (!d_export_vec[i]->noname)
qsort (d_export_vec, d_nfuncs, sizeof (export_type *), pfunc);
- /* fill in the unset ordinals with ones from our range */
-
+ /* Fill in the unset ordinals with ones from our range. */
ptr = (char *) xmalloc (size);
memset (ptr, 0, size);
- /* Mark in our large vector all the numbers that are taken */
+ /* Mark in our large vector all the numbers that are taken. */
for (i = 0; i < d_nfuncs; i++)
{
if (d_export_vec[i]->ordinal != -1)
{
ptr[d_export_vec[i]->ordinal] = 1;
+
if (lowest == -1 || d_export_vec[i]->ordinal < lowest)
- {
- lowest = d_export_vec[i]->ordinal;
- }
+ lowest = d_export_vec[i]->ordinal;
}
}
free (ptr);
- /* And resort */
-
+ /* And resort. */
qsort (d_export_vec, d_nfuncs, sizeof (export_type *), pfunc);
/* Work out the lowest and highest ordinal numbers. */
static void
mangle_defs ()
{
- /* First work out the minimum ordinal chosen */
-
+ /* First work out the minimum ordinal chosen. */
export_type *exp;
int i;
inform (_("Processing definitions"));
for (i = 0, exp = d_exports; exp; i++, exp = exp->next)
- {
- d_export_vec[i] = exp;
- }
+ d_export_vec[i] = exp;
process_duplicates (d_export_vec);
fill_ordinals (d_export_vec);
- /* Put back the list in the new order */
+ /* Put back the list in the new order. */
d_exports = 0;
for (i = d_nfuncs - 1; i >= 0; i--)
{
d_exports = d_export_vec[i];
}
- /* Build list in alpha order */
+ /* Build list in alpha order. */
d_exports_lexically = (export_type **)
xmalloc (sizeof (export_type *) * (d_nfuncs + 1));
for (i = 0, exp = d_exports; exp; i++, exp = exp->next)
- {
- d_exports_lexically[i] = exp;
- }
+ d_exports_lexically[i] = exp;
+
d_exports_lexically[i] = 0;
qsort (d_exports_lexically, i, sizeof (export_type *), alphafunc);
- /* Fill exp entries with their hint values */
-
+ /* Fill exp entries with their hint values. */
for (i = 0; i < d_nfuncs; i++)
- {
- if (!d_exports_lexically[i]->noname || show_allnames)
- d_exports_lexically[i]->hint = hint++;
- }
+ if (!d_exports_lexically[i]->noname || show_allnames)
+ d_exports_lexically[i]->hint = hint++;
inform (_("Processed definitions"));
}
dyn_string_delete (ds);
/* Step two. Create a .exp file and a .lib file from the temporary file.
- Do this by recursively invoking dlltool....*/
+ Do this by recursively invoking dlltool... */
ds = dyn_string_new (100);
dyn_string_append (ds, "-S ");
}
/* XXX - FIME: ought to check/copy other command line options as well. */
-
run (program_name, ds->s);
dyn_string_delete (ds);
+2002-11-07 Casper S. Hornstrup <chorns@users.sourceforge.net>
+
+ * binutils-all/dlltool.exp: New file for testing dlltool.
+ * binutils-all/fastcall.def: New file for testing fastcall
+ exports.
+ * config/default.exp: Set DLLTOOL variable.
+
2002-08-27 Alan Modra <amodra@bigpond.net.au>
* binutils-all/objcopy.exp: Revert last change.
--- /dev/null
+# Copyright 2002 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+if {![istarget "i*86-*-*"]} {
+ return
+}
+
+if {![istarget "i*86-*-*pe*"] \
+ && ![istarget "i*86-*-cygwin*"] \
+ && ![istarget "i*86-*-mingw32*"] } {
+ set target_xfail "yes"
+} else {
+ set target_xfail "no"
+}
+
+if {![info exists DLLTOOL]} then {
+ return
+}
+
+if {[which $DLLTOOL] == 0} then {
+ return
+}
+
+verbose "$DLLTOOL -d $srcdir/$subdir/fastcall.def" 1
+catch "exec $DLLTOOL -d $srcdir/$subdir/fastcall.def" err
+
+if ![string match "" $err] then {
+ send_log "$err\n"
+ verbose "$err" 1
+ fail "dlltool (fastcall export)"
+ continue;
+}
+
+pass "dlltool (fastcall export)"
--- /dev/null
+EXPORTS
+@fastcall@4
-# Copyright 1993, 1994, 1995, 1997, 1999, 2001
+# Copyright 1993, 1994, 1995, 1997, 1999, 2001, 2002
# Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
if ![info exists NMFLAGS] then {
set NMFLAGS ""
}
-
if ![info exists SIZE] then {
set SIZE [findfile $base_dir/size]
}
if ![info exists SIZEFLAGS] then {
set SIZEFLAGS ""
}
-
if ![info exists OBJDUMP] then {
set OBJDUMP [findfile $base_dir/objdump]
}
if ![info exists OBJDUMPFLAGS] then {
set OBJDUMPFLAGS ""
}
-
if ![info exists OBJCOPY] then {
set OBJCOPY [findfile $base_dir/objcopy]
}
if ![info exists OBJCOPYFLAGS] then {
set OBJCOPYFLAGS ""
}
-
if ![info exists AR] then {
set AR [findfile $base_dir/ar]
}
-
if ![info exists STRIP] then {
set STRIP [findfile $base_dir/strip-new $base_dir/strip-new [transform strip]]
}
if ![info exists STRIPFLAGS] then {
set STRIPFLAGS ""
}
-
if ![info exists READELF] then {
set READELF [findfile $base_dir/readelf]
}
if ![info exists READELFFLAGS] then {
set READELFFLAGS ""
}
-
if ![info exists WINDRES] then {
set WINDRES [findfile $base_dir/windres]
}
+if ![info exists DLLTOOL] then {
+ set DLLTOOL [findfile $base_dir/dlltool]
+}
if ![file isdirectory tmpdir] {catch "exec mkdir tmpdir" status}
+2002-11-07 Eric Kohl <ekohl@rz-online.de>
+
+ * config/te-pe.h (LEX_AT): Accept at-sign (@) as first character
+ of a label.
+
2002-11-05 H.J. Lu <hjl@gnu.org>
* config/tc-mips.c (support_64bit_objects): Check *l before it
#define TE_PE
-#define LEX_AT 1 /* can have @'s inside labels */
+#define LEX_AT (LEX_BEGIN_NAME | LEX_NAME) /* Can have @'s inside labels. */
/* The PE format supports long section names. */
#define COFF_LONG_SECTION_NAMES
+2002-11-07 Casper S. Hornstrup <chorns@users.sourceforge.net>
+
+ * gas/all/gas.exp: Run fastcall label handling test.
+ * gas/all/fastcall.s: New file for testing handling of fastcall
+ labels.
+
2002-11-01 H.J. Lu <hjl@gnu.org>
* gas/i386/i386.exp: Add "sub".
--- /dev/null
+@fastcall_label@0:\r
run_dump_test incbin
}
}
+
+gas_test "fastcall.s" "" "" "fastcall labels"
+2002-11-07 Danny Smith <dannysmith@users.sourceforge.net>
+
+ * deffilep.y (def_lex): Handle '@' as first character of an ID.
+ * pe-dll.c (auto-export): Filter on "_imp_" prefix, not "_imp__".
+ (make_one): Don't prefix decorated fastcall symbols with '_'.
+ (pe_process_import_defs): Likewise.
+ * emultempl/pe.em (pe_fixup_stdcalls): Don't fixup fastcall
+ symbols to cdecl names or vise-versa.
+
+2002-10-13 Eric Kohl <ekohl@rz-online.de>
+
+ * pe-dll.c (process_def_file): Handle fastcall symbols when
+ generating undecorated aliases. Don't prefix decorated fastcall
+ symbols with '_'.
+ (fill_exported_offsets): Don't prefix decorated fastcall symbols
+ with '_'.
+
2002-10-29 Daniel Jacobowitz <drow@mvista.com>
* emultempl/aix.em: Use include <> for generated headers.
%{ /* deffilep.y - parser for .def files */
-/* Copyright 1995, 1997, 1998, 1999, 2000, 2001
+/* Copyright 1995, 1997, 1998, 1999, 2000, 2001, 2002
Free Software Foundation, Inc.
This file is part of GNU Binutils.
return NUMBER;
}
- if (ISALPHA (c) || strchr ("$:-_?", c))
+ if (ISALPHA (c) || strchr ("$:-_?@", c))
{
bufptr = 0;
+ q = c;
+ put_buf (c);
+ c = def_getc ();
+
+ if (q == '@')
+ {
+ if (ISBLANK (c) ) /* '@' followed by whitespace. */
+ return (q);
+ else if (ISDIGIT (c)) /* '@' followed by digit. */
+ {
+ def_ungetc (c);
+ return (q);
+ }
+#if TRACE
+ printf ("lex: @ returns itself\n");
+#endif
+ }
+
while (c != EOF && (ISALNUM (c) || strchr ("$:-_?/@", c)))
{
put_buf (c);
}
if (c != EOF)
def_ungetc (c);
- for (i = 0; tokens[i].name; i++)
- if (strcmp (tokens[i].name, buffer) == 0)
- {
+ if (ISALPHA (q)) /* Check for tokens. */
+ {
+ for (i = 0; tokens[i].name; i++)
+ if (strcmp (tokens[i].name, buffer) == 0)
+ {
#if TRACE
- printf ("lex: `%s' is a string token\n", buffer);
+ printf ("lex: `%s' is a string token\n", buffer);
#endif
- return tokens[i].token;
- }
+ return tokens[i].token;
+ }
+ }
#if TRACE
printf ("lex: `%s' returns ID\n", buffer);
#endif
return ID;
}
- if (c == '=' || c == '.' || c == '@' || c == ',')
+ if (c == '=' || c == '.' || c == ',')
{
#if TRACE
printf ("lex: `%c' returns itself\n", c);
{
static int gave_warning_message = 0;
struct bfd_link_hash_entry *undef, *sym;
- char *at;
+
if (pe_dll_extra_pe_debug)
- {
- printf ("%s\n", __FUNCTION__);
- }
+ printf ("%s\n", __FUNCTION__);
for (undef = link_info.hash->undefs; undef; undef=undef->next)
if (undef->type == bfd_link_hash_undefined)
- {
- at = strchr (undef->root.string, '@');
- if (at)
- {
- /* The symbol is a stdcall symbol, so let's look for a cdecl
- symbol with the same name and resolve to that */
- char *cname = xstrdup (undef->root.string);
- at = strchr (cname, '@');
- *at = 0;
- sym = bfd_link_hash_lookup (link_info.hash, cname, 0, 0, 1);
- if (sym && sym->type == bfd_link_hash_defined)
- {
- undef->type = bfd_link_hash_defined;
- undef->u.def.value = sym->u.def.value;
- undef->u.def.section = sym->u.def.section;
- if (pe_enable_stdcall_fixup == -1)
- {
- einfo (_("Warning: resolving %s by linking to %s\n"),
- undef->root.string, cname);
- if (! gave_warning_message)
- {
- gave_warning_message = 1;
- einfo(_("Use --enable-stdcall-fixup to disable these warnings\n"));
- einfo(_("Use --disable-stdcall-fixup to disable these fixups\n"));
- }
- }
- }
- }
- else
{
- /* The symbol is a cdecl symbol, so we look for stdcall
- symbols - which means scanning the whole symbol table */
- pe_undef_found_sym = 0;
- bfd_link_hash_traverse (link_info.hash, pe_undef_cdecl_match,
- (PTR) undef->root.string);
- sym = pe_undef_found_sym;
- if (sym)
- {
- undef->type = bfd_link_hash_defined;
- undef->u.def.value = sym->u.def.value;
- undef->u.def.section = sym->u.def.section;
- if (pe_enable_stdcall_fixup == -1)
- {
- einfo (_("Warning: resolving %s by linking to %s\n"),
- undef->root.string, sym->root.string);
- if (! gave_warning_message)
- {
- gave_warning_message = 1;
- einfo(_("Use --enable-stdcall-fixup to disable these warnings\n"));
- einfo(_("Use --disable-stdcall-fixup to disable these fixups\n"));
- }
- }
- }
+ char* at = strchr (undef->root.string, '@');
+ int lead_at = (*undef->root.string == '@');
+ /* For now, don't try to fixup fastcall symbols. */
+
+ if (at && !lead_at)
+ {
+ /* The symbol is a stdcall symbol, so let's look for a
+ cdecl symbol with the same name and resolve to that. */
+ char *cname = xstrdup (undef->root.string /* + lead_at */);
+ at = strchr (cname, '@');
+ *at = 0;
+ sym = bfd_link_hash_lookup (link_info.hash, cname, 0, 0, 1);
+
+ if (sym && sym->type == bfd_link_hash_defined)
+ {
+ undef->type = bfd_link_hash_defined;
+ undef->u.def.value = sym->u.def.value;
+ undef->u.def.section = sym->u.def.section;
+ if (pe_enable_stdcall_fixup == -1)
+ {
+ einfo (_("Warning: resolving %s by linking to %s\n"),
+ undef->root.string, cname);
+ if (! gave_warning_message)
+ {
+ gave_warning_message = 1;
+ einfo(_("Use --enable-stdcall-fixup to disable these warnings\n"));
+ einfo(_("Use --disable-stdcall-fixup to disable these fixups\n"));
+ }
+ }
+ }
+ }
+ else
+ {
+ /* The symbol is a cdecl symbol, so we look for stdcall
+ symbols - which means scanning the whole symbol table */
+ pe_undef_found_sym = 0;
+ bfd_link_hash_traverse (link_info.hash, pe_undef_cdecl_match,
+ (PTR) undef->root.string);
+ sym = pe_undef_found_sym;
+ if (sym)
+ {
+ undef->type = bfd_link_hash_defined;
+ undef->u.def.value = sym->u.def.value;
+ undef->u.def.section = sym->u.def.section;
+ if (pe_enable_stdcall_fixup == -1)
+ {
+ einfo (_("Warning: resolving %s by linking to %s\n"),
+ undef->root.string, sym->root.string);
+ if (! gave_warning_message)
+ {
+ gave_warning_message = 1;
+ einfo(_("Use --enable-stdcall-fixup to disable these warnings\n"));
+ einfo(_("Use --disable-stdcall-fixup to disable these fixups\n"));
+ }
+ }
+ }
+ }
}
- }
}
static int
asection *s;
{
struct symbol_cache_entry *sym = *rel->sym_ptr_ptr;
+ int addend = 0;
if (pe_dll_extra_pe_debug)
- {
- printf ("arelent: %s@%#lx: add=%li\n", sym->name,
- (long) rel->address, (long) rel->addend);
- }
+ printf ("arelent: %s@%#lx: add=%li\n", sym->name,
+ (long) rel->address, (long) rel->addend);
- {
- int addend = 0;
- if (!bfd_get_section_contents(s->owner, s, &addend, rel->address, sizeof(addend)))
- {
- einfo (_("%C: Cannot get section contents - auto-import exception\n"),
- s->owner, s, rel->address);
- }
+ if (!bfd_get_section_contents(s->owner, s, &addend, rel->address, sizeof(addend)))
+ einfo (_("%C: Cannot get section contents - auto-import exception\n"),
+ s->owner, s, rel->address);
- if (addend == 0)
- pe_create_import_fixup (rel);
- else
- {
- einfo (_("%C: variable '%T' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.\n"),
- s->owner, s, rel->address, sym->name);
- einfo ("%X");
- }
- }
+ if (addend == 0)
+ pe_create_import_fixup (rel);
+ else
+ {
+ einfo (_("%C: variable '%T' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.\n"),
+ s->owner, s, rel->address, sym->name);
+ einfo ("%X");
+ }
return 1;
}
pe_find_data_imports ()
{
struct bfd_link_hash_entry *undef, *sym;
+
for (undef = link_info.hash->undefs; undef; undef=undef->next)
{
if (undef->type == bfd_link_hash_undefined)
{
/* C++ symbols are *long* */
char buf[4096];
- if (pe_dll_extra_pe_debug)
- {
- printf ("%s:%s\n", __FUNCTION__, undef->root.string);
- }
+
+ if (pe_dll_extra_pe_debug)
+ printf ("%s:%s\n", __FUNCTION__, undef->root.string);
+
sprintf (buf, "__imp_%s", undef->root.string);
sym = bfd_link_hash_lookup (link_info.hash, buf, 0, 0, 1);
+
if (sym && sym->type == bfd_link_hash_defined)
{
if (link_info.pei386_auto_import == -1)
info_msg (_("Info: resolving %s by linking to %s (auto-import)\n"),
- undef->root.string, buf);
- {
- bfd *b = sym->u.def.section->owner;
- asymbol **symbols;
- int nsyms, symsize, i;
-
- symsize = bfd_get_symtab_upper_bound (b);
- symbols = (asymbol **) xmalloc (symsize);
- nsyms = bfd_canonicalize_symtab (b, symbols);
-
- for (i = 0; i < nsyms; i++)
- {
- if (memcmp(symbols[i]->name, "__head_",
- sizeof ("__head_") - 1))
- continue;
- if (pe_dll_extra_pe_debug)
- {
- printf ("->%s\n", symbols[i]->name);
- }
- pe_data_import_dll = (char*) (symbols[i]->name +
- sizeof ("__head_") - 1);
- break;
- }
- }
-
- pe_walk_relocs_of_symbol (&link_info, undef->root.string,
- make_import_fixup);
-
- /* let's differentiate it somehow from defined */
- undef->type = bfd_link_hash_defweak;
- /* we replace original name with __imp_ prefixed, this
- 1) may trash memory 2) leads to duplicate symbol generation.
- Still, IMHO it's better than having name poluted. */
- undef->root.string = sym->root.string;
- undef->u.def.value = sym->u.def.value;
- undef->u.def.section = sym->u.def.section;
+ undef->root.string, buf);
+
+ {
+ bfd *b = sym->u.def.section->owner;
+ asymbol **symbols;
+ int nsyms, symsize, i;
+
+ symsize = bfd_get_symtab_upper_bound (b);
+ symbols = (asymbol **) xmalloc (symsize);
+ nsyms = bfd_canonicalize_symtab (b, symbols);
+
+ for (i = 0; i < nsyms; i++)
+ {
+ if (memcmp(symbols[i]->name, "__head_",
+ sizeof ("__head_") - 1))
+ continue;
+
+ if (pe_dll_extra_pe_debug)
+ printf ("->%s\n", symbols[i]->name);
+
+ pe_data_import_dll = (char*) (symbols[i]->name +
+ sizeof ("__head_") - 1);
+ break;
+ }
+ }
+
+ pe_walk_relocs_of_symbol (&link_info, undef->root.string,
+ make_import_fixup);
+
+ /* Let's differentiate it somehow from defined. */
+ undef->type = bfd_link_hash_defweak;
+ /* We replace original name with __imp_ prefixed, this
+ 1) may trash memory 2) leads to duplicate symbol generation.
+ Still, IMHO it's better than having name poluted. */
+ undef->root.string = sym->root.string;
+ undef->u.def.value = sym->u.def.value;
+ undef->u.def.section = sym->u.def.section;
}
}
}
PTR string ATTRIBUTE_UNUSED;
{
if (pe_dll_extra_pe_debug)
- {
- printf("+%s\n",h->string);
- }
+ printf ("+%s\n",h->string);
+
return true;
}
static void
gld_${EMULATION_NAME}_after_open ()
{
-
if (pe_dll_extra_pe_debug)
{
bfd *a;
struct bfd_link_hash_entry *sym;
+
printf ("%s()\n", __FUNCTION__);
for (sym = link_info.hash->undefs; sym; sym=sym->next)
bfd_hash_traverse (&link_info.hash->table, pr_sym,NULL);
for (a = link_info.input_bfds; a; a = a->link_next)
- {
- printf("*%s\n",a->filename);
- }
+ printf ("*%s\n",a->filename);
}
/* Pass the wacky PE command line options into the output bfd.
gld_${EMULATION_NAME}_before_allocation()
{
#ifdef TARGET_IS_ppcpe
- /* Here we rummage through the found bfds to collect toc information */
+ /* Here we rummage through the found bfds to collect toc information. */
{
LANG_FOR_EACH_INPUT_STATEMENT (is)
{
}
}
- /* We have seen it all. Allocate it, and carry on */
+ /* We have seen it all. Allocate it, and carry on. */
ppc_allocate_toc_section (&link_info);
#endif /* TARGET_IS_ppcpe */
Here we rummage through the found bfds to collect glue
information. FIXME: should this be based on a command line
- option? krk@cygnus.com */
+ option? krk@cygnus.com. */
{
LANG_FOR_EACH_INPUT_STATEMENT (is)
{
}
}
- /* We have seen it all. Allocate it, and carry on */
+ /* We have seen it all. Allocate it, and carry on. */
bfd_arm_pe_allocate_interworking_sections (& link_info);
#endif /* TARGET_IS_armpe */
}
\f
#ifdef DLL_SUPPORT
/* This is called when an input file isn't recognized as a BFD. We
- check here for .DEF files and pull them in automatically. */
+ check here for .DEF files and pull them in automatically. */
static int
-saw_option(char *option)
+saw_option (char * option)
{
int i;
- for (i=0; init[i].ptr; i++)
+
+ for (i = 0; init[i].ptr; i++)
if (strcmp (init[i].symbol, option) == 0)
return init[i].inited;
return 0;
const char *ext = entry->filename + strlen (entry->filename) - 4;
if (strcmp (ext, ".def") == 0 || strcmp (ext, ".DEF") == 0)
- {
- if (pe_def_file == 0)
- pe_def_file = def_file_empty ();
- def_file_parse (entry->filename, pe_def_file);
- if (pe_def_file)
{
- int i, buflen=0, len;
- char *buf;
- for (i=0; i<pe_def_file->num_exports; i++)
- {
- len = strlen(pe_def_file->exports[i].internal_name);
- if (buflen < len+2)
- buflen = len+2;
- }
- buf = (char *) xmalloc (buflen);
- for (i=0; i<pe_def_file->num_exports; i++)
+ if (pe_def_file == 0)
+ pe_def_file = def_file_empty ();
+
+ def_file_parse (entry->filename, pe_def_file);
+
+ if (pe_def_file)
{
- struct bfd_link_hash_entry *h;
- sprintf(buf, "_%s", pe_def_file->exports[i].internal_name);
+ int i, buflen=0, len;
+ char *buf;
- h = bfd_link_hash_lookup (link_info.hash, buf, true, true, true);
- if (h == (struct bfd_link_hash_entry *) NULL)
- einfo (_("%P%F: bfd_link_hash_lookup failed: %E\n"));
- if (h->type == bfd_link_hash_new)
+ for (i = 0; i < pe_def_file->num_exports; i++)
{
- h->type = bfd_link_hash_undefined;
- h->u.undef.abfd = NULL;
- bfd_link_add_undef (link_info.hash, h);
+ len = strlen(pe_def_file->exports[i].internal_name);
+ if (buflen < len + 2)
+ buflen = len + 2;
}
- }
- free (buf);
- /* def_file_print (stdout, pe_def_file); */
- if (pe_def_file->is_dll == 1)
- link_info.shared = 1;
+ buf = (char *) xmalloc (buflen);
- if (pe_def_file->base_address != (bfd_vma)(-1))
- {
- pe.ImageBase =
- pe_data (output_bfd)->pe_opthdr.ImageBase =
- init[IMAGEBASEOFF].value = pe_def_file->base_address;
- init[IMAGEBASEOFF].inited = 1;
- if (image_base_statement)
- image_base_statement->exp =
- exp_assop ('=', "__image_base__", exp_intop (pe.ImageBase));
- }
+ for (i = 0; i < pe_def_file->num_exports; i++)
+ {
+ struct bfd_link_hash_entry *h;
+
+ sprintf(buf, "_%s", pe_def_file->exports[i].internal_name);
+
+ h = bfd_link_hash_lookup (link_info.hash, buf, true, true, true);
+ if (h == (struct bfd_link_hash_entry *) NULL)
+ einfo (_("%P%F: bfd_link_hash_lookup failed: %E\n"));
+ if (h->type == bfd_link_hash_new)
+ {
+ h->type = bfd_link_hash_undefined;
+ h->u.undef.abfd = NULL;
+ bfd_link_add_undef (link_info.hash, h);
+ }
+ }
+ free (buf);
+
+ /* def_file_print (stdout, pe_def_file); */
+ if (pe_def_file->is_dll == 1)
+ link_info.shared = 1;
+
+ if (pe_def_file->base_address != (bfd_vma)(-1))
+ {
+ pe.ImageBase =
+ pe_data (output_bfd)->pe_opthdr.ImageBase =
+ init[IMAGEBASEOFF].value = pe_def_file->base_address;
+ init[IMAGEBASEOFF].inited = 1;
+ if (image_base_statement)
+ image_base_statement->exp =
+ exp_assop ('=', "__image_base__", exp_intop (pe.ImageBase));
+ }
#if 0
- /* Not sure if these *should* be set */
- if (pe_def_file->version_major != -1)
- {
- pe.MajorImageVersion = pe_def_file->version_major;
- pe.MinorImageVersion = pe_def_file->version_minor;
- }
+ /* Not sure if these *should* be set */
+ if (pe_def_file->version_major != -1)
+ {
+ pe.MajorImageVersion = pe_def_file->version_major;
+ pe.MinorImageVersion = pe_def_file->version_minor;
+ }
#endif
- if (pe_def_file->stack_reserve != -1
- && ! saw_option ("__size_of_stack_reserve__"))
- {
- pe.SizeOfStackReserve = pe_def_file->stack_reserve;
- if (pe_def_file->stack_commit != -1)
- pe.SizeOfStackCommit = pe_def_file->stack_commit;
- }
- if (pe_def_file->heap_reserve != -1
- && ! saw_option ("__size_of_heap_reserve__"))
- {
- pe.SizeOfHeapReserve = pe_def_file->heap_reserve;
- if (pe_def_file->heap_commit != -1)
- pe.SizeOfHeapCommit = pe_def_file->heap_commit;
- }
- return true;
+ if (pe_def_file->stack_reserve != -1
+ && ! saw_option ("__size_of_stack_reserve__"))
+ {
+ pe.SizeOfStackReserve = pe_def_file->stack_reserve;
+ if (pe_def_file->stack_commit != -1)
+ pe.SizeOfStackCommit = pe_def_file->stack_commit;
+ }
+ if (pe_def_file->heap_reserve != -1
+ && ! saw_option ("__size_of_heap_reserve__"))
+ {
+ pe.SizeOfHeapReserve = pe_def_file->heap_reserve;
+ if (pe_def_file->heap_commit != -1)
+ pe.SizeOfHeapCommit = pe_def_file->heap_commit;
+ }
+ return true;
+ }
}
- }
#endif
return false;
-
}
static boolean
if (bfd_get_format (entry->the_bfd) == bfd_object)
{
const char *ext = entry->filename + strlen (entry->filename) - 4;
+
if (strcmp (ext, ".dll") == 0 || strcmp (ext, ".DLL") == 0)
return pe_implied_import_dll (entry->filename);
}
pe_dll_generate_def_file (pe_out_def_filename);
#endif /* DLL_SUPPORT */
- /* I don't know where .idata gets set as code, but it shouldn't be */
+ /* I don't know where .idata gets set as code, but it shouldn't be. */
{
asection *asec = bfd_get_section_by_name (output_bfd, ".idata");
+
if (asec)
{
asec->flags &= ~SEC_CODE;
lang_statement_union_type **stmt;
};
-/*ARGSUSED*/
static boolean
gld_${EMULATION_NAME}_place_orphan (file, s)
lang_input_statement_type *file;
secname = bfd_get_section_name (s->owner, s);
/* Look through the script to see where to place this section. */
-
hold_section_name = xstrdup (secname);
if (!link_info.relocateable)
{
{
char *symname;
- /* lang_leave_ouput_section_statement resets stat_ptr. Put
- stat_ptr back where we want it. */
+ /* lang_leave_ouput_section_statement resets stat_ptr.
+ Put stat_ptr back where we want it. */
if (place != NULL)
stat_ptr = &add;
/* The section name has a '$'. Sort it with the other '$'
sections. */
-
found_dollar = false;
for ( ; *pl != NULL; pl = &(*pl)->header.next)
{
#endif
+ 1);
- /* Try "libfoo.dll.a" first (preferred explicit import library for dll's */
+ /* Try "libfoo.dll.a" first (preferred explicit import library for dll's. */
sprintf (string, "%s/lib%s.dll.a", search->name, filename);
if (! ldfile_try_open_bfd (string, entry))
{
- /* Try "foo.dll.a" next (alternate explicit import library for dll's */
+ /* Try "foo.dll.a" next (alternate explicit import library for dll's. */
sprintf (string, "%s/%s.dll.a", search->name, filename);
if (! ldfile_try_open_bfd (string, entry))
{
-/*
- Try libfoo.a next. Normally, this would be interpreted as a static
- library, but it *could* be an import library. For backwards compatibility,
- libfoo.a needs to ==precede== libfoo.dll and foo.dll in the search,
- or sometimes errors occur when building legacy packages.
-
- Putting libfoo.a here means that in a failure case (i.e. the library
- -lfoo is not found) we will search for libfoo.a twice before
- giving up -- once here, and once when searching for a "static" lib.
- for a "static" lib.
-*/
+ /* Try libfoo.a next. Normally, this would be interpreted as a static
+ library, but it *could* be an import library. For backwards compatibility,
+ libfoo.a needs to ==precede== libfoo.dll and foo.dll in the search,
+ or sometimes errors occur when building legacy packages.
+
+ Putting libfoo.a here means that in a failure case (i.e. the library
+ -lfoo is not found) we will search for libfoo.a twice before
+ giving up -- once here, and once when searching for a "static" lib.
+ for a "static" lib. */
/* Try "libfoo.a" (import lib, or static lib, but must
take precedence over dll's) */
sprintf (string, "%s/lib%s.a", search->name, filename);
}
}
}
- else /* pe_dll_search_prefix not specified */
+ else /* pe_dll_search_prefix not specified. */
#endif
{
- /* Try "libfoo.dll" (preferred dll name) */
+ /* Try "libfoo.dll" (preferred dll name). */
sprintf (string, "%s/lib%s.dll", search->name, filename);
if (! ldfile_try_open_bfd (string, entry))
{
- /* Finally, try "foo.dll" (alternate dll name) */
+ /* Finally, try "foo.dll" (alternate dll name). */
sprintf (string, "%s/%s.dll", search->name, filename);
if (! ldfile_try_open_bfd (string, entry))
{
/* This will preserve internal_name, which may have been
pointing to the same memory as name, or might not
have. */
- char *tmp = xstrdup (pe_def_file->exports[i].name);
+ int lead_at = (*pe_def_file->exports[i].name =='@');
+ char *tmp = xstrdup (pe_def_file->exports[i].name + lead_at);
*(strchr (tmp, '@')) = 0;
pe_def_file->exports[i].name = tmp;
{
if (strchr (pe_def_file->exports[i].name, '@'))
{
- char *tmp = xstrdup (pe_def_file->exports[i].name);
+ int lead_at = (*pe_def_file->exports[i].name == '@' ) ;
+ char *tmp = xstrdup (pe_def_file->exports[i].name + lead_at);
*(strchr (tmp, '@')) = 0;
if (auto_export (NULL, pe_def_file, tmp))
{
char *name = (char *) xmalloc (strlen (pe_def_file->exports[i].internal_name) + 2);
- if (pe_details->underscored)
+ if (pe_details->underscored
+ && (*pe_def_file->exports[i].internal_name != '@'))
{
*name = '_';
strcpy (name + 1, pe_def_file->exports[i].internal_name);
{
char *name = (char *) xmalloc (strlen (pe_def_file->exports[i].internal_name) + 2);
- if (pe_details->underscored)
+ if (pe_details->underscored
+ && (*pe_def_file->exports[i].internal_name != '@'))
{
*name = '_';
strcpy (name + 1, pe_def_file->exports[i].internal_name);
id5 = quick_section (abfd, ".idata$5", SEC_HAS_CONTENTS, 2);
id4 = quick_section (abfd, ".idata$4", SEC_HAS_CONTENTS, 2);
id6 = quick_section (abfd, ".idata$6", SEC_HAS_CONTENTS, 2);
- if (! exp->flag_data)
- quick_symbol (abfd, U (""), exp->internal_name, "", tx, BSF_GLOBAL, 0);
- quick_symbol (abfd, U ("_head_"), dll_symname, "", UNDSEC, BSF_GLOBAL, 0);
- quick_symbol (abfd, U ("_imp__"), exp->internal_name, "", id5, BSF_GLOBAL, 0);
- /* Symbol to reference ord/name of imported
- data symbol, used to implement auto-import. */
- if (exp->flag_data)
- quick_symbol (abfd, U("_nm__"), exp->internal_name, "", id6,
- BSF_GLOBAL,0);
+
+ if (*exp->internal_name == '@')
+ {
+ if (! exp->flag_data)
+ quick_symbol (abfd, "", exp->internal_name, "", tx, BSF_GLOBAL, 0);
+ quick_symbol (abfd, U ("_head_"), dll_symname, "", UNDSEC, BSF_GLOBAL, 0);
+ quick_symbol (abfd, U ("_imp_"), exp->internal_name, "", id5, BSF_GLOBAL, 0);
+ /* Fastcall applies only to functions,
+ so no need for auto-import symbol. */
+ }
+ else
+ {
+ if (! exp->flag_data)
+ quick_symbol (abfd, U (""), exp->internal_name, "", tx, BSF_GLOBAL, 0);
+ quick_symbol (abfd, U ("_head_"), dll_symname, "", UNDSEC, BSF_GLOBAL, 0);
+ quick_symbol (abfd, U ("_imp__"), exp->internal_name, "", id5, BSF_GLOBAL, 0);
+ /* Symbol to reference ord/name of imported
+ data symbol, used to implement auto-import. */
+ if (exp->flag_data)
+ quick_symbol (abfd, U("_nm__"), exp->internal_name, "", id6, BSF_GLOBAL,0);
+ }
if (pe_dll_compat_implib)
quick_symbol (abfd, U ("__imp_"), exp->internal_name, "",
id5, BSF_GLOBAL, 0);
{
def_file_export exp;
struct bfd_link_hash_entry *blhe;
-
+ int lead_at = (*pe_def_file->imports[i].internal_name == '@');
/* See if we need this import. */
char *name = (char *) xmalloc (strlen (pe_def_file->imports[i].internal_name) + 2 + 6);
- sprintf (name, "%s%s", U (""), pe_def_file->imports[i].internal_name);
+
+ if (lead_at)
+ sprintf (name, "%s%s", "", pe_def_file->imports[i].internal_name);
+ else
+ sprintf (name, "%s%s",U (""), pe_def_file->imports[i].internal_name);
+
blhe = bfd_link_hash_lookup (link_info->hash, name,
false, false, false);
+
if (!blhe || (blhe && blhe->type != bfd_link_hash_undefined))
{
- sprintf (name, "%s%s", U ("_imp__"),
- pe_def_file->imports[i].internal_name);
+ if (lead_at)
+ sprintf (name, "%s%s", U ("_imp_"),
+ pe_def_file->imports[i].internal_name);
+ else
+ sprintf (name, "%s%s", U ("_imp__"),
+ pe_def_file->imports[i].internal_name);
+
blhe = bfd_link_hash_lookup (link_info->hash, name,
false, false, false);
}
free (name);
+
if (blhe && blhe->type == bfd_link_hash_undefined)
{
bfd *one;
+2002-11-07 Casper S. Hornstrup <chorns@users.sourceforge.net>
+
+ * ld-fastcall: New directory for testing fastcall support.
+ * ld-fastcall/export.s: New file for testing fastcall symbol
+ handling.
+ * ld-fastcall/import.s: Likewise.
+ * ld-fastcall/fastcall.exp: Likewise.
+
2002-11-03 Kaz Kojima <kkojima@rr.iij4u.or.jp>
* ld-sh/rd-sh.exp: Add -isa=SHcompact to ASFLAGS for SH-5.
--- /dev/null
+ .text
+.globl @extern_fastcall_function@0
+@extern_fastcall_function@0:
--- /dev/null
+# Test that the linker can handle fastcall symbols correctly.
+# Copyright 2002 Free Software Foundation, Inc.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+set testname "ld (fastcall symbols)"
+
+if {![istarget "i*86-*-*"]} {
+ return
+}
+
+if {![istarget "i*86-*-*pe*"] \
+ && ![istarget "i*86-*-cygwin*"] \
+ && ![istarget "i*86-*-mingw32*"] } {
+ set target_xfail "yes"
+} else {
+ set target_xfail "no"
+}
+
+set ldflags ""
+
+if ![ld_assemble $as $srcdir/$subdir/export.s tmpdir/export.o] {
+ verbose "Unable to assemble test file!" 1
+ unresolved $testname
+ return
+}
+
+if ![ld_assemble $as $srcdir/$subdir/import.s tmpdir/import.o] {
+ verbose "Unable to assemble test file!" 1
+ unresolved $testname
+ return
+}
+
+if ![ld_simple_link $ld tmpdir/extern.x "$ldflags tmpdir/export.o tmpdir/import.o"] {
+ fail $testname
+} else {
+ pass $testname
+}
--- /dev/null
+ .text
+.globl _start
+_start:
+ call @extern_fastcall_function@0