Commit d9d1399e authored by David Crawshaw's avatar David Crawshaw

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/28541Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 44ee2b00
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment