diff options
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp | 32 | ||||
| -rw-r--r-- | llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.h | 3 | ||||
| -rw-r--r-- | llvm/lib/MC/MCObjectFileInfo.cpp | 4 | 
3 files changed, 39 insertions, 0 deletions
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp index f780137d087..50f63fb8dd3 100644 --- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp +++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp @@ -819,6 +819,34 @@ void RuntimeDyldELF::resolveSystemZRelocation(const SectionEntry &Section,    }  } +void RuntimeDyldELF::resolveBPFRelocation(const SectionEntry &Section, +                                          uint64_t Offset, uint64_t Value, +                                          uint32_t Type, int64_t Addend) { +  bool isBE = Arch == Triple::bpfeb; + +  switch (Type) { +  default: +    llvm_unreachable("Relocation type not implemented yet!"); +    break; +  case ELF::R_BPF_NONE: +    break; +  case ELF::R_BPF_64_64: { +    write(isBE, Section.getAddressWithOffset(Offset), Value + Addend); +    DEBUG(dbgs() << "Writing " << format("%p", (Value + Addend)) << " at " +                 << format("%p\n", Section.getAddressWithOffset(Offset))); +    break; +  } +  case ELF::R_BPF_64_32: { +    Value += Addend; +    assert(Value <= UINT32_MAX); +    write(isBE, Section.getAddressWithOffset(Offset), static_cast<uint32_t>(Value)); +    DEBUG(dbgs() << "Writing " << format("%p", Value) << " at " +                 << format("%p\n", Section.getAddressWithOffset(Offset))); +    break; +  } +  } +} +  // The target location for the relocation is described by RE.SectionID and  // RE.Offset.  RE.SectionID can be used to find the SectionEntry.  Each  // SectionEntry has three members describing its location. @@ -879,6 +907,10 @@ void RuntimeDyldELF::resolveRelocation(const SectionEntry &Section,    case Triple::systemz:      resolveSystemZRelocation(Section, Offset, Value, Type, Addend);      break; +  case Triple::bpfel: +  case Triple::bpfeb: +    resolveBPFRelocation(Section, Offset, Value, Type, Addend); +    break;    default:      llvm_unreachable("Unsupported CPU type!");    } diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.h b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.h index 498979705b7..84dd810101f 100644 --- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.h +++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.h @@ -58,6 +58,9 @@ class RuntimeDyldELF : public RuntimeDyldImpl {    void resolveSystemZRelocation(const SectionEntry &Section, uint64_t Offset,                                  uint64_t Value, uint32_t Type, int64_t Addend); +  void resolveBPFRelocation(const SectionEntry &Section, uint64_t Offset, +                            uint64_t Value, uint32_t Type, int64_t Addend); +    unsigned getMaxStubSize() override {      if (Arch == Triple::aarch64 || Arch == Triple::aarch64_be)        return 20; // movz; movk; movk; movk; br diff --git a/llvm/lib/MC/MCObjectFileInfo.cpp b/llvm/lib/MC/MCObjectFileInfo.cpp index 9f94264684f..b685790910d 100644 --- a/llvm/lib/MC/MCObjectFileInfo.cpp +++ b/llvm/lib/MC/MCObjectFileInfo.cpp @@ -286,6 +286,10 @@ void MCObjectFileInfo::initELFMCObjectFileInfo(const Triple &T) {                       ((CMModel == CodeModel::Large) ? dwarf::DW_EH_PE_sdata8                                                      : dwarf::DW_EH_PE_sdata4);      break; +  case Triple::bpfel: +  case Triple::bpfeb: +    FDECFIEncoding = dwarf::DW_EH_PE_sdata8; +    break;    default:      FDECFIEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;      break;  | 

