Skip to content

Commit 65fa2b6

Browse files
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 <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent 0bad634 commit 65fa2b6

File tree

1 file changed

+1
-1
lines changed
  • src/cmd/internal/objfile

1 file changed

+1
-1
lines changed

src/cmd/internal/objfile/elf.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func (f *elfFile) goarch() string {
114114

115115
func (f *elfFile) loadAddress() (uint64, error) {
116116
for _, p := range f.elf.Progs {
117-
if p.Type == elf.PT_LOAD {
117+
if p.Type == elf.PT_LOAD && p.Flags&elf.PF_X != 0 {
118118
return p.Vaddr, nil
119119
}
120120
}

0 commit comments

Comments
 (0)