[llvm] [llvm-objcopy] Fix file offsets when PT_INTERP/PT_LOAD offsets are equal (PR #80562)
Dmitriy Chestnykh via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 8 01:36:57 PST 2024
================
@@ -1234,6 +1234,13 @@ static bool compareSegmentsByOffset(const Segment *A, const Segment *B) {
return true;
if (A->OriginalOffset > B->OriginalOffset)
return false;
+ // If one is PT_LOAD and the other isn't (e.g. PT_INTERP, PT_GNU_RELRO,
+ // PT_TLS), order the PT_LOAD first to ensure ParentSegment relationship will
+ // be correct.
+ bool AIsLOAD = A->Type == PT_LOAD;
+ bool BIsLOAD = B->Type == PT_LOAD;
+ if (AIsLOAD != BIsLOAD)
----------------
chestnykh wrote:
I've testst the fix, yes, the fix is correct
https://github.com/llvm/llvm-project/pull/80562
More information about the llvm-commits
mailing list