]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/ld: maintain Ctxt.Etextp when removing dead code
authorMichael Hudson-Doyle <michael.hudson@canonical.com>
Sun, 29 Mar 2015 23:27:58 +0000 (23:27 +0000)
committerIan Lance Taylor <iant@golang.org>
Sat, 4 Apr 2015 00:06:19 +0000 (00:06 +0000)
I wrote some code that added a function in gentext() by sticking it
after Ctxt.Etextp and was very confused when this wasn't written out
sometimes. It turned out that Etextp was not updated by deadcode() so
if the last function is not reachable, my new function was never
seen. This changes deadcode() to update Etextp to the last reachable
funtion.

Change-Id: Ib6a3e7c67ccfb8a15826ce9e0ef046732b5e25d2
Reviewed-on: https://go-review.googlesource.com/8233
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/cmd/internal/ld/go.go

index c50e82b60d6b9c4ca98b624279f6db106b96f01f..1aab4f96802b402ab8d6bb09b61f69a2fc754bee 100644 (file)
@@ -656,8 +656,10 @@ func deadcode() {
 
        if last == nil {
                Ctxt.Textp = nil
+               Ctxt.Etextp = nil
        } else {
                last.Next = nil
+               Ctxt.Etextp = last
        }
 
        for s := Ctxt.Allsym; s != nil; s = s.Allsym {