summaryrefslogtreecommitdiffstats
path: root/lib/Target
diff options
context:
space:
mode:
authorBruno Cardoso Lopes <bruno.cardoso@gmail.com>2009-07-20 08:52:02 +0000
committerBruno Cardoso Lopes <bruno.cardoso@gmail.com>2009-07-20 08:52:02 +0000
commit0a38dc5fda9a22aceecccbad2f024b118ce1d5d8 (patch)
treeaeacae71db2e46b27baffc7bd6a94477d1df2200 /lib/Target
parent1488670076908261af145778c23cb9aca30904e5 (diff)
downloadexternal_llvm-0a38dc5fda9a22aceecccbad2f024b118ce1d5d8.zip
external_llvm-0a38dc5fda9a22aceecccbad2f024b118ce1d5d8.tar.gz
external_llvm-0a38dc5fda9a22aceecccbad2f024b118ce1d5d8.tar.bz2
For PC relative relocations where symbols are defined in the same section they
are referenced, ignore the relocation entry and patch the relocatable field with the computed symbol offset directly git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76414 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target')
-rw-r--r--lib/Target/X86/X86ELFWriterInfo.cpp36
-rw-r--r--lib/Target/X86/X86ELFWriterInfo.h13
2 files changed, 47 insertions, 2 deletions
diff --git a/lib/Target/X86/X86ELFWriterInfo.cpp b/lib/Target/X86/X86ELFWriterInfo.cpp
index 9e44f97..618cc5b 100644
--- a/lib/Target/X86/X86ELFWriterInfo.cpp
+++ b/lib/Target/X86/X86ELFWriterInfo.cpp
@@ -103,8 +103,44 @@ unsigned X86ELFWriterInfo::getRelocationTySize(unsigned RelTy) const {
return 0;
}
+bool X86ELFWriterInfo::isPCRelativeRel(unsigned RelTy) const {
+ if (is64Bit) {
+ switch(RelTy) {
+ case R_X86_64_PC32:
+ return true;
+ case R_X86_64_32:
+ case R_X86_64_32S:
+ case R_X86_64_64:
+ return false;
+ default:
+ llvm_unreachable("unknown x86_64 relocation type");
+ }
+ } else {
+ switch(RelTy) {
+ case R_386_PC32:
+ return true;
+ case R_386_32:
+ return false;
+ default:
+ llvm_unreachable("unknown x86 relocation type");
+ }
+ }
+ return 0;
+}
+
unsigned X86ELFWriterInfo::getAbsoluteLabelMachineRelTy() const {
return is64Bit ?
X86::reloc_absolute_dword : X86::reloc_absolute_word;
}
+long int X86ELFWriterInfo::computeRelocation(unsigned SymOffset,
+ unsigned RelOffset,
+ unsigned RelTy) const {
+
+ if (RelTy == R_X86_64_PC32 || RelTy == R_386_PC32)
+ return SymOffset - (RelOffset + 4);
+ else
+ assert("computeRelocation unknown for this relocation type");
+
+ return 0;
+}
diff --git a/lib/Target/X86/X86ELFWriterInfo.h b/lib/Target/X86/X86ELFWriterInfo.h
index e534e17..e882a0c 100644
--- a/lib/Target/X86/X86ELFWriterInfo.h
+++ b/lib/Target/X86/X86ELFWriterInfo.h
@@ -59,16 +59,25 @@ namespace llvm {
/// for a jump table index.
virtual unsigned getJumpTableIndexRelTy() const { return R_X86_64_32S; }
- /// getAddendForRelTy - Gets the addend value for an ELF relocation entry
- /// based on the target relocation type
+ /// getDefaultAddendForRelTy - Gets the default addend value for a
+ /// relocation entry based on the target ELF relocation type.
virtual long int getDefaultAddendForRelTy(unsigned RelTy) const;
/// getRelTySize - Returns the size of relocatable field in bits
virtual unsigned getRelocationTySize(unsigned RelTy) const;
+ /// isPCRelativeRel - True if the relocation type is pc relative
+ virtual bool isPCRelativeRel(unsigned RelTy) const;
+
/// getJumpTableRelocationTy - Returns the machine relocation type used
/// to reference a jumptable.
virtual unsigned getAbsoluteLabelMachineRelTy() const;
+
+ /// computeRelocation - Some relocatable fields could be relocated
+ /// directly, avoiding the relocation symbol emission, compute the
+ /// final relocation value for this symbol.
+ virtual long int computeRelocation(unsigned SymOffset, unsigned RelOffset,
+ unsigned RelTy) const;
};
} // end llvm namespace