github.com/go-asm/go@v1.21.1-0.20240213172139-40c5ead50c48/cmd/link/sym/symbol.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 import ( 8 "github.com/go-asm/go/buildcfg" 9 "github.com/go-asm/go/cmd/obj" 10 ) 11 12 const ( 13 SymVerABI0 = 0 14 SymVerABIInternal = 1 15 SymVerABICount = 2 // Number of internal ABIs 16 SymVerStatic = 10 // Minimum version used by static (file-local) syms 17 ) 18 19 func ABIToVersion(abi obj.ABI) int { 20 switch abi { 21 case obj.ABI0: 22 return SymVerABI0 23 case obj.ABIInternal: 24 if !buildcfg.Experiment.RegabiWrappers { 25 // If wrappers are not enabled, ABI0 and ABIInternal are actually same 26 // so we normalize everything to ABI0. 27 return SymVerABI0 28 } 29 return SymVerABIInternal 30 } 31 return -1 32 } 33 34 func VersionToABI(v int) (obj.ABI, bool) { 35 switch v { 36 case SymVerABI0: 37 return obj.ABI0, true 38 case SymVerABIInternal: 39 return obj.ABIInternal, true 40 } 41 return ^obj.ABI(0), false 42 }