summaryrefslogtreecommitdiff
path: root/lib/Target/X86/X86ELFWriterInfo.cpp
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/X86/X86ELFWriterInfo.cpp
parent1488670076908261af145778c23cb9aca30904e5 (diff)
downloadllvm-0a38dc5fda9a22aceecccbad2f024b118ce1d5d8.tar.gz
llvm-0a38dc5fda9a22aceecccbad2f024b118ce1d5d8.tar.bz2
llvm-0a38dc5fda9a22aceecccbad2f024b118ce1d5d8.tar.xz
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/X86/X86ELFWriterInfo.cpp')
-rw-r--r--lib/Target/X86/X86ELFWriterInfo.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/Target/X86/X86ELFWriterInfo.cpp b/lib/Target/X86/X86ELFWriterInfo.cpp
index 9e44f97ca8..618cc5b82b 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;
+}