]> granicus.if.org Git - llvm/commitdiff
[mips][ias] N32/N64 must not sort the relocation table.
authorSimon Dardis <simon.dardis@imgtec.com>
Mon, 5 Dec 2016 12:55:19 +0000 (12:55 +0000)
committerSimon Dardis <simon.dardis@imgtec.com>
Mon, 5 Dec 2016 12:55:19 +0000 (12:55 +0000)
Doing so changes the evaluation order for relocation composition.

Patch By: Daniel Sanders

Reviewers: vkalintiris, atanasyan

Differential Revision: https://reviews.llvm.org/D26401

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288666 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp
test/MC/Mips/reloc-directive.s

index 0bfd4690f47f0a6adc6a01e48f292605c19d39a6..b2efd726da53d16cf008d8c59bd5928bc98a3908 100644 (file)
@@ -419,6 +419,13 @@ unsigned MipsELFObjectWriter::getRelocType(MCContext &Ctx,
 /// 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;
 
index fee4c1379b13fac2712b8949a40b6cd35ef2e4cb..b2da7ca1b2c038d48181efbc1595810d835686c8 100644 (file)
@@ -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