func elfreloc1(ctxt *ld.Link, r *sym.Reloc, sectoff int64) bool {
ctxt.Out.Write64(uint64(sectoff))
- elfsym := r.Xsym.ElfsymForReloc()
+ elfsym := ld.ElfSymForReloc(ctxt, r.Xsym)
switch r.Type {
default:
return false
func elfreloc1(ctxt *ld.Link, r *sym.Reloc, sectoff int64) bool {
ctxt.Out.Write32(uint32(sectoff))
- elfsym := r.Xsym.ElfsymForReloc()
+ elfsym := ld.ElfSymForReloc(ctxt, r.Xsym)
switch r.Type {
default:
return false
func elfreloc1(ctxt *ld.Link, r *sym.Reloc, sectoff int64) bool {
ctxt.Out.Write64(uint64(sectoff))
- elfsym := r.Xsym.ElfsymForReloc()
+ elfsym := ld.ElfSymForReloc(ctxt, r.Xsym)
switch r.Type {
default:
return false
Errorf(s, "missing xsym in relocation %#v %#v", r.Sym.Name, s)
continue
}
- if r.Xsym.ElfsymForReloc() == 0 {
+ esr := ElfSymForReloc(ctxt, r.Xsym)
+ if esr == 0 {
Errorf(s, "reloc %d (%s) to non-elf symbol %s (outer=%s) %d (%s)", r.Type, sym.RelocName(ctxt.Arch, r.Type), r.Sym.Name, r.Xsym.Name, r.Sym.Type, r.Sym.Type)
}
if !r.Xsym.Attr.Reachable() {
return ctxt.loader.SymPkg(loader.Sym(s.SymIdx))
}
+func ElfSymForReloc(ctxt *Link, s *sym.Symbol) int32 {
+ // If putelfsym created a local version of this symbol, use that in all
+ // relocations.
+ les := ctxt.loader.SymLocalElfSym(loader.Sym(s.SymIdx))
+ if les != 0 {
+ return les
+ } else {
+ return ctxt.loader.SymElfSym(loader.Sym(s.SymIdx))
+ }
+}
+
func (ctxt *Link) dumpsyms() {
for _, s := range ctxt.loader.Syms {
if s == nil {
// ELF linker -Bsymbolic-functions option, but that is buggy on
// several platforms.
putelfsyment(ctxt.Out, putelfstr("local."+s), addr, size, STB_LOCAL<<4|typ&0xf, elfshnum, other)
- x.LocalElfsym = int32(ctxt.numelfsym)
+ ctxt.loader.SetSymLocalElfSym(loader.Sym(x.SymIdx), int32(ctxt.numelfsym))
ctxt.numelfsym++
return
} else if bind != ctxt.elfbind {
}
putelfsyment(ctxt.Out, putelfstr(s), addr, size, bind<<4|typ&0xf, elfshnum, other)
- x.Elfsym = int32(ctxt.numelfsym)
+ ctxt.loader.SetSymElfSym(loader.Sym(x.SymIdx), int32(ctxt.numelfsym))
ctxt.numelfsym++
}
func putelfsectionsym(ctxt *Link, out *OutBuf, s *sym.Symbol, shndx int) {
putelfsyment(out, 0, 0, 0, STB_LOCAL<<4|STT_SECTION, shndx, 0)
- s.Elfsym = int32(ctxt.numelfsym)
+ ctxt.loader.SetSymElfSym(loader.Sym(s.SymIdx), int32(ctxt.numelfsym))
ctxt.numelfsym++
}
func elfreloc1(ctxt *ld.Link, r *sym.Reloc, sectoff int64) bool {
ctxt.Out.Write32(uint32(sectoff))
- elfsym := r.Xsym.ElfsymForReloc()
+ elfsym := ld.ElfSymForReloc(ctxt, r.Xsym)
switch r.Type {
default:
return false
ctxt.Out.Write64(uint64(sectoff))
- elfsym := r.Xsym.ElfsymForReloc()
+ elfsym := ld.ElfSymForReloc(ctxt, r.Xsym)
ctxt.Out.Write32(uint32(elfsym))
ctxt.Out.Write8(0)
ctxt.Out.Write8(0)
}
ctxt.Out.Write64(uint64(sectoff))
- elfsym := r.Xsym.ElfsymForReloc()
+ elfsym := ld.ElfSymForReloc(ctxt, r.Xsym)
switch r.Type {
default:
return false
func elfreloc1(ctxt *ld.Link, r *sym.Reloc, sectoff int64) bool {
ctxt.Out.Write64(uint64(sectoff))
- elfsym := r.Xsym.ElfsymForReloc()
+ elfsym := ld.ElfSymForReloc(ctxt, r.Xsym)
switch r.Type {
default:
return false
_32bit uintptr // size on 32bit platforms
_64bit uintptr // size on 64bit platforms
}{
- {Symbol{}, 92, 144},
+ {Symbol{}, 84, 136},
}
for _, tt := range tests {
// Symbol is an entry in the symbol table.
type Symbol struct {
- Name string
- Type SymKind
- Version int16
- Attr Attribute
- Dynid int32
- Align int32
- Elfsym int32
- LocalElfsym int32
- Value int64
- Size int64
- Sub *Symbol
- Outer *Symbol
- SymIdx LoaderSym
- auxinfo *AuxSymbol
- Sect *Section
+ Name string
+ Type SymKind
+ Version int16
+ Attr Attribute
+ Dynid int32
+ Align int32
+ Value int64
+ Size int64
+ Sub *Symbol
+ Outer *Symbol
+ SymIdx LoaderSym
+ auxinfo *AuxSymbol
+ Sect *Section
// P contains the raw symbol data.
P []byte
R []Reloc
return s.Version >= SymVerStatic
}
-func (s *Symbol) ElfsymForReloc() int32 {
- // If putelfsym created a local version of this symbol, use that in all
- // relocations.
- if s.LocalElfsym != 0 {
- return s.LocalElfsym
- } else {
- return s.Elfsym
- }
-}
-
func (s *Symbol) Len() int64 {
return s.Size
}
func elfreloc1(ctxt *ld.Link, r *sym.Reloc, sectoff int64) bool {
ctxt.Out.Write32(uint32(sectoff))
- elfsym := r.Xsym.ElfsymForReloc()
+ elfsym := ld.ElfSymForReloc(ctxt, r.Xsym)
switch r.Type {
default:
return false