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]
Other format: [Raw text]

Patch of dlltool for enhanced dll-stub creation@rsl-sie.de


Hi,

I created a patch for dlltool.c that allows all Win32-DLL users to use a DEF file with EXPORTS of the form

external_name = internal_name

and the created archive contains an export with "external_name" but it'll call the DLL function "internal_name".

We needed this because we had to use a 3rd party DLL that contains __stdcall functions *without* the @n at the end of the names ...

Best regards,

Mark Junker
RSL SIE GmbH

--- binutils-2.15.90-20040222-1/binutils/dlltool.c	Sun Feb 22 03:25:50 2004
+++ binutils-patched/binutils/dlltool.c	Mon May 17 15:08:16 2004
@@ -359,6 +359,7 @@
 static int add_indirect = 0;
 static int add_underscore = 0;
 static int dontdeltemps = 0;
+static int map_to_internal_name = 0;
 
 /* TRUE if we should export all symbols.  Otherwise, we only export
    symbols listed in .drectve sections or in the def file.  */
@@ -2475,11 +2476,11 @@
                      why it did that, and it does not match what I see
                      in programs compiled with the MS tools.  */
 		  int idx = exp->hint;
-		  si->size = strlen (xlate (exp->name)) + 3;
+                  si->size = strlen (xlate (map_to_internal_name ? exp->internal_name : exp->name)) + 3;
 		  si->data = xmalloc (si->size);
 		  si->data[0] = idx & 0xff;
 		  si->data[1] = idx >> 8;
-		  strcpy (si->data + 2, xlate (exp->name));
+		  strcpy (si->data + 2, xlate (map_to_internal_name ? exp->internal_name : exp->name));
 		}
 	      break;
 	    case IDATA7:
@@ -3130,6 +3131,7 @@
   fprintf (file, _("   -S --as <name>            Use <name> for assembler.\n"));
   fprintf (file, _("   -f --as-flags <flags>     Pass <flags> to the assembler.\n"));
   fprintf (file, _("   -C --compat-implib        Create backward compatible import library.\n"));
+  fprintf (file, _("   -i --internal-name        Maps external to internal name\n"));
   fprintf (file, _("   -n --no-delete            Keep temp files (repeat for extra preservation).\n"));
   fprintf (file, _("   -t --temp-prefix <prefix> Use <prefix> to construct temp file names.\n"));
   fprintf (file, _("   -v --verbose              Be verbose.\n"));
@@ -3176,6 +3178,7 @@
   {"as-flags", required_argument, NULL, 'f'},
   {"mcore-elf", required_argument, NULL, 'M'},
   {"compat-implib", no_argument, NULL, 'C'},
+  {"internal-name", no_argument, NULL, 'i'},
   {"temp-prefix", required_argument, NULL, 't'},
   {NULL,0,NULL,0}
 };
@@ -3202,9 +3205,9 @@
 
   while ((c = getopt_long (ac, av,
 #ifdef DLLTOOL_MCORE_ELF
-			   "m:e:l:aD:d:z:b:xcCuUkAS:f:nvVHhM:L:F:",
+			   "m:e:l:aD:d:z:b:xcCiuUkAS:f:nvVHhM:L:F:",
 #else
-			   "m:e:l:aD:d:z:b:xcCuUkAS:f:nvVHh",
+			   "m:e:l:aD:d:z:b:xcCiuUkAS:f:nvVHh",
 #endif
 			   long_options, 0))
 	 != EOF)
@@ -3306,6 +3309,9 @@
 #endif
 	case 'C':
 	  create_compat_implib = 1;
+	  break;
+	case 'i':
+	  map_to_internal_name = 1;
 	  break;
 	default:
 	  usage (stderr, 1);

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