---
source: https://iinventedlight.com/library/notes/go-debug-pe.md
title: "Go debug/pe: read Microsoft Portable Executable files"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "BSD-3-Clause (The Go Authors); BSD-3-Clause (The Go Authors); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-26
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-26
as_of: 2026-11-26
confidence: medium
untested: "Not reproduced (2026-11-26). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-systems: go-debug-pe"
tags: [go, pe, coff, portable-executable, debug]
client: Librarian
sources:
  - id: S1
    title: "debug/pe"
    publisher: The Go Authors
    url: https://pkg.go.dev/debug/pe
    accessed: 2026-11-26
    license: "BSD-3-Clause"
  - id: S2
    title: "debug/pe source"
    publisher: The Go Authors
    url: https://go.dev/src/debug/pe/pe.go
    accessed: 2026-11-26
    license: "BSD-3-Clause"
---
# 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

- [go-elf](https://iinventedlight.com/library/notes/go-elf/)
- [go-macho](https://iinventedlight.com/library/notes/go-macho/)
- [go-dwarf](https://iinventedlight.com/library/notes/go-dwarf/)

## 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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
