sking@nowhere.uucp (Steven King) (03/12/91)
TFM page for a.out defines two magic numbers 0410 & 0413 for executables, and describes the difference as: "A magic number of 0410 indicates thats the executable must be swapped through the private swapping store of the UNIX system, while the magic number of 0413 causes the system to attempt to page the text directly from the a.out file". While I think I understand what the difference is, I don't understand why the difference. Is there any advantage to one over the other? How does one, short of directly editing the binary, assign one or the other? ( the link editor doesn't offer any clues ) -- Look Ma! No .sig! ..!cs.utexas.edu!ut-emx!nowhere!sking
jik@athena.mit.edu (Jonathan I. Kamens) (03/12/91)
In article <1991Mar12.012401.557@nowhere.uucp>, sking@nowhere.uucp (Steven King) writes: |> "A magic number of 0410 indicates thats the executable must |> be swapped through the private swapping store of the UNIX system, |> while the magic number of 0413 causes the system to attempt to |> page the text directly from the a.out file". |> |> While I think I understand what the difference is, I don't understand |> why the difference. Is there any advantage to one over the other? How |> does one, short of directly editing the binary, assign one or the other? |> ( the link editor doesn't offer any clues ) Well, if you're installing a binary on an NFS server that lots of machines are going to be using, you probably want the machines using it to copy the binary into local swap space, because of the performance gain that will result. If, on the other hand, you're installing a binary on a local disk, then you won't get any gain by copying the file into swap space, since that'll just be another local disk (and me even be an NFS swap partition, which would be worse). My ld(1) claims that "-z" causes 0413 to be used, and that's the default, while "-n" causes 0410 to be used. -- Jonathan Kamens USnail: MIT Project Athena 11 Ashford Terrace jik@Athena.MIT.EDU Allston, MA 02134 Office: 617-253-8085 Home: 617-782-0710
sef@kithrup.COM (Sean Eric Fagan) (03/12/91)
In article <1991Mar12.012401.557@nowhere.uucp> sking@nowhere.uucp (Steven King) writes: > While I think I understand what the difference is, I don't understand > why the difference. Is there any advantage to one over the other? How > does one, short of directly editing the binary, assign one or the other? > ( the link editor doesn't offer any clues ) At one point, the linker would just willy-nilly put things back to back. For example, text might end at 0x1231, and data would then begin at 0x1232. When paging, you do *not* want to use old data. Therefore, if you want to page directly from disk, you arrange things such that everything is in a decent arrangement (which is what your kernel would do for you when it swapped pages to the swap device). At least, that's how I understand it. -- Sean Eric Fagan | "I made the universe, but please don't blame me for it; sef@kithrup.COM | I had a bellyache at the time." -----------------+ -- The Turtle (Stephen King, _It_) Any opinions expressed are my own, and generally unpopular with others.
martin@adpplz.UUCP (Martin Golding) (03/14/91)
In <1991Mar12.104352.23097@kithrup.COM> sef@kithrup.COM (Sean Eric Fagan) writes: >In article <1991Mar12.012401.557@nowhere.uucp> sking@nowhere.uucp (Steven King) writes: >> While I think I understand what the difference is, I don't understand >> why the difference. Is there any advantage to one over the other? How >> does one, short of directly editing the binary, assign one or the other? >> ( the link editor doesn't offer any clues ) >At one point, the linker would just willy-nilly put things back to back. >For example, text might end at 0x1231, and data would then begin at 0x1232. >When paging, you do *not* want to use old data. Therefore, if you want to >page directly from disk, you arrange things such that everything is in a >decent arrangement (which is what your kernel would do for you when it >swapped pages to the swap device). In the very bad old days, PDP 11's had two ways to map memory: one combined the data and program in a single 64k segment, and one had separate (64k) data and program spaces. Given the addressing modes, the difference between data and program accesses were a study in themselves. My impression is that the (original) version of the Magic Number was the actual value to load into the PDP 11 MMU control register, to select one or the other model. Martin Golding | sync, sync, sync, sank ... sunk: Dod #0236 | He who steals my code steals trash. {mcspdx,pdxgate}!adpplz!martin or martin@adpplz.uucp
dyson@cbnewsk.att.com (john.s.dyson) (03/14/91)
In article <573@adpplz.UUCP>, martin@adpplz.UUCP (Martin Golding) writes: > In <1991Mar12.104352.23097@kithrup.COM> sef@kithrup.COM (Sean Eric Fagan) writes: > > >In article <1991Mar12.012401.557@nowhere.uucp> sking@nowhere.uucp (Steven King) writes: > >> While I think I understand what the difference is, I don't understand > >> why the difference. Is there any advantage to one over the other? How > >> does one, short of directly editing the binary, assign one or the other? > >> ( the link editor doesn't offer any clues ) > > >At one point, the linker would just willy-nilly put things back to back. > >For example, text might end at 0x1231, and data would then begin at 0x1232. > >When paging, you do *not* want to use old data. Therefore, if you want to > >page directly from disk, you arrange things such that everything is in a > >decent arrangement (which is what your kernel would do for you when it > >swapped pages to the swap device). > > My impression is that the (original) version of the Magic Number was > the actual value to load into the PDP 11 MMU control register, to select > one or the other model. > > Martin Golding | sync, sync, sync, sank ... sunk: > Dod #0236 | He who steals my code steals trash. > {mcspdx,pdxgate}!adpplz!martin or martin@adpplz.uucp My memory is sometimes foggy, but I think that the magic number was the branch instruction around some header info in the a.out?????? John Dyson inuxy.att.com
gwyn@smoke.brl.mil (Doug Gwyn) (03/15/91)
In article <573@adpplz.UUCP> martin@adpplz.UUCP (Martin Golding) writes: >My impression is that the (original) version of the Magic Number was >the actual value to load into the PDP 11 MMU control register, to select >one or the other model. No, not at all. The original a.out magic number was a PDP-11 branch-always instruction that jumped around the a.out header, so an a.out could be executed directly, as in a boot block or standalone diagnostic program.
jfw@ksr.com (John F. Woods) (03/15/91)
martin@adpplz.UUCP (Martin Golding) writes: >In the very bad old days, PDP 11's had two ways to map memory: one >combined the data and program in a single 64k segment, and one had >separate (64k) data and program spaces. Given the addressing modes, >the difference between data and program accesses were a study in themselves. >My impression is that the (original) version of the Magic Number was >the actual value to load into the PDP 11 MMU control register, to select >one or the other model. Bzzt! But thanks for playing the game! The Original Magic Number, 0407, is a PDP-11 branch instruction, whose span is just enough to jump around the header information. This made it easy to build and run standalone programs -- as long as they were position independant (piece of cake on the 11) you just load the UNIX object file into memory and start at 0 (or whereever). This executable type contained contiguous text and data, just like you'd want on a PDP-11/20. The Second Original Magic Number, 0410, stood for a sharable object (data began at an 8K page boundary, so the text could be a bunch of shared, readonly pages), and was chosen because it was (tada!) one greater than 0407. Note that the header was exactly the same size. The Third Original Magic Number, 0411, stood for separate I&D; how it was chosen is left to the reader as an exercise. While we're on PDP-11 trivia: my favorite instruction was mov -(r7),-(r7) for obvious reasons.
boyd@necisa.ho.necisa.oz.au (Boyd Roberts) (03/15/91)
In article <573@adpplz.UUCP> martin@adpplz.UUCP (Martin Golding) writes: >My impression is that the (original) version of the Magic Number was >the actual value to load into the PDP 11 MMU control register, to select >one or the other model. > The original 0407 magic number was the PDP-11 instruction to branch over the a.out header of the executable. Back then the a.out header was loaded into core with the executable code and data. The other magic numbers were just arbitrarily assigned as new a.out formats evolved. Chris or Doug or Henry will correct me if I'm wrong on this point :-) Boyd Roberts boyd@necisa.ho.necisa.oz.au ``When the going gets wierd, the weird turn pro...''
terryl@sail.LABS.TEK.COM (03/21/91)
In article <1991Mar14.043302.3567@cbnewsk.att.com> dyson@cbnewsk.att.com (john.s.dyson) writes: >In article <573@adpplz.UUCP>, martin@adpplz.UUCP (Martin Golding) writes: >> In <1991Mar12.104352.23097@kithrup.COM> sef@kithrup.COM (Sean Eric Fagan) writes: >> >> My impression is that the (original) version of the Magic Number was >> the actual value to load into the PDP 11 MMU control register, to select >> one or the other model. > >My memory is sometimes foggy, but I think that the magic number was >the branch instruction around some header info in the a.out?????? Pulling out my trusty (but VERY dusty!!! (-:) PDP11 Processor handbook, the original a.out magic number 0407 (that's octal, folks!!!) says it is an unconditional branch to seven words (i.e. 14 bytes) past the current PC; thus, the original a.out magic number was chosen to branch around the a.out header, since the header is 16 bytes long..... __________________________________________________________ Terry Laskodi "There's a permanent crease of in your right and wrong." Tektronix Sly and the Family Stone, "Stand!" __________________________________________________________
martin@adpplz.UUCP (Martin Golding) (03/26/91)
In <9166@sail.LABS.TEK.COM> terryl@sail.LABS.TEK.COM writes: >>In article <573@adpplz.UUCP>, martin@adpplz.UUCP I wrote: >>> My impression is that the (original) version of the Magic Number was >>> the actual value to load into the PDP 11 MMU control register, to select >>> one or the other model. Which was, of course, nonsense. <:-( and dyson@cbnewsk.att.com (john.s.dyson) was about the hundredth person to say > Pulling out my trusty (but VERY dusty!!! (-:) PDP11 Processor handbook, >the original a.out magic number 0407 (that's octal, folks!!!) says it is >an unconditional branch to seven words (i.e. 14 bytes) past the current PC; OK! OK! I screwed up! I promise never to answer a question again without having the hardware manual in hand, all right? Just let this damn thing die a natural death. Unless you like torturing the mentally incompetent... Martin Golding | sync, sync, sync, sank ... sunk: Dod #0236 | He who steals my code steals trash. A Poor old decrepit Pick(tm) programmer ... Sympathize at: {mcspdx,pdxgate}!adpplz!martin or martin@adpplz.uucp
rbj@uunet.UU.NET (Root Boy Jim) (03/26/91)
In article <573@adpplz.UUCP> martin@adpplz.UUCP (Martin Golding) writes: > >In the very bad old days, PDP 11's had two ways to map memory: one >combined the data and program in a single 64k segment, and one had >separate (64k) data and program spaces. Given the addressing modes, >the difference between data and program accesses were a study in themselves. Actually, they had three. The third used separate text and data segments within the same virtual 64K. >My impression is that the (original) version of the Magic Number was >the actual value to load into the PDP 11 MMU control register, to select >one or the other model. HAHAHAHA! It's even worse than that! The Magic Number was a JUMP (actually a branch) across the a.out header. A 407 executable had a seven word (14 byte) header, a 410, eight words, 411 nine... Sneaky, huh? -- [rbj@uunet 1] stty sane unknown mode: sane
thomas@nexus.se (03/26/91)
In article <573@adpplz.UUCP> martin@adpplz.UUCP (Martin Golding) writes:
<text deleted>
My impression is that the (original) version of the Magic Number was
the actual value to load into the PDP 11 MMU control register, to select
one or the other model.
Actually the magic numbers for the PDP11 was a branch instruction that
made the processor jump past the header. Writeable text (code was trated as
data) had 0407 which meant jump 7 words forward and read/execute-only text
had 0410 which meant jump 8 words (the magic numbers were in octal) forward.
I don't know whether the magic number actually WAS executed, it sure could
have been.
There was also a 0411 which was separate I and D spaces.
Pageable objects have 0413, don't know if this was ever used on a pdp11.
Thomas
--
Real life: Thomas Tornblom Email: t_tornblom@nexus.se
Snail mail: Communicator Nexus Phone: +46 18 171814
Box 857 Fax: +46 18 696516
S - 751 08 Uppsala, Sweden
rbj@uunet.UU.NET (Root Boy Jim) (03/28/91)
In article <126505@uunet.UU.NET> rbj@uunet.UU.NET (Root Boy Jim) writes: >In article <573@adpplz.UUCP> martin@adpplz.UUCP (Martin Golding) writes: > >>My impression is that the (original) version of the Magic Number was >>the actual value to load into the PDP 11 MMU control register, to select >>one or the other model. > >HAHAHAHA! It's even worse than that! The Magic Number was a JUMP >(actually a branch) across the a.out header. A 407 executable >had a seven word (14 byte) header, a 410, eight words, 411 nine... >Sneaky, huh? >-- > [rbj@uunet 1] stty sane > unknown mode: sane I suppose this is one for the computer folklore file. In my mailbox this morning was the following message: From dmr@research.att.com Wed Mar 27 01:49:38 1991 From: dmr@research.att.com Date: Wed, 27 Mar 91 01:49:26 EST To: rbj@uunet.UU.NET Subject: 407 [netnews] > HAHAHAHA! It's even worse than that! The Magic Number was a JUMP > (actually a branch) across the a.out header. A 407 executable > had a seven word (14 byte) header, a 410, eight words, 411 nine... > Sneaky, huh? Nonsense. Dennis Ritchie Perhaps this was actually considered at one time but cooler heads prevailed? I'm sure many people would be delighted with an elaboration. -- [rbj@uunet 1] stty sane unknown mode: sane
guy@auspex.auspex.com (Guy Harris) (03/31/91)
>HAHAHAHA! It's even worse than that! The Magic Number was a JUMP >(actually a branch) across the a.out header. A 407 executable >had a seven word (14 byte) header, a 410, eight words, 411 nine... >Sneaky, huh? *Real* sneaky, given that the header was, for all three types of executable, 8 words long.... "407" actually skipped all 8 words; the PC to which was added 7*2 was the PC of the instruction *following* the branch. "410" was intended to be "407+1", not "br .+10".