HomePhabricator

[llvm-readelf/obj] - Handle out-of-order PT_LOADs better.

Authored by grimar on Dec 4 2020, 12:54 AM.

Description

[llvm-readelf/obj] - Handle out-of-order PT_LOADs better.

This is https://bugs.llvm.org/show_bug.cgi?id=45698.

Specification says that
"Loadable segment entries in the program header table appear
in ascending order, sorted on the p_vaddr member."

Our toMappedAddr() relies on this condition. This patch
adds a warning when the sorting order of loadable segments is wrong.
In this case we force segments sorting and that allows
toMappedAddr() to work as expected.

Differential revision: https://reviews.llvm.org/D92641