* pe-dll.c : Fix typo.

(autofilter_symbolprefixlist) : Remove __imp_.
  (is_import) : New.
  (auto-export) : Remove  re-import check. Moved to callers.
  (process_def_file) : Check is symbol is an import. Always underscore __imp_.
  Only skip underscore on underscored targets.
  (make_one) : Always underscore __imp_.
  (pe_create_runtime_relocator_reference) : Only underscore _pei386_runtime_relocator on underscored targets.
  (pe_process_import_defs) : Always underscore __imp_.
* pe.em (U) : New macro.
  (set_pe_subsystem) : Remove underscore from _WinMainCRTStartup on wince subsystem case.
  (pe_find_data_imports) : Use U on "_head_".
  (gld_${EMULATION_NAME}_unrecognized_file) : Use U.
This commit is contained in:
Nick Clifton 2006-10-03 10:06:26 +00:00
parent 9f1bed8bb1
commit 00479ba8f9
3 changed files with 50 additions and 22 deletions

View File

@ -1,3 +1,22 @@
2006-10-03 Pedro Alves <pedro_alves@portugalmail.pt>
* pe-dll.c : Fix typo.
(autofilter_symbolprefixlist) : Remove __imp_.
(is_import) : New.
(auto-export) : Remove re-import check. Moved to callers.
(process_def_file) : Check is symbol is an import. Always
underscore __imp_.
Only skip underscore on underscored targets.
(make_one) : Always underscore __imp_.
(pe_create_runtime_relocator_reference) : Only underscore
_pei386_runtime_relocator on underscored targets.
(pe_process_import_defs) : Always underscore __imp_.
* pe.em (U) : New macro.
(set_pe_subsystem) : Remove underscore from _WinMainCRTStartup
on wince subsystem case.
(pe_find_data_imports) : Use U on "_head_".
(gld_${EMULATION_NAME}_unrecognized_file) : Use U.
2006-09-26 H.J. Lu <hongjiu.lu@intel.com>
PR ld/3223

View File

