[llvm] r207636 - [mips] Emit all three relocation operations for each relocation entry on Mips64 big-endian systems.

Matheus Almeida matheus.almeida at imgtec.com
Wed Apr 30 04:21:10 PDT 2014


Author: matheusalmeida
Date: Wed Apr 30 06:21:10 2014
New Revision: 207636

URL: http://llvm.org/viewvc/llvm-project?rev=207636&view=rev
Log:
[mips] Emit all three relocation operations for each relocation entry on Mips64 big-endian systems.

Summary:
The N64 ABI allows up to three operations to be specified per relocation record
independently of the endianness.

Reviewers: dsanders

Reviewed By: dsanders

Differential Revision: http://reviews.llvm.org/D3529

Modified:
    llvm/trunk/include/llvm/Object/ELF.h
    llvm/trunk/test/MC/Mips/elf-N64.s
    llvm/trunk/test/MC/Mips/elf-gprel-32-64.s

Modified: llvm/trunk/include/llvm/Object/ELF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELF.h?rev=207636&r1=207635&r2=207636&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ELF.h (original)
+++ llvm/trunk/include/llvm/Object/ELF.h Wed Apr 30 06:21:10 2014
@@ -317,6 +317,11 @@ public:
 
   ELFFile(MemoryBuffer *Object, error_code &ec);
 
+  bool isMipsELF64() const {
+    return Header->e_machine == ELF::EM_MIPS &&
+      Header->getFileClass() == ELF::ELFCLASS64;
+  }
+
   bool isMips64EL() const {
     return Header->e_machine == ELF::EM_MIPS &&
       Header->getFileClass() == ELF::ELFCLASS64 &&
@@ -537,10 +542,16 @@ StringRef ELFFile<ELFT>::getRelocationTy
 template <class ELFT>
 void ELFFile<ELFT>::getRelocationTypeName(uint32_t Type,
                                           SmallVectorImpl<char> &Result) const {
-  if (!isMips64EL()) {
+  if (!isMipsELF64()) {
     StringRef Name = getRelocationTypeName(Type);
     Result.append(Name.begin(), Name.end());
   } else {
+    // The Mips N64 ABI allows up to three operations to be specified per
+    // relocation record. Unfortunately there's no easy way to test for the
+    // presence of N64 ELFs as they have no special flag that identifies them
+    // as being N64. We can safely assume at the moment that all Mips
+    // ELFCLASS64 ELFs are N64. New Mips64 ABIs should provide enough
+    // information to disambiguate between old vs new ABIs.
     uint8_t Type1 = (Type >> 0) & 0xFF;
     uint8_t Type2 = (Type >> 8) & 0xFF;
     uint8_t Type3 = (Type >> 16) & 0xFF;

Modified: llvm/trunk/test/MC/Mips/elf-N64.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Mips/elf-N64.s?rev=207636&r1=207635&r2=207636&view=diff
==============================================================================
--- llvm/trunk/test/MC/Mips/elf-N64.s (original)
+++ llvm/trunk/test/MC/Mips/elf-N64.s Wed Apr 30 06:21:10 2014
@@ -1,4 +1,5 @@
 // RUN: llvm-mc -filetype=obj -triple=mips64el-pc-linux -mcpu=mips64  %s -o - | llvm-readobj -r | FileCheck %s
+// RUN: llvm-mc -filetype=obj -triple=mips64-pc-linux -mcpu=mips64  %s -o - | llvm-readobj -r | FileCheck %s
 
 // Check for N64 relocation production.
 // Check that the appropriate relocations were created.

Modified: llvm/trunk/test/MC/Mips/elf-gprel-32-64.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Mips/elf-gprel-32-64.s?rev=207636&r1=207635&r2=207636&view=diff
==============================================================================
--- llvm/trunk/test/MC/Mips/elf-gprel-32-64.s (original)
+++ llvm/trunk/test/MC/Mips/elf-gprel-32-64.s Wed Apr 30 06:21:10 2014
@@ -1,6 +1,9 @@
 // RUN: llvm-mc -filetype=obj -triple=mips64el-pc-linux -mcpu=mips64 %s -o - \
 // RUN: | llvm-readobj -r \
 // RUN: | FileCheck %s
+// RUN: llvm-mc -filetype=obj -triple=mips64-pc-linux -mcpu=mips64 %s -o - \
+// RUN: | llvm-readobj -r \
+// RUN: | FileCheck %s
 
 // Check that the appropriate relocations were created.
 





More information about the llvm-commits mailing list