efb9813
From 1ea34a218ac99e35695617e5d3648e6762254cc7 Mon Sep 17 00:00:00 2001
efb9813
From: Ian Lance Taylor <iant@golang.org>
efb9813
Date: Fri, 3 Aug 2018 14:52:54 -0700
efb9813
Subject: [PATCH 4/4] cmd/internal/objfile: only consider executable segments
efb9813
 for load address
efb9813
efb9813
Reportedly on some new Fedora systems the linker is producing extra
efb9813
load segments, basically making the dynamic section non-executable.
efb9813
We were assuming that the first load segment could be used to
efb9813
determine the program's load offset, but that is no longer true.
efb9813
Use the first executable load segment instead.
efb9813
efb9813
Fixes #26369
efb9813
efb9813
Change-Id: I5ee31ddeef2e8caeed3112edc5149065a6448456
efb9813
Reviewed-on: https://go-review.googlesource.com/127895
efb9813
Run-TryBot: Ian Lance Taylor <iant@golang.org>
efb9813
TryBot-Result: Gobot Gobot <gobot@golang.org>
efb9813
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
efb9813
---
efb9813
 src/cmd/internal/objfile/elf.go | 2 +-
efb9813
 1 file changed, 1 insertion(+), 1 deletion(-)
efb9813
efb9813
diff --git a/src/cmd/internal/objfile/elf.go b/src/cmd/internal/objfile/elf.go
efb9813
index 7d5162a1e8..a48a9df5d6 100644
efb9813
--- a/src/cmd/internal/objfile/elf.go
efb9813
+++ b/src/cmd/internal/objfile/elf.go
efb9813
@@ -114,7 +114,7 @@ func (f *elfFile) goarch() string {
efb9813
 
efb9813
 func (f *elfFile) loadAddress() (uint64, error) {
efb9813
 	for _, p := range f.elf.Progs {
efb9813
-		if p.Type == elf.PT_LOAD {
efb9813
+		if p.Type == elf.PT_LOAD && p.Flags&elf.PF_X != 0 {
efb9813
 			return p.Vaddr, nil
efb9813
 		}
efb9813
 	}
efb9813
-- 
efb9813
2.14.4
efb9813