Alexandre Julliard : winebuild: Add a -ordinal flag for entry points that must be imported by ordinal but exported by name .

Alexandre Julliard julliard at winehq.org
Fri Oct 26 08:34:42 CDT 2007


Module: wine
Branch: master
Commit: 324331121435cfbc43d36cfe8616ef9d098810ba
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=324331121435cfbc43d36cfe8616ef9d098810ba

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Fri Oct 26 12:47:40 2007 +0200

winebuild: Add a -ordinal flag for entry points that must be imported by ordinal but exported by name.

---

 tools/winebuild/build.h          |    7 ++++---
 tools/winebuild/parser.c         |   21 ++++++++++++++++-----
 tools/winebuild/spec32.c         |    2 +-
 tools/winebuild/winebuild.man.in |    7 ++++++-
 4 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/tools/winebuild/build.h b/tools/winebuild/build.h
index 5668271..85309ad 100644
--- a/tools/winebuild/build.h
+++ b/tools/winebuild/build.h
@@ -124,15 +124,16 @@ extern enum target_platform target_platform;
 
 /* entry point flags */
 #define FLAG_NORELAY   0x01  /* don't use relay debugging for this function */
-#define FLAG_NONAME    0x02  /* don't import function by name */
+#define FLAG_NONAME    0x02  /* don't export function by name */
 #define FLAG_RET16     0x04  /* function returns a 16-bit value */
 #define FLAG_RET64     0x08  /* function returns a 64-bit value */
 #define FLAG_I386      0x10  /* function is i386 only */
 #define FLAG_REGISTER  0x20  /* use register calling convention */
 #define FLAG_PRIVATE   0x40  /* function is private (cannot be imported) */
+#define FLAG_ORDINAL   0x80  /* function should be imported by ordinal */
 
-#define FLAG_FORWARD   0x80  /* function is a forwarded name */
-#define FLAG_EXT_LINK  0x100 /* function links to an external symbol */
+#define FLAG_FORWARD   0x100  /* function is a forwarded name */
+#define FLAG_EXT_LINK  0x200  /* function links to an external symbol */
 
 #define MAX_ORDINALS  65535
 
diff --git a/tools/winebuild/parser.c b/tools/winebuild/parser.c
index 9246fd2..bcbf951 100644
--- a/tools/winebuild/parser.c
+++ b/tools/winebuild/parser.c
@@ -70,6 +70,7 @@ static const char * const FlagNames[] =
     "i386",        /* FLAG_I386 */
     "register",    /* FLAG_REGISTER */
     "private",     /* FLAG_PRIVATE */
+    "ordinal",     /* FLAG_ORDINAL */
     NULL
 };
 
@@ -545,11 +546,14 @@ static int parse_spec_ordinal( int ordinal, DLLSPEC *spec )
         }
     }
 
-    if (!strcmp( odp->name, "@" ) || odp->flags & FLAG_NONAME)
+    if (!strcmp( odp->name, "@" ) || odp->flags & (FLAG_NONAME | FLAG_ORDINAL))
     {
         if (ordinal == -1)
         {
-            error( "Nameless function needs an explicit ordinal number\n" );
+            if (!strcmp( odp->name, "@" ))
+                error( "Nameless function needs an explicit ordinal number\n" );
+            else
+                error( "Function imported by ordinal needs an explicit ordinal number\n" );
             goto error;
         }
         if (spec->type != SPEC_WIN32)
@@ -557,9 +561,16 @@ static int parse_spec_ordinal( int ordinal, DLLSPEC *spec )
             error( "Nameless functions not supported for Win16\n" );
             goto error;
         }
-        if (!strcmp( odp->name, "@" )) free( odp->name );
-        else odp->export_name = odp->name;
-        odp->name = NULL;
+        if (!strcmp( odp->name, "@" ))
+        {
+            free( odp->name );
+            odp->name = NULL;
+        }
+        else if (!(odp->flags & FLAG_ORDINAL))  /* -ordinal only affects the import library */
+        {
+            odp->export_name = odp->name;
+            odp->name = NULL;
+        }
     }
     return 1;
 
diff --git a/tools/winebuild/spec32.c b/tools/winebuild/spec32.c
index 26e66b8..8df5b85 100644
--- a/tools/winebuild/spec32.c
+++ b/tools/winebuild/spec32.c
@@ -552,7 +552,7 @@ void BuildDef32File( DLLSPEC *spec )
             assert(0);
         }
         output( " @%d", odp->ordinal );
-        if (!odp->name) output( " NONAME" );
+        if (!odp->name || (odp->flags & FLAG_ORDINAL)) output( " NONAME" );
         if (is_data) output( " DATA" );
         if (odp->flags & FLAG_PRIVATE) output( " PRIVATE" );
         output( "\n" );
diff --git a/tools/winebuild/winebuild.man.in b/tools/winebuild/winebuild.man.in
index 87f47f8..d135968 100644
--- a/tools/winebuild/winebuild.man.in
+++ b/tools/winebuild/winebuild.man.in
@@ -260,7 +260,8 @@ The entry point is not displayed in relay debugging traces (Win32
 only).
 .TP
 .B -noname
-The entry point will be imported by ordinal instead of by name.
+The entry point will be exported by ordinal instead of by name. The
+name is still available for importing.
 .TP
 .B -ret16
 The function returns a 16-bit value (Win16 only).
@@ -277,6 +278,10 @@ The function uses CPU register to pass arguments.
 .B -private
 The function cannot be imported from other dlls, it can only be
 accessed through GetProcAddress.
+.TP
+.B -ordinal
+The entry point will be imported by ordinal instead of by name. The
+name is still exported.
 .SS "Function ordinals"
 Syntax:
 .br




More information about the wine-cvs mailing list