mirror of
https://github.com/golang/go
synced 2024-11-17 21:44:43 -07: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
@ -236,6 +236,7 @@ const (
|
||||
PT_LOPROC = 0x70000000
|
||||
PT_HIPROC = 0x7fffffff
|
||||
PT_GNU_STACK = 0x6474e551
|
||||
PT_GNU_RELRO = 0x6474e552
|
||||
PT_PAX_FLAGS = 0x65041580
|
||||
PF_X = 0x1
|
||||
PF_W = 0x2
|
||||
@ -1599,6 +1600,17 @@ func elfphload(ctxt *Link, seg *Segment) *ElfPhdr {
|
||||
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 {
|
||||
var off int
|
||||
var sh *ElfShdr
|
||||
@ -2291,6 +2303,7 @@ func Asmbelf(ctxt *Link, symo int64) {
|
||||
}
|
||||
if Segrelrodata.Sect != nil {
|
||||
elfphload(ctxt, &Segrelrodata)
|
||||
elfphrelro(ctxt, &Segrelrodata)
|
||||
}
|
||||
elfphload(ctxt, &Segdata)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user