dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-pnet-commits] CVS: pnet/ilasm ilasm_main.c,1.7,1.8 ilasm_output


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnet/ilasm ilasm_main.c,1.7,1.8 ilasm_output.c,1.13,1.14 ilasm_output.h,1.4,1.5
Date: Thu, 12 Dec 2002 02:32:12 -0500

Update of /cvsroot/dotgnu-pnet/pnet/ilasm
In directory subversions:/tmp/cvs-serv14004/ilasm

Modified Files:
        ilasm_main.c ilasm_output.c ilasm_output.h 
Log Message:


Add Microsoft command-line syntax compatibility support to "ilasm".


Index: ilasm_main.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ilasm/ilasm_main.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** ilasm_main.c        5 Oct 2002 04:25:40 -0000       1.7
--- ilasm_main.c        12 Dec 2002 07:32:10 -0000      1.8
***************
*** 87,90 ****
--- 87,109 ----
                "--help",
                "Print this help message."},
+ 
+       /* Options for compatibility with Microsoft's IL assembler */
+       {"/ali*", '?', 1, 0, 0},        /* "/alignment=integer" */
+       {"/bas*", '?', 1, 0, 0},        /* "/base=integer" */
+       {"/clo*", '?', 0, 0, 0},        /* "/clock" */
+       {"/deb*", 'g', 0, 0, 0},        /* "/debug" */
+       {"/dll", 'd', 0, 0, 0},
+       {"/exe", 'e', 0, 0, 0},
+       {"/fla*", '?', 1, 0, 0},        /* "/flags=integer" */
+       {"/key", '?', 1, 0, 0},         /* "/key:key-identifier" */
+       {"/lis*", '?', 0, 0, 0},        /* "/listing" */
+       {"/nol*", 'N', 0, 0, 0},        /* "/nologo" */
+       {"/out*", 'o', 1, 0, 0},        /* "/output:filename" */
+       {"/qui*", 'N', 0, 0, 0},        /* "/quiet" */
+       {"/res*", 'R', 1, 0, 0},        /* "/resource:filename" */
+       {"/sub*", '?', 1, 0, 0},        /* "/subsystem=integer" */
+       {"/?", 'h', 0, 0, 0},
+       {"/hel*", 'h', 0, 0, 0},        /* "/help" */
+ 
        {0, 0, 0, 0, 0}
  };
***************
*** 126,129 ****
--- 145,150 ----
        FILE *outfile;
        int flags = IL_WRITEFLAG_SUBSYS_CUI;
+       int defFormatIsExe = 0;
+       char *resourceFile = 0;
  
        /* Parse the command-line arguments */
***************
*** 299,302 ****
--- 320,344 ----
                        /* Not reached */
  
+                       case '?':
+                       {
+                               /* Compatibility option that is ignored */
+                       }
+                       break;
+ 
+                       case 'N':
+                       {
+                               /* "/nologo" or "/quiet": switch the default 
format to ".exe"
+                                  instead of ".obj", to be compatible with 
MS'es ilasm */
+                               defFormatIsExe = 1;
+                       }
+                       break;
+ 
+                       case 'R':
+                       {
+                               /* Resource file specified using 
"/resource:FILE" */
+                               resourceFile = param;
+                       }
+                       break;
+ 
                        default:
                        {
***************
*** 318,322 ****
        if(format == -1)
        {
!               format = IL_IMAGETYPE_OBJ;
                if(outputFile)
                {
--- 360,364 ----
        if(format == -1)
        {
!               format = (defFormatIsExe ? IL_IMAGETYPE_EXE : IL_IMAGETYPE_OBJ);
                if(outputFile)
                {
***************
*** 439,442 ****
--- 481,504 ----
                ++argv;
                --argc;
+       }
+ 
+       /* Process the MS compatibility resource file specification */
+       if(resourceFile)
+       {
+               if((infile = fopen(resourceFile, "rb")) == NULL)
+               {
+                       /* Try again, in case libc does not understand "rb" */
+                       infile = fopen(resourceFile, "r");
+               }
+               if(!infile)
+               {
+                       perror(resourceFile);
+                       ILAsmErrors = 1;
+               }
+               else
+               {
+                       ILAsmOutAddResource(resourceFile, infile);
+                       fclose(infile);
+               }
        }
  

Index: ilasm_output.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ilasm/ilasm_output.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -r1.13 -r1.14
*** ilasm_output.c      31 Oct 2002 14:21:02 -0000      1.13
--- ilasm_output.c      12 Dec 2002 07:32:10 -0000      1.14
***************
*** 2004,2007 ****
--- 2004,2058 ----
  }
  
+ void ILAsmOutAddResource(const char *name, FILE *stream)
+ {
+       unsigned long rva;
+       unsigned long length;
+       char buffer[BUFSIZ];
+       int len;
+       ILManifestRes *res;
+ 
+       /* Strip the directory information from the filename */
+       len = strlen(name);
+       while(len > 0 && name[len - 1] != '/' && name[len - 1] != '\\')
+       {
+               --len;
+       }
+       name += len;
+ 
+       /* Initialize the resources section */
+       ILWriterTextAlign(ILAsmWriter);
+       rva = ILWriterGetTextRVA(ILAsmWriter);
+ 
+       /* Write a place-holder for the resource length */
+       ILMemZero(buffer, 4);
+       ILWriterTextWrite(ILAsmWriter, buffer, 4);
+ 
+       /* Copy the contents of the input stream to the resource section */
+       length = 0;
+       while((len = fread(buffer, 1, BUFSIZ, stream)) > 0)
+       {
+               ILWriterTextWrite(ILAsmWriter, buffer, len);
+               length += (unsigned long)len;
+               if(len < BUFSIZ)
+               {
+                       break;
+               }
+       }
+ 
+       /* Back-patch the place-holder with the resource length */
+       ILWriterTextWrite32Bit(ILAsmWriter, rva, length);
+ 
+       /* Update the total size of the resources section */
+       ILWriterUpdateHeader(ILAsmWriter, IL_IMAGEENTRY_RESOURCES, rva,
+                                                
ILWriterGetTextRVA(ILAsmWriter) - rva);
+ 
+       /* Add a manifest resource record to the metadata */
+       res = ILManifestResCreate(ILAsmImage, 0, name, IL_META_MANIFEST_PUBLIC);
+       if(!res)
+       {
+               ILAsmOutOfMemory();
+       }
+ }
+ 
  void ILJavaAsmInitPool()
  {

Index: ilasm_output.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ilasm/ilasm_output.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** ilasm_output.h      31 Oct 2002 14:21:02 -0000      1.4
--- ilasm_output.h      12 Dec 2002 07:32:10 -0000      1.5
***************
*** 224,227 ****
--- 224,232 ----
  
  /*
+  * Output a resource stream to the image being constructed.
+  */
+ void ILAsmOutAddResource(const char *name, FILE *stream);
+ 
+ /*
   * Initialize the constant pool attached to the current class
   */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]