Changeset View
Changeset View
Standalone View
Standalone View
lld/ELF/Arch/BPF.cpp
- This file was added.
//===---- BPF.cpp ---------------------------------------------------------===// | |||||
// | |||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |||||
// See https://llvm.org/LICENSE.txt for license information. | |||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |||||
// | |||||
//===----------------------------------------------------------------------===// | |||||
#include "InputFiles.h" | |||||
#include "Symbols.h" | |||||
#include "Target.h" | |||||
#include "llvm/Object/ELF.h" | |||||
using namespace llvm; | |||||
using namespace llvm::ELF; | |||||
using namespace lld; | |||||
using namespace lld::elf; | |||||
namespace { | |||||
class BPF final : public TargetInfo { | |||||
public: | |||||
BPF(); | |||||
void relocate(uint8_t *loc, const Relocation &rel, | |||||
uint64_t val) const override; | |||||
RelType getDynRel(RelType type) const override; | |||||
RelExpr getRelExpr(RelType type, const Symbol &s, | |||||
const uint8_t *loc) const override; | |||||
bool emitFuncDataSections() const override; | |||||
}; | |||||
} // namespace | |||||
BPF::BPF() { noneRel = R_BPF_NONE; } | |||||
void BPF::relocate(uint8_t *loc, const Relocation &rel, uint64_t val) const { | |||||
switch (rel.type) { | |||||
case R_BPF_NONE: | |||||
break; | |||||
case R_BPF_64_64: | |||||
write64(loc, val); | |||||
break; | |||||
case R_BPF_64_32: | |||||
write32(loc, val); | |||||
break; | |||||
default: | |||||
llvm_unreachable("unknown relocation"); | |||||
} | |||||
} | |||||
RelType BPF::getDynRel(RelType type) const { return type; } | |||||
MaskRay: `R_NONE` if no dynamic relocation is expected | |||||
RelExpr BPF::getRelExpr(RelType type, const Symbol &s, | |||||
const uint8_t *loc) const { | |||||
if (type == R_BPF_NONE) | |||||
MaskRayUnsubmitted Not Done ReplyInline ActionsSee other Arch/*.cpp: add switch in getRelExpr and add error MaskRay: See other `Arch/*.cpp`: add switch in getRelExpr and add `error` | |||||
return R_NONE; | |||||
return R_ABS; | |||||
} | |||||
Not Done ReplyInline ActionsSee other getRelExpr implementations. The allowed relocation types must be listed. MaskRay: See other getRelExpr implementations. The allowed relocation types must be listed. | |||||
will do. yonghong-song: will do. | |||||
bool BPF::emitFuncDataSections() const { return !config->relocatable; } | |||||
TargetInfo *elf::getBPFTargetInfo() { | |||||
static BPF target; | |||||
return ⌖ | |||||
} |
R_NONE if no dynamic relocation is expected