@@ -614,10 +614,7 @@ bool RISCVAsmBackend::evaluateTargetFixup(const MCFixup &Fixup,
614614
615615void RISCVAsmBackend::maybeAddVendorReloc (const MCFragment &F,
616616 const MCFixup &Fixup) {
617- MCContext &Ctx = Asm->getContext ();
618-
619617 StringRef VendorIdentifier;
620-
621618 switch (Fixup.getTargetKind ()) {
622619 default :
623620 // No Vendor Relocation Required.
@@ -632,6 +629,7 @@ void RISCVAsmBackend::maybeAddVendorReloc(const MCFragment &F,
632629
633630 // Create a local symbol for the vendor relocation to reference. It's fine if
634631 // the symbol has the same name as an existing symbol.
632+ MCContext &Ctx = Asm->getContext ();
635633 MCSymbol *VendorSymbol = Ctx.createLocalSymbol (VendorIdentifier);
636634 auto [It, Inserted] =
637635 VendorSymbols.try_emplace (VendorIdentifier, VendorSymbol);
@@ -645,12 +643,10 @@ void RISCVAsmBackend::maybeAddVendorReloc(const MCFragment &F,
645643 VendorSymbol = It->getValue ();
646644 }
647645
648- const MCExpr *VendorExpr = MCSymbolRefExpr::create (VendorSymbol, Ctx);
649646 MCFixup VendorFixup =
650- MCFixup::create (Fixup.getOffset (), VendorExpr, ELF::R_RISCV_VENDOR);
651- // Explicitly create MCValue rather than using
652- // `VendorExpr->evaluateAsRelocatable` so that the absolute symbol is not
653- // evaluated to constant 0.
647+ MCFixup::create (Fixup.getOffset (), nullptr , ELF::R_RISCV_VENDOR);
648+ // Explicitly create MCValue rather than using an MCExpr and evaluating it so
649+ // that the absolute vendor symbol is not evaluated to constant 0.
654650 MCValue VendorTarget = MCValue::get (VendorSymbol);
655651 uint64_t VendorValue;
656652 Asm->getWriter ().recordRelocation (F, VendorFixup, VendorTarget, VendorValue);
0 commit comments