Index: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp =================================================================== RCS file: /cvsroot/src/external/bsd/llvm/dist/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp,v retrieving revision 1.1.1.12 diff -p -u -r1.1.1.12 RuntimeDyldELF.cpp --- llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp 17 Jul 2018 18:33:38 -0000 1.1.1.12 +++ llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp 28 Jun 2019 00:27:08 -0000 @@ -525,6 +525,9 @@ void RuntimeDyldELF::resolveARMRelocatio (support::ulittle32_t::ref{TargetPtr} & ~0x000F0FFF) | (Value & 0xFFF) | (((Value >> 12) & 0xF) << 16); break; + case ELF::R_ARM_REL32: + support::ulittle32_t::ref{TargetPtr} = Value - FinalAddress; + break; // Write 24 bit relative value to the branch instruction. case ELF::R_ARM_PC24: // Fall through. case ELF::R_ARM_CALL: // Fall through. @@ -698,12 +701,15 @@ static inline uint16_t applyPPChighesta return ((value + 0x8000) >> 48) & 0xffff; } +#include void RuntimeDyldELF::resolvePPC32Relocation(const SectionEntry &Section, uint64_t Offset, uint64_t Value, uint32_t Type, int64_t Addend) { uint8_t *LocalAddress = Section.getAddressWithOffset(Offset); + uint32_t FinalAddress = Section.getLoadAddressWithOffset(Offset); switch (Type) { default: + fprintf(stderr, "type %u\n", Type); llvm_unreachable("Relocation type not implemented yet!"); break; case ELF::R_PPC_ADDR16_LO: @@ -715,6 +721,24 @@ void RuntimeDyldELF::resolvePPC32Relocat case ELF::R_PPC_ADDR16_HA: writeInt16BE(LocalAddress, applyPPCha(Value + Addend)); break; + case ELF::R_PPC_PLTREL24: { + // S - value of symbol (var:Value) + // low24* (L + A - P) >> 2 + // A - addend (var:Addend) + // L - PLT address for symbol + // P - place of storage being relocated, computed with r_offset (var:FinalAddress?) + // low24* - 24bit in reloc, goes into bits 2..25 + int32_t delta = static_cast(Value + Addend - FinalAddress); + if (SignExtend32<26>(delta) != delta) + llvm_unreachable("Relocation R_PPC_PLTREL24 overflow"); + uint32_t Inst = readBytesUnaligned(LocalAddress, 4); + writeInt32BE(LocalAddress, (Inst & 0xFC000003) | + ((delta << 2) & 0x03FFFFFC)); + } break; + case ELF::R_PPC_REL32: { + uint32_t delta = static_cast(Value + Addend - FinalAddress); + writeInt32BE(LocalAddress, delta); + } break; } } Index: llvm/lib/Support/Unix/Memory.inc =================================================================== RCS file: /cvsroot/src/external/bsd/llvm/dist/llvm/lib/Support/Unix/Memory.inc,v retrieving revision 1.1.1.9 diff -p -u -r1.1.1.9 Memory.inc --- llvm/lib/Support/Unix/Memory.inc 17 Jul 2018 18:33:35 -0000 1.1.1.9 +++ llvm/lib/Support/Unix/Memory.inc 28 Jun 2019 00:27:08 -0000 @@ -32,7 +32,7 @@ #if defined(__mips__) # if defined(__OpenBSD__) # include -# elif !defined(__FreeBSD__) +# elif !defined(__FreeBSD__) && !defined(__NetBSD__) # include # endif #endif