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

     1  // Do not edit. Bootstrap copy of /Users/rsc/g/go/src/cmd/internal/ld/link.go
     2  
     3  // Derived from Inferno utils/6l/l.h and related files.
     4  // http://code.google.com/p/inferno-os/source/browse/utils/6l/l.h
     5  //
     6  //	Copyright © 1994-1999 Lucent Technologies Inc.  All rights reserved.
     7  //	Portions Copyright © 1995-1997 C H Forsyth (forsyth@terzarima.net)
     8  //	Portions Copyright © 1997-1999 Vita Nuova Limited
     9  //	Portions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuova.com)
    10  //	Portions Copyright © 2004,2006 Bruce Ellis
    11  //	Portions Copyright © 2005-2007 C H Forsyth (forsyth@terzarima.net)
    12  //	Revisions Copyright © 2000-2007 Lucent Technologies Inc. and others
    13  //	Portions Copyright © 2009 The Go Authors.  All rights reserved.
    14  //
    15  // Permission is hereby granted, free of charge, to any person obtaining a copy
    16  // of this software and associated documentation files (the "Software"), to deal
    17  // in the Software without restriction, including without limitation the rights
    18  // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    19  // copies of the Software, and to permit persons to whom the Software is
    20  // furnished to do so, subject to the following conditions:
    21  //
    22  // The above copyright notice and this permission notice shall be included in
    23  // all copies or substantial portions of the Software.
    24  //
    25  // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    26  // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    27  // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
    28  // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    29  // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    30  // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    31  // THE SOFTWARE.
    32  
    33  package ld
    34  
    35  import "encoding/binary"
    36  
    37  type LSym struct {
    38  	Name        string
    39  	Extname     string
    40  	Type        int16
    41  	Version     int16
    42  	Dupok       uint8
    43  	Cfunc       uint8
    44  	External    uint8
    45  	Nosplit     uint8
    46  	Reachable   bool
    47  	Cgoexport   uint8
    48  	Special     uint8
    49  	Stkcheck    uint8
    50  	Hide        uint8
    51  	Leaf        uint8
    52  	Localentry  uint8
    53  	Onlist      uint8
    54  	Dynid       int32
    55  	Plt         int32
    56  	Got         int32
    57  	Align       int32
    58  	Elfsym      int32
    59  	Args        int32
    60  	Locals      int32
    61  	Value       int64
    62  	Size        int64
    63  	Hash        *LSym
    64  	Allsym      *LSym
    65  	Next        *LSym
    66  	Sub         *LSym
    67  	Outer       *LSym
    68  	Gotype      *LSym
    69  	Reachparent *LSym
    70  	Queue       *LSym
    71  	File        string
    72  	Dynimplib   string
    73  	Dynimpvers  string
    74  	Sect        interface{}
    75  	Autom       *Auto
    76  	Pcln        *Pcln
    77  	P           []byte
    78  	R           []Reloc
    79  	Local       bool
    80  	gcmask      []byte
    81  }
    82  
    83  type Reloc struct {
    84  	Off     int32
    85  	Siz     uint8
    86  	Done    uint8
    87  	Type    int32
    88  	Variant int32
    89  	Add     int64
    90  	Xadd    int64
    91  	Sym     *LSym
    92  	Xsym    *LSym
    93  }
    94  
    95  type Auto struct {
    96  	Asym    *LSym
    97  	Link    *Auto
    98  	Aoffset int32
    99  	Name    int16
   100  	Gotype  *LSym
   101  }
   102  
   103  type Link struct {
   104  	Thechar   int32
   105  	Thestring string
   106  	Goarm     int32
   107  	Headtype  int
   108  	Arch      *LinkArch
   109  	Debugasm  int32
   110  	Debugvlog int32
   111  	Bso       *Biobuf
   112  	Windows   int32
   113  	Goroot    string
   114  	Hash      map[symVer]*LSym
   115  	Allsym    *LSym
   116  	Nsymbol   int32
   117  	Tlsg      *LSym
   118  	Libdir    []string
   119  	Library   []Library
   120  	Shlibs    []string
   121  	Tlsoffset int
   122  	Diag      func(string, ...interface{})
   123  	Cursym    *LSym
   124  	Version   int
   125  	Textp     *LSym
   126  	Etextp    *LSym
   127  	Nhistfile int32
   128  	Filesyms  *LSym
   129  }
   130  
   131  type LinkArch struct {
   132  	ByteOrder binary.ByteOrder
   133  	Name      string
   134  	Thechar   int
   135  	Minlc     int
   136  	Ptrsize   int
   137  	Regsize   int
   138  }
   139  
   140  type Library struct {
   141  	Objref string
   142  	Srcref string
   143  	File   string
   144  	Pkg    string
   145  	Shlib  string
   146  }
   147  
   148  type Pcln struct {
   149  	Pcsp        Pcdata
   150  	Pcfile      Pcdata
   151  	Pcline      Pcdata
   152  	Pcdata      []Pcdata
   153  	Npcdata     int
   154  	Funcdata    []*LSym
   155  	Funcdataoff []int64
   156  	Nfuncdata   int
   157  	File        []*LSym
   158  	Nfile       int
   159  	Mfile       int
   160  	Lastfile    *LSym
   161  	Lastindex   int
   162  }
   163  
   164  type Pcdata struct {
   165  	P []byte
   166  }
   167  
   168  type Pciter struct {
   169  	d       Pcdata
   170  	p       []byte
   171  	pc      uint32
   172  	nextpc  uint32
   173  	pcscale uint32
   174  	value   int32
   175  	start   int
   176  	done    int
   177  }
   178  
   179  // Reloc.variant
   180  const (
   181  	RV_NONE = iota
   182  	RV_POWER_LO
   183  	RV_POWER_HI
   184  	RV_POWER_HA
   185  	RV_POWER_DS
   186  	RV_CHECK_OVERFLOW = 1 << 8
   187  	RV_TYPE_MASK      = RV_CHECK_OVERFLOW - 1
   188  )
   189  
   190  const (
   191  	LINKHASH = 100003
   192  )
   193  
   194  // Pcdata iterator.
   195  //	for(pciterinit(ctxt, &it, &pcd); !it.done; pciternext(&it)) { it.value holds in [it.pc, it.nextpc) }
   196  
   197  // Link holds the context for writing object code from a compiler
   198  // to be linker input or for reading that input into the linker.
   199  
   200  // LinkArch is the definition of a single architecture.
   201  
   202  const (
   203  	LinkAuto = 0 + iota
   204  	LinkInternal
   205  	LinkExternal
   206  )