pyelftools icon indicating copy to clipboard operation
pyelftools copied to clipboard

Non-determinism of dict enumeration results in non-deterministic parsing

Open dcolascione opened this issue 11 years ago • 5 comments

If we enumerate the segments of an ARM EABI ELF file and print the p_type field of each, we print different results on different runs with the same input. Both PT_ARM_UNWIND and PT_AARCH64_UNWIND have the value 0x70000001; we decode this value using the Enum facility of the Construct library. Depending on the order in which we enumerate the ENUM_P_TYPE entries, Enum can prefer either PT_ARM_UNWIND or PT_AARCH64_UNWIND.

Enumeration mappings we provide to Construct should never be ambiguous!

dcolascione avatar Apr 29 '15 19:04 dcolascione

I forget, but is it actually correct for them to have the same value?

eliben avatar Apr 30 '15 12:04 eliben

Yes, the values for PT_ARM_UNWIND and PR_AARCH64_UNWIND fall within the PT_LOPROC - PT_HIPROC range, which is an inclusive range reserved for processor-specific semantics. (0x70000000 - 0x7fffffff)

bigboze avatar Apr 30 '15 14:04 bigboze

Same should ideally be applied for *_LOPROC - *_HIPROC and _*LOOS - *_HIOS ranges for other ELF fields.

bigboze avatar Apr 30 '15 14:04 bigboze

Also discussed in #121

eliben avatar Oct 26 '16 03:10 eliben

I believe this should be addressed by the latest commit (linked above ^^^).

eliben avatar Jan 15 '18 22:01 eliben