User Tools

Site Tools


blog:pushbx:2023:1119_mid_november_work

Mid November work

2023-11-19

This week I worked some on lDebug, its Extensions for lDebug, and on a few other projects.

Adding the E.

lDebug, lDOS boot, inicomp, instsect, and the pushbx.org/ecm/web/ page were all updated to render my name more completely, adding the initial for my first given name.

Web site update

The section for seekext received a few updates.

AMIS multiplexer lister (amitsrs)

The amitsrs program originates in Ralf Brown's AMIS libraries. I have updated it several times in the past. This week I fixed a few bugs:

Port to 8086 assembly and ELD

(I wrote about this port in an earlier blog post.)

I also ported amitsrs to an ELD of the same name. This was at first a very close recreation of the original, except I did allow it to operate as a residently installed ELD to begin with.

Later, I replaced the simple check for a nonempty command line tail by parsing for specific keywords to select which lines to additionally display. This allows to select the second line (multiplex number, version, private entry point) or the hotkeys display or the interrupt list display.

TSR changes

testhotk

A new TSR, testhotk, was added to test out the amitsrs hotkey list display.

BP process relocation change

All TSRs were updated to push BP before the termination call used for process relocation, and pop it afterwards. This means the method is less dependent on the termination preserving registers, though it does depend on the SS:SP being carried over correctly.

KEEPHOOK section fix

When KEEPHOOK was updated between 2023 March and 2023 May, a differing alignment directive presumably let the patch utility place the /J options table in the wrong section. It was placed at the end of the resident section, rather than in the transient section. This is now fixed.

The most obvious tell, which actually made me notice something was wrong, was that KEEPHOOK would install into the LMA even though no /JU switch was present and enough UMA space was free.

I did an audit of all other TSRs and the same error was not present in any of them.

It seems that the patch went wrong because the end of the transient section had a align 16, db 0 directive in KEEPHOOK, as opposed to the align 16 in all other TSRs.

lDebug

Path search ELD

The path.eld uses the filename extension warning and guessing as well as the path search originally added to the debugger's init and ports them to a residently installable ELD.

A later change, which affects the init's path search too, is to ignore directories found during the search.

The path.eld also gained subcommands to display, turn on, turn off, or toggle parts of its functionality. These correspond to the /PW, /PS, and /PE switches of init.

