Skip to content

PE: a section the file does not contain is skipped from the image but still counts toward max_addr #794

Description

@zardus

THIS MESSAGE WAS GENERATED BY AN AUTOMATED PROCESS

PE._get_memory_mapped_image skips a section whose raw data begins past the end of the file, and logs that it is doing so, while _register_sections registers that same section, so it still counts toward max_addr. The object ends up declaring a range nothing backs.

On the committed fixture tests/i386/windows/a94bbeed0ef51db3d3964bb0cc2cbed0adab0e47997d88f34daa92faa1a91e8a, ld.main_object.contains_addr(ld.main_object.max_addr) is True while ld.find_object_containing of that same address is None, describe_addr calls it "not part of a loaded object", and ld.memory.load(ld.main_object.sections_map[".rdata"].vaddr, 1) raises KeyError.

That fixture is the one test_loading_incomplete_pe_file pins, and #663 already decided a truncated file's missing bytes stay missing. Zero-filling the whole declared extent breaks that test and turns the padding into blocks; backing only the sections the file omits entirely does neither, but still invents bytes.

So either the object should stop claiming addresses it cannot back, or those sections should be zeroed. Neither changes the functions or blocks CFGFast recovers here. Happy to open a pull request for whichever you prefer.

Related: #790.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions