Mail Archives: djgpp-workers/1996/06/23/18:16:37
On 23/6/96 9:00 pm, Eli Zaretskii <eliz AT is DOT elta DOT co DOT il> did thus say >>>
> > After a look at the specs I suspect this is because gcc calls stubify
> > after ld created the COFF image. Is this true ?
>
> I doubt it, unless your image is very large indeed. Stubify is usually
> very fast compared to ld.exe. But you can see how much time each of the
> programs takes by adding -v to the gcc command line and looking at your
> watch when gcc prints the programs it invokes.
Stubify is fairly fast, but I managed to more than double it's speed (with
caching completly disabled: 1.6M file went from 21 seconds to stubify to 8 (32k
trasnfer buffer) on my 386 33 at home (timed using redir -t)). I kept it
compatable with non djgpp compilers using #ifdef __DJGPP__. Below are the diffs
(-c):
Hope this can be of use (until BFD learns stubs:)
Bill
-----------------------cut-------------------------------------------------
*** old/stubify.c Sun Nov 5 22:32:32 1995
--- stubify.c Sun Jun 23 19:13:36 1996
***************
*** 6,11 ****
--- 6,18 ----
#include <string.h>
#ifdef __DJGPP__
#include <io.h>
+ #include <unistd.h>
+ #include <libc/dosio.h>
+ #include <go32.h>
+ #include <dpmi.h>
+ #include <errno.h>
+
+ #define tbsize _go32_info_block.size_of_transfer_buffer
#endif
#ifndef O_BINARY
***************
*** 143,156 ****
--- 150,200 ----
write(ofile, stub_bytes, sizeof(stub_bytes));
+ #ifdef __DJGPP__
+ /* if 0 bytes are read (or an error occurs, the loop will be broken from */
+ while (1) {
+ __dpmi_regs r;
+ int wb;
+ /* bypass the normal read routine to avoid the unnecessary copying of the
+ * file contents into extended memory (the data is not actually being
+ * used, only copied from one file to another, and so easy access from gcc
+ * compiled code is not needed).
+ */
+ r.x.ax = 0x3f00; /* dos read from file handle function */
+ r.x.bx = ifile;
+ r.x.cx = tbsize; /* number of bytes to read */
+ r.x.dx = __tb & 15; /* transfer buffer offset */
+ r.x.ds = __tb / 16; /* transfer buffer segment */
+ __dpmi_int(0x21, &r);
+ if (r.x.flags & 1)
+ errno = __doserr_to_errno(r.x.ax);
+ if ((rbytes=(r.x.flags & 1) ? -1 : r.x.ax) <= 0)
+ break;
+ #else
while ((rbytes=read(ifile, buf, 4096)) > 0)
{
int wb;
+ #endif
if (drop_last_four_bytes && rbytes < 4096)
rbytes -= 4;
+ #ifdef __DJGPP__
+ /* bypass the normal write routine to avoid the unnecessary copying of the
+ * file contents from extended memory.
+ */
+ r.x.ax = 0x4000; /* dos write to file handle function */
+ r.x.bx = ofile;
+ r.x.cx = rbytes; /* number of bytes to write */
+ r.x.dx = __tb & 15; /* transfer buffer offset */
+ r.x.ds = __tb / 16; /* transfer buffer segment */
+ __dpmi_int(0x21, &r);
+ wb = (r.x.flags & 1) ? -1 : r.x.ax;
+ if (r.x.flags & 1)
+ errno = __doserr_to_errno(r.x.ax);
+ #else
wb = write(ofile, buf, rbytes);
+ #endif
if (wb < 0)
{
perror(ofname);
***************
*** 227,233 ****
{
printf("Cannot open output file to generate\n");
perror(ofilename);
! return;
}
v_printf("stubify: generate %s\n", argv[2]);
--- 271,277 ----
{
printf("Cannot open output file to generate\n");
perror(ofilename);
! return 1;
}
v_printf("stubify: generate %s\n", argv[2]);
- Raw text -