Do you believe in MAGIC?

Guy Harris guy at sun.uucp
Mon Jun 17 13:25:49 AEST 1985


> >	"...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



More information about the Comp.unix.wizards mailing list