* peicode.h (pe_ILF_build_a_bfd): Strip only one prefix
authorDanny Smith <dannysmith@users.sourceforge.net>
Sat, 19 Mar 2005 06:48:31 +0000 (06:48 +0000)
committerDanny Smith <dannysmith@users.sourceforge.net>
Sat, 19 Mar 2005 06:48:31 +0000 (06:48 +0000)
character in IMPORT_NAME_UNDECORATE and IMPORT_NAME_NOPREFIX
cases.  Add comment.

bfd/ChangeLog
bfd/peicode.h

index de6b496..f528566 100644 (file)
@@ -1,3 +1,10 @@
+2005-03-19  Danny Smith <dannysmith@users.sourceforge.net>
+           Ross Ridge  <rridge@csclub.uwaterloo.ca>
+
+       * 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  <hongjiu.lu@intel.com>
 
        * elflink.c (elf_mark_used_section): Remove check for special
index 7d5f361..fc9e4d6 100644 (file)
@@ -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);