Skip to content

Read section names from string table if needed - #540

Open
madebr wants to merge 1 commit into
isledecomp:masterfrom
madebr:section-names-from-string-table
Open

madebr wants to merge 1 commit into
isledecomp:masterfrom
madebr:section-names-from-string-table

Conversation

@madebr

@madebr madebr commented Sep 5, 2026

Copy link
Copy Markdown
Collaborator

The debug sections of MinGW executables are longer than 8 characters and are stored in the string table.
In the same way as is done in PE/COFF object files, this table is stored after the symbol table.

On a dummy MinGW executables, this changes the output of the following small program:

import reccmp.formats

# /tmp/a.exe is a minimal MinGW executable
image = reccmp.formats.detect.detect_image("/tmp/a.exe")

for section in image.sections:
    print(
        f"{section.name:20} 0x{section.virtual_range.start:08x} 0x{section.virtual_range.stop-section.virtual_range.start:08x}"
    )

From:

.text                0x00401000 0x00001710
.data                0x00403000 0x00000034
.rdata               0x00404000 0x000009f0
/4                   0x00405000 0x000007f0
.bss                 0x00406000 0x000000b0
.idata               0x00407000 0x00000444
.tls                 0x00408000 0x00000008
.reloc               0x00409000 0x0000023c
/14                  0x0040a000 0x00000360
/29                  0x0040b000 0x0000b575
/41                  0x00417000 0x00001e0c
/55                  0x00419000 0x00001d15
/67                  0x0041b000 0x00000038
/80                  0x0041c000 0x0000035b
/91                  0x0041d000 0x00002141
/107                 0x00420000 0x00000b1d
/123                 0x00421000 0x00000185

To:

.text                0x00401000 0x00001710
.data                0x00403000 0x00000034
.rdata               0x00404000 0x000009f0
.eh_frame            0x00405000 0x000007f0
.bss                 0x00406000 0x000000b0
.idata               0x00407000 0x00000444
.tls                 0x00408000 0x00000008
.reloc               0x00409000 0x0000023c
.debug_aranges       0x0040a000 0x00000360
.debug_info          0x0040b000 0x0000b575
.debug_abbrev        0x00417000 0x00001e0c
.debug_line          0x00419000 0x00001d15
.debug_frame         0x0041b000 0x00000038
.debug_str           0x0041c000 0x0000035b
.debug_line_str      0x0041d000 0x00002141
.debug_loclists      0x00420000 0x00000b1d
.debug_rnglists      0x00421000 0x00000185

@madebr
madebr force-pushed the section-names-from-string-table branch from d5d0e82 to 6af8d38 Compare September 5, 2026 05:48
The debug sections of MinGW executables are longer than 8
characters and are stored in the string table.
In the same way as is done in PE/COFF object files, this
table is stored after the symbol table.
@madebr
madebr force-pushed the section-names-from-string-table branch from 6af8d38 to c3fd4f2 Compare September 5, 2026 05:53
Comment thread reccmp/formats/pe.py
# pylint: disable=too-many-lines


PE_COFF_SYMBOL_SIZE = 18

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where did this constant come from?

Suggested change
PE_COFF_SYMBOL_SIZE = 18
PE_COFF_SYMBOL_SIZE = 18
"""<link to PE standard> / <explanation why 18 was chosen>"""

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@madebr madebr Sep 16, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the link.

I put this pr aside because the symbol table does exist in MinGW debug executables, giving us access to the addresses of linked symbols. But I guess that can be added in a future pr.

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.

3 participants