mirror of
https://github.com/golang/go
synced 2024-11-06 16:36:20 -07:00
[dev.link] cmd/link: avoid allsyms loop in initarray setup
In the linker's symtab() function, avoid looping over the context's Syms.Allsyms array to locate the entry symbol when setting up the init array section; do an explicit ABI0 symbol lookup instead. This is a minor efficiency tweak / code cleanup. Fixes #20205. Change-Id: I2ebc17a3cb2cd63e9f5052bc80f1b0ac72c960e3 Reviewed-on: https://go-review.googlesource.com/c/go/+/209838 Run-TryBot: Than McIntosh <thanm@google.com> Reviewed-by: Jeremy Faller <jeremy@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
f7672d39ca
commit
29f886e427
@ -326,12 +326,11 @@ func textsectionmap(ctxt *Link) uint32 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ctxt *Link) symtab() {
|
func (ctxt *Link) symtab() {
|
||||||
switch ctxt.BuildMode {
|
if ctxt.HeadType != objabi.Haix {
|
||||||
case BuildModeCArchive, BuildModeCShared:
|
switch ctxt.BuildMode {
|
||||||
for _, s := range ctxt.Syms.Allsym {
|
case BuildModeCArchive, BuildModeCShared:
|
||||||
// Create a new entry in the .init_array section that points to the
|
s := ctxt.Syms.ROLookup(*flagEntrySymbol, sym.SymVerABI0)
|
||||||
// library initializer function.
|
if s != nil {
|
||||||
if s.Name == *flagEntrySymbol && ctxt.HeadType != objabi.Haix {
|
|
||||||
addinitarrdata(ctxt, s)
|
addinitarrdata(ctxt, s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user