Skip to content

Conversation

MangoFizz
Copy link

Adding .gnu_debuglink/.gnu_debugaltlink support to the PE/COFF format lets libbacktrace find and use DWARF stored in a separate file instead of only embedded sections. For MinGW-built binaries this matters because toolchains and packaging often place DWARF in external .debug files (or emit debuglink entries) rather than keeping it in the .exe/.dll.

Changes

pecoff.c

  • (coff_add): Parse .gnu_debuglink and .gnu_debugaltlink, attempt to open and validate external debug files, recursively parse external DWARF on success, and fallback to embedded DWARF on failure.
  • (coff_crc32, coff_crc32_file): Add CRC-32 helpers to verify .gnu_debuglink CRC.
  • (coff_try_debugfile, coff_find_debugfile_by_debuglink, coff_open_debugfile_by_debuglink): Add candidate search/open helpers and validation for external debug files.
  • (dll_notification): Fix callback/data usage to avoid crashes when enumerating/loading DLLs.

	* pecoff.c (coff_crc32, coff_crc32_file):
    Add CRC-32 helpers to verify .gnu_debuglink CRC.
	(coff_try_debugfile, coff_find_debugfile_by_debuglink,
 	coff_open_debugfile_by_debuglink): Add candidate search/open helpers
    and validation for external debug files.
	(coff_add): Parse .gnu_debuglink and .gnu_debugaltlink, attempt to
	open and validate external debug files, recursively parse external
	DWARF on success, and fallback to embedded DWARF on failure.
	(dll_notification): Fix callback/data usage to avoid crashes when
 	enumerating/loading DLLs.
@MangoFizz MangoFizz changed the title libbacktrace: update pecoff.c to support .gnu_debuglink external files Update pecoff.c to support .gnu_debuglink external files Aug 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant