Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84 SMI; site sun.uucp Path: utzoo!watmath!clyde!burl!ulysses!gamma!epsilon!zeta!sabre!bellcore!decvax!decwrl!sun!guy From: guy@sun.uucp (Guy Harris) Newsgroups: net.unix-wizards Subject: Re: Do you believe in MAGIC? Message-ID: <2314@sun.uucp> Date: Sun, 16-Jun-85 23:25:49 EDT Article-I.D.: sun.2314 Posted: Sun Jun 16 23:25:49 1985 Date-Received: Wed, 19-Jun-85 03:36:11 EDT References: <821@unmvax.UUCP> <490@usl.UUCP> <82@decvax.UUCP> <106@aplvax.UUCP> <814@mako.UUCP> <491@aicchi.UUCP> Distribution: net Organization: Sun Microsystems, Inc. Lines: 34 > > "...their code space is writable. Two uses > > are old binaries, and new programs that, for some reason, require > > writes to code space. ... " > Like programs to be run under interactive, intrusive debuggers. I.e., a debugger that runs in the same address space as the program being debugged? If a debugger running outside that address space uses "ptrace" to write to the code space, the code will be made non-sharable (unless it's already being shared) and briefly made writable while the word in the code space is changed. > > The only way we know to have writable data below the code > > space is to use OMAGIC format. > I assume, from your comments, that you're on a BSD or BSD-derived site. I > would like to point out that, although it's not yet widely documented, > the COFF (Common Object File Format) loader (admittedly only on System > V) has a fairly rich range of link editor directives, which give the > programmer good control over the final composition of the executable image > and its memory layout. I would like to point out that the System V "exec" system call ignores all the information stuck in the executable image indicating the final composition of the executable image and its memory layout; it requires an executable image to consist of a text segment and a data segment further subdivided into an initialized data segment and a zero-filled BSS segment. The text segment may be omitted. The linker supports lots of control over the format of an executable image, but this is for the purpose of cross-development. "Mainstream" UNIX hasn't added any new capabilities to its executable image format since shared text segments were introduced. (The "exec" code in S5 isn't much changed from the V7 "exec" code; it just throws away the COFF header and uses the "optional header" as an old-style UNIX executable image header.) Guy Harris