a.out man page on UNIXv7

Man page or keyword search:  
man Server   300 pages
apropos Keyword Search (all sections)
Output format
UNIXv7 logo
[printable version]

A.OUT(5)							      A.OUT(5)

NAME
       a.out - assembler and link editor output

SYNOPSIS
       #include <a.out.h>

DESCRIPTION
       A.out  is  the  output  file of the assembler as(1) and the link editor
       ld(1).  Both programs make a.out executable if there were no errors and
       no  unresolved external references.  Layout information as given in the
       include file for the PDP11 is:

       #ifndef __A_OUT_GNU_H__
       #define __A_OUT_GNU_H__

       #include <bits/a.out.h>

       #define __GNU_EXEC_MACROS__

       struct exec
       {
	 unsigned long a_info;	   /* Use macros N_MAGIC, etc for access.  */
	 unsigned int a_text;	   /* Length of text, in bytes.	 */
	 unsigned int a_data;	   /* Length of data, in bytes.	 */
	 unsigned int a_bss;	   /* Length of uninitialized data area for file, in bytes.  */
	 unsigned int a_syms;	   /* Length of symbol table data in file, in bytes.  */
	 unsigned int a_entry;	   /* Start address.  */
	 unsigned int a_trsize;/* Length of relocation info for text, in bytes.	 */
	 unsigned int a_drsize;/* Length of relocation info for data, in bytes.	 */
       };

       enum machine_type
       {
	 M_OLDSUN2 = 0,
	 M_68010 = 1,
	 M_68020 = 2,
	 M_SPARC = 3,
	 M_386 = 100,
	 M_MIPS1 = 151,
	 M_MIPS2 = 152
       };

       #define N_MAGIC(exec)	   ((exec).a_info & 0xffff)
       #define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff))
       #define N_FLAGS(exec)	   (((exec).a_info >> 24) & 0xff)
       #define N_SET_INFO(exec, magic, type, flags)   ((exec).a_info = ((magic) & 0xffff)   | (((int)(type) & 0xff) << 16)   | (((flags) & 0xff) << 24))
       #define N_SET_MAGIC(exec, magic)	  ((exec).a_info = ((exec).a_info & 0xffff0000) | ((magic) & 0xffff))
       #define N_SET_MACHTYPE(exec, machtype)	((exec).a_info =   ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16))
       #define N_SET_FLAGS(exec, flags)	  ((exec).a_info =   ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24))

       /* Code indicating object file or impure executable.  */
       #define OMAGIC 0407
       /* Code indicating pure executable.  */
       #define NMAGIC 0410
       /* Code indicating demand-paged executable.  */
       #define ZMAGIC 0413
       /* This indicates a demand-paged executable with the header in the text.
	  The first page is unmapped to help trap NULL pointer references.  */
       #define QMAGIC 0314
       /* Code indicating core file.  */
       #define CMAGIC 0421

       #define N_TRSIZE(a)	   ((a).a_trsize)
       #define N_DRSIZE(a)	   ((a).a_drsize)
       #define N_SYMSIZE(a)	   ((a).a_syms)
       #define N_BADMAG(x)   (N_MAGIC(x) != OMAGIC&& N_MAGIC(x) != NMAGIC   && N_MAGIC(x) != ZMAGIC && N_MAGIC(x) != QMAGIC)
       #define _N_HDROFF(x)	   (1024 - sizeof (struct exec))
       #define N_TXTOFF(x)   (N_MAGIC(x) == ZMAGIC ? _N_HDROFF((x)) + sizeof (struct exec) :   (N_MAGIC(x) == QMAGIC ? 0 : sizeof (struct exec)))
       #define N_DATOFF(x)	   (N_TXTOFF(x) + (x).a_text)
       #define N_TRELOFF(x)	   (N_DATOFF(x) + (x).a_data)
       #define N_DRELOFF(x)	   (N_TRELOFF(x) + N_TRSIZE(x))
       #define N_SYMOFF(x)	   (N_DRELOFF(x) + N_DRSIZE(x))
       #define N_STROFF(x)	   (N_SYMOFF(x) + N_SYMSIZE(x))

       /* Address of text segment in memory after it is loaded.	 */
       #define N_TXTADDR(x)	   (N_MAGIC(x) == QMAGIC ? 4096 : 0)

       /* Address of data segment in memory after it is loaded.	 */
       #define SEGMENT_SIZE	   1024

       #define _N_SEGMENT_ROUND(x) (((x) + SEGMENT_SIZE - 1) & ~(SEGMENT_SIZE - 1))
       #define _N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_text)

       #define N_DATADDR(x)   (N_MAGIC(x)==OMAGIC? (_N_TXTENDADDR(x))	: (_N_SEGMENT_ROUND (_N_TXTENDADDR(x))))
       #define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)

       #if !defined (N_NLIST_DECLARED)
       struct nlist
       {
	 union
	   {
	     char *n_name;
	     struct nlist *n_next;
	     long n_strx;
	   } n_un;
	 unsigned char n_type;
	 char n_other;
	 short n_desc;
	 unsigned long n_value;
       };
       #endif /* no N_NLIST_DECLARED.  */

       #define N_UNDF	0
       #define N_ABS	2
       #define N_TEXT	4
       #define N_DATA	6
       #define N_BSS	8
       #define N_FN	15
       #define N_EXT	1
       #define N_TYPE	036
       #define N_STAB	0340
       #define N_INDR	0xa
       #define N_SETA	0x14	   /* Absolute set element symbol.  */
       #define N_SETT	0x16	   /* Text set element symbol.	*/
       #define N_SETD	0x18	   /* Data set element symbol.	*/
       #define N_SETB	0x1A	   /* Bss set element symbol.  */
       #define N_SETV	0x1C	   /* Pointer to set vector in data area.  */

       #if !defined (N_RELOCATION_INFO_DECLARED)
       /* This structure describes a single relocation to be performed.
	  The text-relocation section of the file is a vector of these structures,
	  all of which apply to the text section.
	  Likewise, the data-relocation section applies to the data section.  */

       struct relocation_info
       {
	 int r_address;
	 unsigned int r_symbolnum:24;
	 unsigned int r_pcrel:1;
	 unsigned int r_length:2;
	 unsigned int r_extern:1;
	 unsigned int r_pad:4;
       };
       #endif /* no N_RELOCATION_INFO_DECLARED.	 */

       #endif /* __A_OUT_GNU_H__ */

       The file has four sections: a header, the program and data text,	 relo‐
       cation  information,  and a symbol table (in that order).  The last two
       may be empty if the program was loaded with the `-s' option of ld or if
       the symbols and relocation have been removed by strip(1).

       In  the	header	the  sizes of each section are given in bytes, but are
       even.  The size of the header is not  included  in  any	of  the	 other
       sizes.

       When  an	 a.out	file  is loaded into core for execution, three logical
       segments are set up: the text segment, the data	segment	 (with	unini‐
       tialized data, which starts off as all 0, following initialized), and a
       stack.  The text segment begins at 0 in the core image; the  header  is
       not loaded.  If the magic number in the header is 0407(8), it indicates
       that the text segment is not to be write-protected and shared,  so  the
       data  segment  is immediately contiguous with the text segment.	If the
       magic number is 0410, the data segment begins at the  first  0  mod  8K
       byte  boundary  following the text segment, and the text segment is not
       writable by the program; if other  processes  are  executing  the  same
       file,  they  will  share the text segment.  If the magic number is 411,
       the text segment is again pure, write-protected, and shared, and	 more‐
       over  instruction  and data space are separated; the text and data seg‐
       ment both begin at location 0.  If the magic number is 0405,  the  text
       segment	is overlaid on an existing (0411 or 0405) text segment and the
       existing data segment is preserved.

       The stack will occupy the highest possible locations in the core image:
       from  0177776(8)	 and  growing  downwards.   The stack is automatically
       extended as required.  The data segment is only extended	 as  requested
       by brk(2).

       The  start  of the text segment in the file is 020(8); the start of the
       data segment is 020+St (the size of the text) the start of the  reloca‐
       tion  information  is  020+St+Sd;  the  start  of  the  symbol table is
       020+2(St+Sd) if the relocation information  is  present,	 020+St+Sd  if
       not.

       The  layout  of a symbol table entry and the principal flag values that
       distinguish symbol types are given in the  include  file.   Other  flag
       values  may  occur  if  an  assembly  language  program defines machine
       instructions.

       If a symbol's type is undefined external, and the value field  is  non-
       zero,  the symbol is interpreted by the loader ld as the name of a com‐
       mon region whose size is indicated by the value of the symbol.

       The value of a word in the text or data portions which is not a	refer‐
       ence  to	 an undefined external symbol is exactly that value which will
       appear in core when the file is executed.  If a word  in	 the  text  or
       data  portion  involves a reference to an undefined external symbol, as
       indicated by the relocation information for that word, then  the	 value
       of  the	word  as  stored  in the file is an offset from the associated
       external symbol.	 When the file is processed by the link editor and the
       external	 symbol becomes defined, the value of the symbol will be added
       into the word in the file.

       If relocation information is present, it amounts to one word  per  word
       of  program  text or initialized data.  There is no relocation informa‐
       tion if the `relocation info stripped' flag in the header is on.

       Bits 3-1 of a relocation word indicate the segment referred to  by  the
       text or data word associated with the relocation word:

       000    absolute number
       002    reference to text segment
       004    reference to initialized data
       006    reference to uninitialized data (bss)
       010    reference to undefined external symbol

       Bit  0  of  the	relocation word indicates, if 1, that the reference is
       relative to the pc (e.g. `clr x'); if 0, that the reference is  to  the
       actual symbol (e.g., `clr *$x').

       The remainder of the relocation word (bits 15-4) contains a symbol num‐
       ber in the case of external references, and is unused  otherwise.   The
       first symbol is numbered 0, the second 1, etc.

SEE ALSO
       as(1), ld(1), nm(1)

								      A.OUT(5)
[top]

List of man pages available for UNIXv7

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net