This shows you the differences between two versions of the page.
— |
blog:pushbx:2023:0221_ldebugx_dual_code_bug_tsr_checks_allegory_symbol_relocations [2023-02-21 15:41:42 +0100 Feb Tue] (current) ecm created |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== lDebugX dual code bug, TSR checks, Allegory symbol relocations ====== | ||
+ | |||
+ | **2023-02-13** | ||
+ | |||
+ | ===== Bug in lDebugX symbolic (dual code) init ===== | ||
+ | |||
+ | Yesterday during testing of the fix for the '' | ||
+ | |||
+ | They didn't work fine. | ||
+ | |||
+ | Right away the debugger emitted a message about a stack overflow, noting that a certain magic word signature was a mismatch. Further, the debugger didn't execute commands as intended and spewed forth a lot of random messages whenever I attempted to enter anything. I had to kill the dosemu2 process as I wasn't able to return control to the outer lCDebugX. (It may have worked if I had previously installed the timer interrupt handler and switched to serial I/O, then entered a double Control-C to the serial terminal. Albeit, the outer debugger cannot terminate the inner debugger without the latter' | ||
+ | |||
+ | I repeated the attempt, and this time continued tracing the entire initialisation. I didn't notice anything obviously wrong, but when I ran the '' | ||
+ | |||
+ | I repeated the run again, this time giving a repeated trace with a '' | ||
+ | |||
+ | Turns out, I had swapped '' | ||
+ | |||
+ | Now why didn't I notice this earlier? Simple: In the lCDebugX symbolic build I was running, there were precisely zero patches to apply to the second code segment in case of running on a 386 or higher machine. So it didn't matter that the patch function got the wrong target segment, because it didn't write anything. The same was not true for patches to apply on a non-386 machine. | ||
+ | |||
+ | Luckily, I tested the case of running this build on what it detects as a non-386 and the failure was very obvious. This bug could have bitten us much further down the line eventually. | ||
+ | |||
+ | |||
+ | ===== TSR init checks ===== | ||
+ | |||
+ | **2023-02-14** | ||
+ | |||
+ | As the Pofo tests showed, our TSRs depend on some features such as that the interrupt vectors 2Dh and 2Fh are valid and can be called. There is also an 8-byte test that is intended to test for an MS-DOS version 2 or higher level system, by calling interrupt 21h service 4Dh with CY and expecting it to return NC. (This test used to fail on DOSBox and DOSBox-X.) | ||
+ | |||
+ | It would be good to expand the existing check and add two for the interrupt vectors, with somewhat verbose error messages indicating what the problem is. The interrupt vector check could suggest to install the inst2d2f program so as to fix the handlers to allow the TSRs to go on. | ||
+ | |||
+ | Another thing that may need fixing is the PSP relocation. It doesn' | ||
+ | |||
+ | |||
+ | ===== Relocations to support in Allegory ===== | ||
+ | |||
+ | **2023-02-17** | ||
+ | |||
+ | Allegory, the code name for lDebug symbolic, is supposed to support symbol relocation to mirror code or data being relocated. This is needed to implement nontrivial programs. Examples include: | ||
+ | |||
+ | * Our TSRs relocating their process to free the original process memory block (multi-section relocation) | ||
+ | * Our TSRs installing their resident to an allocated memory block (single-section relocation) | ||
+ | * The TSRs free their transient (section deletion) while the resident stays installed | ||
+ | * Debugger relocates its init section higher | ||
+ | * Debugger relocates its code section(s) to final location | ||
+ | * The bootloaded initial loader may relocate in order to fit yet-to-be-loaded parts of its payload in available memory | ||
+ | * Compressed debugger/ | ||
+ | * Compression depacker writes decompressed payload (section creation) | ||
+ | * Debugger or kernel discards init sections one by one | ||
+ | * Kernel may relocate DOSCODE multiple times, to LMA top, then to LMA bottom, UMA, or HMA (I believe this is called HMATEXT for the FreeDOS kernel) | ||
+ | * Bootloaded or device driver debugger relocates its data/entry section | ||
+ | * Debugger creates space for its DATASTACK (nobits) section, then starts initialising and using it | ||
+ | * Bootloaded debugger may relocate multiple times for everything to end up at desired location (init, relocator paragraph, whole load image with prepended init, placement of data entry tables section and code section(s)) | ||
+ | |||
+ | |||
+ | |||
+ | {{tag> | ||
+ | |||
+ | |||
+ | ~~DISCUSSION~~ | ||