[ELF][MIPS] Create dynamic relocations for R_MIPS_32/64 relocations

llvm-svn: 257806
This commit is contained in:
Simon Atanasyan 2016-01-14 21:34:50 +00:00
parent c005e20d3b
commit ca558ea627
2 changed files with 26 additions and 6 deletions

View File

@ -227,6 +227,7 @@ public:
template <class ELFT> class MipsTargetInfo final : public TargetInfo { template <class ELFT> class MipsTargetInfo final : public TargetInfo {
public: public:
MipsTargetInfo(); MipsTargetInfo();
unsigned getDynReloc(unsigned Type) const override;
void writeGotHeaderEntries(uint8_t *Buf) const override; void writeGotHeaderEntries(uint8_t *Buf) const override;
void writeGotPltEntry(uint8_t *Buf, uint64_t Plt) const override; void writeGotPltEntry(uint8_t *Buf, uint64_t Plt) const override;
void writePltZeroEntry(uint8_t *Buf, uint64_t GotEntryAddr, void writePltZeroEntry(uint8_t *Buf, uint64_t GotEntryAddr,
@ -1453,6 +1454,16 @@ void AMDGPUTargetInfo::relocateOne(uint8_t *Loc, uint8_t *BufEnd, uint32_t Type,
template <class ELFT> MipsTargetInfo<ELFT>::MipsTargetInfo() { template <class ELFT> MipsTargetInfo<ELFT>::MipsTargetInfo() {
PageSize = 65536; PageSize = 65536;
GotHeaderEntriesNum = 2; GotHeaderEntriesNum = 2;
RelativeReloc = R_MIPS_REL32;
}
template <class ELFT>
unsigned MipsTargetInfo<ELFT>::getDynReloc(unsigned Type) const {
if (Type == R_MIPS_32 || Type == R_MIPS_64)
return R_MIPS_REL32;
StringRef S = getELFRelocationTypeName(EM_MIPS, Type);
error("Relocation " + S + " cannot be used when making a shared object; "
"recompile with -fPIC.");
} }
template <class ELFT> template <class ELFT>

View File

@ -1,14 +1,16 @@
# Check R_MIPS_32 relocation calculation. # Check R_MIPS_32 relocation calculation.
# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t-be.o # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t-be.o
# RUN: ld.lld %t-be.o -o %t-be.exe # RUN: ld.lld -shared %t-be.o -o %t-be.so
# RUN: llvm-objdump -t %t-be.exe | FileCheck %s # RUN: llvm-objdump -t %t-be.so | FileCheck %s
# RUN: llvm-objdump -s %t-be.exe | FileCheck -check-prefix=BE %s # RUN: llvm-objdump -s %t-be.so | FileCheck -check-prefix=BE %s
# RUN: llvm-readobj -relocations %t-be.so | FileCheck -check-prefix=REL %s
# RUN: llvm-mc -filetype=obj -triple=mipsel-unknown-linux %s -o %t-el.o # RUN: llvm-mc -filetype=obj -triple=mipsel-unknown-linux %s -o %t-el.o
# RUN: ld.lld %t-el.o -o %t-el.exe # RUN: ld.lld -shared %t-el.o -o %t-el.so
# RUN: llvm-objdump -t %t-el.exe | FileCheck %s # RUN: llvm-objdump -t %t-el.so | FileCheck %s
# RUN: llvm-objdump -s %t-el.exe | FileCheck -check-prefix=EL %s # RUN: llvm-objdump -s %t-el.so | FileCheck -check-prefix=EL %s
# RUN: llvm-readobj -relocations %t-el.so | FileCheck -check-prefix=REL %s
# REQUIRES: mips # REQUIRES: mips
@ -40,3 +42,10 @@ v2:
# EL: Contents of section .data: # EL: Contents of section .data:
# EL-NEXT: 30000 00000000 08000300 00000300 # EL-NEXT: 30000 00000000 08000300 00000300
# ^-- v2+4 ^-- v1 # ^-- v2+4 ^-- v1
# REL: Relocations [
# REL-NEXT: Section (7) .rel.dyn {
# REL-NEXT: 0x30004 R_MIPS_REL32 v2 0x0
# REL-NEXT: 0x30008 R_MIPS_REL32 - 0x0
# REL-NEXT: }
# REL-NEXT: ]