Created using spr 1.3.5-bogner
This commit is contained in:
Fangrui Song 2025-04-06 00:15:22 -07:00
commit 44bc417c36
40 changed files with 113 additions and 122 deletions

View File

@ -262,8 +262,8 @@ public:
const MCSymbol &getSymbol() const { return *Symbol; } const MCSymbol &getSymbol() const { return *Symbol; }
// Some targets encode the relocation specifier within SymA using // Some targets encode the relocation specifier within SymA using
// MCSymbolRefExpr::SubclassData and access it via getAccessVariant(), though // MCSymbolRefExpr::SubclassData, which is copied to MCValue::Specifier,
// this method is now deprecated. // though this method is now deprecated.
VariantKind getKind() const { VariantKind getKind() const {
return (VariantKind)(getSubclassData() & VariantKindMask); return (VariantKind)(getSubclassData() & VariantKindMask);
} }

View File

@ -32,12 +32,16 @@ class MCValue {
int64_t Cst = 0; int64_t Cst = 0;
uint32_t Specifier = 0; uint32_t Specifier = 0;
void print(raw_ostream &OS) const;
/// Print the value to stderr.
void dump() const;
public: public:
friend class MCAssembler; friend class MCAssembler;
friend class MCExpr; friend class MCExpr;
MCValue() = default; MCValue() = default;
int64_t getConstant() const { return Cst; } int64_t getConstant() const { return Cst; }
uint32_t getRefKind() const { return Specifier; }
uint32_t getSpecifier() const { return Specifier; } uint32_t getSpecifier() const { return Specifier; }
void setSpecifier(uint32_t S) { Specifier = S; } void setSpecifier(uint32_t S) { Specifier = S; }
@ -47,18 +51,6 @@ public:
/// Is this an absolute (as opposed to relocatable) value. /// Is this an absolute (as opposed to relocatable) value.
bool isAbsolute() const { return !SymA && !SymB; } bool isAbsolute() const { return !SymA && !SymB; }
/// Print the value to the stream \p OS.
void print(raw_ostream &OS) const;
/// Print the value to stderr.
void dump() const;
// Get the relocation specifier from SymA. This is a workaround for targets
// that do not use MCValue::Specifier.
uint16_t getSymSpecifier() const { return Specifier; }
// Get the relocation specifier from SymA, or 0 when SymA is null.
uint16_t getAccessVariant() const { return Specifier; }
static MCValue get(const MCSymbol *SymA, const MCSymbol *SymB = nullptr, static MCValue get(const MCSymbol *SymA, const MCSymbol *SymB = nullptr,
int64_t Val = 0, uint32_t Specifier = 0) { int64_t Val = 0, uint32_t Specifier = 0) {
MCValue R; MCValue R;

View File

@ -122,11 +122,11 @@ bool MCAssembler::isThumbFunc(const MCSymbol *Symbol) const {
if (!Expr->evaluateAsRelocatable(V, nullptr)) if (!Expr->evaluateAsRelocatable(V, nullptr))
return false; return false;
if (V.getSubSym() || V.getRefKind() != MCSymbolRefExpr::VK_None) if (V.getSubSym() || V.getSpecifier() != MCSymbolRefExpr::VK_None)
return false; return false;
auto *Sym = V.getAddSym(); auto *Sym = V.getAddSym();
if (!Sym || V.getSymSpecifier()) if (!Sym || V.getSpecifier())
return false; return false;
if (!isThumbFunc(Sym)) if (!isThumbFunc(Sym))

View File

@ -291,7 +291,7 @@ bool MCExpr::evaluateAsAbsolute(int64_t &Res, const MCAssembler *Asm,
// Value with RefKind (e.g. %hi(0xdeadbeef) in MIPS) is not considered // Value with RefKind (e.g. %hi(0xdeadbeef) in MIPS) is not considered
// absolute (the value is unknown at parse time), even if it might be resolved // absolute (the value is unknown at parse time), even if it might be resolved
// by evaluateFixup. // by evaluateFixup.
return IsRelocatable && Value.isAbsolute() && Value.getRefKind() == 0; return IsRelocatable && Value.isAbsolute() && Value.getSpecifier() == 0;
} }
/// Helper method for \see EvaluateSymbolAdd(). /// Helper method for \see EvaluateSymbolAdd().
@ -533,7 +533,7 @@ bool MCExpr::evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm,
// If the reference has a variant kind, we can only handle expressions // If the reference has a variant kind, we can only handle expressions
// which evaluate exactly to a single unadorned symbol. Attach the // which evaluate exactly to a single unadorned symbol. Attach the
// original VariantKind to SymA of the result. // original VariantKind to SymA of the result.
if (Res.getRefKind() != MCSymbolRefExpr::VK_None || if (Res.getSpecifier() != MCSymbolRefExpr::VK_None ||
!Res.getAddSym() || Res.getSubSym() || Res.getConstant()) !Res.getAddSym() || Res.getSubSym() || Res.getConstant())
return false; return false;
Res.Specifier = Kind; Res.Specifier = Kind;

View File

@ -24,8 +24,8 @@ void MCValue::print(raw_ostream &OS) const {
// FIXME: prints as a number, which isn't ideal. But the meaning will be // FIXME: prints as a number, which isn't ideal. But the meaning will be
// target-specific anyway. // target-specific anyway.
if (getRefKind()) if (getSpecifier())
OS << ':' << getRefKind() << ':'; OS << ':' << getSpecifier() << ':';
SymA->print(OS, nullptr); SymA->print(OS, nullptr);

View File

@ -606,7 +606,7 @@ void WasmObjectWriter::recordRelocation(MCAssembler &Asm,
SymA->setUsedInReloc(); SymA->setUsedInReloc();
} }
switch (Target.getSymSpecifier()) { switch (Target.getSpecifier()) {
case MCSymbolRefExpr::VK_GOT: case MCSymbolRefExpr::VK_GOT:
case MCSymbolRefExpr::VK_WASM_GOT_TLS: case MCSymbolRefExpr::VK_WASM_GOT_TLS:
SymA->setUsedInGOT(); SymA->setUsedInGOT();

View File

@ -8243,7 +8243,7 @@ bool AArch64AsmParser::classifySymbolRef(const MCExpr *Expr,
return false; return false;
if (Res.getAddSym()) if (Res.getAddSym())
DarwinSpec = AArch64MCExpr::Specifier(Res.getSymSpecifier()); DarwinSpec = AArch64MCExpr::Specifier(Res.getSpecifier());
Addend = Res.getConstant(); Addend = Res.getConstant();
// It's some symbol reference + a constant addend, but really // It's some symbol reference + a constant addend, but really

View File

@ -222,7 +222,7 @@ static uint64_t adjustFixupValue(const MCFixup &Fixup, const MCValue &Target,
return Value >> 4; return Value >> 4;
case AArch64::fixup_aarch64_movw: { case AArch64::fixup_aarch64_movw: {
AArch64MCExpr::Specifier RefKind = AArch64MCExpr::Specifier RefKind =
static_cast<AArch64MCExpr::Specifier>(Target.getRefKind()); static_cast<AArch64MCExpr::Specifier>(Target.getSpecifier());
if (AArch64MCExpr::getSymbolLoc(RefKind) != AArch64MCExpr::VK_ABS && if (AArch64MCExpr::getSymbolLoc(RefKind) != AArch64MCExpr::VK_ABS &&
AArch64MCExpr::getSymbolLoc(RefKind) != AArch64MCExpr::VK_SABS) { AArch64MCExpr::getSymbolLoc(RefKind) != AArch64MCExpr::VK_SABS) {
if (!RefKind) { if (!RefKind) {
@ -422,7 +422,7 @@ void AArch64AsmBackend::applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
bool IsResolved, bool IsResolved,
const MCSubtargetInfo *STI) const { const MCSubtargetInfo *STI) const {
if (Fixup.getTargetKind() == FK_Data_8 && TheTriple.isOSBinFormatELF()) { if (Fixup.getTargetKind() == FK_Data_8 && TheTriple.isOSBinFormatELF()) {
auto RefKind = static_cast<AArch64MCExpr::Specifier>(Target.getRefKind()); auto RefKind = static_cast<AArch64MCExpr::Specifier>(Target.getSpecifier());
AArch64MCExpr::Specifier SymLoc = AArch64MCExpr::getSymbolLoc(RefKind); AArch64MCExpr::Specifier SymLoc = AArch64MCExpr::getSymbolLoc(RefKind);
if (SymLoc == AArch64AuthMCExpr::VK_AUTH || if (SymLoc == AArch64AuthMCExpr::VK_AUTH ||
SymLoc == AArch64AuthMCExpr::VK_AUTHADDR) { SymLoc == AArch64AuthMCExpr::VK_AUTHADDR) {
@ -480,7 +480,7 @@ void AArch64AsmBackend::applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
// FIXME: getFixupKindInfo() and getFixupKindNumBytes() could be fixed to // FIXME: getFixupKindInfo() and getFixupKindNumBytes() could be fixed to
// handle this more cleanly. This may affect the output of -show-mc-encoding. // handle this more cleanly. This may affect the output of -show-mc-encoding.
AArch64MCExpr::Specifier RefKind = AArch64MCExpr::Specifier RefKind =
static_cast<AArch64MCExpr::Specifier>(Target.getRefKind()); static_cast<AArch64MCExpr::Specifier>(Target.getSpecifier());
if (AArch64MCExpr::getSymbolLoc(RefKind) == AArch64MCExpr::VK_SABS || if (AArch64MCExpr::getSymbolLoc(RefKind) == AArch64MCExpr::VK_SABS ||
(!RefKind && Fixup.getTargetKind() == AArch64::fixup_aarch64_movw)) { (!RefKind && Fixup.getTargetKind() == AArch64::fixup_aarch64_movw)) {
// If the immediate is negative, generate MOVN else MOVZ. // If the immediate is negative, generate MOVN else MOVZ.

View File

@ -112,7 +112,7 @@ unsigned AArch64ELFObjectWriter::getRelocType(MCContext &Ctx,
if (Kind >= FirstLiteralRelocationKind) if (Kind >= FirstLiteralRelocationKind)
return Kind - FirstLiteralRelocationKind; return Kind - FirstLiteralRelocationKind;
AArch64MCExpr::Specifier RefKind = AArch64MCExpr::Specifier RefKind =
static_cast<AArch64MCExpr::Specifier>(Target.getRefKind()); static_cast<AArch64MCExpr::Specifier>(Target.getSpecifier());
AArch64MCExpr::Specifier SymLoc = AArch64MCExpr::getSymbolLoc(RefKind); AArch64MCExpr::Specifier SymLoc = AArch64MCExpr::getSymbolLoc(RefKind);
bool IsNC = AArch64MCExpr::isNotChecked(RefKind); bool IsNC = AArch64MCExpr::isNotChecked(RefKind);
@ -137,7 +137,7 @@ unsigned AArch64ELFObjectWriter::getRelocType(MCContext &Ctx,
case FK_Data_2: case FK_Data_2:
return R_CLS(PREL16); return R_CLS(PREL16);
case FK_Data_4: { case FK_Data_4: {
return AArch64MCExpr::Specifier(Target.getAccessVariant()) == return AArch64MCExpr::Specifier(Target.getSpecifier()) ==
AArch64MCExpr::VK_PLT AArch64MCExpr::VK_PLT
? R_CLS(PLT32) ? R_CLS(PLT32)
: R_CLS(PREL32); : R_CLS(PREL32);
@ -249,7 +249,7 @@ unsigned AArch64ELFObjectWriter::getRelocType(MCContext &Ctx,
case FK_Data_2: case FK_Data_2:
return R_CLS(ABS16); return R_CLS(ABS16);
case FK_Data_4: case FK_Data_4:
return (!IsILP32 && AArch64MCExpr::Specifier(Target.getAccessVariant()) == return (!IsILP32 && AArch64MCExpr::Specifier(Target.getSpecifier()) ==
AArch64MCExpr::VK_GOTPCREL) AArch64MCExpr::VK_GOTPCREL)
? ELF::R_AARCH64_GOTPCREL32 ? ELF::R_AARCH64_GOTPCREL32
: R_CLS(ABS32); : R_CLS(ABS32);
@ -543,10 +543,10 @@ bool AArch64ELFObjectWriter::needsRelocateWithSymbol(const MCValue &Val,
if (Val.getAddSym() && cast<MCSymbolELF>(Val.getAddSym())->isMemtag()) if (Val.getAddSym() && cast<MCSymbolELF>(Val.getAddSym())->isMemtag())
return true; return true;
if ((Val.getRefKind() & AArch64MCExpr::VK_GOT) == AArch64MCExpr::VK_GOT) if ((Val.getSpecifier() & AArch64MCExpr::VK_GOT) == AArch64MCExpr::VK_GOT)
return true; return true;
return is_contained({AArch64MCExpr::VK_GOTPCREL, AArch64MCExpr::VK_PLT}, return is_contained({AArch64MCExpr::VK_GOTPCREL, AArch64MCExpr::VK_PLT},
AArch64MCExpr::Specifier(Val.getAccessVariant())); AArch64MCExpr::Specifier(Val.getSpecifier()));
} }
std::unique_ptr<MCObjectTargetWriter> std::unique_ptr<MCObjectTargetWriter>

View File

@ -192,7 +192,7 @@ void AArch64MachObjectWriter::recordRelocation(
} }
if (!getAArch64FixupKindMachOInfo( if (!getAArch64FixupKindMachOInfo(
Fixup, Type, AArch64MCExpr::Specifier(Target.getSymSpecifier()), Fixup, Type, AArch64MCExpr::Specifier(Target.getSpecifier()),
Log2Size, Asm)) { Log2Size, Asm)) {
Asm.getContext().reportError(Fixup.getLoc(), "unknown AArch64 fixup kind!"); Asm.getContext().reportError(Fixup.getLoc(), "unknown AArch64 fixup kind!");
return; return;
@ -221,7 +221,7 @@ void AArch64MachObjectWriter::recordRelocation(
// Check for "_foo@got - .", which comes through here as: // Check for "_foo@got - .", which comes through here as:
// Ltmp0: // Ltmp0:
// ... _foo@got - Ltmp0 // ... _foo@got - Ltmp0
if (Target.getSymSpecifier() == AArch64MCExpr::M_GOT && if (Target.getSpecifier() == AArch64MCExpr::M_GOT &&
Asm.getSymbolOffset(*B) == Asm.getSymbolOffset(*B) ==
Asm.getFragmentOffset(*Fragment) + Fixup.getOffset()) { Asm.getFragmentOffset(*Fragment) + Fixup.getOffset()) {
// SymB is the PC, so use a PC-rel pointer-to-GOT relocation. // SymB is the PC, so use a PC-rel pointer-to-GOT relocation.
@ -232,7 +232,7 @@ void AArch64MachObjectWriter::recordRelocation(
MRE.r_word1 = (IsPCRel << 24) | (Log2Size << 25) | (Type << 28); MRE.r_word1 = (IsPCRel << 24) | (Log2Size << 25) | (Type << 28);
Writer->addRelocation(A_Base, Fragment->getParent(), MRE); Writer->addRelocation(A_Base, Fragment->getParent(), MRE);
return; return;
} else if (Target.getSymSpecifier() != AArch64MCExpr::None) { } else if (Target.getSpecifier() != AArch64MCExpr::None) {
// Otherwise, neither symbol can be modified. // Otherwise, neither symbol can be modified.
Asm.getContext().reportError(Fixup.getLoc(), Asm.getContext().reportError(Fixup.getLoc(),
"unsupported relocation of modified symbol"); "unsupported relocation of modified symbol");
@ -391,8 +391,8 @@ void AArch64MachObjectWriter::recordRelocation(
Value = 0; Value = 0;
} }
if (Target.getRefKind() == AArch64MCExpr::VK_AUTH || if (Target.getSpecifier() == AArch64MCExpr::VK_AUTH ||
Target.getRefKind() == AArch64MCExpr::VK_AUTHADDR) { Target.getSpecifier() == AArch64MCExpr::VK_AUTHADDR) {
auto *Expr = cast<AArch64AuthMCExpr>(Fixup.getValue()); auto *Expr = cast<AArch64AuthMCExpr>(Fixup.getValue());
assert(Type == MachO::ARM64_RELOC_UNSIGNED); assert(Type == MachO::ARM64_RELOC_UNSIGNED);

View File

@ -61,8 +61,7 @@ unsigned AArch64WinCOFFObjectWriter::getRelocType(
FixupKind = FK_PCRel_4; FixupKind = FK_PCRel_4;
} }
auto Modifier = auto Spec = Target.getSpecifier();
Target.isAbsolute() ? AArch64MCExpr::None : Target.getSymSpecifier();
const MCExpr *Expr = Fixup.getValue(); const MCExpr *Expr = Fixup.getValue();
if (const AArch64MCExpr *A64E = dyn_cast<AArch64MCExpr>(Expr)) { if (const AArch64MCExpr *A64E = dyn_cast<AArch64MCExpr>(Expr)) {
@ -98,7 +97,7 @@ unsigned AArch64WinCOFFObjectWriter::getRelocType(
return COFF::IMAGE_REL_ARM64_REL32; return COFF::IMAGE_REL_ARM64_REL32;
case FK_Data_4: case FK_Data_4:
switch (Modifier) { switch (Spec) {
default: default:
return COFF::IMAGE_REL_ARM64_ADDR32; return COFF::IMAGE_REL_ARM64_ADDR32;
case MCSymbolRefExpr::VK_COFF_IMGREL32: case MCSymbolRefExpr::VK_COFF_IMGREL32:

View File

@ -46,7 +46,7 @@ unsigned AMDGPUELFObjectWriter::getRelocType(MCContext &Ctx,
return ELF::R_AMDGPU_ABS32_LO; return ELF::R_AMDGPU_ABS32_LO;
} }
switch (AMDGPUMCExpr::Specifier(Target.getAccessVariant())) { switch (AMDGPUMCExpr::Specifier(Target.getSpecifier())) {
default: default:
break; break;
case AMDGPUMCExpr::S_GOTPCREL: case AMDGPUMCExpr::S_GOTPCREL:

View File

@ -82,7 +82,7 @@ unsigned ARMELFObjectWriter::GetRelocTypeInner(const MCValue &Target,
unsigned Kind = Fixup.getTargetKind(); unsigned Kind = Fixup.getTargetKind();
if (Kind >= FirstLiteralRelocationKind) if (Kind >= FirstLiteralRelocationKind)
return Kind - FirstLiteralRelocationKind; return Kind - FirstLiteralRelocationKind;
uint8_t Specifier = Target.getAccessVariant(); uint8_t Specifier = Target.getSpecifier();
auto CheckFDPIC = [&](uint32_t Type) { auto CheckFDPIC = [&](uint32_t Type) {
if (getOSABI() != ELF::ELFOSABI_ARM_FDPIC) if (getOSABI() != ELF::ELFOSABI_ARM_FDPIC)
Ctx.reportError(Fixup.getLoc(), Ctx.reportError(Fixup.getLoc(),

View File

@ -44,7 +44,7 @@ unsigned ARMWinCOFFObjectWriter::getRelocType(MCContext &Ctx,
const MCFixup &Fixup, const MCFixup &Fixup,
bool IsCrossSection, bool IsCrossSection,
const MCAsmBackend &MAB) const { const MCAsmBackend &MAB) const {
auto Spec = Target.getAddSym() ? Target.getSymSpecifier() : 0; auto Spec = Target.getSpecifier();
unsigned FixupKind = Fixup.getKind(); unsigned FixupKind = Fixup.getKind();
if (IsCrossSection) { if (IsCrossSection) {
if (FixupKind != FK_Data_4) { if (FixupKind != FK_Data_4) {

View File

@ -40,7 +40,7 @@ unsigned AVRELFObjectWriter::getRelocType(MCContext &Ctx, const MCValue &Target,
const unsigned Kind = Fixup.getTargetKind(); const unsigned Kind = Fixup.getTargetKind();
if (Kind >= FirstLiteralRelocationKind) if (Kind >= FirstLiteralRelocationKind)
return Kind - FirstLiteralRelocationKind; return Kind - FirstLiteralRelocationKind;
auto Modifier = AVRMCExpr::Specifier(Target.getAccessVariant()); auto Modifier = AVRMCExpr::Specifier(Target.getSpecifier());
switch ((unsigned)Fixup.getKind()) { switch ((unsigned)Fixup.getKind()) {
case FK_Data_1: case FK_Data_1:
switch (Modifier) { switch (Modifier) {

View File

@ -81,7 +81,7 @@ bool AVRMCExpr::evaluateAsRelocatableImpl(MCValue &Result,
return false; return false;
auto Spec = AVRMCExpr::VK_None; auto Spec = AVRMCExpr::VK_None;
if (Value.getSymSpecifier() != MCSymbolRefExpr::VK_None) if (Value.getSpecifier() != MCSymbolRefExpr::VK_None)
return false; return false;
assert(!Value.getSubSym()); assert(!Value.getSubSym());
if (specifier == VK_PM) if (specifier == VK_PM)

View File

@ -42,9 +42,9 @@ unsigned CSKYELFObjectWriter::getRelocType(MCContext &Ctx,
const MCExpr *Expr = Fixup.getValue(); const MCExpr *Expr = Fixup.getValue();
// Determine the type of the relocation // Determine the type of the relocation
unsigned Kind = Fixup.getTargetKind(); unsigned Kind = Fixup.getTargetKind();
uint8_t Modifier = Target.getAccessVariant(); uint8_t Modifier = Target.getSpecifier();
switch (Target.getRefKind()) { switch (Target.getSpecifier()) {
case CSKYMCExpr::VK_TLSIE: case CSKYMCExpr::VK_TLSIE:
case CSKYMCExpr::VK_TLSLE: case CSKYMCExpr::VK_TLSLE:
case CSKYMCExpr::VK_TLSGD: case CSKYMCExpr::VK_TLSGD:
@ -170,7 +170,7 @@ unsigned CSKYELFObjectWriter::getRelocType(MCContext &Ctx,
bool CSKYELFObjectWriter::needsRelocateWithSymbol(const MCValue &V, bool CSKYELFObjectWriter::needsRelocateWithSymbol(const MCValue &V,
const MCSymbol &, const MCSymbol &,
unsigned Type) const { unsigned Type) const {
switch (V.getRefKind()) { switch (V.getSpecifier()) {
case CSKYMCExpr::VK_PLT: case CSKYMCExpr::VK_PLT:
case CSKYMCExpr::VK_GOT: case CSKYMCExpr::VK_GOT:
return true; return true;

View File

@ -1249,7 +1249,7 @@ bool HexagonAsmParser::parseInstruction(OperandVector &Operands) {
MCValue Value; MCValue Value;
if (Expr->evaluateAsRelocatable(Value, nullptr)) { if (Expr->evaluateAsRelocatable(Value, nullptr)) {
if (!Value.isAbsolute()) { if (!Value.isAbsolute()) {
switch (HexagonMCExpr::VariantKind(Value.getAccessVariant())) { switch (HexagonMCExpr::VariantKind(Value.getSpecifier())) {
case HexagonMCExpr::VK_TPREL: case HexagonMCExpr::VK_TPREL:
case HexagonMCExpr::VK_DTPREL: case HexagonMCExpr::VK_DTPREL:
// Don't lazy extend these expression variants // Don't lazy extend these expression variants

View File

@ -42,7 +42,7 @@ unsigned HexagonELFObjectWriter::getRelocType(MCContext &Ctx,
MCValue const &Target, MCValue const &Target,
MCFixup const &Fixup, MCFixup const &Fixup,
bool IsPCRel) const { bool IsPCRel) const {
auto Variant = HexagonMCExpr::VariantKind(Target.getAccessVariant()); auto Variant = HexagonMCExpr::VariantKind(Target.getSpecifier());
switch (Variant) { switch (Variant) {
case HexagonMCExpr::VK_GD_GOT: case HexagonMCExpr::VK_GD_GOT:
case HexagonMCExpr::VK_LD_GOT: case HexagonMCExpr::VK_LD_GOT:

View File

@ -707,7 +707,7 @@ bool LoongArchAsmParser::classifySymbolRef(const MCExpr *Expr,
MCValue Res; MCValue Res;
if (Expr->evaluateAsRelocatable(Res, nullptr)) if (Expr->evaluateAsRelocatable(Res, nullptr))
return Res.getRefKind() == LoongArchMCExpr::VK_None; return Res.getSpecifier() == LoongArchMCExpr::VK_None;
return false; return false;
} }

View File

@ -452,7 +452,7 @@ bool LoongArchAsmBackend::handleAddSubRelocations(const MCAssembler &Asm,
const MCFixup &Fixup, const MCFixup &Fixup,
const MCValue &Target, const MCValue &Target,
uint64_t &FixedValue) const { uint64_t &FixedValue) const {
assert(Target.getRefKind() == 0 && assert(Target.getSpecifier() == 0 &&
"relocatable SymA-SymB cannot have relocation specifier"); "relocatable SymA-SymB cannot have relocation specifier");
std::pair<MCFixupKind, MCFixupKind> FK; std::pair<MCFixupKind, MCFixupKind> FK;
uint64_t FixedValueA, FixedValueB; uint64_t FixedValueA, FixedValueB;

View File

@ -50,7 +50,7 @@ unsigned LoongArchELFObjectWriter::getRelocType(MCContext &Ctx,
const MCValue &Target, const MCValue &Target,
const MCFixup &Fixup, const MCFixup &Fixup,
bool IsPCRel) const { bool IsPCRel) const {
switch (Target.getRefKind()) { switch (Target.getSpecifier()) {
case LoongArchMCExpr::VK_TLS_LE_HI20: case LoongArchMCExpr::VK_TLS_LE_HI20:
case LoongArchMCExpr::VK_TLS_IE_PC_HI20: case LoongArchMCExpr::VK_TLS_IE_PC_HI20:
case LoongArchMCExpr::VK_TLS_IE_HI20: case LoongArchMCExpr::VK_TLS_IE_HI20:

View File

@ -65,7 +65,7 @@ unsigned M68kELFObjectWriter::getRelocType(MCContext &Ctx,
const MCValue &Target, const MCValue &Target,
const MCFixup &Fixup, const MCFixup &Fixup,
bool IsPCRel) const { bool IsPCRel) const {
auto Specifier = M68kMCExpr::Specifier(Target.getAccessVariant()); auto Specifier = M68kMCExpr::Specifier(Target.getSpecifier());
unsigned Kind = Fixup.getKind(); unsigned Kind = Fixup.getKind();
M68kRelType Type = getType(Kind, Specifier, IsPCRel); M68kRelType Type = getType(Kind, Specifier, IsPCRel);
switch (Specifier) { switch (Specifier) {

View File

@ -162,7 +162,7 @@ unsigned MipsELFObjectWriter::getRelocType(MCContext &Ctx,
if (Kind >= FirstLiteralRelocationKind) if (Kind >= FirstLiteralRelocationKind)
return Kind - FirstLiteralRelocationKind; return Kind - FirstLiteralRelocationKind;
switch (Target.getRefKind()) { switch (Target.getSpecifier()) {
case MipsMCExpr::MEK_DTPREL: case MipsMCExpr::MEK_DTPREL:
case MipsMCExpr::MEK_DTPREL_HI: case MipsMCExpr::MEK_DTPREL_HI:
case MipsMCExpr::MEK_DTPREL_LO: case MipsMCExpr::MEK_DTPREL_LO:

View File

@ -38,25 +38,15 @@ PPCELFObjectWriter::PPCELFObjectWriter(bool Is64Bit, uint8_t OSABI)
Is64Bit ? ELF::EM_PPC64 : ELF::EM_PPC, Is64Bit ? ELF::EM_PPC64 : ELF::EM_PPC,
/*HasRelocationAddend*/ true) {} /*HasRelocationAddend*/ true) {}
static PPCMCExpr::Specifier getAccessVariant(const MCValue &Target,
const MCFixup &Fixup) {
const MCExpr *Expr = Fixup.getValue();
if (Expr->getKind() != MCExpr::Target)
return PPCMCExpr::Specifier(Target.getAccessVariant());
return cast<PPCMCExpr>(Expr)->getSpecifier();
}
unsigned PPCELFObjectWriter::getRelocType(MCContext &Ctx, const MCValue &Target, unsigned PPCELFObjectWriter::getRelocType(MCContext &Ctx, const MCValue &Target,
const MCFixup &Fixup, const MCFixup &Fixup,
bool IsPCRel) const { bool IsPCRel) const {
MCFixupKind Kind = Fixup.getKind(); MCFixupKind Kind = Fixup.getKind();
if (Kind >= FirstLiteralRelocationKind) if (Kind >= FirstLiteralRelocationKind)
return Kind - FirstLiteralRelocationKind; return Kind - FirstLiteralRelocationKind;
auto RefKind = static_cast<PPCMCExpr::Specifier>(Target.getRefKind()); SMLoc Loc = Fixup.getValue()->getLoc();
auto Modifier = getAccessVariant(Target, Fixup); auto Spec = static_cast<PPCMCExpr::Specifier>(Target.getSpecifier());
switch (Spec) {
switch (PPCMCExpr::Specifier(Modifier)) {
case PPCMCExpr::VK_DTPMOD: case PPCMCExpr::VK_DTPMOD:
case PPCMCExpr::VK_DTPREL: case PPCMCExpr::VK_DTPREL:
case PPCMCExpr::VK_DTPREL_HA: case PPCMCExpr::VK_DTPREL_HA:
@ -108,7 +98,7 @@ unsigned PPCELFObjectWriter::getRelocType(MCContext &Ctx, const MCValue &Target,
} }
// determine the type of the relocation // determine the type of the relocation
unsigned Type; unsigned Type = 0;
if (IsPCRel) { if (IsPCRel) {
switch (Fixup.getTargetKind()) { switch (Fixup.getTargetKind()) {
default: default:
@ -116,8 +106,10 @@ unsigned PPCELFObjectWriter::getRelocType(MCContext &Ctx, const MCValue &Target,
case PPC::fixup_ppc_br24: case PPC::fixup_ppc_br24:
case PPC::fixup_ppc_br24abs: case PPC::fixup_ppc_br24abs:
case PPC::fixup_ppc_br24_notoc: case PPC::fixup_ppc_br24_notoc:
switch (Modifier) { switch (Spec) {
default: llvm_unreachable("Unsupported Modifier"); default:
Ctx.reportError(Loc, "unsupported relocation type");
break;
case PPCMCExpr::VK_None: case PPCMCExpr::VK_None:
Type = ELF::R_PPC_REL24; Type = ELF::R_PPC_REL24;
break; break;
@ -137,9 +129,9 @@ unsigned PPCELFObjectWriter::getRelocType(MCContext &Ctx, const MCValue &Target,
Type = ELF::R_PPC_REL14; Type = ELF::R_PPC_REL14;
break; break;
case PPC::fixup_ppc_half16: case PPC::fixup_ppc_half16:
switch (RefKind) { switch (Spec) {
default: default:
Ctx.reportError(Fixup.getLoc(), "invalid VariantKind"); Ctx.reportError(Loc, "unsupported relocation type");
return ELF::R_PPC_NONE; return ELF::R_PPC_NONE;
case PPCMCExpr::VK_None: case PPCMCExpr::VK_None:
return ELF::R_PPC_REL16; return ELF::R_PPC_REL16;
@ -153,13 +145,13 @@ unsigned PPCELFObjectWriter::getRelocType(MCContext &Ctx, const MCValue &Target,
break; break;
case PPC::fixup_ppc_half16ds: case PPC::fixup_ppc_half16ds:
case PPC::fixup_ppc_half16dq: case PPC::fixup_ppc_half16dq:
Target.print(errs()); Ctx.reportError(Loc, "unsupported relocation type");
errs() << '\n'; break;
report_fatal_error("Invalid PC-relative half16ds relocation");
case PPC::fixup_ppc_pcrel34: case PPC::fixup_ppc_pcrel34:
switch (Modifier) { switch (Spec) {
default: default:
llvm_unreachable("Unsupported Modifier for fixup_ppc_pcrel34"); Ctx.reportError(Loc, "unsupported relocation type");
break;
case PPCMCExpr::VK_PCREL: case PPCMCExpr::VK_PCREL:
Type = ELF::R_PPC64_PCREL34; Type = ELF::R_PPC64_PCREL34;
break; break;
@ -196,9 +188,10 @@ unsigned PPCELFObjectWriter::getRelocType(MCContext &Ctx, const MCValue &Target,
Type = ELF::R_PPC_ADDR14; // XXX: or BRNTAKEN?_ Type = ELF::R_PPC_ADDR14; // XXX: or BRNTAKEN?_
break; break;
case PPC::fixup_ppc_half16: case PPC::fixup_ppc_half16:
switch (Modifier) { switch (Spec) {
default: default:
llvm_unreachable("Unsupported specifier"); Ctx.reportError(Loc, "unsupported relocation type");
break;
case PPCMCExpr::VK_LO: case PPCMCExpr::VK_LO:
return ELF::R_PPC_ADDR16_LO; return ELF::R_PPC_ADDR16_LO;
case PPCMCExpr::VK_HI: case PPCMCExpr::VK_HI:
@ -371,10 +364,10 @@ unsigned PPCELFObjectWriter::getRelocType(MCContext &Ctx, const MCValue &Target,
break; break;
case PPC::fixup_ppc_half16ds: case PPC::fixup_ppc_half16ds:
case PPC::fixup_ppc_half16dq: case PPC::fixup_ppc_half16dq:
switch (Modifier) { switch (Spec) {
default: default:
Ctx.reportError(Fixup.getLoc(), "invalid VariantKind"); Ctx.reportError(Loc, "unsupported relocation type");
return ELF::R_PPC64_NONE; break;
case PPCMCExpr::VK_LO: case PPCMCExpr::VK_LO:
return ELF::R_PPC64_ADDR16_LO_DS; return ELF::R_PPC64_ADDR16_LO_DS;
case PPCMCExpr::VK_None: case PPCMCExpr::VK_None:
@ -419,8 +412,10 @@ unsigned PPCELFObjectWriter::getRelocType(MCContext &Ctx, const MCValue &Target,
} }
break; break;
case PPC::fixup_ppc_nofixup: case PPC::fixup_ppc_nofixup:
switch (Modifier) { switch (Spec) {
default: llvm_unreachable("Unsupported Modifier"); default:
Ctx.reportError(Loc, "unsupported relocation type");
break;
case PPCMCExpr::VK_TLSGD: case PPCMCExpr::VK_TLSGD:
if (is64Bit()) if (is64Bit())
Type = ELF::R_PPC64_TLSGD; Type = ELF::R_PPC64_TLSGD;
@ -445,9 +440,10 @@ unsigned PPCELFObjectWriter::getRelocType(MCContext &Ctx, const MCValue &Target,
} }
break; break;
case PPC::fixup_ppc_imm34: case PPC::fixup_ppc_imm34:
switch (Modifier) { switch (Spec) {
default: default:
report_fatal_error("Unsupported Modifier for fixup_ppc_imm34."); Ctx.reportError(Loc, "unsupported relocation type");
break;
case PPCMCExpr::VK_DTPREL: case PPCMCExpr::VK_DTPREL:
Type = ELF::R_PPC64_DTPREL34; Type = ELF::R_PPC64_DTPREL34;
break; break;
@ -457,8 +453,10 @@ unsigned PPCELFObjectWriter::getRelocType(MCContext &Ctx, const MCValue &Target,
} }
break; break;
case FK_Data_8: case FK_Data_8:
switch (Modifier) { switch (Spec) {
default: llvm_unreachable("Unsupported Modifier"); default:
Ctx.reportError(Loc, "unsupported relocation type");
break;
case PPCMCExpr::VK_TOCBASE: case PPCMCExpr::VK_TOCBASE:
Type = ELF::R_PPC64_TOC; Type = ELF::R_PPC64_TOC;
break; break;
@ -477,7 +475,7 @@ unsigned PPCELFObjectWriter::getRelocType(MCContext &Ctx, const MCValue &Target,
} }
break; break;
case FK_Data_4: case FK_Data_4:
switch (Modifier) { switch (Spec) {
case PPCMCExpr::VK_DTPREL: case PPCMCExpr::VK_DTPREL:
Type = ELF::R_PPC_DTPREL32; Type = ELF::R_PPC_DTPREL32;
break; break;

View File

@ -40,8 +40,7 @@ llvm::createPPCXCOFFObjectWriter(bool Is64Bit) {
std::pair<uint8_t, uint8_t> PPCXCOFFObjectWriter::getRelocTypeAndSignSize( std::pair<uint8_t, uint8_t> PPCXCOFFObjectWriter::getRelocTypeAndSignSize(
const MCValue &Target, const MCFixup &Fixup, bool IsPCRel) const { const MCValue &Target, const MCFixup &Fixup, bool IsPCRel) const {
const auto Specifier = const auto Specifier = Target.getSpecifier();
Target.isAbsolute() ? PPCMCExpr::VK_None : Target.getSymSpecifier();
// People from AIX OS team says AIX link editor does not care about // People from AIX OS team says AIX link editor does not care about
// the sign bit in the relocation entry "most" of the time. // the sign bit in the relocation entry "most" of the time.
// The system assembler seems to set the sign bit on relocation entry // The system assembler seems to set the sign bit on relocation entry

View File

@ -2798,14 +2798,14 @@ bool RISCVAsmParser::classifySymbolRef(const MCExpr *Expr,
MCValue Res; MCValue Res;
if (Expr->evaluateAsRelocatable(Res, nullptr)) if (Expr->evaluateAsRelocatable(Res, nullptr))
return Res.getRefKind() == RISCVMCExpr::VK_None; return Res.getSpecifier() == RISCVMCExpr::VK_None;
return false; return false;
} }
bool RISCVAsmParser::isSymbolDiff(const MCExpr *Expr) { bool RISCVAsmParser::isSymbolDiff(const MCExpr *Expr) {
MCValue Res; MCValue Res;
if (Expr->evaluateAsRelocatable(Res, nullptr)) { if (Expr->evaluateAsRelocatable(Res, nullptr)) {
return Res.getRefKind() == RISCVMCExpr::VK_None && Res.getAddSym() && return Res.getSpecifier() == RISCVMCExpr::VK_None && Res.getAddSym() &&
Res.getSubSym(); Res.getSubSym();
} }
return false; return false;

View File

@ -628,7 +628,7 @@ bool RISCVAsmBackend::handleAddSubRelocations(const MCAssembler &Asm,
const MCFixup &Fixup, const MCFixup &Fixup,
const MCValue &Target, const MCValue &Target,
uint64_t &FixedValue) const { uint64_t &FixedValue) const {
assert(Target.getRefKind() == 0 && assert(Target.getSpecifier() == 0 &&
"relocatable SymA-SymB cannot have relocation specifier"); "relocatable SymA-SymB cannot have relocation specifier");
uint64_t FixedValueA, FixedValueB; uint64_t FixedValueA, FixedValueB;
unsigned TA = 0, TB = 0; unsigned TA = 0, TB = 0;

View File

@ -56,7 +56,7 @@ unsigned RISCVELFObjectWriter::getRelocType(MCContext &Ctx,
if (Kind >= FirstLiteralRelocationKind) if (Kind >= FirstLiteralRelocationKind)
return Kind - FirstLiteralRelocationKind; return Kind - FirstLiteralRelocationKind;
auto Spec = RISCVMCExpr::Specifier(Target.getRefKind()); auto Spec = RISCVMCExpr::Specifier(Target.getSpecifier());
switch (Spec) { switch (Spec) {
case RISCVMCExpr::VK_TPREL_HI: case RISCVMCExpr::VK_TPREL_HI:
case RISCVMCExpr::VK_TLS_GOT_HI: case RISCVMCExpr::VK_TLS_GOT_HI:

View File

@ -46,7 +46,7 @@ unsigned SparcELFObjectWriter::getRelocType(MCContext &Ctx,
if (Kind >= FirstLiteralRelocationKind) if (Kind >= FirstLiteralRelocationKind)
return Kind - FirstLiteralRelocationKind; return Kind - FirstLiteralRelocationKind;
switch (Target.getRefKind()) { switch (Target.getSpecifier()) {
case SparcMCExpr::VK_TLS_GD_HI22: case SparcMCExpr::VK_TLS_GD_HI22:
case SparcMCExpr::VK_TLS_GD_LO10: case SparcMCExpr::VK_TLS_GD_LO10:
case SparcMCExpr::VK_TLS_GD_ADD: case SparcMCExpr::VK_TLS_GD_ADD:

View File

@ -158,7 +158,7 @@ unsigned SystemZELFObjectWriter::getRelocType(MCContext &Ctx,
unsigned Kind = Fixup.getKind(); unsigned Kind = Fixup.getKind();
if (Kind >= FirstLiteralRelocationKind) if (Kind >= FirstLiteralRelocationKind)
return Kind - FirstLiteralRelocationKind; return Kind - FirstLiteralRelocationKind;
auto Specifier = SystemZMCExpr::Specifier(Target.getAccessVariant()); auto Specifier = SystemZMCExpr::Specifier(Target.getSpecifier());
switch (Specifier) { switch (Specifier) {
case SystemZMCExpr::VK_INDNTPOFF: case SystemZMCExpr::VK_INDNTPOFF:
case SystemZMCExpr::VK_NTPOFF: case SystemZMCExpr::VK_NTPOFF:
@ -220,7 +220,7 @@ unsigned SystemZELFObjectWriter::getRelocType(MCContext &Ctx,
bool SystemZELFObjectWriter::needsRelocateWithSymbol(const MCValue &V, bool SystemZELFObjectWriter::needsRelocateWithSymbol(const MCValue &V,
const MCSymbol &Sym, const MCSymbol &Sym,
unsigned Type) const { unsigned Type) const {
switch (V.getSymSpecifier()) { switch (V.getSpecifier()) {
case SystemZMCExpr::VK_GOT: case SystemZMCExpr::VK_GOT:
case SystemZMCExpr::VK_PLT: case SystemZMCExpr::VK_PLT:
return true; return true;

View File

@ -40,7 +40,7 @@ protected:
unsigned VEELFObjectWriter::getRelocType(MCContext &Ctx, const MCValue &Target, unsigned VEELFObjectWriter::getRelocType(MCContext &Ctx, const MCValue &Target,
const MCFixup &Fixup, const MCFixup &Fixup,
bool IsPCRel) const { bool IsPCRel) const {
switch (Target.getRefKind()) { switch (Target.getSpecifier()) {
case VEMCExpr::VK_TLS_GD_HI32: case VEMCExpr::VK_TLS_GD_HI32:
case VEMCExpr::VK_TLS_GD_LO32: case VEMCExpr::VK_TLS_GD_LO32:
case VEMCExpr::VK_TPOFF_HI32: case VEMCExpr::VK_TPOFF_HI32:

View File

@ -66,7 +66,7 @@ unsigned WebAssemblyWasmObjectWriter::getRelocType(
const MCValue &Target, const MCFixup &Fixup, const MCValue &Target, const MCFixup &Fixup,
const MCSectionWasm &FixupSection, bool IsLocRel) const { const MCSectionWasm &FixupSection, bool IsLocRel) const {
auto &SymA = cast<MCSymbolWasm>(*Target.getAddSym()); auto &SymA = cast<MCSymbolWasm>(*Target.getAddSym());
auto Spec = Target.getSymSpecifier(); auto Spec = Target.getSpecifier();
switch (Spec) { switch (Spec) {
case MCSymbolRefExpr::VK_GOT: case MCSymbolRefExpr::VK_GOT:
case MCSymbolRefExpr::VK_WASM_GOT_TLS: case MCSymbolRefExpr::VK_WASM_GOT_TLS:

View File

@ -744,7 +744,7 @@ bool X86AsmBackend::fixupNeedsRelaxationAdvanced(const MCAssembler &Asm,
if (Fixup.getKind() == FK_Data_1) { if (Fixup.getKind() == FK_Data_1) {
MCValue Target; MCValue Target;
if (Fixup.getValue()->evaluateAsRelocatable(Target, &Asm) && if (Fixup.getValue()->evaluateAsRelocatable(Target, &Asm) &&
Target.getAddSym() && Target.getSymSpecifier() == X86MCExpr::VK_ABS8) Target.getAddSym() && Target.getSpecifier() == X86MCExpr::VK_ABS8)
return false; return false;
} }
return true; return true;

View File

@ -340,7 +340,7 @@ unsigned X86ELFObjectWriter::getRelocType(MCContext &Ctx, const MCValue &Target,
MCFixupKind Kind = Fixup.getKind(); MCFixupKind Kind = Fixup.getKind();
if (Kind >= FirstLiteralRelocationKind) if (Kind >= FirstLiteralRelocationKind)
return Kind - FirstLiteralRelocationKind; return Kind - FirstLiteralRelocationKind;
auto Specifier = X86MCExpr::Specifier(Target.getAccessVariant()); auto Specifier = X86MCExpr::Specifier(Target.getSpecifier());
switch (Specifier) { switch (Specifier) {
case X86MCExpr::VK_GOTTPOFF: case X86MCExpr::VK_GOTTPOFF:
case X86MCExpr::VK_INDNTPOFF: case X86MCExpr::VK_INDNTPOFF:
@ -391,7 +391,7 @@ unsigned X86ELFObjectWriter::getRelocType(MCContext &Ctx, const MCValue &Target,
bool X86ELFObjectWriter::needsRelocateWithSymbol(const MCValue &V, bool X86ELFObjectWriter::needsRelocateWithSymbol(const MCValue &V,
const MCSymbol &Sym, const MCSymbol &Sym,
unsigned Type) const { unsigned Type) const {
switch (V.getSymSpecifier()) { switch (V.getSpecifier()) {
case X86MCExpr::VK_GOT: case X86MCExpr::VK_GOT:
case X86MCExpr::VK_PLT: case X86MCExpr::VK_PLT:
case X86MCExpr::VK_GOTPCREL: case X86MCExpr::VK_GOTPCREL:

View File

@ -151,7 +151,7 @@ void X86MachObjectWriter::RecordX86_64Relocation(
const MCSymbol *B_Base = Writer->getAtom(*B); const MCSymbol *B_Base = Writer->getAtom(*B);
// Neither symbol can be modified. // Neither symbol can be modified.
if (Target.getSymSpecifier()) { if (Target.getSpecifier()) {
Asm.getContext().reportError(Fixup.getLoc(), Asm.getContext().reportError(Fixup.getLoc(),
"unsupported relocation of modified symbol"); "unsupported relocation of modified symbol");
return; return;
@ -266,7 +266,7 @@ void X86MachObjectWriter::RecordX86_64Relocation(
return; return;
} }
auto Specifier = Target.getSymSpecifier(); auto Specifier = Target.getSpecifier();
if (IsPCRel) { if (IsPCRel) {
if (IsRIPRel) { if (IsRIPRel) {
if (Specifier == X86MCExpr::VK_GOTPCREL) { if (Specifier == X86MCExpr::VK_GOTPCREL) {
@ -461,7 +461,7 @@ void X86MachObjectWriter::recordTLVPRelocation(MachObjectWriter *Writer,
MCValue Target, MCValue Target,
uint64_t &FixedValue) { uint64_t &FixedValue) {
const MCSymbol *SymA = Target.getAddSym(); const MCSymbol *SymA = Target.getAddSym();
assert(Target.getSymSpecifier() == X86MCExpr::VK_TLVP && !is64Bit() && assert(Target.getSpecifier() == X86MCExpr::VK_TLVP && !is64Bit() &&
"Should only be called with a 32-bit TLVP relocation!"); "Should only be called with a 32-bit TLVP relocation!");
unsigned Log2Size = getFixupKindLog2Size(Fixup.getKind()); unsigned Log2Size = getFixupKindLog2Size(Fixup.getKind());
@ -503,7 +503,7 @@ void X86MachObjectWriter::RecordX86Relocation(MachObjectWriter *Writer,
const MCSymbol *A = Target.getAddSym(); const MCSymbol *A = Target.getAddSym();
// If this is a 32-bit TLVP reloc it's handled a bit differently. // If this is a 32-bit TLVP reloc it's handled a bit differently.
if (A && Target.getSymSpecifier() == X86MCExpr::VK_TLVP) { if (A && Target.getSpecifier() == X86MCExpr::VK_TLVP) {
recordTLVPRelocation(Writer, Asm, Fragment, Fixup, Target, FixedValue); recordTLVPRelocation(Writer, Asm, Fragment, Fixup, Target, FixedValue);
return; return;
} }

View File

@ -59,7 +59,7 @@ unsigned X86WinCOFFObjectWriter::getRelocType(MCContext &Ctx,
} }
} }
auto Spec = Target.getAddSym() ? Target.getSymSpecifier() : 0; auto Spec = Target.getSpecifier();
if (Is64Bit) { if (Is64Bit) {
switch (FixupKind) { switch (FixupKind) {
case FK_PCRel_4: case FK_PCRel_4:

View File

@ -1,7 +0,0 @@
# RUN: not --crash llvm-mc -triple powerpc64-- --filetype=obj < %s 2> %t
# RUN: FileCheck < %t %s
# RUN: not --crash llvm-mc -triple powerpc64le-- --filetype=obj < %s 2> %t
# RUN: FileCheck < %t %s
# CHECK: Unsupported Modifier for fixup_ppc_imm34.
paddi 3, 13, symbol@toc, 0

View File

@ -1,7 +0,0 @@
# RUN: not --crash llvm-mc -triple=powerpc64le-unknown-linux-gnu -filetype=obj %s \
# RUN: 2>&1 | FileCheck %s
_stext:
ld %r5, p_end - _stext(%r5)
# CHECK: LLVM ERROR: Invalid PC-relative half16ds relocation

View File

@ -0,0 +1,17 @@
# RUN: not llvm-mc -triple powerpc64 --filetype=obj %s -o %t 2>&1 | FileCheck %s
# RUN: not llvm-mc -triple powerpc64le --filetype=obj %s -o %t 2>&1 | FileCheck %s
# CHECK: [[#@LINE+1]]:4: error: unsupported relocation type
bl foo@toc
# CHECK: [[#@LINE+1]]:12: error: unsupported relocation type
addi 3, 3, foo@plt
# CHECK: [[#@LINE+1]]:14: error: unsupported relocation type
paddi 3, 13, foo@toc, 0
# CHECK: [[#@LINE+1]]:15: error: unsupported relocation type
ld %r5, p_end - .(%r5)
# CHECK: [[#@LINE+1]]:7: error: unsupported relocation type
.quad foo@toc