[mips] Fix relocation record format and ELF header for N32 ABI

The N32 ABI uses RELA relocation format, do not use 3-in-1 relocation's
encoding, and uses ELFCLASS32. This change passes the `IsN32` flag
to the `MCAsmBackend` to distinguish usage of N32 ABI.

We still do not handle some cases like providing the `-target-abi=o32`
command line option with the `mips64` target triple. That's why
elf_header.s contains some "FIXME" strings. This case will be fixed in
a separate patch.

Differential revision: https://reviews.llvm.org/D37960

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313873 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Simon Atanasyan 2017-09-21 10:44:26 +00:00
parent 28b2d0c96f
commit 0771400c1d
10 changed files with 188 additions and 47 deletions

View File

@ -24,6 +24,7 @@
#include "llvm/MC/MCFixupKindInfo.h"
#include "llvm/MC/MCObjectWriter.h"
#include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/MC/MCTargetOptions.h"
#include "llvm/MC/MCValue.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Format.h"
@ -211,7 +212,7 @@ static unsigned adjustFixupValue(const MCFixup &Fixup, uint64_t Value,
MCObjectWriter *
MipsAsmBackend::createObjectWriter(raw_pwrite_stream &OS) const {
return createMipsELFObjectWriter(OS, TheTriple);
return createMipsELFObjectWriter(OS, TheTriple, IsN32);
}
// Little-endian fixup data byte ordering:
@ -473,3 +474,10 @@ bool MipsAsmBackend::writeNopData(uint64_t Count, MCObjectWriter *OW) const {
OW->WriteZeros(Count);
return true;
}
MCAsmBackend *llvm::createMipsAsmBackend(const Target &T,
const MCRegisterInfo &MRI,
const Triple &TT, StringRef CPU,
const MCTargetOptions &Options) {
return new MipsAsmBackend(T, MRI, TT, CPU, Options.ABIName == "n32");
}

View File

@ -30,11 +30,12 @@ class Target;
class MipsAsmBackend : public MCAsmBackend {
Triple TheTriple;
bool IsLittle; // Big or little endian
bool IsN32;
public:
MipsAsmBackend(const Target &T, const MCRegisterInfo &MRI, const Triple &TT,
StringRef CPU)
: TheTriple(TT), IsLittle(TT.isLittleEndian()) {}
StringRef CPU, bool N32)
: TheTriple(TT), IsLittle(TT.isLittleEndian()), IsN32(N32) {}
MCObjectWriter *createObjectWriter(raw_pwrite_stream &OS) const override;

View File

@ -657,12 +657,10 @@ bool MipsELFObjectWriter::needsRelocateWithSymbol(const MCSymbol &Sym,
}
MCObjectWriter *llvm::createMipsELFObjectWriter(raw_pwrite_stream &OS,
const Triple &TT) {
const Triple &TT, bool IsN32) {
uint8_t OSABI = MCELFObjectTargetWriter::getOSABI(TT.getOS());
// FIXME: We need to check an actual ABI. mips64/mips64el do not
// always imply the N64 ABI and RELA relocation's format.
bool IsN64 = TT.isArch64Bit();
bool HasRelocationAddend = IsN64;
bool IsN64 = TT.isArch64Bit() && !IsN32;
bool HasRelocationAddend = TT.isArch64Bit();
auto *MOTW = new MipsELFObjectWriter(OSABI, HasRelocationAddend, IsN64,
TT.isLittleEndian());
return createELFObjectWriter(MOTW, OS, TT.isLittleEndian());

View File

@ -183,7 +183,7 @@ extern "C" void LLVMInitializeMipsTargetMC() {
*T, createMipsObjectTargetStreamer);
// Register the asm backend.
RegisterMCAsmBackend<MipsAsmBackend> Y(*T);
TargetRegistry::RegisterMCAsmBackend(*T, createMipsAsmBackend);
}
// Register the MC Code Emitter

View File

@ -43,8 +43,12 @@ MCCodeEmitter *createMipsMCCodeEmitterEL(const MCInstrInfo &MCII,
const MCRegisterInfo &MRI,
MCContext &Ctx);
MCAsmBackend *createMipsAsmBackend(const Target &T, const MCRegisterInfo &MRI,
const Triple &TT, StringRef CPU,
const MCTargetOptions &Options);
MCObjectWriter *createMipsELFObjectWriter(raw_pwrite_stream &OS,
const Triple &TT);
const Triple &TT, bool IsN32);
namespace MIPS_MC {
StringRef selectMipsCPU(const Triple &TT, StringRef CPU);

View File

@ -4,6 +4,8 @@
# RUN: llvm-mc -triple mips-unknown-linux -target-abi o32 %s | \
# RUN: FileCheck -check-prefixes=ALL,ASM,ASM-O32 %s
# FIXME: Now we check .cpsetup expansion for `-mno-shared` case only.
# We also need to implement/check the `-mshared` case.
# RUN: llvm-mc -triple mips64-unknown-linux -target-abi n32 -filetype=obj -o - %s | \
# RUN: llvm-objdump -d -r - | \
# RUN: FileCheck -check-prefixes=ALL,NXX,N32 %s
@ -32,10 +34,10 @@ t1:
# NXX-NEXT: sd $gp, 8($sp)
# NXX-NEXT: lui $gp, 0
# N32-NEXT: R_MIPS_HI16/R_MIPS_NONE/R_MIPS_NONE __gnu_local_gp
# N32-NEXT: R_MIPS_HI16 __gnu_local_gp
# N64-NEXT: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_HI16 __cerror
# NXX-NEXT: addiu $gp, $gp, 0
# N32-NEXT: R_MIPS_LO16/R_MIPS_NONE/R_MIPS_NONE __gnu_local_gp
# N32-NEXT: R_MIPS_LO16 __gnu_local_gp
# N64-NEXT: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_LO16 __cerror
# N64-NEXT: daddu $gp, $gp, $25
@ -60,10 +62,10 @@ t2:
# NXX-NEXT: move $2, $gp
# NXX-NEXT: lui $gp, 0
# N32-NEXT: R_MIPS_HI16/R_MIPS_NONE/R_MIPS_NONE __gnu_local_gp
# N32-NEXT: R_MIPS_HI16 __gnu_local_gp
# N64-NEXT: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_HI16 __cerror
# NXX-NEXT: addiu $gp, $gp, 0
# N32-NEXT: R_MIPS_LO16/R_MIPS_NONE/R_MIPS_NONE __gnu_local_gp
# N32-NEXT: R_MIPS_LO16 __gnu_local_gp
# N64-NEXT: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_LO16 __cerror
# N64-NEXT: daddu $gp, $gp, $25
@ -96,10 +98,10 @@ t3:
# NXX-NEXT: move $2, $gp
# NXX-NEXT: lui $gp, 0
# N32-NEXT: {{^ *0+}}38: R_MIPS_HI16/R_MIPS_NONE/R_MIPS_NONE __gnu_local_gp
# N32-NEXT: {{^ *0+}}38: R_MIPS_HI16 __gnu_local_gp
# N64-NEXT: {{^ *0+}}40: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_HI16 .text
# NXX-NEXT: addiu $gp, $gp, 0
# N32-NEXT: {{^ *0+}}3c: R_MIPS_LO16/R_MIPS_NONE/R_MIPS_NONE __gnu_local_gp
# N32-NEXT: {{^ *0+}}3c: R_MIPS_LO16 __gnu_local_gp
# N64-NEXT: {{^ *0+}}44: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_LO16 .text
# N64-NEXT: daddu $gp, $gp, $25
# NXX-NEXT: nop
@ -151,10 +153,10 @@ t5:
# NXX-NEXT: sd $gp, 8($sp)
# NXX-NEXT: lui $gp, 0
# N32-NEXT: R_MIPS_HI16/R_MIPS_NONE/R_MIPS_NONE __gnu_local_gp
# N32-NEXT: R_MIPS_HI16 __gnu_local_gp
# N64-NEXT: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_HI16 __cerror
# NXX-NEXT: addiu $gp, $gp, 0
# N32-NEXT: R_MIPS_LO16/R_MIPS_NONE/R_MIPS_NONE __gnu_local_gp
# N32-NEXT: R_MIPS_LO16 __gnu_local_gp
# N64-NEXT: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_LO16 __cerror
# N64-NEXT: daddu $gp, $gp, $25
@ -176,10 +178,10 @@ IMM_8 = 8
# NXX-NEXT: sd $gp, 8($sp)
# NXX-NEXT: lui $gp, 0
# N32-NEXT: R_MIPS_HI16/R_MIPS_NONE/R_MIPS_NONE __gnu_local_gp
# N32-NEXT: R_MIPS_HI16 __gnu_local_gp
# N64-NEXT: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_HI16 __cerror
# NXX-NEXT: addiu $gp, $gp, 0
# N32-NEXT: R_MIPS_LO16/R_MIPS_NONE/R_MIPS_NONE __gnu_local_gp
# N32-NEXT: R_MIPS_LO16 __gnu_local_gp
# N64-NEXT: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_LO16 __cerror
# N64-NEXT: daddu $gp, $gp, $25

139
test/MC/Mips/elf_header.s Normal file
View File

@ -0,0 +1,139 @@
# Default ABI for MIPS32 is O32.
# RUN: llvm-mc -filetype=obj -triple mips-unknown-linux -mcpu=mips1 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,BE,O32,NAN1985,MIPS1 %s
# RUN: llvm-mc -filetype=obj -triple mips-unknown-linux -mcpu=mips2 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,BE,O32,NAN1985,MIPS2 %s
# RUN: llvm-mc -filetype=obj -triple mips-unknown-linux -mcpu=mips3 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,BE,O32,NAN1985,MIPS3,32BITMODE %s
# RUN: llvm-mc -filetype=obj -triple mips-unknown-linux -mcpu=mips4 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,BE,O32,NAN1985,MIPS4,32BITMODE %s
# RUN: llvm-mc -filetype=obj -triple mips-unknown-linux -mcpu=mips5 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,BE,O32,NAN1985,MIPS5,32BITMODE %s
# RUN: llvm-mc -filetype=obj -triple mips-unknown-linux %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,BE,O32,NAN1985,MIPS32R1 %s
# RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,O32,NAN1985,MIPS32R1 %s
# RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,O32,NAN1985,MIPS32R1 %s
# RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips32r2 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,O32,NAN1985,MIPS32R2 %s
# RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips32r3 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,O32,NAN1985,MIPS32R3 %s
# RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips32r5 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,O32,NAN1985,MIPS32R5 %s
# RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips32r2 -mattr=+nan2008 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,O32,NAN2008,MIPS32R2 %s
# RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips32r3 -mattr=+nan2008 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,O32,NAN2008,MIPS32R3 %s
# RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips32r5 -mattr=+nan2008 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,O32,NAN2008,MIPS32R5 %s
# RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips32r6 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,O32,NAN2008,MIPS32R6 %s
# Selected ABI O32 takes precedence over target triple.
# FIXME: llvm-mc -filetype=obj -triple mips64-unknown-linux -mcpu=mips1 -target-abi=o32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,BE,O32,NAN1985,MIPS1 %s
# FIXME: llvm-mc -filetype=obj -triple mips64-unknown-linux -mcpu=mips2 -target-abi=o32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,BE,O32,NAN1985,MIPS2 %s
# FIXME: llvm-mc -filetype=obj -triple mips64-unknown-linux -mcpu=mips3 -target-abi=o32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,BE,O32,NAN1985,MIPS3,32BITMODE %s
# FIXME: llvm-mc -filetype=obj -triple mips64-unknown-linux -mcpu=mips4 -target-abi=o32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,BE,O32,NAN1985,MIPS4,32BITMODE %s
# FIXME: llvm-mc -filetype=obj -triple mips64-unknown-linux -mcpu=mips5 -target-abi=o32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,BE,O32,NAN1985,MIPS5,32BITMODE %s
# FIXME: llvm-mc -filetype=obj -triple mips64-unknown-linux -target-abi=o32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,BE,O32,NAN1985,MIPS32R1 %s
# FIXME: llvm-mc -filetype=obj -triple mips64el-unknown-linux -target-abi=o32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,O32,NAN1985,MIPS32R1 %s
# FIXME: llvm-mc -filetype=obj -triple mips64el-unknown-linux -target-abi=o32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,O32,NAN1985,MIPS32R1 %s
# FIXME: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips32r2 -target-abi=o32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,O32,NAN1985,MIPS32R2 %s
# FIXME: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips32r3 -target-abi=o32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,O32,NAN1985,MIPS32R3 %s
# FIXME: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips32r5 -target-abi=o32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,O32,NAN1985,MIPS32R5 %s
# FIXME: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips32r2 -target-abi=o32 -mattr=+nan2008 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,O32,NAN2008,MIPS32R2 %s
# FIXME: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips32r3 -target-abi=o32 -mattr=+nan2008 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,O32,NAN2008,MIPS32R3 %s
# FIXME: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips32r5 -target-abi=o32 -mattr=+nan2008 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,O32,NAN2008,MIPS32R5 %s
# FIXME: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips32r6 -target-abi=o32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,O32,NAN2008,MIPS32R6 %s
# Default ABI for MIPS64 is N64 as opposed to GCC/GAS (N32).
# RUN: llvm-mc -filetype=obj -triple mips-unknown-linux -mcpu=mips3 -target-abi=n32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,BE,N32,NAN1985,MIPS3 %s
# RUN: llvm-mc -filetype=obj -triple mips-unknown-linux -mcpu=mips4 -target-abi=n32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,BE,N32,NAN1985,MIPS4 %s
# RUN: llvm-mc -filetype=obj -triple mips-unknown-linux -mcpu=mips5 -target-abi=n32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,BE,N32,NAN1985,MIPS5 %s
# FIXME: llvm-mc -filetype=obj -triple mips-unknown-linux -target-abi=n32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,BE,N32,NAN1985,MIPS64R1 %s
# FIXME: llvm-mc -filetype=obj -triple mipsel-unknown-linux -target-abi=n32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,N32,NAN1985,MIPS64R1 %s
# RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips64r2 -target-abi=n32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,N32,NAN1985,MIPS64R2 %s
# RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips64r3 -target-abi=n32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,N32,NAN1985,MIPS64R3 %s
# RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips64r5 -target-abi=n32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,N32,NAN1985,MIPS64R5 %s
# RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips64r2 -target-abi=n32 -mattr=+nan2008 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,N32,NAN2008,MIPS64R2 %s
# RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips64r3 -target-abi=n32 -mattr=+nan2008 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,N32,NAN2008,MIPS64R3 %s
# RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips64r5 -target-abi=n32 -mattr=+nan2008 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,N32,NAN2008,MIPS64R5 %s
# RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips64r6 -target-abi=n32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,N32,NAN2008,MIPS64R6 %s
# RUN: llvm-mc -filetype=obj -triple mips64-unknown-linux -mcpu=mips3 -target-abi=n32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,BE,N32,NAN1985,MIPS3 %s
# RUN: llvm-mc -filetype=obj -triple mips64-unknown-linux -mcpu=mips4 -target-abi=n32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,BE,N32,NAN1985,MIPS4 %s
# RUN: llvm-mc -filetype=obj -triple mips64-unknown-linux -mcpu=mips5 -target-abi=n32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,BE,N32,NAN1985,MIPS5 %s
# RUN: llvm-mc -filetype=obj -triple mips64-unknown-linux -target-abi=n32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,BE,N32,NAN1985,MIPS64R1 %s
# RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux -target-abi=n32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,N32,NAN1985,MIPS64R1 %s
# RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips64r2 -target-abi=n32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,N32,NAN1985,MIPS64R2 %s
# RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips64r3 -target-abi=n32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,N32,NAN1985,MIPS64R3 %s
# RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips64r5 -target-abi=n32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,N32,NAN1985,MIPS64R5 %s
# RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips64r2 -target-abi=n32 -mattr=+nan2008 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,N32,NAN2008,MIPS64R2 %s
# RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips64r3 -target-abi=n32 -mattr=+nan2008 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,N32,NAN2008,MIPS64R3 %s
# RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips64r5 -target-abi=n32 -mattr=+nan2008 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,N32,NAN2008,MIPS64R5 %s
# RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips64r6 -target-abi=n32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,N32,NAN2008,MIPS64R6 %s
# Default ABI for MIPS64 is N64 as opposed to GCC/GAS (N32).
# FIXME: llvm-mc -filetype=obj -triple mips-unknown-linux -mcpu=mips3 -target-abi=n64 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,BE,N64,NAN1985,MIPS3 %s
# FIXME: llvm-mc -filetype=obj -triple mips-unknown-linux -mcpu=mips4 -target-abi=n64 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,BE,N64,NAN1985,MIPS4 %s
# FIXME: llvm-mc -filetype=obj -triple mips-unknown-linux -mcpu=mips5 -target-abi=n64 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,BE,N64,NAN1985,MIPS5 %s
# FIXME: llvm-mc -filetype=obj -triple mips-unknown-linux -target-abi=n64 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,BE,N64,NAN1985,MIPS64R1 %s
# FIXME: llvm-mc -filetype=obj -triple mipsel-unknown-linux -target-abi=n64 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,LE,N64,NAN1985,MIPS64R1 %s
# FIXME: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips64r2 -target-abi=n64 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,LE,N64,NAN1985,MIPS64R2 %s
# FIXME: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips64r3 -target-abi=n64 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,LE,N64,NAN1985,MIPS64R3 %s
# FIXME: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips64r5 -target-abi=n64 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,LE,N64,NAN1985,MIPS64R5 %s
# FIXME: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips64r2 -target-abi=n64 -mattr=+nan2008 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,LE,N64,NAN2008,MIPS64R2 %s
# FIXME: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips64r3 -target-abi=n64 -mattr=+nan2008 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,LE,N64,NAN2008,MIPS64R3 %s
# FIXME: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips64r5 -target-abi=n64 -mattr=+nan2008 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,LE,N64,NAN2008,MIPS64R5 %s
# FIXME: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips64r6 -target-abi=n64 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,LE,N64,NAN2008,MIPS64R6 %s
# RUN: llvm-mc -filetype=obj -triple mips64-unknown-linux -mcpu=mips3 -target-abi=n64 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,BE,N64,NAN1985,MIPS3 %s
# RUN: llvm-mc -filetype=obj -triple mips64-unknown-linux -mcpu=mips4 -target-abi=n64 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,BE,N64,NAN1985,MIPS4 %s
# RUN: llvm-mc -filetype=obj -triple mips64-unknown-linux -mcpu=mips5 -target-abi=n64 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,BE,N64,NAN1985,MIPS5 %s
# RUN: llvm-mc -filetype=obj -triple mips64-unknown-linux %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,BE,N64,NAN1985,MIPS64R1 %s
# RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,LE,N64,NAN1985,MIPS64R1 %s
# RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips64r2 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,LE,N64,NAN1985,MIPS64R2 %s
# RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips64r3 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,LE,N64,NAN1985,MIPS64R3 %s
# RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips64r5 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,LE,N64,NAN1985,MIPS64R5 %s
# RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips64r2 -mattr=+nan2008 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,LE,N64,NAN2008,MIPS64R2 %s
# RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips64r3 -mattr=+nan2008 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,LE,N64,NAN2008,MIPS64R3 %s
# RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips64r5 -mattr=+nan2008 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,LE,N64,NAN2008,MIPS64R5 %s
# RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips64r6 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,LE,N64,NAN2008,MIPS64R6 %s
# RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=octeon -target-abi=n64 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,LE,N64,NAN1985,OCTEON %s
# ALL: ElfHeader {
# ALL-NEXT: Ident {
# ALL-NEXT: Magic: (7F 45 4C 46)
# ELF32-NEXT: Class: 32-bit
# ELF64-NEXT: Class: 64-bit
# LE-NEXT: DataEncoding: LittleEndian
# BE-NEXT: DataEncoding: BigEndian
# ALL-NEXT: FileVersion: 1
# ALL-NEXT: OS/ABI: SystemV
# ALL-NEXT: ABIVersion: 0
# ALL-NEXT: Unused: (00 00 00 00 00 00 00)
# ALL-NEXT: }
# ALL-NEXT: Type: Relocatable
# ALL-NEXT: Machine: EM_MIPS
# ALL-NEXT: Version: 1
# ALL-NEXT: Entry: 0x0
# ALL-NEXT: ProgramHeaderOffset: 0x0
# ALL-NEXT: SectionHeaderOffset:
# ALL-NEXT: Flags [
# 32BITMODE-NEXT: EF_MIPS_32BITMODE
# N64-NOT: EF_MIPS_32BITMODE
# N32-NEXT: EF_MIPS_ABI2
# O32-NEXT: EF_MIPS_ABI_O32
# N64-NOT: EF_MIPS_ABI2
# N64-NOT: EF_MIPS_ABI_O32
# MIPS2-NEXT: EF_MIPS_ARCH_2
# MIPS3-NEXT: EF_MIPS_ARCH_3
# MIPS4-NEXT: EF_MIPS_ARCH_4
# MIPS5-NEXT: EF_MIPS_ARCH_5
# MIPS32R1-NEXT: EF_MIPS_ARCH_32
# MIPS32R2-NEXT: EF_MIPS_ARCH_32R2
# The R2 flag is reused for R3 and R5.
# MIPS32R3-NEXT: EF_MIPS_ARCH_32R2
# MIPS32R5-NEXT: EF_MIPS_ARCH_32R2
# MIPS32R6-NEXT: EF_MIPS_ARCH_32R6
# MIPS64R1-NEXT: EF_MIPS_ARCH_64
# MIPS64R2-NEXT: EF_MIPS_ARCH_64R2
# The R2 flag is reused for R3 and R5.
# MIPS64R3-NEXT: EF_MIPS_ARCH_64R2
# MIPS64R5-NEXT: EF_MIPS_ARCH_64R2
# MIPS64R6-NEXT: EF_MIPS_ARCH_64R6
# OCTEON-NEXT: EF_MIPS_ARCH_64R2
# ALL-NEXT: EF_MIPS_CPIC
# OCTEON-NEXT: EF_MIPS_MACH_OCTEON
# NAN2008-NEXT: EF_MIPS_NAN2008
# ALL-NEXT: ]

View File

@ -21,9 +21,9 @@
# RUN: llvm-mc %s -arch=mips -mcpu=mips32 -filetype=obj | \
# RUN: llvm-objdump -d -r - | FileCheck %s -check-prefixes=ELF-O32
# RUN: llvm-mc %s -arch=mips64 -mcpu=mips64 -target-abi n32 -filetype=obj | \
# RUN: llvm-objdump -d -r - | FileCheck %s -check-prefixes=ELF-NXX
# RUN: llvm-objdump -d -r - | FileCheck %s -check-prefixes=ELF-NXX,ELF-N32
# RUN: llvm-mc %s -arch=mips64 -mcpu=mips64 -target-abi n64 -filetype=obj | \
# RUN: llvm-objdump -d -r - | FileCheck %s -check-prefixes=ELF-NXX
# RUN: llvm-objdump -d -r - | FileCheck %s -check-prefixes=ELF-NXX,ELF-N64
.weak weak_label
@ -61,7 +61,8 @@ local_label:
# ELF-O32-NEXT: R_MIPS_PC16 weak_label
# ELF-NXX: 10 00 00 00 b 4
# ELF-NXX-NEXT: R_MIPS_PC16/R_MIPS_NONE/R_MIPS_NONE weak_label
# ELF-N32-NEXT: R_MIPS_PC16 weak_label
# ELF-N64-NEXT: R_MIPS_PC16/R_MIPS_NONE/R_MIPS_NONE weak_label
j global_label
nop
@ -76,7 +77,8 @@ local_label:
# ELF-O32-NEXT: 00000010: R_MIPS_PC16 global_label
# ELF-NXX: 10 00 00 00 b 4
# ELF-NXX-NEXT: R_MIPS_PC16/R_MIPS_NONE/R_MIPS_NONE global_label
# ELF-N32-NEXT: R_MIPS_PC16 global_label
# ELF-N64-NEXT: R_MIPS_PC16/R_MIPS_NONE/R_MIPS_NONE global_label
j .text
nop

View File

@ -55,7 +55,7 @@ local_label:
# N32: # fixup A - offset: 0, value: %got_disp(local_label), kind: fixup_Mips_GOT_DISP
# ELF-N32: 8f 99 00 00 lw $25, 0($gp)
# ELF-N32-NEXT: R_MIPS_GOT_DISP/R_MIPS_NONE/R_MIPS_NONE local_label
# ELF-N32-NEXT: R_MIPS_GOT_DISP local_label
# N64: ld $25, %got_disp(local_label)($gp) # encoding: [0xdf,0x99,A,A]
# N64: # fixup A - offset: 0, value: %got_disp(local_label), kind: fixup_Mips_GOT_DISP
@ -92,7 +92,7 @@ local_label:
# N32: # fixup A - offset: 0, value: %call16(weak_label), kind: fixup_Mips_CALL16
# ELF-N32: 8f 99 00 00 lw $25, 0($gp)
# ELF-N32-NEXT: R_MIPS_CALL16/R_MIPS_NONE/R_MIPS_NONE weak_label
# ELF-N32-NEXT: R_MIPS_CALL16 weak_label
# N64: ld $25, %call16(weak_label)($gp) # encoding: [0xdf,0x99,A,A]
# N64: # fixup A - offset: 0, value: %call16(weak_label), kind: fixup_Mips_CALL16
@ -127,7 +127,7 @@ local_label:
# N32: # fixup A - offset: 0, value: %call16(global_label), kind: fixup_Mips_CALL16
# ELF-N32: 8f 99 00 00 lw $25, 0($gp)
# ELF-N32-NEXT: R_MIPS_CALL16/R_MIPS_NONE/R_MIPS_NONE global_label
# ELF-N32-NEXT: R_MIPS_CALL16 global_label
# N64: ld $25, %call16(global_label)($gp) # encoding: [0xdf,0x99,A,A]
# N64: # fixup A - offset: 0, value: %call16(global_label), kind: fixup_Mips_CALL16
@ -162,7 +162,7 @@ local_label:
# N32-NEXT: # fixup A - offset: 0, value: %got_disp(.text), kind: fixup_Mips_GOT_DISP
# ELF-N32: 8f 99 00 00 lw $25, 0($gp)
# ELF-N32-NEXT: R_MIPS_GOT_DISP/R_MIPS_NONE/R_MIPS_NONE .text
# ELF-N32-NEXT: R_MIPS_GOT_DISP .text
# N64: ld $25, %got_disp(.text)($gp) # encoding: [0xdf,0x99,A,A]
# N64-NEXT: # fixup A - offset: 0, value: %got_disp(.text), kind: fixup_Mips_GOT_DISP
@ -204,7 +204,7 @@ local_label:
# N32: # fixup A - offset: 0, value: %got_disp($tmp0), kind: fixup_Mips_GOT_DISP
# ELF-N32: 8f 99 00 00 lw $25, 0($gp)
# ELF-N32-NEXT: R_MIPS_GOT_DISP/R_MIPS_NONE/R_MIPS_NONE .Ltmp0
# ELF-N32-NEXT: R_MIPS_GOT_DISP .Ltmp0
# N64: ld $25, %got_disp(.Ltmp0)($gp) # encoding: [0xdf,0x99,A,A]
# N64: # fixup A - offset: 0, value: %got_disp(.Ltmp0), kind: fixup_Mips_GOT_DISP
@ -246,7 +246,7 @@ local_label:
# N32-FIXME: # fixup A - offset: 0, value: %got_disp(forward_local), kind: fixup_Mips_GOT_DISP
# ELF-N32: 8f 99 00 00 lw $25, 0($gp)
# ELF-N32-NEXT: R_MIPS_GOT_DISP/R_MIPS_NONE/R_MIPS_NONE forward_local
# ELF-N32-NEXT: R_MIPS_GOT_DISP forward_local
# N64-FIXME: ld $25, %got_disp(forward_local)($gp) # encoding: [0xdf,0x99,A,A]
# N64-FIXME: # fixup A - offset: 0, value: %got_disp(forward_local), kind: fixup_Mips_GOT_DISP

View File

@ -33,28 +33,15 @@ foo:
# OBJ-O32: 0x8 R_MIPS_32 .text 0x0
# OBJ-O32: 0xC R_MIPS_NONE - 0x0
# FIXME: We can't get N32 correct at the moment. If we use a mips-* triple then
# we incorrectly drop the addend. If we use a mips64-* triple then we
# incorrectly use the 3-reloc encoding (and ELF64). mips64-* triples
# are closest to being correct so we use them for now.
# This should be corrected once the triple bugfixes allow us to be ABI
# dependent rather than triple dependent.
# OBJ-N32-LABEL: Name: .text
# OBJ-N32: 0000: 00000000 00000000 00000000
# OBJ-N32-LABEL: }
# OBJ-N32-LABEL: Relocations [
# 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-N32: 0x4 R_MIPS_NONE .text 0x0
# OBJ-N32: 0x0 R_MIPS_NONE .text 0x4
# OBJ-N32: 0x8 R_MIPS_32 .text 0x8
# OBJ-N32: 0xC R_MIPS_NONE - 0x0
# OBJ-N64-LABEL: Name: .text
# OBJ-N64: 0000: 00000000 00000000 00000000