diff options
author | TDYa127 <a127a127@gmail.com> | 2011-06-15 03:08:18 +0800 |
---|---|---|
committer | TDYa127 <a127a127@gmail.com> | 2011-06-15 03:08:18 +0800 |
commit | f3f63d6ded54ea520f5066979b53c2356092692d (patch) | |
tree | 67ce6d2a715acfaffac7408572c6340d84469e57 | |
parent | a13b6909c66260aabbcd32b6519d05e469881141 (diff) | |
download | linkloader-f3f63d6ded54ea520f5066979b53c2356092692d.tar.gz |
Add X86_64 relocation type: R_X86_64_64.
-rw-r--r-- | include/impl/ELFObject.hxx | 5 | ||||
-rw-r--r-- | include/impl/ELFSymbol.hxx | 28 |
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: |