[net.unix-wizards] the -n flag on ld on 4.1bsd

smk@Mitre-Bedford (10/11/82)

Date: Sun Oct 10 15:29:38 1982
We seem to have a controversy here about the -n flag on ld.  From what
I understand, if the -n flag is NOT used, the text portion of the program is
loaded as needed, but it is NOT shared between users who invoke the same
program.  If the -n flag is used, the text portion is shared (RO) between all
users who invoke it, but the text portion is loaded all at once which slows
down the initialization of the program.  In addition, the sticky bit can only
be used on files that were loaded with the -n flag.
	If programs loaded WITHOUT the -n flag are still shared between users,
what is the need for the -n flag on 4.1 at all?  For backwards compatibility?
For the sticky bit?
	This topic came up because we have at times filled swap space (at
least we would get messages like `table full') and couldn't do a ps without
errors on drum and kmem.  I thought it was due to programs like vaxima and
emacs and other monsters that weren't shared between users and tended to fill
up swap space.
	Am I right or wrong?  There is no real documentation/guidance on this
subject.  I haven't seen such discussions appearing here before.

	--steve kramer

jreuter (10/21/82)

I don't know for sure how the 4.1BSD code works, but the code for the
VAX ld in System III completely ignores the -n, -i, or whatever flags.
The code that deals with those is commented out, and the loader
ALWAYS generates code that is "-n style".  I would expect that this is
similar to 32V and thus 4.?BSD.  Any BSD loader experts have comments?

	Jim Reuter	(decvax!pur-ee!purdue!ncrday!cincy!jreuter)

ark (10/27/82)

The version of ld in use on our 4.1BSD system behaves as follows.
It can produce load modules in "old format" (writeable text and data),
in "shared format" (pure text, writeable data, but no particular
boundaries observed), and "paged format" (pure text with size rounded
up to a multiple of 1024 bytes.  If you say -z you get paged format.
If you say -n you get paged format.  If you say nothing you get old format.
The cc command supplies -z to the loader unless you say -n at it.
If you want to get an old format load module from cc, you must say
cc -N, which removes the -z from the loader's input.