[llvm] r288666 - [mips][ias] N32/N64 must not sort the relocation table.
Simon Dardis via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 5 04:55:20 PST 2016
Author: sdardis
Date: Mon Dec 5 06:55:19 2016
New Revision: 288666
URL: http://llvm.org/viewvc/llvm-project?rev=288666&view=rev
Log:
[mips][ias] N32/N64 must not sort the relocation table.
Doing so changes the evaluation order for relocation composition.
Patch By: Daniel Sanders
Reviewers: vkalintiris, atanasyan
Differential Revision: https://reviews.llvm.org/D26401
Modified:
llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp
llvm/trunk/test/MC/Mips/reloc-directive.s
Modified: llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp?rev=288666&r1=288665&r2=288666&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp Mon Dec 5 06:55:19 2016
@@ -419,6 +419,13 @@ unsigned MipsELFObjectWriter::getRelocTy
/// always match using the expressions from the source.
void MipsELFObjectWriter::sortRelocs(const MCAssembler &Asm,
std::vector<ELFRelocationEntry> &Relocs) {
+
+ // We do not need to sort the relocation table for RELA relocations which
+ // N32/N64 uses as the relocation addend contains the value we require,
+ // rather than it being split across a pair of relocations.
+ if (hasRelocationAddend())
+ return;
+
if (Relocs.size() < 2)
return;
Modified: llvm/trunk/test/MC/Mips/reloc-directive.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Mips/reloc-directive.s?rev=288666&r1=288665&r2=288666&view=diff
==============================================================================
--- llvm/trunk/test/MC/Mips/reloc-directive.s (original)
+++ llvm/trunk/test/MC/Mips/reloc-directive.s Mon Dec 5 06:55:19 2016
@@ -43,16 +43,24 @@ foo:
# OBJ-N32: 0000: 00000000 00000000 00000000
# OBJ-N32-LABEL: }
# OBJ-N32-LABEL: Relocations [
-# OBJ-N32: 0x0 R_MIPS_NONE/R_MIPS_NONE/R_MIPS_NONE .text 0x4
+
# OBJ-N32: 0x4 R_MIPS_NONE/R_MIPS_NONE/R_MIPS_NONE .text 0x0
+# OBJ-N32: 0x0 R_MIPS_NONE/R_MIPS_NONE/R_MIPS_NONE .text 0x4
# OBJ-N32: 0x8 R_MIPS_32/R_MIPS_NONE/R_MIPS_NONE .text 0x8
# OBJ-N32: 0xC R_MIPS_NONE/R_MIPS_NONE/R_MIPS_NONE - 0x0
+# FIXME:This is the correct output for reference.
+
+# OBJ-N32-FIXME: 0x4 R_MIPS_NONE .text 0x0
+# OBJ-N32-FIXME: 0x0 R_MIPS_NONE .text 0x4
+# OBJ-N32-FIXME: 0x8 R_MIPS_32 .text 0x8
+# OBJ-N32-FIXME: 0xC R_MIPS_NONE - 0x0
+
# OBJ-N64-LABEL: Name: .text
# OBJ-N64: 0000: 00000000 00000000 00000000
# OBJ-N64-LABEL: }
# OBJ-N64-LABEL: Relocations [
-# OBJ-N64: 0x0 R_MIPS_NONE/R_MIPS_NONE/R_MIPS_NONE .text 0x4
# OBJ-N64: 0x4 R_MIPS_NONE/R_MIPS_NONE/R_MIPS_NONE .text 0x0
+# OBJ-N64: 0x0 R_MIPS_NONE/R_MIPS_NONE/R_MIPS_NONE .text 0x4
# OBJ-N64: 0x8 R_MIPS_32/R_MIPS_NONE/R_MIPS_NONE .text 0x8
# OBJ-N64: 0xC R_MIPS_NONE/R_MIPS_NONE/R_MIPS_NONE - 0x0
More information about the llvm-commits
mailing list