aboutsummaryrefslogtreecommitdiff
path: root/ld/pe-dll.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2006-10-03 10:06:26 +0000
committerNick Clifton <nickc@redhat.com>2006-10-03 10:06:26 +0000
commit00479ba8f9cd7f2ba84c6c3304987afcb4f109b8 (patch)
tree3990d1c557eba956aed6188aeae444a8cb82e95e /ld/pe-dll.c
parent9f1bed8bb1e87c140fa1980ce9e6c5f64021657c (diff)
downloadgdb-00479ba8f9cd7f2ba84c6c3304987afcb4f109b8.zip
gdb-00479ba8f9cd7f2ba84c6c3304987afcb4f109b8.tar.gz
gdb-00479ba8f9cd7f2ba84c6c3304987afcb4f109b8.tar.bz2
* 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.
Diffstat (limited to 'ld/pe-dll.c')
-rw-r--r--ld/pe-dll.c44
1 files changed, 26 insertions, 18 deletions
diff --git a/ld/pe-dll.c b/ld/pe-dll.c
index 994af14..a308c94 100644
--- a/ld/pe-dll.c
+++ b/ld/pe-dll.c
@@ -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,