More verbose output of UPX method (sys or exe) used and fix case without UPX so kernel boots.
git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@1431 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
parent
054631c300
commit
3239b3d4b0
@ -36,8 +36,10 @@ production: ../bin/$(TARGET).sys
|
|||||||
$(CP) kernel.sys ..$(DIRSEP)bin$(DIRSEP)$(TARGET).sys
|
$(CP) kernel.sys ..$(DIRSEP)bin$(DIRSEP)$(TARGET).sys
|
||||||
$(CP) kernel.map ..$(DIRSEP)bin$(DIRSEP)$(TARGET).map
|
$(CP) kernel.map ..$(DIRSEP)bin$(DIRSEP)$(TARGET).map
|
||||||
|
|
||||||
|
# -S to avoid showing expected relocations
|
||||||
|
# 0x10 & 0x74 for non-fat32 kernel, 0x10 & 0x73 for fat32 enabled kernel
|
||||||
kernel.sys: kernel.exe ../utils/exeflat.exe
|
kernel.sys: kernel.exe ../utils/exeflat.exe
|
||||||
..$(DIRSEP)utils$(DIRSEP)exeflat.exe kernel.exe kernel.sys 0x60 -S0x10 -S0x74 $(UPXOPT) $(XUPX)
|
..$(DIRSEP)utils$(DIRSEP)exeflat.exe kernel.exe kernel.sys 0x60 -S0x10 -S0x73 -S0x74 $(UPXOPT) $(XUPX)
|
||||||
|
|
||||||
kernel.exe: $(TARGET).lnk $(OBJS) $(LIBS)
|
kernel.exe: $(TARGET).lnk $(OBJS) $(LIBS)
|
||||||
$(LINK) @$(TARGET).lnk;
|
$(LINK) @$(TARGET).lnk;
|
||||||
|
@ -36,11 +36,11 @@ large portions copied from task.c
|
|||||||
|
|
||||||
/* history
|
/* history
|
||||||
|
|
||||||
10/??/01 - Bart Oldeman
|
10/??/01 - Bart Oldeman
|
||||||
primary release
|
primary release
|
||||||
|
|
||||||
11/28/01 - tom ehlert
|
11/28/01 - tom ehlert
|
||||||
added -UPX option to make the kernel compressable with UPX
|
added -UPX option to make the kernel compressable with UPX
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ static void usage(void)
|
|||||||
|
|
||||||
static int exeflat(const char *srcfile, const char *dstfile,
|
static int exeflat(const char *srcfile, const char *dstfile,
|
||||||
const char *start, short *silentSegments, short silentcount,
|
const char *start, short *silentSegments, short silentcount,
|
||||||
int flat_exe, exe_header *header)
|
int UPX, exe_header *header)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
size_t bufsize;
|
size_t bufsize;
|
||||||
@ -198,16 +198,18 @@ static int exeflat(const char *srcfile, const char *dstfile,
|
|||||||
printf("\nProcessed %d relocations, %d not shown\n",
|
printf("\nProcessed %d relocations, %d not shown\n",
|
||||||
header->exRelocItems, silentdone);
|
header->exRelocItems, silentdone);
|
||||||
|
|
||||||
/* The biggest .sys file that UPX accepts seems to be 65419 bytes long */
|
|
||||||
compress_sys_file = flat_exe && size < 65420;
|
|
||||||
|
|
||||||
if ((dest = fopen(dstfile, "wb+")) == NULL)
|
if ((dest = fopen(dstfile, "wb+")) == NULL)
|
||||||
{
|
{
|
||||||
printf("Destination file %s could not be created\n", dstfile);
|
printf("Destination file %s could not be created\n", dstfile);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flat_exe && !compress_sys_file) {
|
/* The biggest .sys file that UPX accepts seems to be 65419 bytes long */
|
||||||
|
compress_sys_file = size < 65420;
|
||||||
|
if (UPX) {
|
||||||
|
printf("Compressing kernel - %s format\n", (compress_sys_file)?"sys":"exe");
|
||||||
|
}
|
||||||
|
if (UPX && !compress_sys_file) {
|
||||||
/* write header without relocations to file */
|
/* write header without relocations to file */
|
||||||
exe_header nheader = *header;
|
exe_header nheader = *header;
|
||||||
nheader.exRelocItems = 0;
|
nheader.exRelocItems = 0;
|
||||||
@ -240,7 +242,7 @@ static int exeflat(const char *srcfile, const char *dstfile,
|
|||||||
free(*curbuf);
|
free(*curbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flat_exe && compress_sys_file) {
|
if (UPX && compress_sys_file) {
|
||||||
/* overwrite first 8 bytes with SYS header */
|
/* overwrite first 8 bytes with SYS header */
|
||||||
UWORD dhdr[4];
|
UWORD dhdr[4];
|
||||||
fseek(dest, 0, SEEK_SET);
|
fseek(dest, 0, SEEK_SET);
|
||||||
@ -336,7 +338,7 @@ int main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
short silentSegments[20], silentcount = 0;
|
short silentSegments[20], silentcount = 0;
|
||||||
static exe_header header; /* must be initialized to zero */
|
static exe_header header; /* must be initialized to zero */
|
||||||
int UPX = FALSE, flat_exe = FALSE;
|
int UPX = FALSE;
|
||||||
int i;
|
int i;
|
||||||
size_t sz, len, len2, n;
|
size_t sz, len, len2, n;
|
||||||
int compress_sys_file;
|
int compress_sys_file;
|
||||||
@ -362,9 +364,6 @@ int main(int argc, char **argv)
|
|||||||
case 'U':
|
case 'U':
|
||||||
UPX = i;
|
UPX = i;
|
||||||
break;
|
break;
|
||||||
case 'E':
|
|
||||||
flat_exe = TRUE;
|
|
||||||
break;
|
|
||||||
case 'S':
|
case 'S':
|
||||||
if (silentcount >= LENGTH(silentSegments))
|
if (silentcount >= LENGTH(silentSegments))
|
||||||
{
|
{
|
||||||
@ -372,10 +371,10 @@ int main(int argc, char **argv)
|
|||||||
LENGTH(silentSegments));
|
LENGTH(silentSegments));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
silentSegments[silentcount++] = (short)strtol(argptr + 1, NULL, 0);
|
silentSegments[silentcount++] = (short)strtol(argptr + 1, NULL, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
@ -386,8 +385,8 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
compress_sys_file = exeflat(argv[1], argv[2], argv[3],
|
compress_sys_file = exeflat(argv[1], argv[2], argv[3],
|
||||||
silentSegments, silentcount,
|
silentSegments, silentcount,
|
||||||
TRUE, &header);
|
UPX, &header);
|
||||||
if (!UPX || flat_exe)
|
if (!UPX)
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
||||||
/* move kernel.sys tmp$$$$$.exe */
|
/* move kernel.sys tmp$$$$$.exe */
|
||||||
@ -416,14 +415,14 @@ int main(int argc, char **argv)
|
|||||||
len += n;
|
len += n;
|
||||||
}
|
}
|
||||||
cmdbuf[len++] = ' ';
|
cmdbuf[len++] = ' ';
|
||||||
cmdbuf[len++] = '\'';
|
/* if tmpexe is tmpfile set above no quotes needed, if user needs quotes should add on cmd line */
|
||||||
memcpy(cmdbuf + len, tmpexe, len2);
|
memcpy(cmdbuf + len, tmpexe, len2);
|
||||||
cmdbuf[len + len2 - 1] = '\'';
|
|
||||||
cmdbuf[len + len2] = '\0';
|
cmdbuf[len + len2] = '\0';
|
||||||
printf("%s\n", cmdbuf);
|
printf("%s\n", cmdbuf);
|
||||||
if (system(cmdbuf))
|
if (system(cmdbuf))
|
||||||
{
|
{
|
||||||
printf("Problems executing %s\n", cmdbuf);
|
printf("Problems executing %s\n", cmdbuf);
|
||||||
|
printf("Removing [%s]\n", tmpexe);
|
||||||
remove(tmpexe);
|
remove(tmpexe);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user