New kernel compression methods (Announce)
Hello ecm,
> By the way, you can put a FreeDOS kernel (better to use an uncompressed one
> then) into ldosboot's
> fdkernpl stage, then can use that payload for inicomp. You'd use _IMAGE_EXE=0
> then because the FreeDOS kernel cannot be entered as an .EXE file. However,
> the FreeDOS kernel entrypoint (and the lDOS/RxDOS and PC-DOS/MS-DOS
> 6/MS-DOS 7 kernel entrypoints) would still work. The only thing that that
> does not support is the kernel CONFIG section expected fixed at the start
> of the file by FreeDOS's kernel configuration (which is part of the FreeDOS
> SYS program).
Thanks! I guess I will need to look at the lzd.asm code --- and, if necessary, the fdkernpl.asm code --- to see how to stitch everything together.
> Funny, I don't actually know how much UPX would compress things. So I made
> a test. I had to patch out the short jump in the "last page size" bytes of
> the EXE header. (These are used for the MS-DOS 6.x and FreeDOS kernel
> entrypoints.) The invalid value of the short jump instruction in that field
> otherwise leads to "CantPackException: exe header corrupted". (Obviously,
> packing the kernel file with UPX without special handling makes it no
> longer work as a kernel file.)
Not sure which short jump you are referring to --- care to elaborate?
Also, you might already know this --- but the magic for invoking UPX, converting the .exe to .sys, and adding (a second copy of) the CONFIG structure, is pretty much all in utils/exeflat.c in the kernel source tree. So the workflow is roughly like this:
{uncompressed .exe kernel}
|
v
flatten, but keep a .exe header around
|
v
compress with UPX
|
v
flatten, remove .exe header
|
v
wrap compressed kernel with stub code and CONFIG structure
|
v
{compressed .sys kernel}
The first "flattening" pass basically resolves the .exe relocations (since the kernel is known to go to 0x60:0) and removes the relocation entries. A second "flattening" pass is needed to resolve the relocations introduced by UPX itself.
I guess it will be interesting to see if UPX can be replaced with some other compressor (that also supports .exe files).
Thank you!
---
https://gitlab.com/tkchia · https://codeberg.org/tkchia · 😴 "MOV AX,0D500H+CMOS_REG_D+NMI"
Complete thread:
- New kernel compression methods - ecm, 13.04.2020, 00:05 (Announce)
- New kernel compression methods - ecm, 13.04.2020, 00:17
- New kernel compression methods - tkchia, 13.04.2020, 14:23
- New kernel compression methods - ecm, 13.04.2020, 18:31
- New kernel compression methods - ecm, 13.04.2020, 18:35
- New kernel compression methods - tkchia, 14.04.2020, 14:46
- New kernel compression methods - fdkernpl - ecm, 14.04.2020, 17:05
- New kernel compression methods - exeExtraBytes jump - ecm, 14.04.2020, 17:06
- New kernel compression methods - tom, 14.04.2020, 20:06
- New kernel compression methods - ecm, 13.04.2020, 18:31
- New kernel compression methods - Updated lDebug lzd results - ecm, 16.04.2020, 17:29
- New kernel compression methods - Corrections - ecm, 16.04.2020, 22:06
- New kernel compression methods - X compressor layers - ecm, 16.04.2020, 22:22
- New kernel compression methods - Updated lzd, new lzo - ecm, 25.04.2020, 22:23
- New kernel compression methods - Updated lzd, new lzo - tom, 26.04.2020, 13:46
- New kernel compression methods - UPX, 512 runs clarification - ecm, 26.04.2020, 20:17
- New kernel compression methods - Updated lzd, new lzo - tom, 26.04.2020, 13:46