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

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 9 05:23:11 PST 2020


grimar added inline comments.


================
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");
----------------
jhenderson wrote:
> 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.
Done.


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

https://reviews.llvm.org/D92641



More information about the llvm-commits mailing list