commit e7a073b8699c74f2e9c025078fb275323711a8e1
parent 67b8fdb86aedb707c973b5f8849f2bf2304a1e0a
Author: Ryan Sepassi <rsepassi@gmail.com>
Date: Sun, 3 May 2026 19:28:36 -0700
hex2pp.P1: fix BSS arena overlap on >1 MiB inputs
The cumulative-offset hex literals for output_buf / text_buf / labels
had the high digit in the wrong byte position, so they decoded as ~1/2/3
MiB offsets instead of the intended 16/144/152 MiB. input_buf (sized for
16 MiB) overlapped output_buf, and pass 2's emit_byte clobbered the
unread tail of input as it wrote — surfacing as "byte stream: incomplete
digits" once the scanner read freshly-emitted output bytes. Inputs ≤1 MiB
fit before the overlap and were unaffected.
Unblocks the tcc-boot2 link (combined.M1pp ~4.6 MiB).
Diffstat:
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/hex2pp/hex2pp.P1 b/hex2pp/hex2pp.P1
@@ -77,10 +77,14 @@ DEFINE H2_OFF_other_buf 4021000000000000
DEFINE H2_OFF_pat_buf 4031000000000000
DEFINE H2_OFF_ev_bytes 4041000000000000
DEFINE H2_OFF_df_byte 5041000000000000
+## input_buf: 0x004200 + 16 MiB
+## output_buf: 0x1004200 + 128 MiB
+## text_buf: 0x9004200 + 8 MiB
+## labels: 0x9804200 + 32 MiB (end at ~184 MiB; ELF p_memsz is 512 MiB).
DEFINE H2_OFF_input_buf 0042000000000000
-DEFINE H2_OFF_output_buf 0042100000000000
-DEFINE H2_OFF_text_buf 0042200000000000
-DEFINE H2_OFF_labels 0042300000000000
+DEFINE H2_OFF_output_buf 0042000100000000
+DEFINE H2_OFF_text_buf 0042000900000000
+DEFINE H2_OFF_labels 0042800900000000
## --- p1_main: argv parse -> load input -> two passes -> write -> exit ------