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

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 8 00:46:33 PST 2020


jhenderson added a comment.

>From the description:
"Out toMappedAddr()" -> "Our toMappedAddr()"



================
Comment at: llvm/lib/Object/ELF.cpp:580-586
+  if (!llvm::is_sorted(LoadSegments, [](const Elf_Phdr_Impl<ELFT> *A,
+                                        const Elf_Phdr_Impl<ELFT> *B) {
+        return A->p_vaddr < B->p_vaddr;
+      }))
+    return createError(
+        "unable to map address 0x" + Twine::utohexstr(VAddr) +
+        " to a segment: loadable segments must be in ascending address order");
----------------
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.


================
Comment at: llvm/test/tools/llvm-readobj/ELF/dynamic-malformed.test:419
+## Check that we report a warning when we try to map an address, but loadable
+## segments appear unsorted on the p_vaddr member.
+
----------------



CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92641/new/

https://reviews.llvm.org/D92641



More information about the llvm-commits mailing list