From cabd4ccc81f3c5bd0fb1f40306139b2cdc45b258 Mon Sep 17 00:00:00 2001 From: Danny Smith Date: Sat, 19 Mar 2005 06:48:31 +0000 Subject: [PATCH] * peicode.h (pe_ILF_build_a_bfd): Strip only one prefix character in IMPORT_NAME_UNDECORATE and IMPORT_NAME_NOPREFIX cases. Add comment. --- bfd/ChangeLog | 7 +++++++ bfd/peicode.h | 41 ++++++++++------------------------------- 2 files changed, 17 insertions(+), 31 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index de6b496745a..f528566be7e 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,10 @@ +2005-03-19 Danny Smith + Ross Ridge + + * peicode.h (pe_ILF_build_a_bfd): Strip only one prefix + character in IMPORT_NAME_UNDECORATE and IMPORT_NAME_NOPREFIX + cases. Add comment. + 2005-03-18 H.J. Lu * elflink.c (elf_mark_used_section): Remove check for special diff --git a/bfd/peicode.h b/bfd/peicode.h index 7d5f361ef91..fc9e4d6b02b 100644 --- a/bfd/peicode.h +++ b/bfd/peicode.h @@ -875,39 +875,18 @@ pe_ILF_build_a_bfd (bfd * abfd, /* If necessary, trim the import symbol name. */ symbol = symbol_name; + /* As used by MS compiler, '_', '@', and '?' are alternative + forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, + '@' used for fastcall (in C), '_' everywhere else. Only one + of these is used for a symbol. We strip this leading char for + IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the + PE COFF 6.0 spec (section 8.3, Import Name Type). */ + if (import_name_type != IMPORT_NAME) { - bfd_boolean skipped_leading_underscore = FALSE; - bfd_boolean skipped_leading_at = FALSE; - bfd_boolean skipped_leading_question_mark = FALSE; - bfd_boolean check_again; - - /* Skip any prefix in symbol_name. */ - -- symbol; - do - { - check_again = FALSE; - ++ symbol; - - switch (*symbol) - { - case '@': - if (! skipped_leading_at) - check_again = skipped_leading_at = TRUE; - break; - case '?': - if (! skipped_leading_question_mark) - check_again = skipped_leading_question_mark = TRUE; - break; - case '_': - if (! skipped_leading_underscore) - check_again = skipped_leading_underscore = TRUE; - break; - default: - break; - } - } - while (check_again); + char c = symbol[0]; + if (c == '_' || c == '@' || c == '?') + symbol++; } len = strlen (symbol); -- 2.30.2