Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

reloc(5) [ultrix man page]

reloc(5)							File Formats Manual							  reloc(5)

Name
       reloc - relocation information for a MIPS object file

Syntax
       #include <reloc.h>

Description
       Object  files  have one relocation entry for each relocatable reference in the text or data.  If relocation information is present, it will
       be in the following format:

       struct	reloc
       {
	  long	    r_vaddr ;	       /* (virtual) address of reference */
	  long	    r_symndx ;	       /* index into symbol table */
	  ushort    r_type ;	       /* relocation type */
	  unsigned  r_symndx:24,       /* index into symbol table */
		    r_reserved:3,
		    r_type:4,	       /* relocation type */
		    r_extern:1;        /* if 1 symndx is an index into the
					  external symbol table, else symndx
					  is a section # */
       } ;

       /* Relocation types */

       #define	R_ABS	    0
       #define	R_REFHALF   1
       #define	R_REFWORD   2
       #define	R_JMPADDR   3
       #define	R_REFHI     4
       #define	R_REFLO     5
       #define	R_GPREL     6
       #define	R_LITERAL   7

       /* Section numbers */

       #define	R_SN_NULL   0
       #define	R_SN_TEXT   1
       #define	R_SN_RDATA  2
       #define	R_SN_DATA   3
       #define	R_SN_SDATA  4
       #define	R_SN_SBSS   5
       #define	R_SN_BSS    6
       #define	R_SN_INIT   7
       #define	R_SN_LIT8   8
       #define	R_SN_LIT4   9

       The link editor reads each input section and performs relocation.  The relocation entries direct how references found within the input sec-
       tion are treated.

       If  is zero, it is a local relocation entry and then is a section number (R_SN_*).  For these entries, the starting address for the section
       referenced by the section number is used in place of an external symbol table entry's value.  The assembler and	loader	always	use  local
       relocation entries if the item to be relocated is defined in the object file.

       For  every  external  relocation (except R_ABS) a signed constant is added to the symbol's virtual address that the relocation entry refers
       to.  This constant is assembled at the address being relocated.

       R_ABS	      The reference is absolute and no relocation is necessary.  The entry will be ignored.

       R_REFHALF      A 16-bit reference to the symbol's virtual address.

       R_REFWORD      A 32-bit reference to the symbol's virtual address.

       R_JMPADDR      A 26-bit jump instruction reference to the symbol's virtual address.

       R_REFHI	      A reference to the high 16 bits of the symbol's virtual address.	The  next  relocation  entry  must  be	the  corresponding
		      R_REFLO entry, so the proper value of the constant to be added to the symbol's virtual address can be reconstructed.

       R_REFLO	      A reference to low 16 bits to the symbol's virtual address.

       R_GPREL	      A 16-bit offset to the symbol's virtual address from the global pointer register.

       R_LITERAL      A 16-bit offset to the literal's virtual address from the global pointer register.

       Relocation  entries  are generated automatically by the assembler and automatically used by the link editor.  Link editor options exist for
       both preserving and removing the relocation entries from object files.

       The number of relocation entries for a section is found in the field of the section header.  This field is a C language short and can over-
       flow  with  large objects.  If this field overflows, the section header field has the S_NRELOC_OVFL bit set.  In this case, the true number
       of relocation entries is found in the field of the first relocation entry for that section.  That relocation entry has a type of R_ABS,	so
       it is ignored when the relocation takes place.

See Also
       as(1), ld(1), a.out(5), syms(5), scnhdr(5)

								       RISC								  reloc(5)

Check Out this Related Man Page

MACH-O(5)							File Formats Manual							 MACH-O(5)

NAME
Mach-O - Mach-O assembler and link editor output SYNOPSIS
#include <mach-o/loader.h> #include <mach-o/nlist.h> #include <mach-o/stab.h> #include <mach-o/reloc.h> DESCRIPTION
The object files produced by the assembler and link editor are in Mach-O (Mach object) file format. The file name a.out is the default output file name of the assembler as(1) and the link editor ld(1) The format of the object file however is not 4.3BSD a.out format as the name suggests, but rather Mach-O format. The link editor will make a.out executable if the resulting format is an executable type and there were no errors and no unresolved external references. The complete description of a Mach-O file is given in a number of include files. The file <mach-o/loader.h> describes the headers, <mach- o/nlist.h> describes the symbol table entries with <mach-o/stab.h> supplementing it, and <mach-o/reloc.h> describes the relocation entries. The actual instructions and data used by the program represented by a Mach-O file are the contents of its sections. Sections are grouped together in segments. Each section carries with it, in its header, the information as to which segment it belongs in. When a file type that is executable is created the sections are placed in their proper segment and all the segment headers are created and the segments themselves are padded out to the segment alignment (typically the target pagesize). For the object file type produced by an assembler (or by the link editor for further linking) all the sections are placed in one segment for compactness. When the kernel executes a Mach-O file it maps in the object file's segments, the dynamic link editor (if used) and creates the thread(s) for execution. Any part of the object file that is not part of a segment is not mapped in for execution. For executable using the dynamic link editor the headers and other link edit information is needed to execute the file. These parts include the relocation entries, the symbol table and the string table. These parts are mapped in with the use of the link editor's -seglinkedit option which creates a segment that contains these parts. These parts can be stripped down with the -S option to ld(1) or various options to strip(1). SEE ALSO
as(1), ld(1), nm(1), gdb(1), stab(5), strip(1) Apple Computer, Inc. October 22, 2001 MACH-O(5)
Man Page