[dev.link] cmd/link: begin converting dodata() to loader APIs

This patch begins the work of converting the linker's dodata phase to
work with loader APIs. Passes all.bash on linux/amd64, but hasn't been
tested on anything else (more arch-specific code needs to be written).
Use of the new dodata() phase is currently gated by a temporary
command line flag ("-newdodata"), and there is code in the linker's
main routine to insure that we only use the new version for the right
GOOS/GOARCH (currently restricted to ELF + AMD64).

Change-Id: Ied3966677d2a450bc3e0990e0f519b3fceaab806
Reviewed-on: https://go-review.googlesource.com/c/go/+/229706
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
Than McIntosh 2020-04-21 18:37:43 -04:00
parent 3d1007d28e
commit 941de9760b
18 changed files with 2207 additions and 560 deletions

View file

@ -447,3 +447,10 @@ func GenAddAddrPlusFunc(internalExec bool) func(s *SymbolBuilder, arch *sys.Arch
return (*SymbolBuilder).AddAddrPlus
}
}
func (sb *SymbolBuilder) MakeWritable() {
if sb.ReadOnly() {
sb.data = append([]byte(nil), sb.data...)
sb.l.SetAttrReadOnly(sb.symIdx, false)
}
}