-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/8l: _image_base__ not defined #6431
Labels
Milestone
Comments
Ok it failed on both but I've also found a bit more. I noticed that it was _image_base__ single underscore prefix. The fix c9b56bb76d08 added the double underscore version so on a hunch I added the single undrscore version and it worked again. This is with mingw32 4.7.2 Hope this makes sense to you and Shenghou Ma. Let me know if ou need any more. Tony Wilson, Durban SA |
you mean apply the following patch will fix the problem? diff -r d5f023ae1d0e src/cmd/ld/pe.c --- a/src/cmd/ld/pe.c Fri Sep 20 10:04:52 2013 -0400 +++ b/src/cmd/ld/pe.c Fri Sep 20 11:03:14 2013 -0400 @@ -151,6 +151,7 @@ // some mingw libs depend on this symbol, for example, FindPESectionByName xdefine("__image_base__", SDATA, PEBASE); + xdefine("_image_base__", SDATA, PEBASE); } static void could you also try to install a newer mingw gcc (standalone version, not bundled with some other software) without that patch? |
I extracted the relevant test to issue5986.go [1] and ran "go build -n" to produce the editted build.bat [2] (so I could tinker) Output is at [3] Observations: 1. Fails on mingw32 4.8.1 too 2. Math sqrt introduces the __image_base__ reference (see [3][4][5]) 3. The definition of __image_base__ occurs in _cgo.o (which feeds cgo -dynimport) [6] 4. The reference __image_base__ occurs in _all.o [7] (only with sqrt) 5. No reference to _image_base__ anywhere I suspect 8l/ld is stripping the front underscore but the Go link is still a bit arcane to me (only been using Go for about 5 or 6 months). Tony ============ [1] issue5986.go ============= // Copyright 2013 The Go Authors. All rights reserved. package main /* #cgo LDFLAGS: -lm #include <stdio.h> #include <math.h> static void output5986() { int current_row = 0, row_count = 0; double sum_squares = 0; do { if (current_row == 10) { current_row = 0; } ++row_count; } while (current_row++ != 1); double d = sqrt(sum_squares / row_count); printf("sqrt is: %g\n", d); } */ import "C" func main() { C.output5986() } ============ [2] build.bat ============= @echo off rmdir /q /s WORK del /q issue5986.exe mkdir "WORK/issue5986/obj/" rem PATH=d:/goDev;... set GOROOT=d:/goDev set GOTOOLS=%GOROOT%/pkg/tool/windows_386 "%GOTOOLS%/cgo.exe" -objdir WORK/issue5986/obj/ -- -I WORK/issue5986/obj/ issue5986.go "%GOTOOLS%/8c.exe" -F -V -w -I WORK/issue5986/obj/ -I %GOROOT%/pkg/windows_386 -o WORK/issue5986/obj/_cgo_defun.8 -D GOOS_windows -D GOARCH_386 WORK/issue5986/obj/_cgo_defun.c gcc -I . -g -O2 -m32 -mthreads -I /issue5986/obj/ -o WORK/issue5986/obj/_cgo_main.o -c WORK/issue5986/obj/_cgo_main.c gcc -I . -g -O2 -m32 -mthreads -I WORK/issue5986/obj/ -o WORK/issue5986/obj/_cgo_export.o -c WORK/issue5986/obj/_cgo_export.c gcc -I . -g -O2 -m32 -mthreads -I WORK/issue5986/obj/ -o WORK/issue5986/obj/issue5986.cgo2.o -c WORK/issue5986/obj/issue5986.cgo2.c gcc -I . -g -O2 -m32 -o WORK/issue5986/obj/_cgo_.o WORK/issue5986/obj/_cgo_main.o WORK/issue5986/obj/_cgo_export.o WORK/issue5986/obj/issue5986.cgo2.o -lm "%GOTOOLS%/cgo.exe" -objdir WORK/issue5986/obj/ -dynimport WORK/issue5986/obj/_cgo_.o -dynout WORK/issue5986/obj/_cgo_import.c "%GOTOOLS%/8c.exe" -F -V -w -I WORK/issue5986/obj/ -I %GOROOT%/pkg/windows_386 -o WORK/issue5986/obj/_cgo_import.8 -D GOOS_windows -D GOARCH_386 WORK/issue5986/obj/_cgo_import.c set LIBGCC=q:/qt/qt5.0.1/tools/mingw/bin/../lib/gcc/i686-w64-mingw32/4.7.2/libgcc.a gcc -I . -g -O2 -m32 -mthreads -o WORK/issue5986/obj/_all.o WORK/issue5986/obj/_cgo_export.o WORK/issue5986/obj/issue5986.cgo2.o -Wl,-r -nostdlib -Wl,--start-group -lmingwex -lmingw32 -Wl,--end-group %LIBGCC% "%GOTOOLS%/8g.exe" -o WORK/issue5986/obj/_go_.8 -p issue5986 -D issue5986 -I WORK WORK/issue5986/obj/_cgo_gotypes.go WORK/issue5986/obj/issue5986.cgo1.go "%GOTOOLS%/pack.exe" grcP WORK WORK/issue5986.a WORK/issue5986/obj/_go_.8 WORK/issue5986/obj/_cgo_import.8 WORK/issue5986/obj/_cgo_defun.8 WORK/issue5986/obj/_all.o "%GOTOOLS%/8l.exe" -o issue5986.exe -L WORK WORK/issue5986.a issue5986.exe set GOROOT=d:/go set GOTOOLS= set LIBGCC= ============ [3] output of build.bat ============= _image_base__(0): not defined sqrt is: 0 ============ [4] issue5986.go ============= <<< double d = sqrt(sum_squares / row_count); >>> double d = (sum_squares / row_count); ============ [5] output of build.bat ============= sqrt is: 0 ============ [6] output of objdump -t _cgo_.o ============= WORK\issue5986\obj\_cgo_.o: file format pei-i386 SYMBOL TABLE: [ 0](sec -2)(fl 0x00)(ty 0)(scl 103) (nx 1) 0x0000001d crtexe.c File [ 2](sec 1)(fl 0x00)(ty 20)(scl 3) (nx 1) 0x00000000 ___mingw_invalidParameterHandler AUX tagndx 0 ttlsiz 0x0 lnnos 0 next 0 [ 4](sec 1)(fl 0x00)(ty 20)(scl 3) (nx 0) 0x00000010 _pre_cpp_init ... [1239](sec 2)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000044 ___lc_codepage [1240](sec -1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 _GetTickCount@0 [1241](sec -1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00400000 __image_base__ [1242](sec 5)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x000001ec __imp__exit [1243](sec -1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00001000 __section_alignment__ ... [1373](sec -1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 _WideCharToMultiByte@32 [1374](sec 6)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000002c ___crt_xt_end__ [1375](sec 5)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000138 __imp__EnterCriticalSection@4 ============ [7] output of objdump -t _all.o ============= WORK\issue5986\obj\_all.o: file format pe-i386 SYMBOL TABLE: [ 0](sec -2)(fl 0x00)(ty 0)(scl 103) (nx 1) 0x00000010 _cgo_export.c File [ 2](sec 1)(fl 0x00)(ty 0)(scl 3) (nx 1) 0x00000000 .text AUX scnlen 0x0 nreloc 0 nlnno 0 [ 4](sec 2)(fl 0x00)(ty 0)(scl 3) (nx 1) 0x00000000 .data AUX scnlen 0x0 nreloc 0 nlnno 0 ... [361](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x000003a0 ___tens_D2A [362](sec 2)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000024 ___lc_codepage [363](sec 0)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 __image_base__ [364](sec 0)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x00000000 _atoi [365](sec 0)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x00000000 _memcpy ... [385](sec 0)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 __imp__DeleteCriticalSection@4 [386](sec 0)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x00000000 _printf [387](sec 0)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 __imp__EnterCriticalSection@4 |
thank you for your diagnosis, please try this patch if it fixes your problem: diff -r 00ff0c821b3f src/cmd/ld/ldpe.c --- a/src/cmd/ld/ldpe.c Sun Sep 22 10:56:06 2013 -0700 +++ b/src/cmd/ld/ldpe.c Sun Sep 22 14:44:01 2013 -0400 @@ -448,7 +448,7 @@ name = sym->name; if(strncmp(name, "__imp_", 6) == 0) name = &name[6]; // __imp_Name => Name - if(thechar == '8' && name[0] == '_') + if(thechar == '8' && name[0] == '_' && strcmp(name, "__image_base__") != 0) name = &name[1]; // _Name => Name } // remove last @XXX this only serves to see if i've found the right cause, the final fix perhaps is just the one in #9. Labels changed: added priority-soon, go1.2, arch-x86-32, os-windows, removed priority-triage, go1.2maybe. Status changed to Accepted. |
thank you for confirmation. i mailed https://golang.org/cl/13314048. Owner changed to @minux. Status changed to Started. |
This issue was closed by revision 60513bf. Status changed to Fixed. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
by kin.wilson.za:
The text was updated successfully, but these errors were encountered: