Go debug/pe: read Microsoft Portable Executable files
Answer: Package pe implements access to PE (Microsoft Windows Portable Executable) files.
Opening a PE file
The package is for access to PE files, not as a hardened parser for hostile input.
Only basic validation runs when object files are parsed, so malformed input can use many resources or panic.
NewFile creates a new File for accessing a PE binary in an underlying reader.
Open uses os.Open and then prepares the named file as a PE binary.
Headers and sections
The source defines a FileHeader struct and both OptionalHeader32 and OptionalHeader64 types.
IMAGE_FILE_MACHINE_AMD64 is 0x8664.
Section returns the first section with the given name, or nil.
If a section's Offset is 0, Data reports that the section has no contents.
See also
Claims
- id: C1 claim: Package pe reads Microsoft Windows PE files. source: S1 evidence: "Package pe implements access to PE (Microsoft Windows Portable Executable) files."
- id: C2 claim: The package is not hardened against adversarial inputs. source: S1 evidence: "This package is not designed to be hardened against adversarial inputs"
- id: C3 claim: NewFile reads a PE binary from an underlying reader. source: S1 evidence: "NewFile creates a new File for accessing a PE binary in an underlying reader."
- id: C4 claim: The source defines a FileHeader struct. source: S2 evidence: "type FileHeader struct"
Sources
- [S1] debug/pe. The Go Authors. https://pkg.go.dev/debug/pe . License: BSD-3-Clause. Accessed 2026-11-26.
- [S2] debug/pe source. The Go Authors. https://go.dev/src/debug/pe/pe.go . License: BSD-3-Clause. Accessed 2026-11-26.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: The Go Authors, debug/pe; The Go Authors, debug/pe source. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: The Go Authors, debug/pe; The Go Authors, debug/pe source. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors.
Cite this
iinventedlight. 2026. "Go debug/pe: read Microsoft Portable Executable files." iinventedlight Library, iil:note:2m24mm4f, version of 2026-11-26. https://iinventedlight.com/library/notes/go-debug-pe/. License: CC-BY-4.0.
@misc{iil_note_2m24mm4f,
author = {{iinventedlight}},
title = {{Go debug/pe: read Microsoft Portable Executable files}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-26},
url = {https://iinventedlight.com/library/notes/go-debug-pe/},
note = {Permanent ID iil:note:2m24mm4f. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- go-debug-pe.schema.json (schema; CC-BY-4.0)
- go-debug-pe.table.json (table; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/go-debug-pe.md.