The shared source file pathshar.asm defines three different blocks of code, which are to be included at different points in the host program. This was chosen over placing the blocks into mmacros to preserve the excellent NASM listing output. Source code in mmacros is not listed this well. (Whitespace and comments are stripped off the macro expansion, while the macro definition doesn't get the binary opcodes the code assembles into.)

The WHILE buffer and swch1 variables had to be added to the debugger's data links to allow this ELD to work with minimal changes to the shared sources.

The linkinfo_data_as macro was added to make a data link with an alias name differing from the label whose value is actually linked.

Commas before executable pathname

MSDebug allows separators before the executable pathname that it accepts in its K and N commands, as well as on its command line. Compatibility in lDebug only extends to a single comma, however.

The K command already fully supported skipping a single comma, as the cmd4 dispatcher calls skipcomma before dispatching to the command function.

The N command in MSDebug-compatible mode would not include a leading comma in the command line tail it writes. This is fixed.

The init's command line tail invocation of the K command also did not skip a leading comma, which it will now do.

dosdrive.eld

This ELD now allows a SET QUIET command with the empty string as pathname after the keywords. It will silently not change the current drive then.

ldmem

The eldstrict mode was enabled for this ELD. This mode makes most relocation errors fail much more obviously, during build time.

The common string " segment: " is now shared for the MEM display.

There is a new display called SEG which lists only the segment values, and in PM selector values, of all sections. This makes for a much terser output than MEM, which is better if one wants to learn only the seg/sel value of a section.

The SEG display originally re-used the section names from MEM, but shorter aliases were added for some of them. The columns of the SEG display are long enough for the name but at least 5 columns wide.

amitsrs

This ELD was already described in an earlier section and in its own blog post.

FAT12 boot read fix

The FAT12 reader for EXT, Y, and BOOT DIR commands incorrectly detected the condition of a FAT entry that straddles the sector boundary, and thus did not load the second FAT sector required in that case. This randomly popped up during bootloaded testing of lCDebugX and the extname.eld.

extname.eld

This ELD provides filename extension warnings and guessing for the EXT and Y commands. The known extensions exactly match those that will be guessed. They are .ELD and .XLD for the EXT command, and .SLD for the Y command.

This ELD is more complicated than path.eld in that it needs to parse the pathname in the same way as the EXT and Y commands do, including the expansion of the configuration path keywords. Furthermore, if the extension being guessed doesn't match any file, and no path keyword was used, the ELD will next try to guess the extension with the ::scripts:: path prepended, also matching how these commands handle a missing file.

linfo.eld

This ELD displays some information on files and processes loaded using the L command.

The command handler will detect L commands. When detected, it displays the program load name and sets up both a command inject handler to be run when the L command returns to the cmd3 command loop, as well as a puts multi-purpose handler.

The puts handler passes along any messages, but is used to detect output from the L command. Messages about hooking the DPMI entry are allowlisted. Any other message output is assumed to indicate an error in the L command.

After a successful L command or on an LINFO PROBE command, the ELD will probe the file referenced by the N/K program load name buffer. It will display its file size, whether it is an MZ executable with header, and if so then the header size and image size. It will also display the PSP segment and memory block size.

Discard help messages in residently installed ELDs

Most ELDs come with help messages. When the ELD can also be installed residently, frequently the help message would balloon the length of the resident data block without need. This has been fixed by moving the install code behind the data section and conditionally shortening the data block when installing.

The history.eld already had some code in place to do just the same. The set.eld actually retains uninitialised buffers so long that the conditional shortening code in its install is not used. For a lot of ELDs however, this change brought an optimisation of their resident ELD data block sizes.

dosdir.eld

The dosdir ELD was changed to expand its ELD data block to the maximum permissible size for use as a sort buffer. This allows it to operate even if the auxiliary buffer is in use. If it is not in use, then whichever buffer is larger is used.

The ELD also gained the SORTDEBUG keyword which will display the buffer sizes and which one would be chosen if the ELD had been run without the debugging keyword. This handling can be excluded at build time with a _DEBUG=0 build option.

The dosdir.eld also gained the found flag byte from the bootdir.eld, which it uses so that dot and dotdot entries are not only excluded from display but also do not count as "files found" to prevent the "File not found" message from being displayed.

bootdir.eld

This ELD is a build option of dosdir.eld which will make it work (only) when bootloaded, using the debugger's FAT FS support. The auxiliary buffer can only be partially used as a sort buffer then, the first sector (for FAT16 and FAT32) or the first two sectors (for FAT12) must be reserved for use as FAT and directory sector buffers. Fortunately, the dosdir.eld change to allow use of the ELD data block translated directly.

Most of the directory scanning is re-used from list.eld, with a re-initialisation when looking for the sorted files in order. The scanning is very wasteful, particularly for the sorted files. The subdirectory in which the search occurs is re-detected for every sorted file. And the entire directory is searched until the end, also for each sorted file.

Subsequent changes were added. One is to move the setting of the found flag byte into the populate_finddata function. This serves to exclude matching dot and dotdot entries.

The final change yet is for sorted files to append a slash to the directory path name if it doesn't end in one. For instance, if a directory named "ldp" is present in the root directory, and the root directory is scanned using a command like ext bootdir.eld * sort then the sorted re-scan would scan for "ldp" which is misparsed as a partition specification without a pathname. Appending the slash, the re-scan will be for "/ldp" instead which has the expected result.

ELD strict mode reloc only disables reloc-abs warnings

The eldstrict mode utilises new NASM 2.16.02 warnings to detect undeclared relocations. Previously, the mode would disable the new errors entirely in the reloc and reloc2 mmacros. Now, they only disable the reloc-abs errors and retain the remaining reloc-rel errors. If there is need for using relative section-crossing relocations, macros to allow them can be added later. For now, this hardens the build of eldstrict-enabled ELDs.

Discussion

E. C. MaslochE. C. Masloch, 2023-11-19 18:32:10 +0100 Nov Sun

Linked to this blog entry from the NASM bug tracker issue in which I requested the relocation warnings: https://bugzilla.nasm.us/show_bug.cgi?id=3392571#c19

Full text of the comment:

By the way, since this has been added to the NASM 2.16.02 branch I have found another use for these new warnings: The eldstrict mode for my Extensions for lDebug (ELDs) requires to mark all relocations with either the reloc or reloc2 mmacros. It uses the reloc-abs warnings to flag all unmarked relocations as errors during build time. (The reloc-rel warnings are always enabled for all sources of the debugger.)

This is needed because I am (mis)using NASM's multi-section -f bin output format to create the ELDs, which are "position-independent" in that an ELD's data section and code section must be loaded at a dynamically-chosen offset each. Each ELD carries a linker which runs first thing when the ELD is loaded and fixes up all the relocations.

So internal relocations need to be marked by "internaldatarelocation" or "internalcoderelocation" afterwards. External relocations to the debugger host program's variables are marked by "linkdatarelocation" macros instead, and the unlinked relocations refer to "relocateddata" which is in an empty nobits section. External relocations to the debugger's functions are done using several more macros, "extcall" and "extcallcall".

The eldstrict mode is mentioned on my blog: https://pushbx.org/ecm/dokuwiki/blog/pushbx/2023/1119_mid_november_work#eld_strict_mode_reloc_only_disables_reloc-abs_warnings

Here's the macro file implementing the eldstrict mode: https://hg.pushbx.org/ecm/ldebug/file/0b8b44f1088a/source/eld/eldcheck.mac

You could leave a comment if you were logged in.
blog/pushbx/2023/1119_mid_november_work.txt · Last modified: 2023-11-19 17:42:55 +0100 Nov Sun by ecm