mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-04 00:40:27 +00:00
Stop APE bare metal loader from reading beyond program image end (#574)
This allows e.g. `qemu-system-x86_64 -s o/examples/hello.com -serial stdio` to work without having to add extra padding to the end of the `hello.com` "disk image". (The sector count computation is divided among two instructions in the assembly code. This is done on purpose, to prevent an ASCII 0x27 (single quote) byte from appearing in the bare metal loader code, which will break the shell script loader. There is probably a better way.) Co-authored-by: tkchia <tkchia-cosmo@gmx.com>
This commit is contained in:
parent
9c017c98d3
commit
8569704c1d
2 changed files with 5 additions and 0 deletions
|
@ -563,6 +563,9 @@ SHSTUB2(ape_loader_dd_count,
|
|||
HIDDEN(v_ape_realsectors =
|
||||
MIN(0x70000 - IMAGE_BASE_REAL,
|
||||
ROUNDUP(RVA(_edata), 4096)) / 512);
|
||||
HIDDEN(v_ape_realslacksectors =
|
||||
v_ape_realsectors - MIN(0x70000 - IMAGE_BASE_REAL,
|
||||
ROUNDUP(RVA(_edata), 512)) / 512);
|
||||
HIDDEN(v_ape_realpages = v_ape_realsectors / (4096 / 512));
|
||||
HIDDEN(v_ape_highsectors =
|
||||
(ROUNDUP(RVA(_edata), 512) / 512) - v_ape_realsectors);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue