mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/link: mark rel.ro segment as PT_GNU_RELRO
Details: http://www.airs.com/blog/archives/189 Part of adding PIE internal linking on linux/amd64. Change-Id: I8843a97f22f6f120346cccd694c7fff32f09f60b Reviewed-on: https://go-review.googlesource.com/28541 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: David Crawshaw <crawshaw@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
44ee2b00db
commit
d9d1399eea
1 changed files with 13 additions and 0 deletions
|
|
@ -236,6 +236,7 @@ const (
|
||||||
PT_LOPROC = 0x70000000
|
PT_LOPROC = 0x70000000
|
||||||
PT_HIPROC = 0x7fffffff
|
PT_HIPROC = 0x7fffffff
|
||||||
PT_GNU_STACK = 0x6474e551
|
PT_GNU_STACK = 0x6474e551
|
||||||
|
PT_GNU_RELRO = 0x6474e552
|
||||||
PT_PAX_FLAGS = 0x65041580
|
PT_PAX_FLAGS = 0x65041580
|
||||||
PF_X = 0x1
|
PF_X = 0x1
|
||||||
PF_W = 0x2
|
PF_W = 0x2
|
||||||
|
|
@ -1599,6 +1600,17 @@ func elfphload(ctxt *Link, seg *Segment) *ElfPhdr {
|
||||||
return ph
|
return ph
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func elfphrelro(ctxt *Link, seg *Segment) {
|
||||||
|
ph := newElfPhdr(ctxt)
|
||||||
|
ph.type_ = PT_GNU_RELRO
|
||||||
|
ph.vaddr = seg.Vaddr
|
||||||
|
ph.paddr = seg.Vaddr
|
||||||
|
ph.memsz = seg.Length
|
||||||
|
ph.off = seg.Fileoff
|
||||||
|
ph.filesz = seg.Filelen
|
||||||
|
ph.align = uint64(*FlagRound)
|
||||||
|
}
|
||||||
|
|
||||||
func elfshname(ctxt *Link, name string) *ElfShdr {
|
func elfshname(ctxt *Link, name string) *ElfShdr {
|
||||||
var off int
|
var off int
|
||||||
var sh *ElfShdr
|
var sh *ElfShdr
|
||||||
|
|
@ -2291,6 +2303,7 @@ func Asmbelf(ctxt *Link, symo int64) {
|
||||||
}
|
}
|
||||||
if Segrelrodata.Sect != nil {
|
if Segrelrodata.Sect != nil {
|
||||||
elfphload(ctxt, &Segrelrodata)
|
elfphload(ctxt, &Segrelrodata)
|
||||||
|
elfphrelro(ctxt, &Segrelrodata)
|
||||||
}
|
}
|
||||||
elfphload(ctxt, &Segdata)
|
elfphload(ctxt, &Segdata)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue