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.
I know this is what the ELF specification says, but I wonder whether it would be almost as easy to sort the segments here (maybe in addition to a warning, specified via a callback probably, if they are unsorted), rather than just giving up? That would be somewhat more useful than just warning and not doing anything.
Also, this is library code - is this code used elsewhere? It might be more appropriate for the test case to be in the Object tests.