mirror of
https://github.com/golang/go
synced 2024-11-17 15:04:45 -07:00
cmd/link: make .dynamic section read-only for MIPS ELF
For #36435 Change-Id: Ie733b641f20ca5bcee3784c088eb27699890a151 Reviewed-on: https://go-review.googlesource.com/c/go/+/463982 Reviewed-by: Joel Sing <joel@sing.id.au> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
This commit is contained in:
parent
00e1091bfd
commit
47e205c344
@ -209,6 +209,11 @@ type ELFArch struct {
|
||||
Elfreloc1 func(*Link, *OutBuf, *loader.Loader, loader.Sym, loader.ExtReloc, int, int64) bool
|
||||
ElfrelocSize uint32 // size of an ELF relocation record, must match Elfreloc1.
|
||||
Elfsetupplt func(ctxt *Link, plt, gotplt *loader.SymbolBuilder, dynamic loader.Sym)
|
||||
|
||||
// DynamicReadOnly can be set to true to make the .dynamic
|
||||
// section read-only. By default it is writable.
|
||||
// This is used by MIPS targets.
|
||||
DynamicReadOnly bool
|
||||
}
|
||||
|
||||
type Elfstring struct {
|
||||
@ -1563,7 +1568,11 @@ func (ctxt *Link) doelf() {
|
||||
|
||||
/* define dynamic elf table */
|
||||
dynamic := ldr.CreateSymForUpdate(".dynamic", 0)
|
||||
dynamic.SetType(sym.SELFSECT) // writable
|
||||
if thearch.ELF.DynamicReadOnly {
|
||||
dynamic.SetType(sym.SELFROSECT)
|
||||
} else {
|
||||
dynamic.SetType(sym.SELFSECT)
|
||||
}
|
||||
|
||||
if ctxt.IsS390X() {
|
||||
// S390X uses .got instead of .got.plt
|
||||
|
@ -72,6 +72,10 @@ func Init() (*sys.Arch, ld.Arch) {
|
||||
Elfreloc1: elfreloc1,
|
||||
ElfrelocSize: 8,
|
||||
Elfsetupplt: elfsetupplt,
|
||||
|
||||
// Historically GNU ld creates a read-only
|
||||
// .dynamic section.
|
||||
DynamicReadOnly: true,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -70,6 +70,10 @@ func Init() (*sys.Arch, ld.Arch) {
|
||||
Elfreloc1: elfreloc1,
|
||||
ElfrelocSize: 24,
|
||||
Elfsetupplt: elfsetupplt,
|
||||
|
||||
// Historically GNU ld creates a read-only
|
||||
// .dynamic section.
|
||||
DynamicReadOnly: true,
|
||||
},
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user