aboutsummaryrefslogtreecommitdiff
path: root/ld/emultempl/pe.em
diff options
context:
space:
mode:
authorKai Tietz <kai.tietz@onevision.com>2009-11-15 07:52:45 +0000
committerKai Tietz <kai.tietz@onevision.com>2009-11-15 07:52:45 +0000
commit8a9eab9b5ee88bda4d83a237e3a3c0723530a51e (patch)
tree75ee2031c97719adc6fd7cb6001988d9b5b06937 /ld/emultempl/pe.em
parent213fc0adc404177897e213e99b8f231dd10d9ead (diff)
downloadgdb-8a9eab9b5ee88bda4d83a237e3a3c0723530a51e.zip
gdb-8a9eab9b5ee88bda4d83a237e3a3c0723530a51e.tar.gz
gdb-8a9eab9b5ee88bda4d83a237e3a3c0723530a51e.tar.bz2
2009-11-15 Kai Tietz <kai.tietz@onevision.com>
* pe-dll.c (pe_undef_alias_cdecl_match): New function. (pe_find_cdecl_alias_match): New function. (pe_process_import_defs): Add matching for import symbols declared as cdecl for fastcall/stdcall. * emultempl/pe.em (pe_undef_cdecl_match): Treat fastcall symbols, too. (pe_fixup_stdcalls): Likewise. (gld_XXX_after_open): Redo scanning for imported fastcall/stdcall symbols as cdecl one. * emultempl/pep.em (pep_undef_cdecl_match): Treat fastcall symbols, too. (pep_fixup_stdcalls): Likewise. (gld_XXX_after_open): Redo scanning for imported fastcall/stdcall symbols as cdecl one. 2009-11-15 Kai Tietz <kai.tietz@onevision.com> * ld-pe/direct2_client.c: New file. * ld-pe/direct2_dll.c: Likewise. * ld-pe/direct2_dll.def: Likewise. * ld-pe/pe-run2.exp: Likewise.
Diffstat (limited to 'ld/emultempl/pe.em')
-rw-r--r--ld/emultempl/pe.em23
1 files changed, 18 insertions, 5 deletions
diff --git a/ld/emultempl/pe.em b/ld/emultempl/pe.em
index 4326e7e..b936199 100644
--- a/ld/emultempl/pe.em
+++ b/ld/emultempl/pe.em
@@ -942,10 +942,13 @@ pe_undef_cdecl_match (struct bfd_link_hash_entry *h, void *inf)
{
int sl;
char *string = inf;
+ const char *hs = h->root.string;
sl = strlen (string);
if (h->type == bfd_link_hash_defined
- && strncmp (h->root.string, string, sl) == 0
+ && ((*hs == '@' && *string == '_'
+ && strncmp (hs + 1, string + 1, sl - 1) == 0)
+ || strncmp (hs, string, sl) == 0)
&& h->root.string[sl] == '@')
{
pe_undef_found_sym = h;
@@ -968,15 +971,20 @@ pe_fixup_stdcalls (void)
{
char* at = strchr (undef->root.string, '@');
int lead_at = (*undef->root.string == '@');
- /* For now, don't try to fixup fastcall symbols. */
+ if (lead_at)
+ at = strchr (undef->root.string + 1, '@');
- if (at && !lead_at)
+ 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 */);
+ char *cname = xstrdup (undef->root.string);
+
+ if (lead_at)
+ *cname = '_';
at = strchr (cname, '@');
- *at = 0;
+ if (at)
+ *at = 0;
sym = bfd_link_hash_lookup (link_info.hash, cname, 0, 0, 1);
if (sym && sym->type == bfd_link_hash_defined)
@@ -1212,6 +1220,11 @@ gld_${EMULATION_NAME}_after_open (void)
pe_find_data_imports ();
+ /* As possibly new symbols are added by imports, we rerun
+ stdcall/fastcall fixup here. */
+ if (pe_enable_stdcall_fixup) /* -1=warn or 1=disable */
+ pe_fixup_stdcalls ();
+
#if defined (TARGET_IS_i386pe) \
|| defined (TARGET_IS_armpe) \
|| defined (TARGET_IS_arm_epoc_pe) \