📄 a.out.5
字号:
.\" This source code is a product of Sun Microsystems, Inc. and is provided.\" for unrestricted use provided that this legend is included on all tape.\" media and as a part of the software program in whole or part. Users.\" may copy or modify this source code without charge, but are not authorized.\" to license or distribute it to anyone else except as part of a product or.\" program developed by the user..\".\" THIS PROGRAM CONTAINS SOURCE CODE COPYRIGHTED BY SUN MICROSYSTEMS, INC..\" SUN MICROSYSTEMS, INC., MAKES NO REPRESENTATIONS ABOUT THE SUITABLITY.\" OF SUCH SOURCE CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT.\" EXPRESS OR IMPLIED WARRANTY OF ANY KIND. SUN MICROSYSTEMS, INC. DISCLAIMS.\" ALL WARRANTIES WITH REGARD TO SUCH SOURCE CODE, INCLUDING ALL IMPLIED.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN.\" NO EVENT SHALL SUN MICROSYSTEMS, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT,.\" INCIDENTAL, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING.\" FROM USE OF SUCH SOURCE CODE, REGARDLESS OF THE THEORY OF LIABILITY..\" .\" This source code is provided with no support and without any obligation on.\" the part of Sun Microsystems, Inc. to assist in its use, correction, .\" modification or enhancement..\".\" SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE.\" INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY THIS.\" SOURCE CODE OR ANY PART THEREOF..\".\" Sun Microsystems, Inc..\" 2550 Garcia Avenue.\" Mountain View, California 94043.\".\" Copyright (c) 1991 Sun Microsystems, Inc..\".\" @(#)a.out.5 1.32 90/01/30 SMI; from UCB 4.2.TH A.OUT 5 "18 February 1988".SH NAMEa.out \- assembler and link editor output format.SH SYNOPSIS.nf.ft B#include <a.out.h>#include <stab.h>#include <nlist.h>.ft R.fi.SH AVAILABILITY.LPSun-2, Sun-3, and Sun-4 systems only.For Sun386i systems refer to.BR coff (5)..SH DESCRIPTION.IX "a.out file" "" "\fLa.out\fP \(em assembler and link editor output".IX "assembler output" "" "assembler output \(em \fLa.out\fP".IX "link editor output" "" "link editor output \(em \fLa.out\fP".LP.B a.outis the output format of the assembler.BR as (1)and the link editor.BR ld (1).The link editor makes.B a.outexecutable files..LPA file in.B a.outformat consists of: a header, the program text, program data, textand data relocation information, a symbol table,and a string table (in that order).In the header, the sizes of each section are given in bytes. Thelast three sections may be absent if the program was loaded withthe.B \-soption of.B ldor if the symbols and relocation have been removed by.BR strip (1)..LPThe machine type in the header indicates the type of hardware onwhich the object code can be executed. Sun-2 code runs onSun-3 systems, but not vice versa. Program files predating release3.0 are recognized by a machine type of.RB ` 0 '.Sun-4 code may not be run on Sun-2 or Sun-3, nor vice versa..SS Header.LPThe header consists of a.B execstructure. The.B execstructure has the form:.LP.RS.nf.ta 1i 2.0i 3.0i.ft Bstruct exec { unsigned char a_dynamic:1; /* has a __DYNAMIC */ unsigned char a_toolversion:7; /* version of toolset used to create this file */ unsigned char a_machtype; /* machine type */ unsigned short a_magic; /* magic number */ unsigned long a_text; /* size of text segment */ unsigned long a_data; /* size of initialized data */ unsigned long a_bss; /* size of uninitialized data */ unsigned long a_syms; /* size of symbol table */ unsigned long a_entry; /* entry point */ unsigned long a_trsize; /* size of text relocation */ unsigned long a_drsize; /* size of data relocation */};.ft R.fi.DT.RE.LPThe members of the structure are:.TP 15.B a_dynamic.B 1if the.B a.outfile is dynamically linked or is a shared object,.B 0otherwise..TP.B a_toolversionThe version number of the toolset.RB ( as ,.BR ld ,etc.) used to create the file..TP.B a_machtypeOne of the following:.RS.TP 12.B 0pre-3.0 executable image.TP.SB M_68010executable image using only \s-1MC\s068010 instructions that can runon Sun-2 or Sun-3systems..TP.SB M_68020executable image using \s-1MC\s068020 instructions that can run onlyon Sun-3systems..TP.SB M_SPARCexecutable image using \s-1SPARC\s0 instructions that can run onlyon Sun-4systems..RE.TP 15.B a_magicOne of the following:.RS.TP 12.SB OMAGICAn text executable image which is not to bewrite-protected, so the data segment is immediately contiguous with thetext segment..TP.SB NMAGICA write-protected text executable image.The data segment begins at the first segment boundary followingthe text segment, and the text segment is not writable by the program.When the image is started with.BR execve (2V),the entire text and data segments will be read into memory..TP.SB ZMAGICA page-aligned text executable image.the data segment begins at the first segment boundary followingthe text segment, and the text segment is not writable by the program.The text and data sizes are both multiples of the page size,and the pages of the file will be brought into the running image as needed,and not pre-loaded as with the other formats. This is the default format produced by.BR ld (1)..RE.IPThe macro.SB N_BADMAGtakes an.B execstructure as an argument; it evaluates to 1 if the.B a_magicfield of that structure is invalid, and evaluates to 0 if it is valid..TP 15.B a_textThe size of the text segment, in bytes..TP.B a_dataThe size of the initialized portion of the data segment, in bytes..TP.B a_bssThe size of the \*(lquninitialized\*(rq portion of the data segment, in bytes.This portion is actually initialized to zero. The zeroes are not stored in the.B a.outfile; the data in this portion of the data segment is zeroed out when it isloaded..TP.B a_symsThe size of the symbol table, in bytes..TP.B a_entryThe virtual address of the entry point of the program; when the image isstarted with.BR execve ,the first instruction executed in the image is at this address..TP.B a_trsizeThe size of the relocation information for the text segment..TP.B a_drsizeThe size of the relocation information for the data segment..LPThe macros.SM.BR N_TXTADDR ,.SM.BR N_DATADDR ,and.SB N_BSSADDRgive the memory addresses at which the text, data, and bss segments,respectively, will be loaded..LPIn the.SB ZMAGICformat, the size of the header is included in the size of the textsection; in other formats, it is not..LPWhen an.B a.outfile is executed, three logical segments are set up: the text segment,the data segment (with uninitialized data, which starts off as all 0,following initialized data), and a stack. For the.SB ZMAGICformat, the header is loaded with the text segment; for otherformats it is not..LPProgram execution begins at the address given by the value ofthe.B a_entryfield. .LPThe stack starts at the highest possible location in the memory image,and grows downwards. The stack is automatically extended as required.The data segment is extended as requested by.BR brk (2)or.BR sbrk ..SS "Text and Data Segments".LPThe text segment begins at the startof the file for.SB ZMAGICformat, or just after the header for the other formats. The.SB N_TXTOFFmacro returns this absolute file position when given an.B execstructure as argument. The data segment is contiguous with thetext and immediately followed by the text relocation and then the datarelocation information. The.SB N_DATOFFmacro returns the absolute file position of the beginning of the data segmentwhen given an.B execstructure as argument..SS Relocation.LPThe relocation information appears after the text and data segments.The.SB N_TRELOFFmacro returns the absolute file position of the relocation informationfor the text segment, when given an.B execstructure as argument.The.SB N_DRELOFFmacro returns the absolute file position of the relocation informationfor the data segment, when given an.B execstructure as argument.There is no relocation information if.BR a_trsize + a_drsize ==0..SS "Relocation (Sun-2 and Sun-3 Systems)"If a byte in the textor data involves a reference to an undefined external symbol, asindicated by the relocation information, then the value stored in thefile is an offset from the associated external symbol. When the fileis processed by the link editor and the external symbol becomesdefined, the value of the symbol is added to the bytes in the file.If a byte involves a reference to a relative location, orrelocatable segment, then the value stored in the file is anoffset from the associated segment..br.ne 12.LPIf relocation information is present, it amounts to eight bytes perrelocatable datum as in the following structure:.LP.RS.nf.ft B.ta +4n; +8n; +8n; +10nstruct reloc_info_68k { long r_address; /* address which is relocated */unsigned int r_symbolnum:24, /* local symbol ordinal */ r_pcrel:1, /* was relocated pc relative already */ r_length:2, /* 0=byte, 1=word, 2=long */ r_extern:1, /* does not include value of sym referenced */ r_baserel:1, /* linkage table relative */ r_jmptable:1, /* pc-relative to jump table */ r_relative:1, /* relative relocation */ :1;};.fi.RE.LPIf.B r_externis 0, then.B r_symbolnumis actually an.B n_typefor the relocation (for instance,.SB N_TEXTmeaning relative to segment text origin.).SS "Relocation (Sun-4 System)".LPIf a byte in the textor data involves a reference to an undefined external symbol, asindicated by the relocation information, then the value stored in thefile is ignored. Unlike the Sun-2 and Sun-3 system, the offset from theassociated symbol is kept with the relocation record. When the fileis processed by the link editor and the external symbol becomesdefined, the value of the symbol is added to this offset, and thesum is inserted into the bytes in the text or data segment..LPIf relocation information is present, it amounts to twelve bytes perrelocatable datum as in the following structure:.LP.nf.ft B.ta 4n; +22n; +22n; +22n; +8n; +8nenum reloc_type{ \s-1RELOC_8\s0, \s-1RELOC_16\s0, \s-1RELOC_32\s0, /* simplest relocs */ \s-1RELOC_DISP8\s0, \s-1RELOC_DISP16\s0, \s-1RELOC_DISP32\s0, /* Disp's (pc-rel) */ \s-1RELOC_WDISP30\s0, \s-1RELOC_WDISP22\s0, /* \s-1SR\s0 word disp's */ \s-1RELOC_HI22\s0, \s-1RELOC_22\s0, /* \s-1SR\s0 22-bit relocs */ \s-1RELOC_13\s0, \s-1RELOC_LO10\s0, /* \s-1SR\s0 13&10-bit relocs */ \s-1RELOC_SFA_BASE\s0, \s-1RELOC_SFA_OFF13\s0, /* \s-1SR S.F.A.\s0 relocs */ \s-1RELOC_BASE10\s0, \s-1RELOC_BASE13\s0, \s-1RELOC_BASE22\s0, /* base_relative pic */ \s-1RELOC_PC10\s0, \s-1RELOC_PC22\s0, /* special pc-rel pic*/ \s-1RELOC_JMP_TBL\s0, /* jmp_tbl_rel in pic */ \s-1RELOC_SEGOFF16\s0, /* ShLib offset-in-seg */ \s-1RELOC_GLOB_DAT\s0, \s-1RELOC_JMP_SLOT\s0, \s-1RELOC_RELATIVE\s0, /* rtld relocs */};.sp .5.ne 9.ta 4n; +18n; +10n; +10nstruct reloc_info_sparc /* used when header.a_machtype == M_SPARC */{ unsigned long int r_address; /* relocation addr (offset in segment) */ unsigned int r_index :24; /* segment index or symbol index */ unsigned int r_extern :\01; /* if F, r_index==SEG#; if T, SYM idx */ int :\02; /* <unused> */ enum reloc_type r_type :\05; /* type of relocation to perform */ long int r_addend; /* addend for relocation value */};.fi.ft.LPIf.B r_externis 0, then.B r_indexis actually a.B n_typefor the relocation (for instance,.SB N_TEXTmeaning relative to segment text origin.).SS Symbol Table.LPThe.SB N_SYMOFFmacro returns the absolute file position of the symbol table when given an.B execstructure as argument.Within this symbol table, distinct symbols point to disjointareas in the string table (even when two symbols have the same name).The string table immediately follows the symbol table; the.SB N_STROFFmacro returns the absolute file position of the string table when given an.B execstructure as argument.The first 4 bytes of the string table are not used for string storage,but rather contain the size of the string table. This size.I includesthe 4 bytes; thus, the minimum string table size is 4.Layout information as given in the include file for the Sun system isshown below..LPThe layout of a symbol table entry and the principal flag valuesthat distinguish symbol types are given in the include file as follows:.LP.nf.ft B.ta 6; +6; +4; +10struct nlist { union { char *n_name; /* for use when in-memory */ long n_strx; /* index into file string table */ } n_un; unsigned char n_type; /* type flag, that is, \s-1N_TEXT\s0 etc; see below */ char n_other; short n_desc; /* see <stab.h> */ unsigned n_value; /* value of this symbol (or adb offset) */};#define n_hash n_desc /* used internally by ld *//** Simple values for n_type.*/#define \s-1N_UNDF\s0 0x0 /* undefined */#define \s-1N_ABS\s0 0x2 /* absolute */#define \s-1N_TEXT\s0 0x4 /* text */#define \s-1N_DATA\s0 0x6 /* data */#define \s-1N_BSS\s0 0x8 /* bss */#define \s-1N_COMM\s0 0x12 /* common (internal to ld) */#define \s-1N_FN\s0 0x1f /* file name symbol */#define \s-1N_EXT\s0 01 /* external bit, or'ed in */#define \s-1N_TYPE\s0 0x1e /* mask for all the type bits */.sp .5v/** Other permanent symbol table entries have some of the \s-1N_STAB\s0 bits set.* These are given in <stab.h>*/#define \s-1N_STAB\s0 0xe0 /* if any of these bits set, don't discard */.ft.fi.LPIn the.B a.outfile a symbol's.B n_un.n_strxfield gives an index into the stringtable. A.B n_strxvalue of 0 indicates that no name is associated with aparticular symbol table entry. The field.B n_un.n_namecan be used torefer to the symbol name only if the program sets this up using.B n_strxand appropriate data from the string table. Because of the union inthe.B nlistdeclaration, it is impossible in C to statically initializesuch a structure. If this must be done (as when using.BR nlist (3V))include the file.BR <nlist.h> ,rather than.BR <a.out.h> .This contains the declaration without the union..LPIf a symbol's type is undefined external, and the value field isnon-zero, the symbol is interpreted by the loader.B ldas the name of a common region whose sizeis indicated by the value of the symbol..SH "SEE ALSO".BR adb (1),.BR as (1),.BR cc (1V),.BR dbx (1),.BR ld (1),.BR nm (1),.BR strip (1),.BR brk (2),.BR nlist (3V),.BR coff (5)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -