}
case objabi.R_PCREL:
if r.Siz == 4 {
- if r.Xsym.Type == sym.SDYNIMPORT && r.Xsym.ElfType == elf.STT_FUNC {
+ if r.Xsym.Type == sym.SDYNIMPORT && r.Xsym.ElfType() == elf.STT_FUNC {
ctxt.Out.Write64(uint64(elf.R_X86_64_PLT32) | uint64(elfsym)<<32)
} else {
ctxt.Out.Write64(uint64(elf.R_X86_64_PC32) | uint64(elfsym)<<32)
continue
}
lsym.Type = sym.SDYNIMPORT
- lsym.ElfType = elf.ST_TYPE(elfsym.Info)
+ lsym.SetElfType(elf.ST_TYPE(elfsym.Info))
lsym.Size = int64(elfsym.Size)
if elfsym.Section != elf.SHN_UNDEF {
// Set .File for the library that actually defines the symbol.
case objabi.R_PCRELDBL, objabi.R_CALL:
isdbl = true
}
- if r.Xsym.Type == sym.SDYNIMPORT && (r.Xsym.ElfType == elf.STT_FUNC || r.Type == objabi.R_CALL) {
+ if r.Xsym.Type == sym.SDYNIMPORT && (r.Xsym.ElfType() == elf.STT_FUNC || r.Type == objabi.R_CALL) {
if isdbl {
switch r.Siz {
case 2:
LocalElfsym int32
Value int64
Size int64
- // ElfType is set for symbols read from shared libraries by ldshlibsyms. It
- // is not set for symbols defined by the packages being linked or by symbols
- // read by ldelf (and so is left as elf.STT_NOTYPE).
- ElfType elf.SymType
- Sub *Symbol
- Outer *Symbol
- Gotype *Symbol
- File string
- auxinfo *AuxSymbol
- Sect *Section
- FuncInfo *FuncInfo
- Lib *Library // Package defining this symbol
+ Sub *Symbol
+ Outer *Symbol
+ Gotype *Symbol
+ File string
+ auxinfo *AuxSymbol
+ Sect *Section
+ FuncInfo *FuncInfo
+ Lib *Library // Package defining this symbol
// P contains the raw symbol data.
P []byte
R []Reloc
localentry uint8
plt int32
got int32
+ // ElfType is set for symbols read from shared libraries by ldshlibsyms. It
+ // is not set for symbols defined by the packages being linked or by symbols
+ // read by ldelf (and so is left as elf.STT_NOTYPE).
+ elftype elf.SymType
}
func (s *Symbol) String() string {
s.auxinfo.got = val
}
+func (s *Symbol) ElfType() elf.SymType {
+ if s.auxinfo == nil {
+ return elf.STT_NOTYPE
+ }
+ return s.auxinfo.elftype
+}
+
+func (s *Symbol) SetElfType(val elf.SymType) {
+ if s.auxinfo == nil {
+ if val == elf.STT_NOTYPE {
+ return
+ }
+ s.makeAuxInfo()
+ }
+ s.auxinfo.elftype = val
+}
+
// SortSub sorts a linked-list (by Sub) of *Symbol by Value.
// Used for sub-symbols when loading host objects (see e.g. ldelf.go).
func SortSub(l *Symbol) *Symbol {