diff options
author | Kai Tietz <kai.tietz@onevision.com> | 2009-11-15 07:52:45 +0000 |
---|---|---|
committer | Kai Tietz <kai.tietz@onevision.com> | 2009-11-15 07:52:45 +0000 |
commit | 8a9eab9b5ee88bda4d83a237e3a3c0723530a51e (patch) | |
tree | 75ee2031c97719adc6fd7cb6001988d9b5b06937 /ld/emultempl | |
parent | 213fc0adc404177897e213e99b8f231dd10d9ead (diff) | |
download | gdb-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')
-rw-r--r-- | ld/emultempl/pe.em | 23 | ||||
-rw-r--r-- | ld/emultempl/pep.em | 24 |
2 files changed, 36 insertions, 11 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) \ diff --git a/ld/emultempl/pep.em b/ld/emultempl/pep.em index a7ea8e1..753f425 100644 --- a/ld/emultempl/pep.em +++ b/ld/emultempl/pep.em @@ -871,10 +871,13 @@ pep_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] == '@') { pep_undef_found_sym = h; @@ -897,15 +900,19 @@ pep_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 (at && !lead_at) + if (lead_at) + at = strchr (undef->root.string + 1, '@'); + 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) @@ -1179,6 +1186,11 @@ gld_${EMULATION_NAME}_after_open (void) pep_find_data_imports (); + /* As possibly new symbols are added by imports, we rerun + stdcall/fastcall fixup here. */ + if (pep_enable_stdcall_fixup) /* -1=warn or 1=disable */ + pep_fixup_stdcalls (); + #ifndef TARGET_IS_i386pep if (link_info.shared) #else |