From: Than McIntosh Date: Thu, 20 Jun 2019 13:02:05 +0000 (-0400) Subject: cmd/link: revise previous __DWARF segment protection fix X-Git-Tag: go1.13beta1~33 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=3f1422c799edb143303c86c0e875d44c3612df64;p=gostls13.git cmd/link: revise previous __DWARF segment protection fix Tweak the previous fix for issue 32673 (in CL 182958) to work around problems with c-shared build mode that crop up on some of the builders (10.11, 10.12). We now consistently set vmaddr and vmsize to zero for the DWARF segment regardless of build mode. Updates #32673 Change-Id: Id1fc213590ad00c28352925e2d754d760e022b5e Reviewed-on: https://go-review.googlesource.com/c/go/+/183237 Reviewed-by: Cherry Zhang Reviewed-by: David Chase --- diff --git a/src/cmd/link/internal/ld/macho_combine_dwarf.go b/src/cmd/link/internal/ld/macho_combine_dwarf.go index 3c123a092f..72ee8affab 100644 --- a/src/cmd/link/internal/ld/macho_combine_dwarf.go +++ b/src/cmd/link/internal/ld/macho_combine_dwarf.go @@ -245,7 +245,7 @@ func machoCombineDwarf(ctxt *Link, exef *os.File, exem *macho.File, dsym, outexe } } // Do the final update of the DWARF segment's load command. - return machoUpdateDwarfHeader(&reader, ctxt.BuildMode, compressedSects) + return machoUpdateDwarfHeader(&reader, compressedSects, dwarfsize) } // machoCompressSections tries to compress the DWARF segments in dwarfm, @@ -390,7 +390,7 @@ func machoUpdateSections(r loadCmdReader, seg, sect reflect.Value, deltaOffset, } // machoUpdateDwarfHeader updates the DWARF segment load command. -func machoUpdateDwarfHeader(r *loadCmdReader, buildmode BuildMode, compressedSects []*macho.Section) error { +func machoUpdateDwarfHeader(r *loadCmdReader, compressedSects []*macho.Section, dwarfsize uint64) error { var seg, sect interface{} cmd, err := r.Next() if err != nil { @@ -408,8 +408,6 @@ func machoUpdateDwarfHeader(r *loadCmdReader, buildmode BuildMode, compressedSec } segv := reflect.ValueOf(seg).Elem() segv.FieldByName("Offset").SetUint(uint64(dwarfstart)) - segv.FieldByName("Addr").SetUint(uint64(dwarfaddr)) - segv.FieldByName("Prot").SetUint(0) if compressedSects != nil { var segSize uint64 @@ -417,23 +415,27 @@ func machoUpdateDwarfHeader(r *loadCmdReader, buildmode BuildMode, compressedSec segSize += newSect.Size } segv.FieldByName("Filesz").SetUint(segSize) - segv.FieldByName("Memsz").SetUint(uint64(Rnd(int64(segSize), 1<