diff options
Diffstat (limited to 'contrib/llvm/lib/MC/MCELFObjectTargetWriter.cpp')
-rw-r--r-- | contrib/llvm/lib/MC/MCELFObjectTargetWriter.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/contrib/llvm/lib/MC/MCELFObjectTargetWriter.cpp b/contrib/llvm/lib/MC/MCELFObjectTargetWriter.cpp index 4cac84d..0c39e4a 100644 --- a/contrib/llvm/lib/MC/MCELFObjectTargetWriter.cpp +++ b/contrib/llvm/lib/MC/MCELFObjectTargetWriter.cpp @@ -39,13 +39,23 @@ const MCSymbol *MCELFObjectTargetWriter::undefinedExplicitRelSym(const MCValue & return &Symbol.AliasedSymbol(); } -void MCELFObjectTargetWriter::adjustFixupOffset(const MCFixup &Fixup, - uint64_t &RelocOffset) { +// ELF doesn't require relocations to be in any order. We sort by the r_offset, +// just to match gnu as for easier comparison. The use type and index is an +// arbitrary way of making the sort deterministic. +static int cmpRel(const ELFRelocationEntry *AP, const ELFRelocationEntry *BP) { + const ELFRelocationEntry &A = *AP; + const ELFRelocationEntry &B = *BP; + if (A.r_offset != B.r_offset) + return B.r_offset - A.r_offset; + if (B.Type != A.Type) + return A.Type - B.Type; + if (B.Index != A.Index) + return B.Index - A.Index; + llvm_unreachable("ELFRelocs might be unstable!"); } void MCELFObjectTargetWriter::sortRelocs(const MCAssembler &Asm, std::vector<ELFRelocationEntry> &Relocs) { - // Sort by the r_offset, just like gnu as does. - array_pod_sort(Relocs.begin(), Relocs.end()); + array_pod_sort(Relocs.begin(), Relocs.end(), cmpRel); } |