golang/go · critical

internal error in windynrelocsym: redirect GOT token applied

Error message

internal error in windynrelocsym: redirect GOT token applied to non-import symbol %s

What it means

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.

Source

Thrown at src/cmd/link/internal/ld/data.go:858

		}
		targ := r.Sym()
		if targ == 0 {
			continue
		}
		if !ctxt.loader.AttrReachable(targ) {
			if r.Weak() {
				continue
			}
			return fmt.Errorf("dynamic relocation to unreachable symbol %s",
				ctxt.loader.SymName(targ))
		}
		tgot := ctxt.loader.SymGot(targ)
		if tgot == loadpe.RedirectToDynImportGotToken {

			// Consistency check: name should be __imp_X
			sname := ctxt.loader.SymName(targ)
			if !strings.HasPrefix(sname, "__imp_") {
				return fmt.Errorf("internal error in windynrelocsym: redirect GOT token applied to non-import symbol %s", sname)
			}

			// Locate underlying symbol (which originally had type
			// SDYNIMPORT but has since been retyped to SWINDOWS).
			ds, err := loadpe.LookupBaseFromImport(targ, ctxt.loader, ctxt.Arch)
			if err != nil {
				return err
			}
			dstyp := ctxt.loader.SymType(ds)
			if dstyp != sym.SWINDOWS {
				return fmt.Errorf("internal error in windynrelocsym: underlying sym for %q has wrong type %s", sname, dstyp.String())
			}

			// Redirect relocation to the dynimport.
			r.SetSym(ds)
			continue
		}

View on GitHub (pinned to b6b368adc5)

Solutions

  1. Report as a Go linker internal bug at https://github.com/golang/go/issues with full reproducer
  2. Clean rebuild: go clean -cache && go build
  3. Try -linkmode=external as a workaround
  4. Try a different Go version to identify a regression
  5. Minimize the reproducer by removing CGO dependencies one at a time
Defensive patterns

Strategy: fallback

Try / catch

// Internal errors in windynrelocsym are not recoverable at runtime
// Wrap with context for bug reporting
if err := windynrelocsym(ctxt, s, r, ri); err != nil {
    if strings.Contains(err.Error(), "internal error") {
        return fmt.Errorf("Go linker internal error (report at golang.org/issues): %w", err)
    }
    return err
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12). Data as JSON: /api/errors/cb0e006b6f25aa7f. Report an issue: GitHub.