本文整理匯總了Golang中bootstrap/link/internal/ld.LSym.Value方法的典型用法代碼示例。如果您正苦於以下問題:Golang LSym.Value方法的具體用法?Golang LSym.Value怎麽用?Golang LSym.Value使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類bootstrap/link/internal/ld.LSym
的用法示例。
在下文中一共展示了LSym.Value方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: adddynrel
//.........這裏部分代碼省略.........
// fall through
case 512 + ld.MACHO_X86_64_RELOC_GOT*2 + 1:
if targ.Type != obj.SDYNIMPORT {
ld.Diag("unexpected GOT reloc for non-dynamic symbol %s", targ.Name)
}
addgotsym(targ)
r.Type = obj.R_PCREL
r.Sym = ld.Linklookup(ld.Ctxt, ".got", 0)
r.Add += int64(targ.Got)
return
}
// Handle references to ELF symbols from our own object files.
if targ.Type != obj.SDYNIMPORT {
return
}
switch r.Type {
case obj.R_CALL,
obj.R_PCREL:
if ld.HEADTYPE == obj.Hwindows {
// nothing to do, the relocation will be laid out in pereloc1
return
} else {
// for both ELF and Mach-O
addpltsym(targ)
r.Sym = ld.Linklookup(ld.Ctxt, ".plt", 0)
r.Add = int64(targ.Plt)
return
}
case obj.R_ADDR:
if s.Type == obj.STEXT && ld.Iself {
if ld.HEADTYPE == obj.Hsolaris {
addpltsym(targ)
r.Sym = ld.Linklookup(ld.Ctxt, ".plt", 0)
r.Add += int64(targ.Plt)
return
}
// The code is asking for the address of an external
// function. We provide it with the address of the
// correspondent GOT symbol.
addgotsym(targ)
r.Sym = ld.Linklookup(ld.Ctxt, ".got", 0)
r.Add += int64(targ.Got)
return
}
if s.Type != obj.SDATA {
break
}
if ld.Iself {
ld.Adddynsym(ld.Ctxt, targ)
rela := ld.Linklookup(ld.Ctxt, ".rela", 0)
ld.Addaddrplus(ld.Ctxt, rela, s, int64(r.Off))
if r.Siz == 8 {
ld.Adduint64(ld.Ctxt, rela, ld.ELF64_R_INFO(uint32(targ.Dynid), ld.R_X86_64_64))
} else {
ld.Adduint64(ld.Ctxt, rela, ld.ELF64_R_INFO(uint32(targ.Dynid), ld.R_X86_64_32))
}
ld.Adduint64(ld.Ctxt, rela, uint64(r.Add))
r.Type = 256 // ignore during relocsym
return
}
if ld.HEADTYPE == obj.Hdarwin && s.Size == int64(ld.Thearch.Ptrsize) && r.Off == 0 {
// Mach-O relocations are a royal pain to lay out.
// They use a compact stateful bytecode representation
// that is too much bother to deal with.
// Instead, interpret the C declaration
// void *_Cvar_stderr = &stderr;
// as making _Cvar_stderr the name of a GOT entry
// for stderr. This is separate from the usual GOT entry,
// just in case the C code assigns to the variable,
// and of course it only works for single pointers,
// but we only need to support cgo and that's all it needs.
ld.Adddynsym(ld.Ctxt, targ)
got := ld.Linklookup(ld.Ctxt, ".got", 0)
s.Type = got.Type | obj.SSUB
s.Outer = got
s.Sub = got.Sub
got.Sub = s
s.Value = got.Size
ld.Adduint64(ld.Ctxt, got, 0)
ld.Adduint32(ld.Ctxt, ld.Linklookup(ld.Ctxt, ".linkedit.got", 0), uint32(targ.Dynid))
r.Type = 256 // ignore during relocsym
return
}
if ld.HEADTYPE == obj.Hwindows {
// nothing to do, the relocation will be laid out in pereloc1
return
}
}
ld.Ctxt.Cursym = s
ld.Diag("unsupported relocation for dynamic symbol %s (type=%d stype=%d)", targ.Name, r.Type, targ.Type)
}