dlm@cuuxb.ATT.COM (Dennis L. Mumaugh) (05/25/88)
In article <1988May6.165741.633@utzoo.uucp> henry@utzoo.uucp (Henry Spencer) writes: >> >Actually, no. The a.out header was not part of the actual core image, so >> >the first instruction of the program was first; >> >> Was this always so? > >Perhaps not. It can't be a coincidence that the magic number is a branch >around the rest of the header. This may have been aimed at things like >standalone diagnostics rather than normal Unix programs, though. I know >that it wasn't in the core image in V7 or V6, and I'm fairly sure that it >wasn't in V5, but that's as far back as my experience goes. Dennis? The magic number was used in the V6 and V7 bootstraps. The bootstrap looked it its first word and if it was 407 then copied itself over the a.out header. It could do so because the assembly lagnuage was written as PIC -- position independent code -- which was easy to do on a PDP-11. The kernel for V6 and V7 loaded an executable by reading in the first ##n words and using them. Thus no unix program had the 407 in its address space. In V6 for loading /unix there was no need to remove the 407 because the bootstrap loader did the removal by the same code as it removed its own 407 header. In V7 the standalone boot loader mimiced UNIX and ignored it. BTW the V6 boot loader didn't stop with the program but also loaded the relocation information and the symbol table; this would trash the loader for /unix with too many drivers or symbols. V7 used the a.out header and didn't load symbols and relocation. As for the origin of 407 it IS a br .+10. and was designed for just that purpose: to jump over the header. But it worked ONLY on PIC. I can't recall when Ken or Dennis said it stopped being used in executables. -- =Dennis L. Mumaugh Lisle, IL ...!{ihnp4,cbosgd,lll-crg}!cuuxb!dlm
henry@utzoo.uucp (Henry Spencer) (05/27/88)
> The magic number was used in the V6 and V7 bootstraps... > ...no unix program had the 407 in its address space... > I can't recall when Ken or Dennis said it stopped being > used in executables. I got private mail from DMR during the earlier discussion of this. He said, as I recall, that the 407 was in the address space in the very beginning of Unix on the 11. However, it vanished quite early, possibly at the time of the assembler-to-C rewrite. (He wasn't sure of the exact timing either.) It did linger for quite a while in bootstraps. > The bootstrap looked it its first word and if it was 407 then copied > itself over the a.out header... Not quite correct for V7, although it may have been for V6. The V7 boots check whether they are in low core, and copy themselves to high core if so. They do inspect the first word for a 407 first, but only to determine where the copying should start from (they skip the header if it's there). -- "For perfect safety... sit on a fence| Henry Spencer @ U of Toronto Zoology and watch the birds." --Wilbur Wright| {ihnp4,decvax,uunet!mnetor}!utzoo!henry
jfh@rpp386.UUCP (John F. Haugh II) (05/29/88)
[ speaking of the 0407 magic numbers and bootstraps at the same time ] i don't recall this to be the case around about system iii. i hacked on the bootstrap for the pdp/11 (11/44) and all it did was check the inode for execute permission, then load the sucker and move it by something like 020 bytes. [ after relocating itself to 0160000 if i remember correctly. ] then, it did clr r0 jmp (r0) to start unix, if i recall correctly (i remember thinking not doing a clr r7 was stupid, so i am pretty sure about the transfer code.) - john. -- John F. Haugh II | "If you aren't part of the solution, River Parishes Programming | you are part of the precipitate." UUCP: ihnp4!killer!rpp386!jfh | -- long since forgot who DOMAIN: jfh@rpp386.uucp |