Skip to content

Commit 6db4d92

Browse files
committed
cmd/link: do not add __image_base__ and _image_base__ if external linker
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 <[email protected]>
1 parent b660a4b commit 6db4d92

File tree

1 file changed

+5
-4
lines changed
  • src/cmd/link/internal/ld

1 file changed

+5
-4
lines changed

src/cmd/link/internal/ld/pe.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -458,10 +458,11 @@ func Peinit(ctxt *Link) {
458458
nextsectoff = int(PESECTHEADR)
459459
nextfileoff = int(PEFILEHEADR)
460460

461-
// some mingw libs depend on this symbol, for example, FindPESectionByName
462-
ctxt.xdefine("__image_base__", obj.SDATA, PEBASE)
463-
464-
ctxt.xdefine("_image_base__", obj.SDATA, PEBASE)
461+
if Linkmode == LinkInternal {
462+
// some mingw libs depend on this symbol, for example, FindPESectionByName
463+
ctxt.xdefine("__image_base__", obj.SDATA, PEBASE)
464+
ctxt.xdefine("_image_base__", obj.SDATA, PEBASE)
465+
}
465466

466467
HEADR = PEFILEHEADR
467468
if *FlagTextAddr == -1 {

0 commit comments

Comments
 (0)