@ -115,6 +115,7 @@ cat >>e${EMULATION_NAME}.c <<EOF
#define PE_DEF_FILE_ALIGNMENT 0x00000200
#endif
#define U(S) ${INITIAL_SYMBOL_CHAR} S
static struct internal_extra_pe_aouthdr pe;
static int dll;
@ -400,7 +401,7 @@ set_pe_subsystem (void)
{ "windows", 2, "WinMainCRTStartup" },
{ "console", 3, "mainCRTStartup" },
{ "posix", 7, "__PosixProcessStartup"},
{ "wince", 9, "_WinMainCRTStartup" },
{ "wince", 9, "WinMainCRTStartup" },
{ "xbox", 14, "mainCRTStartup" },
{ NULL, 0, NULL }
};
@ -925,14 +926,14 @@ pe_find_data_imports (void)
for (i = 0; i < nsyms; i++)
{
if (! CONST_STRNEQ (symbols[i]->name, "__head_"))
if (! CONST_STRNEQ (symbols[i]->name, U ("_head_")))
continue;
if (pe_dll_extra_pe_debug)
printf ("->%s\n", symbols[i]->name);
pe_data_import_dll = (char*) (symbols[i]->name +
sizeof ("__head_") - 1);
sizeof (U ("_head_")) - 1);
break;
}
@ -1342,7 +1343,7 @@ gld_${EMULATION_NAME}_unrecognized_file (lang_input_statement_type *entry ATTRIB
{
struct bfd_link_hash_entry *h;
sprintf (buf, "_%s", pe_def_file->exports[i].internal_name);
sprintf (buf, "%s%s", U (""), 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)

View File

@ -123,7 +123,7 @@
(so, DLL name is referenced by multiple entries), and pointer to symbol
name thunk. Symbol name thunk is singleton vector (__nm_th_<symbol>)
pointing to IMAGE_IMPORT_BY_NAME structure (__nm_<symbol>) directly
containing imported name. Here comes that "om the edge" problem mentioned
containing imported name. Here comes that "on the edge" problem mentioned
above: PE specification rambles that name vector (OriginalFirstThunk)
should run in parallel with addresses vector (FirstThunk), i.e. that they
should have same number of elements and terminated with zero. We violate
@ -331,12 +331,13 @@ static autofilter_entry_type autofilter_objlist[] =
static autofilter_entry_type autofilter_symbolprefixlist[] =
{
{ STRING_COMMA_LEN ("__imp_") },
/* Do __imp_ explicitly to save time. */
/* _imp_ is treated specially, as it is always underscored. */
/* { STRING_COMMA_LEN ("_imp_") }, */
/* Don't export some c++ symbols. */
{ STRING_COMMA_LEN ("__rtti_") },
{ STRING_COMMA_LEN ("__builtin_") },
/* Don't re-export auto-imported symbols. */
{ STRING_COMMA_LEN ("_nm_") },
{ STRING_COMMA_LEN ("__builtin_") },
/* Don't export symbols specifying internal DLL layout. */
{ STRING_COMMA_LEN ("_head_") },
{ STRING_COMMA_LEN (NULL) }
@ -445,6 +446,11 @@ pe_dll_add_excludes (const char *new_excludes, const int type)
free (local_copy);
}
static bfd_boolean
is_import (const char* n)
{
return (CONST_STRNEQ (n, "__imp_"));
}
/* abfd is a bfd containing n (or NULL)
It can be used for contextual checks. */
@ -459,10 +465,6 @@ auto_export (bfd *abfd, def_file *d, const char *n)
if (abfd && abfd->my_archive)
libname = lbasename (abfd->my_archive->filename);
/* We should not re-export imported stuff. */
if (CONST_STRNEQ (n, "_imp_"))
return 0;
for (i = 0; i < d->num_exports; i++)
if (strcmp (d->exports[i].name, n) == 0)
return 0;
@ -617,8 +619,11 @@ process_def_file (bfd *abfd ATTRIBUTE_UNUSED, struct bfd_link_info *info)
/* We should not re-export imported stuff. */
{
char *name = xmalloc (strlen (sn) + 2 + 6);
sprintf (name, "%s%s", U("_imp_"), sn);
if (is_import (sn))
continue;
char *name = xmalloc (strlen ("__imp_") + strlen (sn) + 1);
sprintf (name, "%s%s", "__imp_", sn);
blhe = bfd_link_hash_lookup (info->hash, name,
FALSE, FALSE, FALSE);
@ -628,7 +633,7 @@ process_def_file (bfd *abfd ATTRIBUTE_UNUSED, struct bfd_link_info *info)
continue;
}
if (*sn == '_')
if (pe_details->underscored && *sn == '_')
sn++;
if (auto_export (b, pe_def_file, sn))
@ -674,6 +679,9 @@ process_def_file (bfd *abfd ATTRIBUTE_UNUSED, struct bfd_link_info *info)
{
for (i = 0; i < NE; i++)
{
if (is_import (pe_def_file->exports[i].name))
continue;
if (strchr (pe_def_file->exports[i].name, '@'))
{
int lead_at = (*pe_def_file->exports[i].name == '@');
@ -1918,7 +1926,7 @@ make_one (def_file_export *exp, bfd *parent)
BSF_GLOBAL, 0);
if (! exp->flag_data)
quick_symbol (abfd, "", exp->internal_name, "", tx, BSF_GLOBAL, 0);
quick_symbol (abfd, U ("_imp_"), exp->internal_name, "", id5,
quick_symbol (abfd, "__imp_", exp->internal_name, "", id5,
BSF_GLOBAL, 0);
/* Fastcall applies only to functions,
so no need for auto-import symbol. */
@ -1930,12 +1938,12 @@ make_one (def_file_export *exp, bfd *parent)
if (! exp->flag_data)
quick_symbol (abfd, U (""), exp->internal_name, "", tx,
BSF_GLOBAL, 0);
quick_symbol (abfd, U ("_imp__"), exp->internal_name, "", id5,
quick_symbol (abfd, "__imp_", U (""), 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,
quick_symbol (abfd, U ("_nm_"), U (""), exp->internal_name, id6,
BSF_GLOBAL,0);
}
if (pe_dll_compat_implib)
@ -2259,7 +2267,7 @@ pe_create_runtime_relocator_reference (bfd *parent)
symtab = xmalloc (2 * sizeof (asymbol *));
extern_rt_rel = quick_section (abfd, ".rdata", SEC_HAS_CONTENTS, 2);
quick_symbol (abfd, "", "__pei386_runtime_relocator", "", UNDSEC,
quick_symbol (abfd, "", U ("_pei386_runtime_relocator"), "", UNDSEC,
BSF_NO_FLAGS, 0);
bfd_set_section_size (abfd, extern_rt_rel, 4);
@ -2460,7 +2468,7 @@ pe_process_import_defs (bfd *output_bfd, struct bfd_link_info *link_info)
char *name = xmalloc (len + 2 + 6);
if (lead_at)
sprintf (name, "%s%s", "",
sprintf (name, "%s",
pe_def_file->imports[i].internal_name);
else
sprintf (name, "%s%s",U (""),
@ -2472,10 +2480,10 @@ pe_process_import_defs (bfd *output_bfd, struct bfd_link_info *link_info)
if (!blhe || (blhe && blhe->type != bfd_link_hash_undefined))
{
if (lead_at)
sprintf (name, "%s%s", U ("_imp_"),
sprintf (name, "%s%s", "__imp_",
pe_def_file->imports[i].internal_name);
else
sprintf (name, "%s%s", U ("_imp__"),
sprintf (name, "%s%s%s", "__imp_", U (""),
pe_def_file->imports[i].internal_name);
blhe = bfd_link_hash_lookup (link_info->hash, name,