[PATCH] D16193: [ELF][MIPS] Ignore 'hint' relocations like R_MIPS_JALR in the `scanRelocs` method
Simon Atanasyan via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 14 12:45:59 PST 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL257798: [ELF][MIPS] Ignore 'hint' relocations like R_MIPS_JALR in the `scanRelocs`… (authored by atanasyan).
Changed prior to commit:
http://reviews.llvm.org/D16193?vs=44892&id=44916#toc
Repository:
rL LLVM
http://reviews.llvm.org/D16193
Files:
lld/trunk/ELF/Target.cpp
lld/trunk/ELF/Target.h
lld/trunk/ELF/Writer.cpp
lld/trunk/test/ELF/mips-jalr.test
Index: lld/trunk/ELF/Target.h
===================================================================
--- lld/trunk/ELF/Target.h
+++ lld/trunk/ELF/Target.h
@@ -57,6 +57,11 @@
uint64_t GotEntryAddr, uint64_t PltEntryAddr,
int32_t Index, unsigned RelOff) const = 0;
+ // Returns true if a relocation is just a hint for linker to make for example
+ // some code optimization. Such relocations should not be handled as a regular
+ // ones and lead to dynamic relocation creation etc.
+ virtual bool isHintReloc(uint32_t Type) const;
+
// Returns true if a relocation is relative to the place being relocated,
// such as relocations used for PC-relative instructions. Such relocations
// need not be fixed up if an image is loaded to a different address than
Index: lld/trunk/ELF/Target.cpp
===================================================================
--- lld/trunk/ELF/Target.cpp
+++ lld/trunk/ELF/Target.cpp
@@ -239,6 +239,7 @@
void relocateOne(uint8_t *Loc, uint8_t *BufEnd, uint32_t Type, uint64_t P,
uint64_t SA, uint64_t ZA = 0,
uint8_t *PairedLoc = nullptr) const override;
+ bool isHintReloc(uint32_t Type) const override;
bool isRelRelative(uint32_t Type) const override;
};
} // anonymous namespace
@@ -284,6 +285,8 @@
bool TargetInfo::isGotRelative(uint32_t Type) const { return false; }
+bool TargetInfo::isHintReloc(uint32_t Type) const { return false; }
+
bool TargetInfo::isRelRelative(uint32_t Type) const { return true; }
bool TargetInfo::isSizeReloc(uint32_t Type) const { return false; }
@@ -1581,6 +1584,11 @@
}
template <class ELFT>
+bool MipsTargetInfo<ELFT>::isHintReloc(uint32_t Type) const {
+ return Type == R_MIPS_JALR;
+}
+
+template <class ELFT>
bool MipsTargetInfo<ELFT>::isRelRelative(uint32_t Type) const {
switch (Type) {
default:
Index: lld/trunk/ELF/Writer.cpp
===================================================================
--- lld/trunk/ELF/Writer.cpp
+++ lld/trunk/ELF/Writer.cpp
@@ -210,6 +210,10 @@
SymbolBody *Body = File.getSymbolBody(SymIndex);
uint32_t Type = RI.getType(Config->Mips64EL);
+ // Ignore "hint" relocation because it is for optional code optimization.
+ if (Target->isHintReloc(Type))
+ continue;
+
if (Target->isGotRelative(Type))
HasGotOffRel = true;
Index: lld/trunk/test/ELF/mips-jalr.test
===================================================================
--- lld/trunk/test/ELF/mips-jalr.test
+++ lld/trunk/test/ELF/mips-jalr.test
@@ -3,11 +3,15 @@
# RUN: yaml2obj -format elf %s -o %t.o
# RUN: ld.lld %t.o -o %t.so -shared
# RUN: llvm-objdump -d %t.so | FileCheck %s
+# RUN: llvm-readobj -relocations %t.so | FileCheck -check-prefix=REL %s
# REQUIRES: mips
# CHECK: 10000: 09 f8 20 03 jalr $25
+# REL: Relocations [
+# REL-NEXT: ]
+
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16193.44916.patch
Type: text/x-patch
Size: 2968 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160114/8c789d9e/attachment.bin>
More information about the llvm-commits
mailing list