github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/cmd/link/internal/ld/data.go (about)

     1  // Derived from Inferno utils/6l/obj.c and utils/6l/span.c
     2  // https://bitbucket.org/inferno-os/inferno-os/src/master/utils/6l/obj.c
     3  // https://bitbucket.org/inferno-os/inferno-os/src/master/utils/6l/span.c
     4  //
     5  //	Copyright © 1994-1999 Lucent Technologies Inc.  All rights reserved.
     6  //	Portions Copyright © 1995-1997 C H Forsyth (forsyth@terzarima.net)
     7  //	Portions Copyright © 1997-1999 Vita Nuova Limited
     8  //	Portions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuova.com)
     9  //	Portions Copyright © 2004,2006 Bruce Ellis
    10  //	Portions Copyright © 2005-2007 C H Forsyth (forsyth@terzarima.net)
    11  //	Revisions Copyright © 2000-2007 Lucent Technologies Inc. and others
    12  //	Portions Copyright © 2009 The Go Authors. All rights reserved.
    13  //
    14  // Permission is hereby granted, free of charge, to any person obtaining a copy
    15  // of this software and associated documentation files (the "Software"), to deal
    16  // in the Software without restriction, including without limitation the rights
    17  // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    18  // copies of the Software, and to permit persons to whom the Software is
    19  // furnished to do so, subject to the following conditions:
    20  //
    21  // The above copyright notice and this permission notice shall be included in
    22  // all copies or substantial portions of the Software.
    23  //
    24  // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    25  // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    26  // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
    27  // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    28  // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    29  // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    30  // THE SOFTWARE.
    31  
    32  package ld
    33  
    34  import (
    35  	"github.com/shogo82148/std/cmd/internal/gcprog"
    36  	"github.com/shogo82148/std/cmd/link/internal/loader"
    37  )
    38  
    39  // FoldSubSymbolOffset computes the offset of symbol s to its top-level outer
    40  // symbol. Returns the top-level symbol and the offset.
    41  // This is used in generating external relocations.
    42  func FoldSubSymbolOffset(ldr *loader.Loader, s loader.Sym) (loader.Sym, int64)
    43  
    44  // ExtrelocSimple creates a simple external relocation from r, with the same
    45  // symbol and addend.
    46  func ExtrelocSimple(ldr *loader.Loader, r loader.Reloc) loader.ExtReloc
    47  
    48  // ExtrelocViaOuterSym creates an external relocation from r targeting the
    49  // outer symbol and folding the subsymbol's offset into the addend.
    50  func ExtrelocViaOuterSym(ldr *loader.Loader, r loader.Reloc, s loader.Sym) loader.ExtReloc
    51  
    52  func CodeblkPad(ctxt *Link, out *OutBuf, addr int64, size int64, pad []byte)
    53  
    54  // Used only on Wasm for now.
    55  func DatblkBytes(ctxt *Link, addr int64, size int64) []byte
    56  
    57  type GCProg struct {
    58  	ctxt *Link
    59  	sym  *loader.SymbolBuilder
    60  	w    gcprog.Writer
    61  }
    62  
    63  func (p *GCProg) Init(ctxt *Link, name string)
    64  
    65  func (p *GCProg) End(size int64)
    66  
    67  func (p *GCProg) AddSym(s loader.Sym)
    68  
    69  // add a trampoline with symbol s (to be laid down after the current function)
    70  func (ctxt *Link) AddTramp(s *loader.SymbolBuilder)