{"record":{"id":"66719faec6f73554","repo":"golang/go","slug":"internal-error-in-windynrelocsym-underlying-sym-f","errorCode":null,"errorMessage":"internal error in windynrelocsym: underlying sym for %q has wrong type %s","messagePattern":"internal error in windynrelocsym: underlying sym for %q has wrong type (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"src/cmd/link/internal/ld/data.go","lineNumber":869,"sourceCode":"\t\t}\n\t\ttgot := ctxt.loader.SymGot(targ)\n\t\tif tgot == loadpe.RedirectToDynImportGotToken {\n\n\t\t\t// Consistency check: name should be __imp_X\n\t\t\tsname := ctxt.loader.SymName(targ)\n\t\t\tif !strings.HasPrefix(sname, \"__imp_\") {\n\t\t\t\treturn fmt.Errorf(\"internal error in windynrelocsym: redirect GOT token applied to non-import symbol %s\", sname)\n\t\t\t}\n\n\t\t\t// Locate underlying symbol (which originally had type\n\t\t\t// SDYNIMPORT but has since been retyped to SWINDOWS).\n\t\t\tds, err := loadpe.LookupBaseFromImport(targ, ctxt.loader, ctxt.Arch)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tdstyp := ctxt.loader.SymType(ds)\n\t\t\tif dstyp != sym.SWINDOWS {\n\t\t\t\treturn fmt.Errorf(\"internal error in windynrelocsym: underlying sym for %q has wrong type %s\", sname, dstyp.String())\n\t\t\t}\n\n\t\t\t// Redirect relocation to the dynimport.\n\t\t\tr.SetSym(ds)\n\t\t\tcontinue\n\t\t}\n\n\t\ttplt := ctxt.loader.SymPlt(targ)\n\t\tif tplt == loadpe.CreateImportStubPltToken {\n\n\t\t\t// Consistency check: don't want to see both PLT and GOT tokens.\n\t\t\tif tgot != -1 {\n\t\t\t\treturn fmt.Errorf(\"internal error in windynrelocsym: invalid GOT setting %d for reloc to %s\", tgot, ctxt.loader.SymName(targ))\n\t\t\t}\n\n\t\t\t// make dynimport JMP table for PE object files.\n\t\t\ttplt := int32(rel.Size())\n\t\t\tctxt.loader.SetPlt(targ, tplt)","sourceCodeStart":851,"sourceCodeEnd":887,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/link/internal/ld/data.go#L851-L887","documentation":"An internal consistency error in windynrelocsym. After resolving a __imp_ symbol's GOT redirect token, the code calls loadpe.LookupBaseFromImport to find the underlying symbol (originally SDYNIMPORT, later retyped to SWINDOWS). If the resolved symbol's type is not sym.SWINDOWS, the internal type invariant is violated.","triggerScenarios":"loadpe.LookupBaseFromImport succeeds and returns a symbol handle ds. ctxt.loader.SymType(ds) is then compared against sym.SWINDOWS. If the type differs (e.g. still SDYNIMPORT, or some other type), the error includes the symbol name and actual type string.","commonSituations":"A bug in the PE symbol retyping logic that should have converted SDYNIMPORT to SWINDOWS; object files with unexpected symbol type metadata; a regression in the import resolution pipeline after a Go version upgrade.","solutions":["Report as a Go linker internal bug with full build configuration","Clean rebuild: go clean -cache && go build","Try -linkmode=external as a workaround","Downgrade or upgrade Go to identify the version that introduced the regression","Reduce the test case to the minimal CGO import that triggers the error"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Wrap internal errors for actionable diagnostics\nif err := processReloc(ctxt, s, ri); err != nil {\n    if strings.Contains(err.Error(), \"internal error\") {\n        log.Printf(\"Internal linker error detected. Try: go build -ldflags=-linkmode=external\")\n    }\n    return err\n}","preventionTips":["Internal linker errors are toolchain bugs — report them","External linking can bypass internal linker relocation bugs","Maintain reproducible builds to help diagnose when the issue started"],"tags":["relocation","windows","pe","linker","go-toolchain","internal-error"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:31:55.035Z"}