<ytm@elysium.pl>
VII 2000
- VI 2002
+ VI,VII 2002
(read Building process below). VLIR structure is currently supported only for
project written entirely in assembler.
+grc can be also used as a handy VLIR linker used to build VLIR-structured .cvt
+file out of prepared binary chains.
+
2. Usage
--------
-l name name ld65 output file
-h help
+when used as VLIR linker the correct syntax is:
+ grc -vlir output.cvt header.bin vlir0.bin vlir1.bin...
+
Default output names are made from input name with extension replaced by '.h'
and '.s'. grc will not overwrite existing files unless forced to do so.
This is to avoid situation where you have test.c and test.grc files. Both would
The names between brackets are names of binaries containing code for each VLIR
part. They matter only for generated ld65 configuration file and will be the
names of resulting binary files after linking. Each one will contain one VLIR
-chain and they will have to be put together into VLIR .cvt by vlink utility in
-correct order.
+chain and they will have to be put together into VLIR .cvt by grc in VLIR linker
+modey in correct order.
The 'headname' will be the name for binary which will contain only GEOS .cvt
header made out of compiling .s header file generated also by grc.
At the end of resulting ld65 config file (.cfg) in comments there will be
is important this time. As suggested in comments at the end of cvthead.cfg
we do:
-$ vlink output.cvt vlir-head.bin vlir-0.bin vlir-1.bin vlir-2.bin
+$ grc -vlir output.cvt vlir-head.bin vlir-0.bin vlir-1.bin vlir-2.bin
This is the end. The file 'output.cvt' can be unconverted under GEOS.
Note that the switch '-t geos' wasn't present at any stage of this process.
exit (EXIT_FAILURE);
}
+
+void VLIRLinker(int argc, char *argv[]) {
+FILE *outCVT, *input;
+unsigned char buffer[BLOODY_BIG_BUFFER];
+unsigned char vlirtabt[127];
+unsigned char vlirtabs[127];
+int i,j;
+size_t bytes;
+int blocks,rest;
+
+ i=2;
+
+ /* check if we know enough */
+
+ if (argc<4)
+ Error("too less arguments, required [out] [cvthead] [vlir0] ...\n");
+
+ /* first open and copy CVT header */
+
+ outCVT = fopen(argv[i],"wb+");
+ if (outCVT==NULL)
+ Error("can't open output\n");
+
+ ++i;
+ input = fopen(argv[i],"rb");
+ if (input==NULL)
+ Error("can't open input:%s\n",strerror(errno));
+
+ bytes = fread(buffer,1,BLOODY_BIG_BUFFER,input);
+ fclose(input);
+ if (bytes!=508)
+ Error("%s is not a cvt header\n",argv[i]);
+
+ fwrite(buffer,1,bytes,outCVT);
+
+ /* now put 254 bytes of VLIR table, to update later */
+
+ /* clear out things */
+ memset(buffer,0,254);
+ fwrite(buffer,1,254,outCVT);
+ for (j=0;j!=126;j++) {
+ vlirtabt[j]=0;
+ vlirtabs[j]=0;
+ }
+
+ /* now read all VLIR chains, aligned to 254 bytes */
+
+ ++i;
+ j=0;
+ while (i!=argc) {
+ if (strcmp(argv[i],"blank")==0) {
+ vlirtabt[j]=0; vlirtabs[j]=0; }
+ else if (strcmp(argv[i],"noexist")==0) {
+ vlirtabt[j]=0; vlirtabs[j]=0xff; }
+ else {
+ memset(buffer,0,BLOODY_BIG_BUFFER);
+ input = fopen(argv[i],"rb");
+ if (input==NULL)
+ Error("couldn't open %s:%s\n",argv[i],strerror(errno));
+ bytes = fread(buffer,1,BLOODY_BIG_BUFFER,input);
+ fclose(input);
+ if (bytes<0)
+ Error("couldn't read %s:%s\n",argv[i],strerror(errno));
+ blocks = bytes / 254;
+ rest = bytes % 254 + 2;
+ if (rest>255) rest=255;
+ vlirtabt[j]=blocks+1; vlirtabs[j]=rest;
+ fwrite(buffer,1,(blocks+1)*254,outCVT);
+ }
+ ++j;
+ ++i;
+ }
+
+ /* now rewind and update VLIR table */
+
+ fflush(outCVT);
+ fseek(outCVT,508,SEEK_SET);
+ for (i=0;i!=127;i++) {
+ fputc(vlirtabt[i],outCVT);
+ fputc(vlirtabs[i],outCVT);
+ }
+ fclose(outCVT);
+ exit(EXIT_SUCCESS);
+}
+
void printCHeader (void) {
fprintf(outputCFile, "\n/*\n\tThis file was generated by GEOS Resource Compiler\n"
"\n#\tDO NOT EDIT! Any changes will be lost!\n#"
"\n#\tEdit proper resource file instead\n#"
"\n#\tLook at end of this file to find commandline that must be used\n"
- "#\tto invoke ld65 and vlink\n#"
+ "#\tto invoke ld65 and grc (as VLIR linker)\n#"
"\n#\n\n");
}
"\t-f\t\tforce writting files\n"
"\t-o name\t\tname C output file\n"
"\t-s name\t\tname asm output file\n"
- "\t-l name\t\tname ld65 config output file (for vlir)\n",
- progName);
+ "\t-l name\t\tname ld65 config output file (for vlir)\n"
+ "Or as VLIR linker: %s -vlir output.cvt header [vlir0] ... [blank] ... [vlir_n]\n",
+ progName,progName);
}
/* now put usage info */
fprintf(outputVFile,"\n# ld65 -o output.cvt -C %s file1.o file2.o ...",outputVName);
- fprintf(outputVFile,"\n# vlink outputname %s",headname);
+ fprintf(outputVFile,"\n# grc -vlir outputname %s",headname);
for (i=1;i<=numchains;i++) {
fprintf(outputVFile," %s",vlirtable[i].chainname);
}
printUsage();
exit (EXIT_SUCCESS);
break;
+ case 'v':
+ if (strcmp(arg,"-vlir")==0) {
+ VLIRLinker(argc,argv);
+ exit (EXIT_SUCCESS);
+ break;
+ } else {
+ Error("unknown option %s\n",arg);
+ break;
+ }
default: Error("unknown option %s\n",arg);
}
} else {