github.com/rsc/tmp@v0.0.0-20240517235954-6deaab19748b/bootstrap/internal/ld/textflag.go (about)

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