static void pe_find_data_imports PARAMS ((void));
#endif
-static bfd_boolean pr_sym PARAMS ((struct bfd_hash_entry *, PTR string));
+static bfd_boolean pr_sym PARAMS ((struct bfd_hash_entry *, PTR));
static bfd_boolean gld_${EMULATION_NAME}_unrecognized_file
PARAMS ((lang_input_statement_type *));
static bfd_boolean gld_${EMULATION_NAME}_recognized_file
static lang_assignment_statement_type *image_base_statement = 0;
#ifdef DLL_SUPPORT
-static int pe_enable_stdcall_fixup = -1; /* 0=disable 1=enable */
+static int pe_enable_stdcall_fixup = -1; /* 0=disable 1=enable. */
static char *pe_out_def_filename = NULL;
static char *pe_implib_filename = NULL;
static int pe_enable_auto_image_base = 0;
\f
/* PE format extra command line options. */
-/* Used for setting flags in the PE header. */
+/* Used for setting flags in the PE header. */
#define OPTION_BASE_FILE (300 + 1)
#define OPTION_DLL (OPTION_BASE_FILE + 1)
#define OPTION_FILE_ALIGNMENT (OPTION_DLL + 1)
/* PE/WIN32; added routines to get the subsystem type, heap and/or stack
- parameters which may be input from the command line */
+ parameters which may be input from the command line. */
typedef struct
{
{ NULL, 0, 0, NULL, 0 }
};
+
static void
gld_${EMULATION_NAME}_list_options (file)
FILE * file;
#endif
}
+
static void
set_pe_name (name, val)
char *name;
long val;
{
int i;
- /* Find the name and set it. */
+
+ /* Find the name and set it. */
for (i = 0; init[i].ptr; i++)
{
if (strcmp (name, init[i].symbol) == 0)
}
-
static void
set_pe_value (name)
char *name;
optarg = end;
}
+
static void
set_pe_stack_heap (resname, comname)
char *resname;
}
-
static int
gld_${EMULATION_NAME}_parse_args (argc, argv)
int argc;
}
break;
- /* PE options */
+ /* PE options. */
case OPTION_HEAP:
set_pe_stack_heap ("__size_of_heap_reserve__", "__size_of_heap_commit__");
break;
return hash;
}
-/* Use the output file to create a image base for relocatable DLLs. */
+/* Use the output file to create a image base for relocatable DLLs. */
+
static unsigned long
compute_dll_image_base (const char *ofile)
{
gld_${EMULATION_NAME}_set_symbols ()
{
/* Run through and invent symbols for all the
- names and insert the defaults. */
+ names and insert the defaults. */
int j;
lang_statement_list_type *save;
if (link_info.relocateable)
return;
- /* Glue the assignments into the abs section */
+ /* Glue the assignments into the abs section. */
save = stat_ptr;
stat_ptr = &(abs_output_section->children);
if (j == IMAGEBASEOFF)
image_base_statement = rv;
}
- /* Restore the pointer. */
+ /* Restore the pointer. */
stat_ptr = save;
if (pe.FileAlignment >
PTR string;
{
int sl;
- sl = strlen (string); /* silence compiler warning */
+
+ sl = strlen (string); /* Silence compiler warning. */
if (h->type == bfd_link_hash_defined
&& strncmp (h->root.string, string, sl) == 0
&& h->root.string[sl] == '@')
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"),
else
{
/* The symbol is a cdecl symbol, so we look for stdcall
- symbols - which means scanning the whole symbol table */
+ 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);
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"),
{
struct bfd_link_hash_entry *undef, *sym;
+ if (link_info.pei386_auto_import == 0)
+ return;
+
for (undef = link_info.hash->undefs; undef; undef=undef->next)
{
if (undef->type == bfd_link_hash_undefined)
{
- /* C++ symbols are *long* */
+ /* C++ symbols are *long*. */
char buf[4096];
if (pe_dll_extra_pe_debug)
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;
+ bfd *b = sym->u.def.section->owner;
+ asymbol **symbols;
+ int nsyms, symsize, i;
+
+ if (link_info.pei386_auto_import == -1)
+ info_msg (_("Info: resolving %s by linking to %s (auto-import)\n"),
+ undef->root.string, buf);
+
+ 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;
}
}
}
head/tail objects, causing an improper import table. We detect
those cases and rename the "other" import libraries to match
the one the head/tail come from, so that the linker will sort
- things nicely and produce a valid import table. */
+ things nicely and produce a valid import table. */
LANG_FOR_EACH_INPUT_STATEMENT (is)
{
}
#if 0
- /* Not sure if these *should* be set */
+ /* Not sure if these *should* be set. */
if (pe_def_file->version_major != -1)
{
pe.MajorImageVersion = pe_def_file->version_major;
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) */
+ take precedence over dll's). */
sprintf (string, "%s/lib%s.a", search->name, filename);
if (! ldfile_try_open_bfd (string, entry))
{
#ifdef DLL_SUPPORT
if (pe_dll_search_prefix)
{
- /* Try "<prefix>foo.dll" (preferred dll name, if specified) */
+ /* Try "<prefix>foo.dll" (preferred dll name, if specified). */
sprintf (string, "%s/%s%s.dll", search->name, pe_dll_search_prefix, filename);
if (! ldfile_try_open_bfd (string, entry))
{
- /* Try "libfoo.dll" (default preferred dll name) */
+ /* Try "libfoo.dll" (default 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))
{
gld_${EMULATION_NAME}_get_script,
"${EMULATION_NAME}",
"${OUTPUT_FORMAT}",
- gld_${EMULATION_NAME}_finish, /* finish */
- NULL, /* create output section statements */
+ gld_${EMULATION_NAME}_finish,
+ NULL, /* Create output section statements. */
gld_${EMULATION_NAME}_open_dynamic_archive,
gld_${EMULATION_NAME}_place_orphan,
gld_${EMULATION_NAME}_set_symbols,
gld_${EMULATION_NAME}_list_options,
gld_${EMULATION_NAME}_recognized_file,
gld_${EMULATION_NAME}_find_potential_libraries,
- NULL /* new_vers_pattern */
+ NULL /* new_vers_pattern. */
};
EOF