summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTDYa127 <a127a127@gmail.com>2011-06-15 03:08:18 +0800
committerTDYa127 <a127a127@gmail.com>2011-06-15 03:08:18 +0800
commitf3f63d6ded54ea520f5066979b53c2356092692d (patch)
tree67ce6d2a715acfaffac7408572c6340d84469e57
parenta13b6909c66260aabbcd32b6519d05e469881141 (diff)
downloadlinkloader-f3f63d6ded54ea520f5066979b53c2356092692d.tar.gz
Add X86_64 relocation type: R_X86_64_64.
-rw-r--r--include/impl/ELFObject.hxx5
-rw-r--r--include/impl/ELFSymbol.hxx28
2 files changed, 33 insertions, 0 deletions
diff --git a/include/impl/ELFObject.hxx b/include/impl/ELFObject.hxx
index 839ee3a..4f12866 100644
--- a/include/impl/ELFObject.hxx
+++ b/include/impl/ELFObject.hxx
@@ -238,6 +238,11 @@ relocateX86_64(void *(*find_sym)(void *context, char const *name),
rsl_assert(0 && "Not implemented relocation type.");
break;
+ // FIXME: XXX: R_X86_64_64 is 64 bit, there is a big problem here.
+ case 1: // R_X86_64_64
+ *inst = (S+A);
+ break;
+
case 2: // R_X86_64_PC32
*inst = (S+A-P);
break;
diff --git a/include/impl/ELFSymbol.hxx b/include/impl/ELFSymbol.hxx
index 8e20623..20e4890 100644
--- a/include/impl/ELFSymbol.hxx
+++ b/include/impl/ELFSymbol.hxx
@@ -232,6 +232,34 @@ void *ELFSymbol_CRTP<Bitwidth>::getAddress(bool autoAlloc) const {
break;
case STT_NOTYPE:
+ switch (idx) {
+ default:
+ {
+#ifndef NDEBUG
+ ELFSectionHeaderTableTy const *header =
+ owner->getSectionHeaderTable();
+ rsl_assert(((*header)[idx]->getType() == SHT_PROGBITS ||
+ (*header)[idx]->getType() == SHT_NOBITS) &&
+ "STT_SECTION with not BITS section.");
+#endif
+ ELFSectionTy const *sec = owner->getSectionByIndex(idx);
+ rsl_assert(sec != 0 && "STT_SECTION with null section.");
+
+ ELFSectionBitsTy const &st =
+ static_cast<ELFSectionBitsTy const &>(*sec);
+ my_addr = const_cast<unsigned char *>(&st[0] + (off_t)getValue());
+ }
+ break;
+
+ case SHN_ABS:
+ case SHN_COMMON:
+ case SHN_XINDEX:
+ rsl_assert(0 && "STT_SECTION with special st_shndx.");
+ break;
+ case SHN_UNDEF:
+ return 0;
+ }
+ break;
return 0;
case STT_COMMON: