rsc.io/go@v0.0.0-20150416155037-e040fd465409/src/cmd/internal/ld/textflag.go (about)

     1  // Copyright 2013 The Go Authors.  All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package ld
     6  
     7  // Writing and reading of Go object files.
     8  //
     9  // Originally, Go object files were Plan 9 object files, but no longer.
    10  // Now they are more like standard object files, in that each symbol is defined
    11  // by an associated memory image (bytes) and a list of relocations to apply
    12  // during linking. We do not (yet?) use a standard file format, however.
    13  // For now, the format is chosen to be as simple as possible to read and write.
    14  // It may change for reasons of efficiency, or we may even switch to a
    15  // standard file format if there are compelling benefits to doing so.
    16  // See golang.org/s/go13linker for more background.
    17  //
    18  // The file format is:
    19  //
    20  //	- magic header: "\x00\x00go13ld"
    21  //	- byte 1 - version number
    22  //	- sequence of strings giving dependencies (imported packages)
    23  //	- empty string (marks end of sequence)
    24  //	- sequence of defined symbols
    25  //	- byte 0xff (marks end of sequence)
    26  //	- magic footer: "\xff\xffgo13ld"
    27  //
    28  // All integers are stored in a zigzag varint format.
    29  // See golang.org/s/go12symtab for a definition.
    30  //
    31  // Data blocks and strings are both stored as an integer
    32  // followed by that many bytes.
    33  //
    34  // A symbol reference is a string name followed by a version.
    35  // An empty name corresponds to a nil LSym* pointer.
    36  //
    37  // Each symbol is laid out as the following fields (taken from LSym*):
    38  //
    39  //	- byte 0xfe (sanity check for synchronization)
    40  //	- type [int]
    41  //	- name [string]
    42  //	- version [int]
    43  //	- flags [int]
    44  //		1 dupok
    45  //	- size [int]
    46  //	- gotype [symbol reference]
    47  //	- p [data block]
    48  //	- nr [int]
    49  //	- r [nr relocations, sorted by off]
    50  //
    51  // If type == STEXT, there are a few more fields:
    52  //
    53  //	- args [int]
    54  //	- locals [int]
    55  //	- nosplit [int]
    56  //	- flags [int]
    57  //		1 leaf
    58  //		2 C function
    59  //	- nlocal [int]
    60  //	- local [nlocal automatics]
    61  //	- pcln [pcln table]
    62  //
    63  // Each relocation has the encoding:
    64  //
    65  //	- off [int]
    66  //	- siz [int]
    67  //	- type [int]
    68  //	- add [int]
    69  //	- xadd [int]
    70  //	- sym [symbol reference]
    71  //	- xsym [symbol reference]
    72  //
    73  // Each local has the encoding:
    74  //
    75  //	- asym [symbol reference]
    76  //	- offset [int]
    77  //	- type [int]
    78  //	- gotype [symbol reference]
    79  //
    80  // The pcln table has the encoding:
    81  //
    82  //	- pcsp [data block]
    83  //	- pcfile [data block]
    84  //	- pcline [data block]
    85  //	- npcdata [int]
    86  //	- pcdata [npcdata data blocks]
    87  //	- nfuncdata [int]
    88  //	- funcdata [nfuncdata symbol references]
    89  //	- funcdatasym [nfuncdata ints]
    90  //	- nfile [int]
    91  //	- file [nfile symbol references]
    92  //
    93  // The file layout and meaning of type integers are architecture-independent.
    94  //
    95  // TODO(rsc): The file format is good for a first pass but needs work.
    96  //	- There are SymID in the object file that should really just be strings.
    97  //	- The actual symbol memory images are interlaced with the symbol
    98  //	  metadata. They should be separated, to reduce the I/O required to
    99  //	  load just the metadata.
   100  //	- The symbol references should be shortened, either with a symbol
   101  //	  table or by using a simple backward index to an earlier mentioned symbol.
   102  
   103  // Copyright 2013 The Go Authors.  All rights reserved.
   104  // Use of this source code is governed by a BSD-style
   105  // license that can be found in the LICENSE file.
   106  
   107  // This file defines flags attached to various functions
   108  // and data objects.  The compilers, assemblers, and linker must
   109  // all agree on these values.
   110  
   111  // Don't profile the marked routine.  This flag is deprecated.
   112  
   113  // It is ok for the linker to get multiple of these symbols.  It will
   114  // pick one of the duplicates to use.
   115  
   116  // Don't insert stack check preamble.
   117  
   118  // Put this data in a read-only section.
   119  
   120  // This data contains no pointers.
   121  
   122  // This is a wrapper function and should not count as disabling 'recover'.
   123  
   124  // This function uses its incoming context register.
   125  const (
   126  	NOPROF   = 1
   127  	DUPOK    = 2
   128  	NOSPLIT  = 4
   129  	RODATA   = 8
   130  	NOPTR    = 16
   131  	WRAPPER  = 32
   132  	NEEDCTXT = 64
   133  )