Process relocations before compressing kernel.sys. This shaves about 130 bytes

off the compressed kernel.sys.


git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@1328 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
Bart Oldeman 2007-05-26 20:03:51 +00:00
parent ca4ea74eeb
commit ad58440395
2 changed files with 25 additions and 4 deletions

View File

@ -37,9 +37,10 @@ production: ..\bin\$(TARGET).sys
copy kernel.map ..\bin\$(TARGET).map
kernel.sys: kernel.exe ..\utils\exeflat.exe
dir kernel.exe
$(XUPX) kernel.exe
..\utils\exeflat kernel.exe kernel.sys 0x60 -S0x10 -S0x8B $(UPXOPT)
..\utils\exeflat kernel.exe kernelf.exe 0x60 -S0x10 -S0x74 -E
$(XUPX) kernelf.exe
..\utils\exeflat kernelf.exe kernel.sys 0x60 $(UPXOPT)
-$(RM) kernelf.exe
kernel.exe: $(TARGET).lnk $(OBJS) $(LIBS)
$(LINK) @$(TARGET).lnk;

View File

@ -92,7 +92,7 @@ int main(int argc, char **argv)
UBYTE **curbuf;
FILE *src, *dest;
short silentSegments[20], silentcount = 0, silentdone = 0;
int UPX = FALSE;
int UPX = FALSE, flat_exe = FALSE;
/* if no arguments provided, show usage and exit */
if (argc < 4) usage();
@ -112,6 +112,9 @@ int main(int argc, char **argv)
case 'U':
UPX = TRUE;
break;
case 'E':
flat_exe = TRUE;
break;
case 'S':
if (silentcount >= LENGTH(silentSegments))
{
@ -265,6 +268,23 @@ int main(int argc, char **argv)
fwrite(JumpBehindCode, 1, 0x20, dest);
}
if (flat_exe) {
/* write header without relocations to file */
exe_header nheader = header;
nheader.exRelocItems = 0;
nheader.exHeaderSize = 2;
size += 32;
nheader.exPages = (UWORD)(size >> 9);
nheader.exExtraBytes = (UWORD)size & 511;
if (nheader.exExtraBytes)
nheader.exPages++;
if (fwrite(&nheader, sizeof(nheader), 1, dest) != 1) {
printf("Destination file write error\n");
exit(1);
}
fseek(dest, 32UL, SEEK_SET);
}
/* write dest file from memory chunks */
bufsize = BUFSIZE;
for (to_xfer = size, curbuf = buffers; to_xfer > 0;