mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/internal/obj, cmd/link: record ABIs and aliases in Go obj files
This repurposes the "version" field of a symbol reference in the Go object file format to be an ABI field. Currently, this is just 0 or 1 depending on whether the symbol is static (the linker turns it into a different internal version number), so it's already only tenuously a symbol version. We change this to be -1 for static symbols and otherwise by the ABI number. This also adds a separate list of ABI alias symbols to be recorded in the object file. The ABI aliases must be a separate list and not just part of the symbol definitions because it's possible to have a symbol defined in one package and the alias "defined" in a different package. For example, this can happen if a symbol is defined in assembly in one package and stubbed in a different package. The stub triggers the generation of the ABI alias, but in a different package from the definition. For #27539. Change-Id: I015c9fe54690c027de6ef77e22b5585976a01587 Reviewed-on: https://go-review.googlesource.com/c/147157 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
This commit is contained in:
parent
07544c7e80
commit
c5718b6b26
6 changed files with 96 additions and 26 deletions
|
|
@ -432,7 +432,7 @@ const (
|
|||
)
|
||||
|
||||
// Attribute is a set of symbol attributes.
|
||||
type Attribute int16
|
||||
type Attribute uint16
|
||||
|
||||
const (
|
||||
AttrDuplicateOK Attribute = 1 << iota
|
||||
|
|
@ -468,6 +468,13 @@ const (
|
|||
// For function symbols; indicates that the specified function was the
|
||||
// target of an inline during compilation
|
||||
AttrWasInlined
|
||||
|
||||
// attrABIBase is the value at which the ABI is encoded in
|
||||
// Attribute. This must be last; all bits after this are
|
||||
// assumed to be an ABI value.
|
||||
//
|
||||
// MUST BE LAST since all bits above this comprise the ABI.
|
||||
attrABIBase
|
||||
)
|
||||
|
||||
func (a Attribute) DuplicateOK() bool { return a&AttrDuplicateOK != 0 }
|
||||
|
|
@ -493,6 +500,12 @@ func (a *Attribute) Set(flag Attribute, value bool) {
|
|||
}
|
||||
}
|
||||
|
||||
func (a Attribute) ABI() ABI { return ABI(a / attrABIBase) }
|
||||
func (a *Attribute) SetABI(abi ABI) {
|
||||
const mask = 1 // Only one ABI bit for now.
|
||||
*a = (*a &^ (mask * attrABIBase)) | Attribute(abi)*attrABIBase
|
||||
}
|
||||
|
||||
var textAttrStrings = [...]struct {
|
||||
bit Attribute
|
||||
s string
|
||||
|
|
@ -524,6 +537,12 @@ func (a Attribute) TextAttrString() string {
|
|||
a &^= x.bit
|
||||
}
|
||||
}
|
||||
switch a.ABI() {
|
||||
case ABI0:
|
||||
case ABIInternal:
|
||||
s += "ABIInternal|"
|
||||
a.SetABI(0) // Clear ABI so we don't print below.
|
||||
}
|
||||
if a != 0 {
|
||||
s += fmt.Sprintf("UnknownAttribute(%d)|", a)
|
||||
}
|
||||
|
|
@ -606,6 +625,16 @@ type Link struct {
|
|||
// state for writing objects
|
||||
Text []*LSym
|
||||
Data []*LSym
|
||||
|
||||
// ABIAliases are text symbols that should be aliased to all
|
||||
// ABIs. These symbols may only be referenced and not defined
|
||||
// by this object, since the need for an alias may appear in a
|
||||
// different object than the definition. Hence, this
|
||||
// information can't be carried in the symbol definition.
|
||||
//
|
||||
// TODO(austin): Replace this with ABI wrappers once the ABIs
|
||||
// actually diverge.
|
||||
ABIAliases []*LSym
|
||||
}
|
||||
|
||||
func (ctxt *Link) Diag(format string, args ...interface{}) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue