]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: set S_ATTR_PURE_INSTRUCTIONS bit for text section on darwin
authorCherry Zhang <cherryyz@google.com>
Sat, 7 Apr 2018 01:02:01 +0000 (21:02 -0400)
committerCherry Zhang <cherryyz@google.com>
Wed, 11 Apr 2018 17:59:58 +0000 (17:59 +0000)
Mac otool and llvm-objdump distinguishes a Mach-O section is
text or data by looking at S_ATTR_PURE_INSTRUCTIONS bit. Without
this bit it thinks our function symbols are data, not functions.
Set this bit for text section to make otool/objdump happy.

Fixes #24706.

Change-Id: I5236482cb9a72474c23fbea0f35d5b5cc8491ea4
Reviewed-on: https://go-review.googlesource.com/105256
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/cmd/link/internal/ld/macho.go

index 12037069c8027f78d217e5d2b4b89fc40eb97d8c..db933a6767f062518314fcac229928eb1119d5d9 100644 (file)
@@ -438,6 +438,10 @@ func machoshbits(ctxt *Link, mseg *MachoSeg, sect *sym.Section, segname string)
                msect.flag |= S_ATTR_SOME_INSTRUCTIONS
        }
 
+       if sect.Name == ".text" {
+               msect.flag |= S_ATTR_PURE_INSTRUCTIONS
+       }
+
        if sect.Name == ".plt" {
                msect.name = "__symbol_stub1"
                msect.flag = S_ATTR_PURE_INSTRUCTIONS | S_ATTR_SOME_INSTRUCTIONS | S_SYMBOL_STUBS