]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: do not add __image_base__ and _image_base__ if external linker
authorAlex Brainman <alex.brainman@gmail.com>
Wed, 8 Feb 2017 00:42:24 +0000 (11:42 +1100)
committerAlex Brainman <alex.brainman@gmail.com>
Tue, 21 Feb 2017 06:10:51 +0000 (06:10 +0000)
The symbols get in a way when using external linker. They are
not associated with a section. And linker fails when
generating relocations for them.

__image_base__ and _image_base__ have been added long time ago.
I do not think they are needed anymore. If I delete them, all
tests still PASS. I tried going back to the commit that added
them to see if I can reproduce original error, but I cannot
build it. I don't have hg version of go repo, and my gcc is
complaining about cc source code.

I wasted too much time with this, so I decided to leave them only
for internal linker. That is what they were originally added for.

For #10776.

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

index 876bc70939c49ca9dd11463347f0a543d6939ab6..3a99388381b20999f74cde00058522bce386afe2 100644 (file)
@@ -458,10 +458,11 @@ func Peinit(ctxt *Link) {
        nextsectoff = int(PESECTHEADR)
        nextfileoff = int(PEFILEHEADR)
 
-       // some mingw libs depend on this symbol, for example, FindPESectionByName
-       ctxt.xdefine("__image_base__", obj.SDATA, PEBASE)
-
-       ctxt.xdefine("_image_base__", obj.SDATA, PEBASE)
+       if Linkmode == LinkInternal {
+               // some mingw libs depend on this symbol, for example, FindPESectionByName
+               ctxt.xdefine("__image_base__", obj.SDATA, PEBASE)
+               ctxt.xdefine("_image_base__", obj.SDATA, PEBASE)
+       }
 
        HEADR = PEFILEHEADR
        if *FlagTextAddr == -1 {