[PATCH] D41619: [llvm-objcopy] Use physical instead of virtual address when aligning and placing sections in binary

Jake Ehrlich via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 9 17:07:19 PST 2018


jakehehrlich added inline comments.


================
Comment at: tools/llvm-objcopy/Object.cpp:916
+      [](Segment *A, Segment *B){
+        return A->PAddr < B->PAddr;
+      });
----------------
For the std::unique call to work below identical pointers need to be next to each other so this needs to compare the pointers if PAddr is equal. This would happen if for instance we had multiple empty sections inside the same empty segment (Call it segment A) and then another non-empty segment (with a section in it, call it segment B) that had the same PAddr. It could happen that OrderedSegments was [A, B, A] to start and then stable_sort would produce [A, B, A] as well because as far as stable_sort is concerned [A, B, A] is sorted. Then when std::unqiue is run [A, B, A]  would remain unchanged. 


https://reviews.llvm.org/D41619





More information about the llvm-commits mailing list