Regions: Stop the address lookups from assuming an order the list may not have - #760
Regions: Stop the address lookups from assuming an order the list may not have#760zardus wants to merge 1 commit into
Conversation
… not have Regions keeps its members sorted by start address and then bisects their end addresses, which is a total order only while the regions are disjoint. They are not always, so a lookup can walk past a region that does cover the address and report there is none, and max_addr can name an address that is not the highest. On binaries/tests/armel/btrfs.ko, find_section_containing(0x400024) returns None although .text spans 0x400000-0x4b9b58. .tbss is the common cause in ordinary linked ELFs, and it is not a region of the image at all: its address is where a thread's own copy of the thread-local template begins, and the linker places the section after it over the top. Keeping it out of the sorted list removes that overlap and stops address lookups answering with a section that holds none of the bytes it claims. On angr/binaries master 55 of 817 loadable files overlap for that reason alone. Overlap cannot be ruled out in general, so the lookups now carry a running maximum of the end addresses, which is sorted whether or not the regions are. Where the regions are disjoint that maximum is each region's own end address and both lookups are the bisection they were. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
THIS MESSAGE WAS GENERATED BY AN AUTOMATED PROCESS Validation record for head
Reproducer on a public fixture: Both lookups were evaluated against the same already-loaded object, so the comparison contains nothing but the lookup. Over the 821 loadable files in
Caveats: corpus objects are referred to by architecture, container and digest because the dataset is not public. The remaining 51 overlapping objects are relocatable ELFs placing several sections at one address, which #739 addresses separately. |
|
Corpus decompilation diffs can be found at angr/dec-snapshots@master...angr/cle_760 |
THIS MESSAGE WAS GENERATED BY AN AUTOMATED PROCESS
Regionskeeps its members sorted by start address and then bisects their endaddresses, which is a total order only while the regions are disjoint. They are
not always, so a lookup can walk past a region that does cover the address and
report there is none: on
binaries/tests/armel/btrfs.ko,find_section_containing(0x400024)returnsNonealthough.textspans0x400000-0x4b9b58..tbssis the common cause in ordinary linked ELFs, and it is not a region ofthe image at all: its address is where a thread's own copy of the template
begins, and the linker places the section after it over the top. Keeping it out
of the sorted list removes that overlap and stops lookups answering with a
section that holds none of the bytes it claims. Overlap cannot be ruled out in
general, so the lookups now carry a running maximum of the end addresses, which
is sorted whether or not the regions are; while they are disjoint both reduce to
exactly the bisection they were.
Fixes #742.
Validation: #760 (comment)