{"record":{"id":"99cdf2dcd591cec9","repo":"golang/go","slug":"could-not-map-s-symbol-with-non-text-or-rdata-o","errorCode":null,"errorMessage":"could not map %s symbol with non .text or .rdata or .data section","messagePattern":"could not map (.+?) symbol with non \\.text or \\.rdata or \\.data section","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/link/internal/ld/pe.go","lineNumber":859,"sourceCode":"\n\tf.symbolCount++\n}\n\n// mapToPESection searches peFile f for s symbol's location.\n// It returns PE section index, and offset within that section.\nfunc (f *peFile) mapToPESection(ldr *loader.Loader, s loader.Sym, linkmode LinkMode) (pesectidx int, offset int64, err error) {\n\tsect := ldr.SymSect(s)\n\tif sect == nil {\n\t\treturn 0, 0, fmt.Errorf(\"could not map %s symbol with no section\", ldr.SymName(s))\n\t}\n\tif sect.Seg == &Segtext {\n\t\treturn f.textSect.index, int64(uint64(ldr.SymValue(s)) - Segtext.Vaddr), nil\n\t}\n\tif sect.Seg == &Segrodata {\n\t\treturn f.rdataSect.index, int64(uint64(ldr.SymValue(s)) - Segrodata.Vaddr), nil\n\t}\n\tif sect.Seg != &Segdata {\n\t\treturn 0, 0, fmt.Errorf(\"could not map %s symbol with non .text or .rdata or .data section\", ldr.SymName(s))\n\t}\n\tv := uint64(ldr.SymValue(s)) - Segdata.Vaddr\n\tif linkmode != LinkExternal {\n\t\treturn f.dataSect.index, int64(v), nil\n\t}\n\tif ldr.SymType(s).IsDATA() {\n\t\treturn f.dataSect.index, int64(v), nil\n\t}\n\t// Note: although address of runtime.edata (type sym.SDATA) is at the start of .bss section\n\t// it still belongs to the .data section, not the .bss section.\n\tif v < Segdata.Filelen {\n\t\treturn f.dataSect.index, int64(v), nil\n\t}\n\treturn f.bssSect.index, int64(v - Segdata.Filelen), nil\n}\n\nvar isLabel = make(map[loader.Sym]bool)\n","sourceCodeStart":841,"sourceCodeEnd":877,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/link/internal/ld/pe.go#L841-L877","documentation":"`mapToPESection` only knows how to map symbols whose section belongs to `Segtext`, `Segrodata`, or `Segdata`. If a symbol's section has a `Seg` pointer that is not one of these three (e.g. a TLS section, an exception/unwind-data section like `.pdata`/`.xdata`, or a runtime internal pseudo-segment), the linker cannot compute a PE offset and aborts. This is almost always an internal bug or a non-standard section reaching the PE symbol emitter.","triggerScenarios":"A cgo symbol landing in `.tls`, `.pdata`, or `.rsrc`; an internal-linker symbol whose section was misclassified; building with experimental flags that introduce new segments; toolchain version skew between compiled objects.","commonSituations":"Windows cgo with thread-local storage; exporting a symbol that the compiler placed in an auxiliary data section; older Go versions with PE section-mapping gaps.","solutions":["Upgrade the Go toolchain — PE section mapping has been extended in recent releases.","Rebuild with `go build -a` to rule out cache inconsistency.","Avoid exporting the offending symbol, or ensure it lands in a standard segment (move TLS to a Go-managed variable).","File a Go issue with the symbol name and section, as this usually reflects an unmapped section type."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"# Identify symbols in non-standard PE sections (TLS, pdata, rsrc)\ngo tool nm bin/app 2>/dev/null | awk '{print $NF}' | sort -u\n# Symbols landing in .tls/.pdata/.rsrc trigger this error during export","typeGuard":null,"tryCatchPattern":"set +e\ngo build ./...\nrc=$?\nset -e\nif [ $rc -ne 0 ]; then\n  echo 'PE section mapping failed; upgrade Go or avoid exporting the symbol' >&2\n  go clean -cache && go build -a ./...\nfi","preventionTips":["Upgrade the Go toolchain — PE section coverage has expanded.","Avoid exporting cgo symbols that live in TLS or exception-data sections.","Move Windows TLS state into Go-managed variables.","Rebuild with `-a` after toolchain changes."],"tags":["linker","go-toolchain","windows","pe","symbols","cgo"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}