From 872808e946f3f8be1b30a6672697c2ba8e12f9e1 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Mon, 1 Jun 2015 15:10:51 +0000 Subject: [PATCH 1/1] Fix relocation selection for foo-. on mips. This handles only the 32 bit case. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238751 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp | 2 +- test/MC/Mips/relocation.s | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 test/MC/Mips/relocation.s diff --git a/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp b/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp index 1c0a5ebdcff..4df92d067ea 100644 --- a/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp +++ b/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp @@ -70,7 +70,7 @@ unsigned MipsELFObjectWriter::GetRelocType(const MCValue &Target, switch (Kind) { case Mips::fixup_Mips_32: case FK_Data_4: - return ELF::R_MIPS_32; + return IsPCRel ? ELF::R_MIPS_PC32 : ELF::R_MIPS_32; case Mips::fixup_Mips_64: case FK_Data_8: return ELF::R_MIPS_64; diff --git a/test/MC/Mips/relocation.s b/test/MC/Mips/relocation.s new file mode 100644 index 00000000000..642b40960a6 --- /dev/null +++ b/test/MC/Mips/relocation.s @@ -0,0 +1,10 @@ +// RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux < %s | llvm-readobj -r | FileCheck %s + +// Test that we produce the correct relocation. +// FIXME: move more relocation only tests here. + + .long foo +// CHECK: R_MIPS_32 foo + + .long foo-. +// CHECK: R_MIPS_PC32 foo -- 2.34.1