olson@fortune.UUCP (Dave Olson) (07/11/85)
Actually, the best fix for the shared text user-mode problem is NOT to alter either the kernel loader or 'ld'. Changing ld results in (perhaps many) user programs becoming 1K larger. Loading a null function at the end has the same problem. Changing the kernel loader to allocate an extra K is a waste of memory, same as the 'ld' change. The 'correct' way to fix this is to have the bus error (Unix segmentation violation) code check to see if the error occurred on the first word after the current text segment, and ignore it if it is. (Obviously, if it's not a text segment, you just treat it normally.) You should also verify that the instruction at the end of the segment was an RTS, RTE, JMP, or BRA, etc., and only handle it specially if so. This may be overkill, the worst that could happen is that a program might appear to work correctly, if the ONLY error was the bad intruction fetch, which seems rather unlikely. Since the PC location may actually be at the 'incorrect' location on a bus-error, you have to allow for up to 5 words after the end of the segment. This same fix works for kernel mode, as well, you simply check to see if it is the last word in physical memory, and ignore the error if it is. This is much better than adding a couple of NOP's at the end of each driver that could be relocated, since the next person to write a driver might not know that they should add them. Dave Olson, Fortune Systems