github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/cmd/link/internal/ld/link.go (about) 1 // Derived from Inferno utils/6l/l.h and related files. 2 // https://bitbucket.org/inferno-os/inferno-os/src/master/utils/6l/l.h 3 // 4 // Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved. 5 // Portions Copyright © 1995-1997 C H Forsyth (forsyth@terzarima.net) 6 // Portions Copyright © 1997-1999 Vita Nuova Limited 7 // Portions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuova.com) 8 // Portions Copyright © 2004,2006 Bruce Ellis 9 // Portions Copyright © 2005-2007 C H Forsyth (forsyth@terzarima.net) 10 // Revisions Copyright © 2000-2007 Lucent Technologies Inc. and others 11 // Portions Copyright © 2009 The Go Authors. All rights reserved. 12 // 13 // Permission is hereby granted, free of charge, to any person obtaining a copy 14 // of this software and associated documentation files (the "Software"), to deal 15 // in the Software without restriction, including without limitation the rights 16 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 // copies of the Software, and to permit persons to whom the Software is 18 // furnished to do so, subject to the following conditions: 19 // 20 // The above copyright notice and this permission notice shall be included in 21 // all copies or substantial portions of the Software. 22 // 23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29 // THE SOFTWARE. 30 31 package ld 32 33 import ( 34 "github.com/shogo82148/std/bufio" 35 "github.com/shogo82148/std/cmd/link/internal/loader" 36 "github.com/shogo82148/std/cmd/link/internal/sym" 37 "github.com/shogo82148/std/debug/elf" 38 ) 39 40 type Shlib struct { 41 Path string 42 Hash []byte 43 Deps []string 44 File *elf.File 45 } 46 47 // Link holds the context for writing object code from a compiler 48 // or for reading that input into the linker. 49 type Link struct { 50 Target 51 ErrorReporter 52 ArchSyms 53 54 outSem chan int 55 Out *OutBuf 56 57 version int 58 59 Debugvlog int 60 Bso *bufio.Writer 61 62 Loaded bool 63 64 compressDWARF bool 65 66 Libdir []string 67 Library []*sym.Library 68 LibraryByPkg map[string]*sym.Library 69 Shlibs []Shlib 70 Textp []loader.Sym 71 Moduledata loader.Sym 72 73 PackageFile map[string]string 74 PackageShlib map[string]string 75 76 tramps []loader.Sym 77 78 compUnits []*sym.CompilationUnit 79 runtimeCU *sym.CompilationUnit 80 81 loader *loader.Loader 82 cgodata []cgodata 83 84 datap []loader.Sym 85 dynexp []loader.Sym 86 87 // Elf symtab variables. 88 numelfsym int 89 90 // These are symbols that created and written by the linker. 91 // Rather than creating a symbol, and writing all its data into the heap, 92 // you can create a symbol, and just a generation function will be called 93 // after the symbol's been created in the output mmap. 94 generatorSyms map[loader.Sym]generatorFunc 95 } 96 97 func (ctxt *Link) Logf(format string, args ...interface{}) 98 99 // Allocate a new version (i.e. symbol namespace). 100 func (ctxt *Link) IncVersion() int 101 102 // returns the maximum version number 103 func (ctxt *Link) MaxVersion() int