[llvm] b403632 - [PowerPC] Fix incorrect PC Relative relocations for Big Endian

Stefan Pintilie via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 8 18:30:05 PDT 2020


Author: Stefan Pintilie
Date: 2020-06-08T20:29:43-05:00
New Revision: b4036329f1634f66273516840bedfaae1399f87d

URL: https://github.com/llvm/llvm-project/commit/b4036329f1634f66273516840bedfaae1399f87d
DIFF: https://github.com/llvm/llvm-project/commit/b4036329f1634f66273516840bedfaae1399f87d.diff

LOG: [PowerPC] Fix incorrect PC Relative relocations for Big Endian

Fix the incorrect PC Relative relocations for Big Endian for 34 bit offsets.
The offset should be zero for both BE and LE in this situation.

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

Added: 
    

Modified: 
    llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCCodeEmitter.cpp
    llvm/test/MC/PowerPC/future-reloc.s

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCCodeEmitter.cpp b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCCodeEmitter.cpp
index f5b1e9181298..017ee948dab7 100644
--- a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCCodeEmitter.cpp
+++ b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCCodeEmitter.cpp
@@ -113,7 +113,7 @@ PPCMCCodeEmitter::getImm34Encoding(const MCInst &MI, unsigned OpNo,
     return getMachineOpValue(MI, MO, Fixups, STI);
 
   // Add a fixup for the immediate field.
-  Fixups.push_back(MCFixup::create(IsLittleEndian? 0 : 1, MO.getExpr(),
+  Fixups.push_back(MCFixup::create(0, MO.getExpr(),
                                    (MCFixupKind)PPC::fixup_ppc_pcrel34));
   return 0;
 }
@@ -217,7 +217,7 @@ PPCMCCodeEmitter::getMemRI34PCRelEncoding(const MCInst &MI, unsigned OpNo,
            "VariantKind must be VK_PCREL or VK_PPC_GOT_PCREL");
     // Generate the fixup for the relocation.
     Fixups.push_back(
-        MCFixup::create(IsLittleEndian ? 0 : 1, Expr,
+        MCFixup::create(0, Expr,
                         static_cast<MCFixupKind>(PPC::fixup_ppc_pcrel34)));
     // There is no offset to return so just return 0.
     return 0;
@@ -249,7 +249,7 @@ PPCMCCodeEmitter::getMemRI34PCRelEncoding(const MCInst &MI, unsigned OpNo,
            "VariantKind must be VK_PCREL or VK_PPC_GOT_PCREL");
     // Generate the fixup for the relocation.
     Fixups.push_back(
-        MCFixup::create(IsLittleEndian ? 0 : 1, Expr,
+        MCFixup::create(0, Expr,
                         static_cast<MCFixupKind>(PPC::fixup_ppc_pcrel34)));
     assert(isInt<34>(CE->getValue()) && "Value must fit in 34 bits.");
     // Return the offset that should be added to the relocation by the linker.

diff  --git a/llvm/test/MC/PowerPC/future-reloc.s b/llvm/test/MC/PowerPC/future-reloc.s
index 6dd7fea64171..e6d41b061705 100644
--- a/llvm/test/MC/PowerPC/future-reloc.s
+++ b/llvm/test/MC/PowerPC/future-reloc.s
@@ -3,6 +3,11 @@
 # RUN: llvm-mc -triple=powerpc64le-unknown-unknown -filetype=obj %s | \
 # RUN: llvm-readobj -r | FileCheck %s -check-prefix=READOBJ
 
+# RUN: llvm-mc -triple=powerpc64-unknown-unknown -filetype=obj %s 2>&1 | \
+# RUN: FileCheck %s -check-prefix=MC
+# RUN: llvm-mc -triple=powerpc64-unknown-unknown -filetype=obj %s | \
+# RUN: llvm-readobj -r | FileCheck %s -check-prefix=READOBJ
+
 # This test checks that on Power PC we can correctly convert @pcrel and
 # @got at pcrel into R_PPC64_PCREL34 and R_PPC64_GOT_PCREL34.
 


        


More information about the llvm-commits mailing list