From: Ian Lance Taylor Date: Fri, 3 Aug 2018 21:52:54 +0000 (-0700) Subject: cmd/internal/objfile: only consider executable segments for load address X-Git-Tag: archive/raspbian/1.11.4-4+rpi1^2~2^2~2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=86652bd2fa2d4b654a1f22e913d8934c947cd0b0;p=golang-1.11.git cmd/internal/objfile: only consider executable segments for load address Reportedly on some new Fedora systems the linker is producing extra load segments, basically making the dynamic section non-executable. We were assuming that the first load segment could be used to determine the program's load offset, but that is no longer true. Use the first executable load segment instead. Fixes #26369 Change-Id: I5ee31ddeef2e8caeed3112edc5149065a6448456 Reviewed-on: https://go-review.googlesource.com/127895 Run-TryBot: Ian Lance Taylor TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick Gbp-Pq: Name only-consider-executable-segments.patch --- diff --git a/src/cmd/internal/objfile/elf.go b/src/cmd/internal/objfile/elf.go index 7d5162a..a48a9df 100644 --- a/src/cmd/internal/objfile/elf.go +++ b/src/cmd/internal/objfile/elf.go @@ -114,7 +114,7 @@ func (f *elfFile) goarch() string { func (f *elfFile) loadAddress() (uint64, error) { for _, p := range f.elf.Progs { - if p.Type == elf.PT_LOAD { + if p.Type == elf.PT_LOAD && p.Flags&elf.PF_X != 0 { return p.Vaddr, nil } }