IPnom Home • Manuals • FreeBSD

 FreeBSD Man Pages

Man Sections:Commands (1)System Calls (2)Library Functions (3)Device Drivers (4)File Formats (5)Miscellaneous (7)System Utilities (8)
Keyword Live Search (10 results max):
 Type in part of a command in the search box.
 
Index:
  a.out(5)
  acct(5)
  adduser.conf(5)
  aliases(5)
  amd.conf(5)
  auth.conf(5)
  big5(5)
  bluetooth.hosts(5)
  bluetooth.protocols(5)
  bootparams(5)
  bootptab(5)
  config(5)
  core(5)
  crontab(5)
  ctm(5)
  cvs(5)
  devd.conf(5)
  devfs(5)
  device.hints(5)
  dhclient.conf(5)
  dhclient.leases(5)
  dhcp-eval(5)
  dhcp-options(5)
  dir(5)
  dirent(5)
  disktab(5)
  editrc(5)
  elf(5)
  ethers(5)
  euc(5)
  eui64(5)
  exports(5)
  fbtab(5)
  fdescfs(5)
  finger.conf(5)
  forward(5)
  fs(5)
  fstab(5)
  ftpchroot(5)
  gb18030(5)
  gb2312(5)
  gbk(5)
  gettytab(5)
  groff_font(5)
  groff_out(5)
  groff_tmac(5)
  group(5)
  hcsecd.conf(5)
  hesiod.conf(5)
  hosts(5)
  hosts.equiv(5)
  hosts.lpd(5)
  hosts_access(5)
  hosts_options(5)
  inetd.conf(5)
  info(5)
  inode(5)
  intro(5)
  ipf(5)
  ipnat(5)
  ipnat.conf(5)
  ipsend(5)
  isdnd.acct(5)
  isdnd.rates(5)
  isdnd.rc(5)
  kbdmap(5)
  keycap(5)
  keymap(5)
  krb5.conf(5)
  lastlog(5)
  libarchive-formats(5)
  libmap.conf(5)
  link(5)
  linprocfs(5)
  loader.conf(5)
  login.access(5)
  login.conf(5)
  mac.conf(5)
  magic(5)
  mailer.conf(5)
  make.conf(5)
  malloc.conf(5)
  master.passwd(5)
  moduli(5)
  motd(5)
  msdos(5)
  msdosfs(5)
  mskanji(5)
  named.conf(5)
  netconfig(5)
  netgroup(5)
  netid(5)
  networks(5)
  newsyslog.conf(5)
  nologin(5)
  nsmb.conf(5)
  nsswitch.conf(5)
  ntp.conf(5)
  ntp.keys(5)
  opieaccess(5)
  opiekeys(5)
  passwd(5)
  pbm(5)
  pccard.conf(5)
  periodic.conf(5)
  pf.conf(5)
  pf.os(5)
  phones(5)
  printcap(5)
  procfs(5)
  protocols(5)
  publickey(5)
  pw.conf(5)
  quota.group(5)
  quota.user(5)
  radius.conf(5)
  rc.conf(5)
  rcsfile(5)
  remote(5)
  resolv.conf(5)
  resolver(5)
  rhosts(5)
  rndc.conf(5)
  rpc(5)
  rrenumd.conf(5)
  rtadvd.conf(5)
  services(5)
  shells(5)
  ssh_config(5)
  sshd_config(5)
  stab(5)
  style.Makefile(5)
  sysctl.conf(5)
  syslog.conf(5)
  tacplus.conf(5)
  tar(5)
  term(5)
  termcap(5)
  terminfo(5)
  texinfo(5)
  tmac(5)
  ttys(5)
  tzfile(5)
  usbd.conf(5)
  utf2(5)
  utf8(5)
  utmp(5)
  uuencode(5)
  uuencode.format(5)
  vgrindefs(5)
  wtmp(5)

a.out(5)

NAME

     a.out -- format of executable binary files


SYNOPSIS

     #include <a.out.h>


DESCRIPTION

     The include file <a.out.h> declares three structures and several macros.
     The structures describe the format of executable machine code files
     (`binaries') on the system.

     A binary file consists of up to 7 sections.  In order, these sections
     are:

     exec header       Contains parameters used by the kernel to load a binary
		       file into memory and execute it, and by the link editor
		       ld(1) to combine a binary file with other binary files.
		       This section is the only mandatory one.

     text segment      Contains machine code and related data that are loaded
		       into memory when a program executes.  May be loaded
		       read-only.

     data segment      Contains initialized data; always loaded into writable
		       memory.

     text relocations  Contains records used by the link editor to update
		       pointers in the text segment when combining binary
		       files.

     data relocations  Like the text relocation section, but for data segment
		       pointers.

     symbol table      Contains records used by the link editor to cross ref-
		       erence the addresses of named variables and functions
		       (`symbols') between binary files.

     string table      Contains the character strings corresponding to the
		       symbol names.

     Every binary file begins with an exec structure:

	   struct exec {
		   unsigned long   a_midmag;
		   unsigned long   a_text;
		   unsigned long   a_data;
		   unsigned long   a_bss;
		   unsigned long   a_syms;
		   unsigned long   a_entry;
		   unsigned long   a_trsize;
		   unsigned long   a_drsize;
	   };

     The fields have the following functions:

     a_midmag  This field is stored in host byte-order.  It has a number of
	       sub-components accessed by the macros N_GETFLAG(), N_GETMID(),

			   pendent code.  This flag is set by as(1) when given
			   the `-k' flag and is preserved by ld(1) if neces-
			   sary.

	       If both EX_DYNAMIC and EX_PIC are set, the object file is a
	       position independent executable image (e.g. a shared library),
	       which is to be loaded into the process address space by the
	       run-time link editor.

	       The macro N_GETMID() returns the machine-id.  This indicates
	       which machine(s) the binary is intended to run on.

	       N_GETMAGIC() specifies the magic number, which uniquely identi-
	       fies binary files and distinguishes different loading conven-
	       tions.  The field must contain one of the following values:

	       OMAGIC  The text and data segments immediately follow the
		       header and are contiguous.  The kernel loads both text
		       and data segments into writable memory.

	       NMAGIC  As with OMAGIC, text and data segments immediately fol-
		       low the header and are contiguous.  However, the kernel
		       loads the text into read-only memory and loads the data
		       into writable memory at the next page boundary after
		       the text.

	       ZMAGIC  The kernel loads individual pages on demand from the
		       binary.	The header, text segment and data segment are
		       all padded by the link editor to a multiple of the page
		       size.  Pages that the kernel loads from the text seg-
		       ment are read-only, while pages from the data segment
		       are writable.

     a_text    Contains the size of the text segment in bytes.

     a_data    Contains the size of the data segment in bytes.

     a_bss     Contains the number of bytes in the `bss segment' and is used
	       by the kernel to set the initial break (brk(2)) after the data
	       segment.  The kernel loads the program so that this amount of
	       writable memory appears to follow the data segment and ini-
	       tially reads as zeroes.	(bss = block started by symbol)

     a_syms    Contains the size in bytes of the symbol table section.

     a_entry   Contains the address in memory of the entry point of the pro-
	       gram after the kernel has loaded it; the kernel starts the exe-
	       cution of the program from the machine instruction at this
	       address.

     a_trsize  Contains the size in bytes of the text relocation table.

     a_drsize  Contains the size in bytes of the data relocation table.

     The <a.out.h> include file defines several macros which use an exec
     structure to test consistency or to locate section offsets in the binary
     file.

     N_STROFF(exec)  The byte offset of the beginning of the string table.

     Relocation records have a standard format which is described by the
     relocation_info structure:

	   struct relocation_info {
		   int		   r_address;
		   unsigned int    r_symbolnum : 24,
				   r_pcrel : 1,
				   r_length : 2,
				   r_extern : 1,
				   r_baserel : 1,
				   r_jmptable : 1,
				   r_relative : 1,
				   r_copy : 1;
	   };

     The relocation_info fields are used as follows:

     r_address	  Contains the byte offset of a pointer that needs to be link-
		  edited.  Text relocation offsets are reckoned from the start
		  of the text segment, and data relocation offsets from the
		  start of the data segment.  The link editor adds the value
		  that is already stored at this offset into the new value
		  that it computes using this relocation record.

     r_symbolnum  Contains the ordinal number of a symbol structure in the
		  symbol table (it is not a byte offset).  After the link edi-
		  tor resolves the absolute address for this symbol, it adds
		  that address to the pointer that is undergoing relocation.
		  (If the r_extern bit is clear, the situation is different;
		  see below.)

     r_pcrel	  If this is set, the link editor assumes that it is updating
		  a pointer that is part of a machine code instruction using
		  pc-relative addressing.  The address of the relocated
		  pointer is implicitly added to its value when the running
		  program uses it.

     r_length	  Contains the log base 2 of the length of the pointer in
		  bytes; 0 for 1-byte displacements, 1 for 2-byte displace-
		  ments, 2 for 4-byte displacements.

     r_extern	  Set if this relocation requires an external reference; the
		  link editor must use a symbol address to update the pointer.
		  When the r_extern bit is clear, the relocation is `local';
		  the link editor updates the pointer to reflect changes in
		  the load addresses of the various segments, rather than
		  changes in the value of a symbol (except when r_baserel is
		  also set (see below).  In this case, the content of the
		  r_symbolnum field is an n_type value (see below); this type
		  field tells the link editor what segment the relocated
		  pointer points into.

     r_baserel	  If set, the symbol, as identified by the r_symbolnum field,
		  is to be relocated to an offset into the Global Offset Ta-
		  ble.	At run-time, the entry in the Global Offset Table at
		  this offset is set to be the address of the symbol.

     r_copy	  If set, this relocation record identifies a symbol whose
		  contents should be copied to the location given in
		  r_address.  The copying is done by the run-time link-editor
		  from a suitable data item in a shared object.

     Symbols map names to addresses (or more generally, strings to values).
     Since the link-editor adjusts addresses, a symbol's name must be used to
     stand for its address until an absolute value has been assigned.  Symbols
     consist of a fixed-length record in the symbol table and a variable-
     length name in the string table.  The symbol table is an array of nlist
     structures:

	   struct nlist {
		   union {
			   char    *n_name;
			   long    n_strx;
		   } n_un;
		   unsigned char   n_type;
		   char 	   n_other;
		   short	   n_desc;
		   unsigned long   n_value;
	   };

     The fields are used as follows:

     n_un.n_strx  Contains a byte offset into the string table for the name of
		  this symbol.	When a program accesses a symbol table with
		  the nlist(3) function, this field is replaced with the
		  n_un.n_name field, which is a pointer to the string in mem-
		  ory.

     n_type	  Used by the link editor to determine how to update the sym-
		  bol's value.	The n_type field is broken down into three
		  sub-fields using bitmasks.  The link editor treats symbols
		  with the N_EXT type bit set as `external' symbols and per-
		  mits references to them from other binary files.  The N_TYPE
		  mask selects bits of interest to the link editor:

		  N_UNDF  An undefined symbol.	The link editor must locate an
			  external symbol with the same name in another binary
			  file to determine the absolute value of this symbol.
			  As a special case, if the n_value field is nonzero
			  and no binary file in the link-edit defines this
			  symbol, the link-editor will resolve this symbol to
			  an address in the bss segment, reserving an amount
			  of bytes equal to n_value.  If this symbol is unde-
			  fined in more than one binary file and the binary
			  files do not agree on the size, the link editor
			  chooses the greatest size found across all binaries.

		  N_ABS   An absolute symbol.  The link editor does not update
			  an absolute symbol.

		  N_TEXT  A text symbol.  This symbol's value is a text
			  address and the link editor will update it when it
			  merges binary files.

		  N_BSS   A bss symbol; like text or data symbols but has no
			  corresponding offset in the binary file.

		  N_FN	  A filename symbol.  The link editor inserts this
			  symbol before the other symbols from a binary file
			  when merging binary files.  The name of the symbol
			  is the filename given to the link editor, and its
			  value is the first text address from that binary
			  file.  Filename symbols are not needed for link-
			  editing or loading, but are useful for debuggers.

		  The N_STAB mask selects bits of interest to symbolic debug-
		  gers such as gdb(1); the values are described in stab(5).

     n_other	  This field provides information on the nature of the symbol
		  independent of the symbol's location in terms of segments as
		  determined by the n_type field.  Currently, the lower 4 bits
		  of the n_other field hold one of two values: AUX_FUNC and
		  AUX_OBJECT (see <link.h> for their definitions).  AUX_FUNC
		  associates the symbol with a callable function, while
		  AUX_OBJECT associates the symbol with data, irrespective of
		  their locations in either the text or the data segment.
		  This field is intended to be used by ld(1) for the construc-
		  tion of dynamic executables.

     n_desc	  Reserved for use by debuggers; passed untouched by the link
		  editor.  Different debuggers use this field for different
		  purposes.

     n_value	  Contains the value of the symbol.  For text, data and bss
		  symbols, this is an address; for other symbols (such as
		  debugger symbols), the value may be arbitrary.

     The string table consists of an unsigned long length followed by null-
     terminated symbol strings.  The length represents the size of the entire
     table in bytes, so its minimum value (or the offset of the first string)
     is always 4 on 32-bit machines.


SEE ALSO

     as(1), gdb(1), ld(1), brk(2), execve(2), nlist(3), core(5), elf(5),
     link(5), stab(5)


HISTORY

     The <a.out.h> include file appeared in Version 7 AT&T UNIX.


BUGS

     Since not all of the supported architectures use the a_midmag field, it
     can be difficult to determine what architecture a binary will execute on
     without examining its actual machine code.  Even with a machine identi-
     fier, the byte order of the exec header is machine-dependent.

FreeBSD 5.4			 June 5, 1993			   FreeBSD 5.4

SPONSORED LINKS




Man(1) output converted with man2html , sed , awk