Hi Tom,

sbrk is a little deceiving here since it just administrates a
high-water mark and does not allocate memory from DOS:
old:
https://github.com/tkchia/newlib-ia16/blob/e7c08882834a41d848698a19deae49089c2dab17/libgloss/ia16/dos-sbrk.c
which only returned NULL if heap ptr went beyond 64K (the libc for
ia16-elf-gcc started very bare bones in this respect!)

new (just changed by TK Chia)
https://github.com/tkchia/newlib-ia16/blob/newlib-2_4_0-ia16-tkchia/libgloss/ia16/dos-sbrk.c
malloc returns NULL when the end of the heap is reached but this is
not always checked properly in freecom, but at least it does not grow
into the stack any more.

One could easily swap heap and stack in ia16-elf-gcc though I think we
would just see different memory corruption, stack can then go corrupt
other data or even code.

(that still leaves Turbo C which also grows heap to stack.. and of
course protected mode OSes do it but with virtual memory protection
they
never get close to each other, and this is what can make small mode
DOS debugging extra hard).

Bart


_______________________________________________
Freedos-devel mailing list
Freedos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-devel

Reply via email to