From: sandmann AT clio DOT rice DOT edu (Charles Sandmann) Message-Id: <10211292332.AA12905@clio.rice.edu> Subject: Re: DXE enhancements To: muller AT cerbere DOT u-strasbg DOT fr (Pierre Muller) Date: Fri, 29 Nov 2002 17:32:22 -0600 (CST) Cc: djgpp-workers AT delorie DOT com (DJGPP developers) In-Reply-To: <5.0.2.1.2.20021129103942.0323ebe8@ics.u-strasbg.fr> from "Pierre Muller" at Nov 29, 2002 11:26:17 AM X-Mailer: ELM [version 2.5 PL2] Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp-workers AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp-workers AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk > Yes, sorry, but I tried to patch the dxegen.c that is on CVS tree, but the > patch failed at places... Here's the updated dxegen patch, should be versus the right dxegen.c now. I've fixed a few minor things, made it a little simpler. At the bottom, below the patch, are 3 files which I was using for testing. The imports stuff is behaving pretty well - I'm going to look at multiple symbol exports now. There are some simple utilities to be added (such as dxe2dxi) which will look at a DXE and make what you need to link to it. I'm waiting on this piece, since doing multiple exports may just include that in the same piece. The final step is to consider making pieces of libc an optional DXE, which will require some cleanup (breaking up) of some of our mega-modules. *** dxegen.c Fri Nov 29 10:58:00 2002 --- dxegen5.c Fri Nov 29 16:11:46 2002 *************** int main(int argc, char **argv) *** 71,74 **** --- 71,87 ---- size_t i; dxe_header dh; + int num_import, num_export = 0; + long *import_symndx = NULL; + char **import_name = NULL; + + if (argc >= 2 && strcmp(argv[1], "-i") == 0) + { + argv++; + argc--; + num_import = 0; /* New option to allow imports */ + import_name = malloc(sizeof(char *)); + } + else + num_import = -1; /* No imports allowed */ if (argc < 4) *************** int main(int argc, char **argv) *** 89,93 **** if (fh.f_nscns != 1 || argc > 4) { ! char command[1024], *libdir; fclose(input_f); --- 102,109 ---- if (fh.f_nscns != 1 || argc > 4) { ! char *command, *libdir; ! unsigned cmdmax = 1024; ! command = (char *)malloc(cmdmax); ! fclose(input_f); *************** int main(int argc, char **argv) *** 115,127 **** for(i=3;argv[i];i++) { strcat(command, argv[i]); strcat(command, " "); } strcat(command," -T dxe.ld "); ! printf("%s\n",command); i = system(command); if(i) return i; input_f = fopen("dxe__tmp.o", "rb"); --- 131,153 ---- for(i=3;argv[i];i++) { + if(strlen(command) + strlen(argv[i]) + 2 > cmdmax) { + cmdmax += 1024; + command = realloc(command, cmdmax); + } strcat(command, argv[i]); strcat(command, " "); } + + if(strlen(command) + 12 > cmdmax) { + cmdmax += 12; + command = realloc(command, cmdmax); + } strcat(command," -T dxe.ld "); ! printf("%s\n",command); i = system(command); if(i) return i; + free(command); input_f = fopen("dxe__tmp.o", "rb"); *************** int main(int argc, char **argv) *** 161,164 **** --- 187,203 ---- strings = malloc(strsz); fread(strings+4, 1, strsz-4, input_f); + + relocs = malloc(sizeof(RELOC)*sc.s_nreloc); + fseek(input_f, sc.s_relptr, 0); + fread(relocs, sc.s_nreloc, RELSZ, input_f); + #if 0 + /* Don't swap - it's in i386 order already */ + for (i=0; i 0) + { + for (i=0; i .dxi */ + output_f = fopen(argv[1], "w"); + if (!output_f) + { + perror(argv[1]); + return 1; + } + + fprintf(output_f, "static long dxefixup[] = {\n"); + for (i=0; i #include extern int dxeocount; int dxeicount; char *dxesub(void) { char *t; t = malloc(1); printf("malloc(1)=%p\n",t); dxeicount++; dxeocount++; *t=dxeicount; printf("leaving dxesub\n"); return t; } dxemain.c ----------------------------------------------------------------- #include #include #include static char* (*dxesub)(void); int dxeocount; extern long *_dxe_fixup; #include "dxesub.dxi" /* Created by dxegen -i (contains dxefixup) */ int main(void) { char *t; int i; printf("loading dxesub.dxe...\n"); _dxe_fixup = &dxefixup[0]; dxesub = _dxe_load("dxesub.dxe"); if (dxesub == 0) { printf("Cannot load dxesub.dxe\n"); return 1; } for(i=0;i<5;i++) { t = dxesub(); printf("return[%d] = %d, cnt = %d\n",i,t[0],dxeocount++); } return 0; }