github.com/mattn/go@v0.0.0-20171011075504-07f7db3ea99f/src/cmd/link/internal/sym/attribute.go (about) 1 // Copyright 2017 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 sym 6 7 // Attribute is a set of common symbol attributes. 8 type Attribute int16 9 10 const ( 11 // AttrDuplicateOK marks a symbol that can be present in multiple object 12 // files. 13 AttrDuplicateOK Attribute = 1 << iota 14 // AttrExternal marks function symbols loaded from host object files. 15 AttrExternal 16 // AttrNoSplit marks functions that cannot split the stack; the linker 17 // cares because it checks that there are no call chains of nosplit 18 // functions that require more than StackLimit bytes (see 19 // lib.go:dostkcheck) 20 AttrNoSplit 21 // AttrReachable marks symbols that are transitively referenced from the 22 // entry points. Unreachable symbols are not written to the output. 23 AttrReachable 24 // AttrCgoExportDynamic and AttrCgoExportStatic mark symbols referenced 25 // by directives written by cgo (in response to //export directives in 26 // the source). 27 AttrCgoExportDynamic 28 AttrCgoExportStatic 29 // AttrSpecial marks symbols that do not have their address (i.e. Value) 30 // computed by the usual mechanism of data.go:dodata() & 31 // data.go:address(). 32 AttrSpecial 33 // AttrStackCheck is used by dostkcheck to only check each NoSplit 34 // function's stack usage once. 35 AttrStackCheck 36 // AttrNotInSymbolTable marks symbols that are not written to the symbol table. 37 AttrNotInSymbolTable 38 // AttrOnList marks symbols that are on some list (such as the list of 39 // all text symbols, or one of the lists of data symbols) and is 40 // consulted to avoid bugs where a symbol is put on a list twice. 41 AttrOnList 42 // AttrLocal marks symbols that are only visible within the module 43 // (executable or shared library) being linked. Only relevant when 44 // dynamically linking Go code. 45 AttrLocal 46 // AttrReflectMethod marks certain methods from the reflect package that 47 // can be used to call arbitrary methods. If no symbol with this bit set 48 // is marked as reachable, more dead code elimination can be done. 49 AttrReflectMethod 50 // AttrMakeTypelink Amarks types that should be added to the typelink 51 // table. See typelinks.go:typelinks(). 52 AttrMakeTypelink 53 // AttrShared marks symbols compiled with the -shared option. 54 AttrShared 55 // 14 attributes defined so far. 56 ) 57 58 func (a Attribute) DuplicateOK() bool { return a&AttrDuplicateOK != 0 } 59 func (a Attribute) External() bool { return a&AttrExternal != 0 } 60 func (a Attribute) NoSplit() bool { return a&AttrNoSplit != 0 } 61 func (a Attribute) Reachable() bool { return a&AttrReachable != 0 } 62 func (a Attribute) CgoExportDynamic() bool { return a&AttrCgoExportDynamic != 0 } 63 func (a Attribute) CgoExportStatic() bool { return a&AttrCgoExportStatic != 0 } 64 func (a Attribute) Special() bool { return a&AttrSpecial != 0 } 65 func (a Attribute) StackCheck() bool { return a&AttrStackCheck != 0 } 66 func (a Attribute) NotInSymbolTable() bool { return a&AttrNotInSymbolTable != 0 } 67 func (a Attribute) OnList() bool { return a&AttrOnList != 0 } 68 func (a Attribute) Local() bool { return a&AttrLocal != 0 } 69 func (a Attribute) ReflectMethod() bool { return a&AttrReflectMethod != 0 } 70 func (a Attribute) MakeTypelink() bool { return a&AttrMakeTypelink != 0 } 71 func (a Attribute) Shared() bool { return a&AttrShared != 0 } 72 73 func (a Attribute) CgoExport() bool { 74 return a.CgoExportDynamic() || a.CgoExportStatic() 75 } 76 77 func (a *Attribute) Set(flag Attribute, value bool) { 78 if value { 79 *a |= flag 80 } else { 81 *a &^= flag 82 } 83 }