{"record":{"id":"cb0e006b6f25aa7f","repo":"golang/go","slug":"internal-error-in-windynrelocsym-redirect-got-tok","errorCode":null,"errorMessage":"internal error in windynrelocsym: redirect GOT token applied to non-import symbol %s","messagePattern":"internal error in windynrelocsym: redirect GOT token applied to non-import symbol (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"src/cmd/link/internal/ld/data.go","lineNumber":858,"sourceCode":"\t\t}\n\t\ttarg := r.Sym()\n\t\tif targ == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif !ctxt.loader.AttrReachable(targ) {\n\t\t\tif r.Weak() {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\treturn fmt.Errorf(\"dynamic relocation to unreachable symbol %s\",\n\t\t\t\tctxt.loader.SymName(targ))\n\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","sourceCodeStart":840,"sourceCodeEnd":876,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/link/internal/ld/data.go#L840-L876","documentation":"An internal consistency error in the Windows dynamic relocation handler (windynrelocsym). When a symbol's GOT (Global Offset Table) entry equals loadpe.RedirectToDynimportGotToken, the code expects the symbol to be a PE import (name starting with __imp_). If the name lacks this prefix, the internal state is inconsistent and the error fires.","triggerScenarios":"ctxt.loader.SymGot(targ) returns RedirectToDynimportGotToken, indicating the symbol should be redirected to a dynamic import. The code then retrieves the symbol name and checks strings.HasPrefix(sname, \"__imp_\"). If the prefix is absent, the error is returned with the symbol name.","commonSituations":"A bug in the PE import processing pipeline that sets the GOT redirect token on a non-import symbol; corrupted object file metadata from CGO compilation; race condition in concurrent symbol processing during linking.","solutions":["Report as a Go linker internal bug at https://github.com/golang/go/issues with full reproducer","Clean rebuild: go clean -cache && go build","Try -linkmode=external as a workaround","Try a different Go version to identify a regression","Minimize the reproducer by removing CGO dependencies one at a time"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Internal errors in windynrelocsym are not recoverable at runtime\n// Wrap with context for bug reporting\nif err := windynrelocsym(ctxt, s, r, ri); err != nil {\n    if strings.Contains(err.Error(), \"internal error\") {\n        return fmt.Errorf(\"Go linker internal error (report at golang.org/issues): %w\", err)\n    }\n    return err\n}","preventionTips":["These are internal linker bugs — there is no user-side prevention","Keep build environments clean: go clean -cache between Go version changes","Minimize CGO dependencies to reduce the surface for import-handling bugs","Try -linkmode=external as a workaround when internal linking fails"],"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-13T14:17:21.547Z"}