This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [Patch]: Fastcall support



DJ Delorie <dj@delorie.com> wrote:


>
> +      p = strchr (name+1, '@');
> +      if (p && (p != name))
>
> p *can't* be == name at this point.

Yes, you're absolutely right. The modification below does exactly the same.

+      p = strchr (name+1, '@');
+      if (p)


> -         iname->name = make_label ("__imp_", exp->name);
> +         iname->name = make_label ("___imp", exp->name);
> ...
> -      iname2->name = make_label ("_imp__", exp->name);
> +      iname2->name = make_label ("__imp_", exp->name);
>
> Please explain why these are needed, in greater detail.  Such a change
> makes new versions incompatible with old versions.  Which is right,
> and how can it be proven right?
>
These are needed to create MSVC compatible import libraries. An MSVC
compatible fastcall import label looks like this: __imp_@MyFunction@12.
Without the modifications above the label would be @_imp__MyFunction@12.

 Any import library label must consist of the following parts:
    - import label prefix (__imp_)
    - optional calling convention prefix ('_', '@', '?')
    - label name
    - optional calling convention postfix ('@XX')

The previous order was:
    - optional calling convention prefix ('_', '@', '?')
    - import label prefix (_imp__)
    - label name
    - optional calling convention postfix ('@XX')

The prefix order is changed by the following modification:
-  int len = strlen (ASM_PREFIX) + strlen (prefix) + strlen (name);
-  char *copy = xmalloc (len +1 );
-  strcpy (copy, ASM_PREFIX);
-  strcat (copy, prefix);
-  strcat (copy, name);
-  return copy;
+  int len;
+  char *copy;
+
+  if (name[0] == '@')
+    {
+      len = strlen (prefix) + strlen (name);
+      copy = xmalloc (len + 1);
+      strcpy (copy, prefix);
+      strcat (copy, name);
+    }
+  else
+    {
+      len = strlen (ASM_PREFIX) + strlen (prefix) + strlen (name);
+      copy = xmalloc (len + 1);
+      strcpy (copy, prefix);
+      strcat (copy, ASM_PREFIX);
+      strcat (copy, name);
+    }

To ensure that the stdcall import labels are compatible with the MSVC labels
and the old implementation, I had to change the import label prefixes.

I hope this answers your questions.

Regards,
Eric Kohl


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]