mirror of
https://github.com/golang/go
synced 2024-11-24 03:40:16 -07:00
cmd/link: remove ABI aliases
It is now gone. Change-Id: I59f68b324af706476695de2f291dd3aa5734e192 Reviewed-on: https://go-review.googlesource.com/c/go/+/351332 Trust: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
This commit is contained in:
parent
a630783ba0
commit
55d22f7490
@ -65,13 +65,6 @@ const (
|
||||
SDWARFRANGE
|
||||
SDWARFLOC
|
||||
SDWARFLINES
|
||||
// ABI alias. An ABI alias symbol is an empty symbol with a
|
||||
// single relocation with 0 size that references the native
|
||||
// function implementation symbol.
|
||||
//
|
||||
// TODO(austin): Remove this and all uses once the compiler
|
||||
// generates real ABI wrappers rather than symbol aliases.
|
||||
SABIALIAS
|
||||
// Coverage instrumentation counter for libfuzzer.
|
||||
SLIBFUZZER_EXTRA_COUNTER
|
||||
// Update cmd/link/internal/sym/AbiSymKindToSymKind for new SymKind values.
|
||||
|
@ -25,13 +25,12 @@ func _() {
|
||||
_ = x[SDWARFRANGE-14]
|
||||
_ = x[SDWARFLOC-15]
|
||||
_ = x[SDWARFLINES-16]
|
||||
_ = x[SABIALIAS-17]
|
||||
_ = x[SLIBFUZZER_EXTRA_COUNTER-18]
|
||||
_ = x[SLIBFUZZER_EXTRA_COUNTER-17]
|
||||
}
|
||||
|
||||
const _SymKind_name = "SxxxSTEXTSRODATASNOPTRDATASDATASBSSSNOPTRBSSSTLSBSSSDWARFCUINFOSDWARFCONSTSDWARFFCNSDWARFABSFCNSDWARFTYPESDWARFVARSDWARFRANGESDWARFLOCSDWARFLINESSABIALIASSLIBFUZZER_EXTRA_COUNTER"
|
||||
const _SymKind_name = "SxxxSTEXTSRODATASNOPTRDATASDATASBSSSNOPTRBSSSTLSBSSSDWARFCUINFOSDWARFCONSTSDWARFFCNSDWARFABSFCNSDWARFTYPESDWARFVARSDWARFRANGESDWARFLOCSDWARFLINESSLIBFUZZER_EXTRA_COUNTER"
|
||||
|
||||
var _SymKind_index = [...]uint8{0, 4, 9, 16, 26, 31, 35, 44, 51, 63, 74, 83, 95, 105, 114, 125, 134, 145, 154, 178}
|
||||
var _SymKind_index = [...]uint8{0, 4, 9, 16, 26, 31, 35, 44, 51, 63, 74, 83, 95, 105, 114, 125, 134, 145, 169}
|
||||
|
||||
func (i SymKind) String() string {
|
||||
if i >= SymKind(len(_SymKind_index)-1) {
|
||||
|
@ -544,7 +544,6 @@ func gentrampdyn(arch *sys.Arch, tramp *loader.SymbolBuilder, target loader.Sym,
|
||||
|
||||
func archreloc(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, r loader.Reloc, s loader.Sym, val int64) (o int64, nExtReloc int, ok bool) {
|
||||
rs := r.Sym()
|
||||
rs = ldr.ResolveABIAlias(rs)
|
||||
if target.IsExternal() {
|
||||
switch r.Type() {
|
||||
case objabi.R_CALLARM:
|
||||
@ -592,7 +591,7 @@ func archrelocvariant(*ld.Target, *loader.Loader, loader.Reloc, sym.RelocVariant
|
||||
}
|
||||
|
||||
func extreloc(target *ld.Target, ldr *loader.Loader, r loader.Reloc, s loader.Sym) (loader.ExtReloc, bool) {
|
||||
rs := ldr.ResolveABIAlias(r.Sym())
|
||||
rs := r.Sym()
|
||||
var rr loader.ExtReloc
|
||||
switch r.Type() {
|
||||
case objabi.R_CALLARM:
|
||||
|
@ -668,7 +668,7 @@ func archreloc(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, r loade
|
||||
const noExtReloc = 0
|
||||
const isOk = true
|
||||
|
||||
rs := ldr.ResolveABIAlias(r.Sym())
|
||||
rs := r.Sym()
|
||||
|
||||
if target.IsExternal() {
|
||||
nExtReloc := 0
|
||||
|
@ -113,7 +113,6 @@ func trampoline(ctxt *Link, s loader.Sym) {
|
||||
if !ldr.AttrReachable(rs) || ldr.SymType(rs) == sym.Sxxx {
|
||||
continue // something is wrong. skip it here and we'll emit a better error later
|
||||
}
|
||||
rs = ldr.ResolveABIAlias(rs)
|
||||
if ldr.SymValue(rs) == 0 && (ldr.SymType(rs) != sym.SDYNIMPORT && ldr.SymType(rs) != sym.SUNDEFEXT) {
|
||||
if ldr.SymPkg(s) != "" && ldr.SymPkg(rs) == ldr.SymPkg(s) {
|
||||
// Symbols in the same package are laid out together.
|
||||
@ -194,7 +193,6 @@ func (st *relocSymState) relocsym(s loader.Sym, P []byte) {
|
||||
off := r.Off()
|
||||
siz := int32(r.Siz())
|
||||
rs := r.Sym()
|
||||
rs = ldr.ResolveABIAlias(rs)
|
||||
rt := r.Type()
|
||||
weak := r.Weak()
|
||||
if off < 0 || off+siz > int32(len(P)) {
|
||||
@ -340,7 +338,6 @@ func (st *relocSymState) relocsym(s loader.Sym, P []byte) {
|
||||
if weak && !ldr.AttrReachable(rs) {
|
||||
// Redirect it to runtime.unreachableMethod, which will throw if called.
|
||||
rs = syms.unreachableMethod
|
||||
rs = ldr.ResolveABIAlias(rs)
|
||||
}
|
||||
if target.IsExternal() {
|
||||
nExtReloc++
|
||||
@ -614,7 +611,7 @@ func extreloc(ctxt *Link, ldr *loader.Loader, s loader.Sym, r loader.Reloc) (loa
|
||||
|
||||
case objabi.R_TLS_LE, objabi.R_TLS_IE:
|
||||
if target.IsElf() {
|
||||
rs := ldr.ResolveABIAlias(r.Sym())
|
||||
rs := r.Sym()
|
||||
rr.Xsym = rs
|
||||
if rr.Xsym == 0 {
|
||||
rr.Xsym = ctxt.Tlsg
|
||||
@ -626,10 +623,9 @@ func extreloc(ctxt *Link, ldr *loader.Loader, s loader.Sym, r loader.Reloc) (loa
|
||||
|
||||
case objabi.R_ADDR:
|
||||
// set up addend for eventual relocation via outer symbol.
|
||||
rs := ldr.ResolveABIAlias(r.Sym())
|
||||
rs := r.Sym()
|
||||
if r.Weak() && !ldr.AttrReachable(rs) {
|
||||
rs = ctxt.ArchSyms.unreachableMethod
|
||||
rs = ldr.ResolveABIAlias(rs)
|
||||
}
|
||||
rs, off := FoldSubSymbolOffset(ldr, rs)
|
||||
rr.Xadd = r.Add() + off
|
||||
@ -644,13 +640,13 @@ func extreloc(ctxt *Link, ldr *loader.Loader, s loader.Sym, r loader.Reloc) (loa
|
||||
if target.IsDarwin() {
|
||||
return rr, false
|
||||
}
|
||||
rs := ldr.ResolveABIAlias(r.Sym())
|
||||
rs := r.Sym()
|
||||
rr.Xsym = loader.Sym(ldr.SymSect(rs).Sym)
|
||||
rr.Xadd = r.Add() + ldr.SymValue(rs) - int64(ldr.SymSect(rs).Vaddr)
|
||||
|
||||
// r.Sym() can be 0 when CALL $(constant) is transformed from absolute PC to relative PC call.
|
||||
case objabi.R_GOTPCREL, objabi.R_CALL, objabi.R_PCREL:
|
||||
rs := ldr.ResolveABIAlias(r.Sym())
|
||||
rs := r.Sym()
|
||||
if rt == objabi.R_GOTPCREL && target.IsDynlinkingGo() && target.IsDarwin() && rs != 0 {
|
||||
rr.Xadd = r.Add()
|
||||
rr.Xadd -= int64(siz) // relative to address after the relocated chunk
|
||||
@ -692,7 +688,7 @@ func extreloc(ctxt *Link, ldr *loader.Loader, s loader.Sym, r loader.Reloc) (loa
|
||||
// symbol and addend.
|
||||
func ExtrelocSimple(ldr *loader.Loader, r loader.Reloc) loader.ExtReloc {
|
||||
var rr loader.ExtReloc
|
||||
rs := ldr.ResolveABIAlias(r.Sym())
|
||||
rs := r.Sym()
|
||||
rr.Xsym = rs
|
||||
rr.Xadd = r.Add()
|
||||
rr.Type = r.Type()
|
||||
@ -705,7 +701,7 @@ func ExtrelocSimple(ldr *loader.Loader, r loader.Reloc) loader.ExtReloc {
|
||||
func ExtrelocViaOuterSym(ldr *loader.Loader, r loader.Reloc, s loader.Sym) loader.ExtReloc {
|
||||
// set up addend for eventual relocation via outer symbol.
|
||||
var rr loader.ExtReloc
|
||||
rs := ldr.ResolveABIAlias(r.Sym())
|
||||
rs := r.Sym()
|
||||
rs, off := FoldSubSymbolOffset(ldr, rs)
|
||||
rr.Xadd = r.Add() + off
|
||||
rst := ldr.SymType(rs)
|
||||
|
@ -2471,7 +2471,7 @@ func (ctxt *Link) callgraph() {
|
||||
if rs == 0 {
|
||||
continue
|
||||
}
|
||||
if r.Type().IsDirectCall() && (ldr.SymType(rs) == sym.STEXT || ldr.SymType(rs) == sym.SABIALIAS) {
|
||||
if r.Type().IsDirectCall() && ldr.SymType(rs) == sym.STEXT {
|
||||
ctxt.Logf("%s calls %s\n", ldr.SymName(s), ldr.SymName(rs))
|
||||
}
|
||||
}
|
||||
|
@ -1514,7 +1514,6 @@ func addPEBaseRelocSym(ldr *loader.Loader, s loader.Sym, rt *peBaseRelocTable) {
|
||||
continue
|
||||
}
|
||||
rs := r.Sym()
|
||||
rs = ldr.ResolveABIAlias(rs)
|
||||
if rs == 0 {
|
||||
continue
|
||||
}
|
||||
|
@ -1238,7 +1238,7 @@ func Xcoffadddynrel(target *Target, ldr *loader.Loader, syms *ArchSyms, s loader
|
||||
sym: s,
|
||||
roff: r.Off(),
|
||||
}
|
||||
targ := ldr.ResolveABIAlias(r.Sym())
|
||||
targ := r.Sym()
|
||||
var targType sym.SymKind
|
||||
if targ != 0 {
|
||||
targType = ldr.SymType(targ)
|
||||
@ -1333,7 +1333,7 @@ func (ctxt *Link) doxcoff() {
|
||||
panic("cgo_export on static symbol")
|
||||
}
|
||||
|
||||
if ldr.SymType(s) == sym.STEXT || ldr.SymType(s) == sym.SABIALIAS {
|
||||
if ldr.SymType(s) == sym.STEXT {
|
||||
// On AIX, a exported function must have two symbols:
|
||||
// - a .text symbol which must start with a ".".
|
||||
// - a .data symbol which is a function descriptor.
|
||||
|
@ -307,7 +307,6 @@ type extSymPayload struct {
|
||||
const (
|
||||
// Loader.flags
|
||||
FlagStrictDups = 1 << iota
|
||||
FlagUseABIAlias
|
||||
)
|
||||
|
||||
func NewLoader(flags uint32, elfsetstring elfsetstringFunc, reporter *ErrorReporter) *Loader {
|
||||
@ -2297,27 +2296,6 @@ func abiToVer(abi uint16, localSymVersion int) int {
|
||||
return v
|
||||
}
|
||||
|
||||
// ResolveABIAlias given a symbol returns the ABI alias target of that
|
||||
// symbol. If the sym in question is not an alias, the sym itself is
|
||||
// returned.
|
||||
func (l *Loader) ResolveABIAlias(s Sym) Sym {
|
||||
if l.flags&FlagUseABIAlias == 0 {
|
||||
return s
|
||||
}
|
||||
if s == 0 {
|
||||
return 0
|
||||
}
|
||||
if l.SymType(s) != sym.SABIALIAS {
|
||||
return s
|
||||
}
|
||||
relocs := l.Relocs(s)
|
||||
target := relocs.At(0).Sym()
|
||||
if l.SymType(target) == sym.SABIALIAS {
|
||||
panic(fmt.Sprintf("ABI alias %s references another ABI alias %s", l.SymName(s), l.SymName(target)))
|
||||
}
|
||||
return target
|
||||
}
|
||||
|
||||
// TopLevelSym tests a symbol (by name and kind) to determine whether
|
||||
// the symbol first class sym (participating in the link) or is an
|
||||
// anonymous aux or sub-symbol containing some sub-part or payload of
|
||||
|
@ -92,7 +92,6 @@ func applyrel(arch *sys.Arch, ldr *loader.Loader, rt objabi.RelocType, off int32
|
||||
|
||||
func archreloc(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, r loader.Reloc, s loader.Sym, val int64) (o int64, nExtReloc int, ok bool) {
|
||||
rs := r.Sym()
|
||||
rs = ldr.ResolveABIAlias(rs)
|
||||
if target.IsExternal() {
|
||||
switch r.Type() {
|
||||
default:
|
||||
|
@ -120,7 +120,6 @@ func archreloc(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, r loade
|
||||
const isOk = true
|
||||
const noExtReloc = 0
|
||||
rs := r.Sym()
|
||||
rs = ldr.ResolveABIAlias(rs)
|
||||
switch r.Type() {
|
||||
case objabi.R_ADDRMIPS,
|
||||
objabi.R_ADDRMIPSU:
|
||||
|
@ -547,7 +547,7 @@ func symtoc(ldr *loader.Loader, syms *ld.ArchSyms, s loader.Sym) int64 {
|
||||
// symbol address can be used directly.
|
||||
// This code is for AIX only.
|
||||
func archreloctoc(ldr *loader.Loader, target *ld.Target, syms *ld.ArchSyms, r loader.Reloc, s loader.Sym, val int64) int64 {
|
||||
rs := ldr.ResolveABIAlias(r.Sym())
|
||||
rs := r.Sym()
|
||||
if target.IsLinux() {
|
||||
ldr.Errorf(s, "archrelocaddr called for %s relocation\n", ldr.SymName(rs))
|
||||
}
|
||||
@ -562,7 +562,7 @@ func archreloctoc(ldr *loader.Loader, target *ld.Target, syms *ld.ArchSyms, r lo
|
||||
var t int64
|
||||
useAddi := false
|
||||
relocs := ldr.Relocs(rs)
|
||||
tarSym := ldr.ResolveABIAlias(relocs.At(0).Sym())
|
||||
tarSym := relocs.At(0).Sym()
|
||||
|
||||
if target.IsInternal() && tarSym != 0 && ldr.AttrReachable(tarSym) && ldr.SymSect(tarSym).Seg == &ld.Segdata {
|
||||
t = ldr.SymValue(tarSym) + r.Add() - ldr.SymValue(syms.TOC)
|
||||
@ -603,7 +603,7 @@ func archreloctoc(ldr *loader.Loader, target *ld.Target, syms *ld.ArchSyms, r lo
|
||||
// archrelocaddr relocates a symbol address.
|
||||
// This code is for AIX only.
|
||||
func archrelocaddr(ldr *loader.Loader, target *ld.Target, syms *ld.ArchSyms, r loader.Reloc, s loader.Sym, val int64) int64 {
|
||||
rs := ldr.ResolveABIAlias(r.Sym())
|
||||
rs := r.Sym()
|
||||
if target.IsAIX() {
|
||||
ldr.Errorf(s, "archrelocaddr called for %s relocation\n", ldr.SymName(rs))
|
||||
}
|
||||
@ -802,7 +802,7 @@ func gentramp(ctxt *ld.Link, ldr *loader.Loader, tramp *loader.SymbolBuilder, ta
|
||||
}
|
||||
|
||||
func archreloc(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, r loader.Reloc, s loader.Sym, val int64) (relocatedOffset int64, nExtReloc int, ok bool) {
|
||||
rs := ldr.ResolveABIAlias(r.Sym())
|
||||
rs := r.Sym()
|
||||
if target.IsExternal() {
|
||||
// On AIX, relocations (except TLS ones) must be also done to the
|
||||
// value with the current addresses.
|
||||
@ -909,7 +909,7 @@ func archreloc(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, r loade
|
||||
}
|
||||
|
||||
func archrelocvariant(target *ld.Target, ldr *loader.Loader, r loader.Reloc, rv sym.RelocVariant, s loader.Sym, t int64, p []byte) (relocatedOffset int64) {
|
||||
rs := ldr.ResolveABIAlias(r.Sym())
|
||||
rs := r.Sym()
|
||||
switch rv & sym.RV_TYPE_MASK {
|
||||
default:
|
||||
ldr.Errorf(s, "unexpected relocation variant %d", rv)
|
||||
|
@ -168,7 +168,7 @@ func archreloc(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, r loade
|
||||
return val, 0, false
|
||||
}
|
||||
|
||||
rs := ldr.ResolveABIAlias(r.Sym())
|
||||
rs := r.Sym()
|
||||
|
||||
switch r.Type() {
|
||||
case objabi.R_CALLRISCV:
|
||||
|
@ -118,9 +118,6 @@ const (
|
||||
SDWARFRANGE
|
||||
SDWARFLOC
|
||||
SDWARFLINES
|
||||
|
||||
// ABI aliases (these never appear in the output)
|
||||
SABIALIAS
|
||||
)
|
||||
|
||||
// AbiSymKindToSymKind maps values read from object files (which are
|
||||
@ -143,7 +140,6 @@ var AbiSymKindToSymKind = [...]SymKind{
|
||||
SDWARFRANGE,
|
||||
SDWARFLOC,
|
||||
SDWARFLINES,
|
||||
SABIALIAS,
|
||||
SLIBFUZZER_EXTRA_COUNTER,
|
||||
}
|
||||
|
||||
|
@ -65,12 +65,11 @@ func _() {
|
||||
_ = x[SDWARFRANGE-54]
|
||||
_ = x[SDWARFLOC-55]
|
||||
_ = x[SDWARFLINES-56]
|
||||
_ = x[SABIALIAS-57]
|
||||
}
|
||||
|
||||
const _SymKind_name = "SxxxSTEXTSELFRXSECTSMACHOPLTSTYPESSTRINGSGOSTRINGSGOFUNCSGCBITSSRODATASFUNCTABSELFROSECTSTYPERELROSSTRINGRELROSGOSTRINGRELROSGOFUNCRELROSGCBITSRELROSRODATARELROSFUNCTABRELROSTYPELINKSITABLINKSSYMTABSPCLNTABSFirstWritableSBUILDINFOSELFSECTSMACHOSMACHOGOTSWINDOWSSELFGOTSNOPTRDATASINITARRSDATASXCOFFTOCSBSSSNOPTRBSSSLIBFUZZER_EXTRA_COUNTERSTLSBSSSXREFSMACHOSYMSTRSMACHOSYMTABSMACHOINDIRECTPLTSMACHOINDIRECTGOTSFILEPATHSDYNIMPORTSHOSTOBJSUNDEFEXTSDWARFSECTSDWARFCUINFOSDWARFCONSTSDWARFFCNSDWARFABSFCNSDWARFTYPESDWARFVARSDWARFRANGESDWARFLOCSDWARFLINESSABIALIAS"
|
||||
const _SymKind_name = "SxxxSTEXTSELFRXSECTSMACHOPLTSTYPESSTRINGSGOSTRINGSGOFUNCSGCBITSSRODATASFUNCTABSELFROSECTSTYPERELROSSTRINGRELROSGOSTRINGRELROSGOFUNCRELROSGCBITSRELROSRODATARELROSFUNCTABRELROSTYPELINKSITABLINKSSYMTABSPCLNTABSFirstWritableSBUILDINFOSELFSECTSMACHOSMACHOGOTSWINDOWSSELFGOTSNOPTRDATASINITARRSDATASXCOFFTOCSBSSSNOPTRBSSSLIBFUZZER_EXTRA_COUNTERSTLSBSSSXREFSMACHOSYMSTRSMACHOSYMTABSMACHOINDIRECTPLTSMACHOINDIRECTGOTSFILEPATHSDYNIMPORTSHOSTOBJSUNDEFEXTSDWARFSECTSDWARFCUINFOSDWARFCONSTSDWARFFCNSDWARFABSFCNSDWARFTYPESDWARFVARSDWARFRANGESDWARFLOCSDWARFLINES"
|
||||
|
||||
var _SymKind_index = [...]uint16{0, 4, 9, 19, 28, 33, 40, 49, 56, 63, 70, 78, 88, 98, 110, 124, 136, 148, 160, 173, 182, 191, 198, 206, 220, 230, 238, 244, 253, 261, 268, 278, 286, 291, 300, 304, 313, 337, 344, 349, 361, 373, 390, 407, 416, 426, 434, 443, 453, 465, 476, 485, 497, 507, 516, 527, 536, 547, 556}
|
||||
var _SymKind_index = [...]uint16{0, 4, 9, 19, 28, 33, 40, 49, 56, 63, 70, 78, 88, 98, 110, 124, 136, 148, 160, 173, 182, 191, 198, 206, 220, 230, 238, 244, 253, 261, 268, 278, 286, 291, 300, 304, 313, 337, 344, 349, 361, 373, 390, 407, 416, 426, 434, 443, 453, 465, 476, 485, 497, 507, 516, 527, 536, 547}
|
||||
|
||||
func (i SymKind) String() string {
|
||||
if i >= SymKind(len(_SymKind_index)-1) {
|
||||
|
@ -173,7 +173,7 @@ func asmb2(ctxt *ld.Link, ldr *loader.Loader) {
|
||||
}
|
||||
wfn.Write(P[off:r.Off()])
|
||||
off = r.Off()
|
||||
rs := ldr.ResolveABIAlias(r.Sym())
|
||||
rs := r.Sym()
|
||||
switch r.Type() {
|
||||
case objabi.R_ADDR:
|
||||
writeSleb128(wfn, ldr.SymValue(rs)+r.Add())
|
||||
|
Loading…
Reference in New Issue
Block a user